/* ═══════════════════════════════════════════════════════════════════
   SnowAssign — Design System v2
   Aesthetic: Refined Industrial — Precise, dense, purposeful.
   Fonts: Syne (display) + IBM Plex Mono (mono) + DM Sans (body)
═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Theme Variables ────────────────────────────────────────────── */
:root {
  /* Typography */
  --font-display: 'Syne', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  /* Geometry */
  --sidebar-w: 230px;
  --header-h: 58px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Dark Theme (default) ───────────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #0b0d12;
  --bg2:         #10141e;
  --bg3:         #161c29;
  --bg4:         #1d2436;
  --border:      #1f2940;
  --border2:     #283450;
  --border3:     #314060;

  --accent:      #4f9cf9;
  --accent2:     #2b7adf;
  --accent-dim:  rgba(79,156,249,0.12);
  --accent-glow: rgba(79,156,249,0.25);

  --green:       #34d399;
  --green-dim:   rgba(52,211,153,0.1);
  --red:         #f87171;
  --red-dim:     rgba(248,113,113,0.1);
  --yellow:      #fbbf24;
  --yellow-dim:  rgba(251,191,36,0.1);
  --purple:      #a78bfa;
  --purple-dim:  rgba(167,139,250,0.1);

  --text:        #e8edf5;
  --text2:       #8b96b0;
  --text3:       #4d5c7a;
  --text-muted:  #3a4760;

  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow:      0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.6);
  --shadow-modal: 0 24px 64px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);

  --scrollbar-track: #10141e;
  --scrollbar-thumb: #1d2436;
}

/* ── Light Theme ────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:          #f4f6fb;
  --bg2:         #ffffff;
  --bg3:         #f0f2f8;
  --bg4:         #e8ecf4;
  --border:      #dce1ee;
  --border2:     #cdd4e6;
  --border3:     #bcc6de;

  --accent:      #2b6fd4;
  --accent2:     #1a56b8;
  --accent-dim:  rgba(43,111,212,0.1);
  --accent-glow: rgba(43,111,212,0.2);

  --green:       #059669;
  --green-dim:   rgba(5,150,105,0.08);
  --red:         #dc2626;
  --red-dim:     rgba(220,38,38,0.08);
  --yellow:      #d97706;
  --yellow-dim:  rgba(217,119,6,0.1);
  --purple:      #7c3aed;
  --purple-dim:  rgba(124,58,237,0.08);

  --text:        #1a2035;
  --text2:       #4a5572;
  --text3:       #7d8aaa;
  --text-muted:  #b0b9d0;

  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
  --shadow:      0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.15);
  --shadow-modal: 0 24px 64px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.06);

  --scrollbar-track: #f0f2f8;
  --scrollbar-thumb: #dce1ee;
}

/* ── Base ───────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Custom Scrollbars ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border3); }

/* ════════════════════════════════════════════════════════════════
   LAYOUT
════════════════════════════════════════════════════════════════ */

#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transition: background 0.2s, border-color 0.2s;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-top: 1px;
}

.sidebar-section { padding: 20px 10px 4px; }

.sidebar-section-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  position: relative;
  margin-bottom: 1px;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg3);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 55%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--bg4);
  color: var(--text2);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 99px;
  min-width: 22px;
  text-align: center;
  border: 1px solid var(--border2);
  transition: all 0.2s;
}

