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

:root {
  --bg: #ffffff;
  --bg-subtle: #F8F9FA;
  --surface: #ffffff;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --text: #14141F;
  --text-muted: #6B7280;
  --primary: #0890f2;
  --primary-hover: #067dd6;
  --primary-light: #E8F4FE;
  --purple: #9466ff;
  --purple-light: #EDE8FF;
  --lime: #DFFE6D;
  --lime-text: #1C2700;
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --danger-light: #FEF2F2;
  --success: #16A34A;
  --success-light: #F0FDF4;
  --warning: #D97706;
  --warning-light: #FFFBEB;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 100px;
  --shadow: 0 1px 3px rgba(20,20,31,0.07), 0 1px 2px rgba(20,20,31,0.04);
  --shadow-md: 0 4px 12px rgba(20,20,31,0.10), 0 2px 4px rgba(20,20,31,0.06);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Navbar */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.nav-logo { height: 20px; display: block; }

.nav-brand-divider {
  width: 1px;
  height: 16px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.nav-brand-product {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

.nav-links { display: flex; align-items: center; gap: 12px; }
.nav-user { color: var(--text-muted); font-size: 13px; }
.nav-team { font-size: 12px; }
.nav-link { color: var(--text); text-decoration: none; font-size: 13px; font-weight: 500; }
.nav-link:hover { color: var(--primary); }
.nav-lang-switcher { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav-lang { font-size: 12px; font-weight: 500; color: var(--text-muted); text-decoration: none; padding: 2px 4px; border-radius: 4px; }
.nav-lang:hover { color: var(--text); }
.nav-lang-active { color: var(--text); font-weight: 700; }
.nav-lang-sep { color: var(--border-strong); font-size: 11px; }

/* Container */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 16px; }

/* Auth */
.auth-box { max-width: 380px; margin: 72px auto; }
.auth-logo { margin-bottom: 24px; }
.auth-box h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.02em; }
.auth-subtitle { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; min-height: 2.8em; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; letter-spacing: -0.01em; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.admin-nav { display: flex; gap: 4px; }

/* Dashboard layout */
.dashboard-layout { display: flex; flex-direction: column; gap: 20px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; gap: 16px; }
.form-row { display: flex; gap: 16px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form > .btn-primary { margin-top: 8px; }
.form-group { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text); }
.required { color: var(--danger); }
.hint { font-weight: 400; color: var(--text-muted); }

.input {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8,144,242,0.12);
}
.input-error { border-color: var(--danger); }
.input-readonly { background: var(--bg-subtle); color: var(--text-muted); cursor: not-allowed; }
select.input { cursor: pointer; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 2px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.btn-primary { background: var(--text); color: #fff; }
.btn-primary:hover { opacity: 0.85; }
.btn-lime { background: var(--lime); color: var(--lime-text); }
.btn-lime:hover { opacity: 0.85; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--text); color: #fff; border-color: var(--text); }
.btn-active { background: var(--text); border: 1px solid var(--text); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-copied { color: var(--success); border-color: var(--success); background: var(--success-light); }
.btn-sm { height: 28px; padding: 0 12px; font-size: 12px; }
.btn-xs { height: 22px; padding: 0 8px; font-size: 11px; }
.btn-full { width: 100%; }

/* Notes */
.note-box {
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}
.note-text { color: var(--text-muted); font-size: 13px; font-style: italic; margin: 0; }
.note-actions { display: flex; gap: 4px; align-items: center; margin-top: 4px; }

/* Queue */
.queue-card { border-left: 3px solid var(--lime); }

/* Filter bar */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 16px; }
.filter-bar .input { height: 32px; width: auto; flex: 1; min-width: 120px; }

/* Toggle switch */
.toggle {
  display: flex;
  align-items: center;
  height: 32px;
  gap: 8px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
}
.toggle input { display: none; }
.toggle-track {
  position: relative;
  width: 34px;
  height: 18px;
  background: var(--border-strong);
  border-radius: 9px;
  flex-shrink: 0;
  transition: background 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-track {
  background: var(--text);
}
.toggle input:checked + .toggle-track::after {
  transform: translateX(16px);
}
html[data-theme="dark"] .toggle input:checked + .toggle-track {
  background: var(--lime);
}
html[data-theme="dark"] .toggle input:checked + .toggle-track::after {
  background: var(--lime-text);
}

/* Tab bar */
.tab-bar { display: flex; gap: 4px; }

/* Result */
.result-card { border-left: 3px solid var(--lime); }
.result-block { margin-bottom: 14px; }
.result-block:last-child { margin-bottom: 0; }
.result-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 6px;
}
.result-row { display: flex; align-items: flex-start; gap: 8px; }
.result-url {
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 12px;
  word-break: break-all;
  background: var(--bg-subtle);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex: 1;
  display: block;
  color: var(--text);
}

/* Tables */
.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table td small { font-size: 13px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-subtle); }
.row-inactive td { opacity: 0.45; }
.row-new td { animation: highlight-fade 3s ease-out; }
@keyframes highlight-fade { 0% { background: var(--lime); } 100% { background: transparent; } }
.row-deleted td { opacity: 0.45; }
.row-deleted:hover td { background: inherit; }
.url-cell { max-width: 280px; }
.url-text { font-family: ui-monospace, 'SF Mono', monospace; font-size: 11px; word-break: break-all; display: block; margin-bottom: 4px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  background: #F1F3F5;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-team { background: var(--purple-light); color: #6B3FC0; }
.badge-active { background: var(--lime); color: var(--lime-text); }
button.badge { border: none; cursor: pointer; font-family: inherit; }
button.badge:hover { opacity: 0.75; }

/* Alerts */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; }
.alert-error, .alert-danger { background: var(--danger-light); border: 1px solid #FCA5A5; color: #B91C1C; }
.alert-success { background: var(--success-light); border: 1px solid #86EFAC; color: #15803D; }
.invite-result { margin-top: 16px; }
.invite-result code { display: block; font-size: 12px; word-break: break-all; margin: 6px 0; font-family: ui-monospace, monospace; }

/* Options */
.options-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.option-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.option-list .inactive { opacity: 0.4; }

/* Section header */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-header h3 { margin-bottom: 0; }

/* Note toggle */
details[open] > summary { display: none !important; }

/* Misc */
.muted { color: var(--text-muted); }
.empty-state { color: var(--text-muted); text-align: center; padding: 32px 0; }
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; gap: 12px; }

/* Custom Select */
.cs-wrap { position: relative; width: 100%; }
.cs-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  height: 36px; padding: 0 10px 0 12px; width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; color: var(--text);
  cursor: pointer; font-family: inherit; outline: none; text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cs-trigger:focus, .cs-wrap.open .cs-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8,144,242,0.12);
}
.cs-trigger-val { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
.cs-placeholder { color: var(--text-muted); }
.cs-arrow { flex-shrink: 0; color: var(--text-muted); transition: transform 0.15s; }
.cs-wrap.open .cs-arrow { transform: rotate(180deg); }
.cs-dropdown {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  z-index: 300; max-height: 240px; overflow-y: auto;
}
.cs-wrap.open .cs-dropdown { display: block; }
.cs-option {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--text);
  transition: background 0.1s;
}
.cs-option:hover, .cs-option.cs-selected { background: var(--bg-subtle); }
.cs-trigger.input-error { border-color: var(--danger); }
.filter-bar .cs-wrap { flex: 1; min-width: 120px; width: auto; }
.filter-bar .cs-trigger { height: 32px; }

@media (max-width: 600px) {
  .form-row-2 { grid-template-columns: 1fr; }
  .options-layout { grid-template-columns: 1fr; }
  .admin-nav { flex-wrap: wrap; }
}

/* ── Dark mode ─────────────────────────────────────────── */
html[data-theme="dark"] {
  --bg: #111318;
  --bg-subtle: #1A1D25;
  --surface: #1A1D25;
  --border: #2A2E3D;
  --border-strong: #363A4F;
  --text: #E2E4EF;
  --text-muted: #8B90A7;
  --primary: #38A8F8;
  --primary-hover: #1B9CF0;
  --primary-light: #0C2A45;
  --purple-light: #1E1540;
  --danger-light: #2A0F0F;
  --success: #22C55E;
  --success-light: #0A2316;
  --warning-light: #251A08;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
  color-scheme: dark;
}

html[data-theme="dark"] .badge { background: var(--border); }
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-active { background: var(--lime); color: var(--lime-text); }
html[data-theme="dark"] .btn-ghost:hover { background: var(--lime); color: var(--lime-text); border-color: var(--lime); }
html[data-theme="dark"] .nav-logo { filter: invert(1); }
html[data-theme="dark"] .auth-logo img { filter: invert(1); }
html[data-theme="dark"] .cs-option:hover,
html[data-theme="dark"] .cs-option.cs-selected { background: var(--border); }

/* Theme toggle button */
.btn-theme {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-theme:hover { background: var(--border); color: var(--text); }
