:root,
[data-theme='light'] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e4e4e7;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #09090b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-fg: #ffffff;
  --accent-soft: #eef2ff;
  --accent-text: #4338ca;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --info: #0369a1;
  --info-soft: #e0f2fe;
  --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.05);
  --shadow: 0 1px 3px rgba(9, 9, 11, 0.06), 0 8px 24px rgba(9, 9, 11, 0.06);
  --shadow-lg: 0 24px 60px rgba(9, 9, 11, 0.18);
  --media-bg: #0b0b0e;
  --overlay: rgba(9, 9, 11, 0.45);
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg: #09090b;
  --bg-subtle: #0d0d10;
  --surface: #111114;
  --surface-2: #18181c;
  --surface-3: #232328;
  --border: #25252a;
  --border-strong: #35353c;
  --text: #fafafa;
  --text-2: #d4d4d8;
  --muted: #a1a1aa;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-fg: #ffffff;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-text: #a5b4fc;
  --ok: #4ade80;
  --ok-soft: rgba(34, 197, 94, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --info: #38bdf8;
  --info-soft: rgba(14, 165, 233, 0.14);
  --shadow-sm: none;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.65);
  --media-bg: #000000;
  --overlay: rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
a { color: inherit; text-decoration: none; }
img, video, svg { display: block; }
img, video { max-width: 100%; }
h1, h2 { text-wrap: balance; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 0 0 1em; }
code, .mono { font-family: ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', monospace; font-size: 0.92em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.icon { width: 16px; height: 16px; flex: none; }
.icon.lg { width: 20px; height: 20px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; white-space: nowrap;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.icon-only.sm { width: 30px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.outline { background: transparent; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; position: relative; }
.dot.ok { background: #22c55e; }
.dot.warn { background: #f59e0b; }
.dot.off { background: var(--border-strong); }
.dot.ok.pulse::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid #22c55e; opacity: 0;
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(0.6); opacity: 0.7; } 100% { transform: scale(1.6); opacity: 0; } }

.avatar {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -0.02em;
}
.avatar.sm { width: 28px; height: 28px; border-radius: 7px; font-size: 12.5px; }
.avatar.lg { width: 48px; height: 48px; border-radius: 12px; font-size: 20px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; box-shadow: var(--shadow-sm); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 15px; }

input, textarea, select {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { height: auto; min-height: 112px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--muted); }
label, .label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin: 0 0 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--danger); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 34px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; }
.seg button {
  height: 30px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover:not(:disabled) { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.seg.block { display: flex; }
.seg.block button { flex: 1; justify-content: center; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { white-space: nowrap; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; background: var(--bg-subtle); }
tr:last-child td { border-bottom: none; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.strike { text-decoration: line-through; color: var(--muted); }

#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 380px; animation: toast-in 0.18s ease-out;
}
.toast .dot { width: 8px; height: 8px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; animation: fade 0.15s; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 960px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; border: 1px dashed var(--border-strong); border-radius: 12px; }
.empty .icon { width: 28px; height: 28px; margin: 0 auto 10px; }
.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 18px; background: var(--warn-soft); color: var(--warn); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