.nav-badge.active-badge {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.nav-badge.yellow {
  background: var(--yellow-dim);
  color: var(--yellow);
  border-color: rgba(251,191,36,0.2);
}

.sidebar-bottom {
  margin-top: auto;
  padding: 12px 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Theme toggle in sidebar */
.theme-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  border: 1px solid var(--border);
}

.theme-toggle-label {
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

.theme-switch {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.theme-switch input { display: none; }

.theme-switch-track {
  width: 40px;
  height: 22px;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 99px;
  position: relative;
  transition: background 0.2s;
}

.theme-switch input:checked + .theme-switch-track {
  background: var(--accent);
  border-color: var(--accent);
}

.theme-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s var(--ease-spring);
  box-shadow: var(--shadow-sm);
}

.theme-switch input:checked + .theme-switch-track::after {
  transform: translateX(18px);
}

#api-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 8px rgba(52,211,153,0.5);
}

/* ── Main Area ──────────────────────────────────────────────────── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

#topbar {
  height: var(--header-h);
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  z-index: 10;
}

#topbar-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.2px;
}

.back-btn {
  cursor: pointer;
  padding: 5px 10px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  transition: all 0.15s;
  font-family: var(--font-body);
}

.back-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 26px;
  background: var(--bg);
}

/* ════════════════════════════════════════════════════════════════
   PAGES & ANIMATIONS
════════════════════════════════════════════════════════════════ */

.page { display: none; }

.page.active {
  display: block;
  animation: pageIn 0.22s var(--ease-out);
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header {
  margin-bottom: 22px;
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
}

.page-header p {
  font-size: 13px;
  color: var(--text3);
  margin-top: 4px;
  font-weight: 400;
}

/* ════════════════════════════════════════════════════════════════
   CARDS
════════════════════════════════════════════════════════════════ */

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
  transition: border-color 0.15s;
}

.card:hover { border-color: var(--border2); }

.card-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════════
   FORM ELEMENTS
════════════════════════════════════════════════════════════════ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.input-wrap { position: relative; }

.input-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="date"],
select,
textarea {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 400;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--bg2);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder, textarea::placeholder {
  color: var(--text3);
  font-weight: 400;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234d5c7a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237d8aaa' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
  cursor: pointer;
}

/* ════════════════════════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: 0.1px;
  -webkit-appearance: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent2);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border2);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.25);
}

.btn-danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 9px; font-size: 11px; }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 14px;
}

.btn-icon:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ════════════════════════════════════════════════════════════════
   BADGES
════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.badge-green  { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(52,211,153,0.2); }
.badge-red    { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(248,113,113,0.2); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(251,191,36,0.2); }
.badge-blue   { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(79,156,249,0.2); }
.badge-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(167,139,250,0.2); }
.badge-gray   { background: var(--bg4);        color: var(--text3);  border: 1px solid var(--border2); }

/* ════════════════════════════════════════════════════════════════
   ALERTS
════════════════════════════════════════════════════════════════ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: none;
  border: 1px solid transparent;
  margin-bottom: 16px;
}

.alert.show {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideDown 0.2s var(--ease-out);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert.success {
  background: var(--green-dim);
  border-color: rgba(52,211,153,0.25);
  color: var(--green);
}

.alert.error {
  background: var(--red-dim);
  border-color: rgba(248,113,113,0.25);
  color: var(--red);
}

/* ════════════════════════════════════════════════════════════════
   FILTER BAR (Toolbar)
════════════════════════════════════════════════════════════════ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  background: var(--bg2);
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border2);
  flex-shrink: 0;
}

.toolbar-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Search box within toolbar */
.search-box {
  position: relative;
  flex: 1;
  min-width: 150px;
  max-width: 280px;
}

.search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text3);
  pointer-events: none;
}

.search-box input {
  padding-left: 32px;
  height: 34px;
  font-size: 13px;
}

/* Toolbar selects */
.toolbar select {
  height: 34px;
  font-size: 12.5px;
  padding: 0 28px 0 10px;
  width: auto;
  min-width: 120px;
  flex-shrink: 0;
}

/* Toolbar date inputs */
.toolbar input[type="date"] {
  height: 34px;
  font-size: 12.5px;
  padding: 0 10px;
  width: 140px;
  flex-shrink: 0;
}

/* Date range label */
.date-range-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.date-range-sep {
  font-size: 11px;
  color: var(--text3);
  font-weight: 600;
}

/* Active filters indicator */
.filter-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(79,156,249,0.2);
}

.toolbar-right { margin-left: auto; display: flex; gap: 6px; }

/* Refresh button in toolbar */
.btn-refresh {
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-refresh:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

.btn-refresh.spinning { animation: spin 0.6s linear; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════════
   TABLES
════════════════════════════════════════════════════════════════ */

.table-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.table-wrap + .pagination-bar {
  border-top: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  background: var(--bg3);
  border-bottom: 1px solid var(--border2);
}

th {
  padding: 10px 16px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--bg3);
}

.clickable-row { cursor: pointer; }

td code, .mono {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg4);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text2);
}

.empty-state {
  text-align: center;
  padding: 52px 20px;
  color: var(--text3);
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state p { font-size: 13.5px; margin-top: 6px; }

/* ════════════════════════════════════════════════════════════════
   PAGINATION
════════════════════════════════════════════════════════════════ */

.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border-top: 1px solid var(--border);
}

.pagination-info {
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
}

.pagination-info strong {
  color: var(--text2);
  font-weight: 600;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.per-page-select {
  height: 28px;
  padding: 0 22px 0 8px;
  font-size: 11.5px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  width: auto;
  min-width: 80px;
}

.per-page-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.page-buttons {
  display: flex;
  align-items: center;
  gap: 3px;
}

.page-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}

.page-btn:hover:not(:disabled) {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-btn svg {
  width: 12px;
  height: 12px;
}

.page-indicator {
  font-size: 12px;
  color: var(--text3);
  padding: 0 4px;
  font-weight: 500;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════════
   STATS GRID
════════════════════════════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.stat-card:hover { border-color: var(--border2); box-shadow: var(--shadow); }
.stat-card:hover::after { opacity: 1; }

.stat-card.stat-pending::after  { background: var(--yellow); }
.stat-card.stat-processing::after { background: var(--accent); }
.stat-card.stat-assigned::after { background: var(--green); }
.stat-card.stat-today::after    { background: var(--purple); }

.stat-label {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -1px;
}

.stat-card.stat-pending  .stat-value { color: var(--yellow); }
.stat-card.stat-processing .stat-value { color: var(--accent); }
.stat-card.stat-assigned .stat-value { color: var(--green); }
.stat-card.stat-today    .stat-value { color: var(--purple); }

/* ════════════════════════════════════════════════════════════════
   MODALS
════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
  animation: overlayIn 0.18s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  width: 100%;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  animation: modalIn 0.22s var(--ease-out);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

.modal-close {
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text2);
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 14px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(248,113,113,0.3);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── API Config Modal — special layout ───────────────────────── */
.api-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 4px;
}

.api-modal-grid .form-group { margin-bottom: 0; }

/* Connection type badge in modal header */
.modal-header-meta {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
}

/* ── Test Connection — inline expand ─────────────────────────── */
.test-section {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s var(--ease-out), opacity 0.25s ease, margin-top 0.25s;
  margin-top: 0;
}

.test-section.visible {
  max-height: 300px;
  opacity: 1;
  margin-top: 18px;
}

.test-section-inner {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px;
}

.test-section-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.test-section-header::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Step List ───────────────────────────────────────────────── */
.step-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text3);
  font-weight: 400;
  transition: color 0.2s;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text3);
  flex-shrink: 0;
  transition: all 0.2s;
}

.step-item.active {
  color: var(--text);
  background: var(--bg4);
}

.step-item.active .step-num {
  border-color: var(--accent);
  border-top-color: transparent;
  animation: stepSpin 0.8s linear infinite;
  color: var(--accent);
}

@keyframes stepSpin { to { transform: rotate(360deg); } }

.step-item.done {
  color: var(--green);
}

.step-item.done .step-num {
  border-color: var(--green);
  background: var(--green-dim);
  color: var(--green);
}

.step-item.done .step-num::after { content: '✓'; }

.step-item.fail {
  color: var(--red);
}

.step-item.fail .step-num {
  border-color: var(--red);
  background: var(--red-dim);
  color: var(--red);
}

.step-item.fail .step-num::after { content: '✕'; }

/* ── Delete confirm modal ─────────────────────────────────────── */
.delete-confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--red-dim);
  border: 1px solid rgba(248,113,113,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

/* ════════════════════════════════════════════════════════════════
   TOGGLES
════════════════════════════════════════════════════════════════ */

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle input { display: none; }

.toggle-track {
  width: 38px;
  height: 21px;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 99px;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease-spring);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(17px);
}

.toggle.disabled { opacity: 0.45; pointer-events: none; }

.toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
}

/* ════════════════════════════════════════════════════════════════
   FIELD GRID (detail pages)
════════════════════════════════════════════════════════════════ */

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.field-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.field-key {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 5px;
}

.field-val {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* ════════════════════════════════════════════════════════════════
   ENABLE GROUP PAGE
════════════════════════════════════════════════════════════════ */

.enable-group-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.enable-group-form .form-group { flex: 1; margin: 0; }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .api-modal-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  #sidebar { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
