:root {
  color-scheme: light;
  --ink: #182131;
  --muted: #5d6878;
  --dim: #8993a2;
  --canvas: #f4f6f8;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --panel-2: #f0f3f6;
  --line: #d7dde5;
  --line-soft: #e9edf2;
  --cyan: #087f93;
  --green: #4f7f11;
  --coral: #c33c34;
  --amber: #9a6500;
  --blue: #316fc5;
  --auth-panel: #ffffff;
  --auth-shadow: 0 20px 60px rgba(35, 48, 67, .14);
  --field-label: #3f4a5a;
  --input-bg: #ffffff;
  --input-border: #c9d1dc;
  --button-bg: #f3f5f7;
  --button-hover: #e9edf2;
  --nav-text: #4a5667;
  --nav-hover: #f2f5f7;
  --nav-active: #e7f4f6;
  --topbar: rgba(255, 255, 255, .94);
  --table-text: #3e4857;
  --row-hover: #f5f7f9;
  --thumb-bg: #edf1f4;
  --bar-bg: #dfe5eb;
  --chart-grid: #dce2e8;
  --badge-border: #cfd6df;
  --notice-bg: #fff8e5;
  --notice-text: #694800;
  --on-accent: #ffffff;
  --primary-hover: #066b7c;
  --sidebar-width: 224px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4f7fb;
  --muted: #8d96a6;
  --dim: #596273;
  --canvas: #090b0f;
  --sidebar: #0c0f14;
  --panel: #11151b;
  --panel-2: #151a21;
  --line: #252b35;
  --line-soft: #1b2028;
  --cyan: #35d4e8;
  --green: #b8f34a;
  --coral: #ff6b62;
  --amber: #f4b942;
  --blue: #6ca7ff;
  --auth-panel: #0f1319;
  --auth-shadow: 0 20px 70px rgba(0, 0, 0, .45);
  --field-label: #b6beca;
  --input-bg: #0b0e13;
  --input-border: #303744;
  --button-bg: #181d25;
  --button-hover: #202631;
  --nav-text: #a7b0bf;
  --nav-hover: #151a21;
  --nav-active: #1a2028;
  --topbar: rgba(9, 11, 15, .92);
  --table-text: #c9d0da;
  --row-hover: #171c24;
  --thumb-bg: #090b0f;
  --bar-bg: #242a33;
  --chart-grid: #252b35;
  --badge-border: #303844;
  --notice-bg: rgba(244, 185, 66, .06);
  --notice-text: #e7cd98;
  --on-accent: #071014;
  --primary-hover: #62e0ee;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background-color: var(--canvas);
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px), linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 42px 42px;
}
.auth-panel { width: min(100%, 410px); background: var(--auth-panel); border: 1px solid var(--line); border-radius: 8px; padding: 34px; box-shadow: var(--auth-shadow); }
.auth-theme { position: fixed; top: 20px; right: 20px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--cyan); color: var(--cyan); font-weight: 800; font-size: 14px; }
.brand-copy strong { display: block; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; }
.brand-copy span { color: var(--muted); font-size: 12px; }
.auth-panel h1 { font-size: 24px; line-height: 1.2; margin: 0 0 8px; }
.auth-panel > p { color: var(--muted); margin: 0 0 24px; font-size: 14px; line-height: 1.55; }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 12px; color: var(--field-label); font-weight: 650; }
.input, .select { width: 100%; min-height: 42px; border: 1px solid var(--input-border); border-radius: 5px; background: var(--input-bg); color: var(--ink); padding: 9px 11px; outline: none; }
.textarea { min-height: 112px; resize: vertical; line-height: 1.55; }
.field-help { color: var(--muted); font-size: 11px; line-height: 1.5; }
.input:focus, .select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(53, 212, 232, .1); }
.button { min-height: 40px; border: 1px solid var(--input-border); border-radius: 5px; background: var(--button-bg); padding: 8px 14px; cursor: pointer; font-weight: 650; }
.button:hover { background: var(--button-hover); }
.button:focus-visible, .nav-link:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.button.primary { border-color: var(--cyan); background: var(--cyan); color: var(--on-accent); }
.button.primary:hover { background: var(--primary-hover); }
.button.danger { border-color: rgba(255, 107, 98, .55); color: #ff9d96; background: rgba(255, 107, 98, .06); }
.button.block { width: 100%; }
.button:disabled { opacity: .55; cursor: wait; }
.form-message { min-height: 20px; margin-top: 12px; color: var(--coral); font-size: 13px; line-height: 1.5; }
.form-message.success { color: var(--green); }
.theme-toggle, .refresh { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: var(--button-bg); cursor: pointer; color: var(--muted); font-size: 17px; }
.theme-toggle:hover, .refresh:hover { color: var(--ink); background: var(--button-hover); }

.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--sidebar); z-index: 20; }
.sidebar .auth-brand { padding: 22px 20px; margin: 0; border-bottom: 1px solid var(--line-soft); }
.nav { display: grid; gap: 4px; padding: 18px 12px; }
.nav-link { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 0 11px; border-radius: 5px; color: var(--nav-text); font-size: 13px; font-weight: 620; }
.nav-link:hover { color: var(--ink); background: var(--nav-hover); }
.nav-link.active { color: var(--ink); background: var(--nav-active); box-shadow: inset 2px 0 var(--cyan); }
.nav-icon { width: 16px; height: 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; opacity: .8; }
.nav-icon i { border: 1px solid currentColor; }
.sidebar-foot { margin-top: auto; padding: 16px 20px 20px; border-top: 1px solid var(--line-soft); }
.operator { display: flex; align-items: center; gap: 10px; }
.operator-avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: #111708; font-size: 12px; font-weight: 800; }
.operator-copy { min-width: 0; }
.operator-copy strong, .operator-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.operator-copy strong { font-size: 12px; }
.operator-copy span { color: var(--muted); font-size: 11px; }

.main { grid-column: 2; min-width: 0; }
.topbar { height: 64px; display: flex; align-items: center; gap: 18px; padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--topbar); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.menu-button { display: none; width: 38px; height: 38px; border: 1px solid var(--line); background: var(--panel); border-radius: 5px; }
.page-heading { min-width: 0; }
.page-heading h1 { font-size: 16px; margin: 0; line-height: 1.2; }
.page-heading p { color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.range-control { display: flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.range-control button { height: 32px; border: 0; border-right: 1px solid var(--line); background: var(--button-bg); color: var(--muted); padding: 0 11px; cursor: pointer; font-size: 11px; font-weight: 700; }
.range-control button:last-child { border-right: 0; }
.range-control button.active { color: var(--on-accent); background: var(--cyan); }
.status-live { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.status-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(184, 243, 74, .45); }

.content { padding: 24px 28px 44px; max-width: 1500px; margin: 0 auto; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { min-height: 112px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 17px; }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.metric-value { margin-top: 11px; font-size: 27px; line-height: 1; font-weight: 720; }
.metric-meta { margin-top: 10px; color: var(--dim); font-size: 11px; }
.metric-accent { width: 18px; height: 2px; margin-top: 13px; background: var(--cyan); }
.metric:nth-child(2) .metric-accent { background: var(--green); }
.metric:nth-child(3) .metric-accent { background: var(--blue); }
.metric:nth-child(4) .metric-accent { background: var(--coral); }

.layout-two { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 16px; margin-bottom: 16px; }
.layout-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.panel { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); min-width: 0; }
.panel-header { min-height: 50px; display: flex; align-items: center; gap: 12px; padding: 0 17px; border-bottom: 1px solid var(--line-soft); }
.panel-header h2 { font-size: 12px; margin: 0; }
.panel-header p { color: var(--muted); font-size: 11px; margin: 0 0 0 auto; }
.panel-body { padding: 17px; }
.chart { width: 100%; height: 230px; display: block; overflow: visible; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--cyan); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-line.secondary { stroke: var(--green); }
.chart-area { fill: rgba(53, 212, 232, .06); }
.chart-label { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 16px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 2px; margin-right: 6px; vertical-align: middle; background: var(--cyan); }
.legend span:nth-child(2)::before { background: var(--green); }

.health-list { display: grid; }
.health-row { min-height: 47px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.health-row:last-child { border-bottom: 0; }
.health-name { color: var(--table-text); text-transform: capitalize; }
.health-badge, .status-badge { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--badge-border); border-radius: 999px; padding: 4px 8px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.health-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.health-badge.healthy { color: var(--green); border-color: rgba(184, 243, 74, .25); }
.health-badge.healthy::before { background: var(--green); }
.health-badge.unavailable { color: var(--coral); border-color: rgba(255, 107, 98, .25); }
.health-badge.unavailable::before { background: var(--coral); }
.status-badge.published { color: var(--green); border-color: rgba(184, 243, 74, .25); }
.status-badge.draft { color: var(--amber); }

.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { color: var(--muted); font-size: 10px; text-transform: uppercase; text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 13px; border-bottom: 1px solid var(--line-soft); color: var(--table-text); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr[data-nav] { cursor: pointer; }
.data-table tbody tr[data-nav]:hover { background: var(--row-hover); }
.table-wrap { overflow-x: auto; }
.game-cell { display: flex; align-items: center; gap: 11px; min-width: 190px; }
.game-thumb { width: 44px; height: 44px; object-fit: cover; border: 1px solid var(--line); border-radius: 4px; background: var(--thumb-bg); }
.game-cell strong, .game-cell span { display: block; }
.game-cell strong { color: var(--ink); font-size: 12px; }
.game-cell span { color: var(--muted); font-size: 10px; margin-top: 3px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
.event-name { color: var(--cyan); }

.activity { display: grid; }
.activity-row { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 43px; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
.activity-row:last-child { border-bottom: 0; }
.activity-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); }
.activity-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-time { color: var(--dim); }

.resource-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.resource-card { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 18px; }
.resource-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.resource-top strong { font-size: 24px; }
.resource-top span { color: var(--muted); font-size: 11px; }
.bar { height: 5px; margin-top: 16px; background: var(--bar-bg); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--cyan); }
.resource-card:nth-child(2) .bar > i { background: var(--green); }
.resource-card:nth-child(3) .bar > i { background: var(--coral); }

.section-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 6px 0 14px; }
.section-title h2 { font-size: 14px; margin: 0; }
.section-title p { color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.empty { min-height: 150px; display: grid; place-items: center; color: var(--muted); text-align: center; font-size: 12px; padding: 20px; }
.loading { min-height: 360px; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.loading::before { content: ""; width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--cyan); border-radius: 50%; animation: spin .8s linear infinite; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

.account-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.account-panel { padding: 20px; }
.account-panel h2 { font-size: 14px; margin: 0 0 6px; }
.account-panel > p { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0 0 20px; }
.account-meta { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.account-meta span { color: var(--muted); }
.danger-zone { margin-top: 16px; border-color: rgba(255, 107, 98, .3); }
.notice { border-left: 2px solid var(--amber); background: var(--notice-bg); color: var(--notice-text); padding: 11px 13px; margin-bottom: 16px; font-size: 12px; line-height: 1.5; }
.seo-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); gap: 16px; align-items: start; }
.settings-panel .panel-body { padding: 20px; }
.technical-panel { position: sticky; top: 80px; }
.technical-links { display: grid; border-top: 1px solid var(--line-soft); }
.technical-links a { display: flex; justify-content: space-between; gap: 12px; padding: 13px 17px; border-bottom: 1px solid var(--line-soft); color: var(--cyan); font-size: 12px; font-weight: 650; }
.technical-links a:last-child { border-bottom: 0; }
.technical-links a:hover { background: var(--row-hover); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 0 18px; margin-bottom: 2px; cursor: pointer; }
.toggle-row span { display: grid; gap: 4px; }
.toggle-row strong { font-size: 12px; }
.toggle-row small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row i { width: 40px; height: 22px; flex: 0 0 auto; border-radius: 11px; background: var(--bar-bg); border: 1px solid var(--line); padding: 2px; transition: background .15s ease; }
.toggle-row i::after { content: ""; display: block; width: 16px; height: 16px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); transition: transform .15s ease; }
.toggle-row input:checked + i { background: var(--cyan); }
.toggle-row input:checked + i::after { transform: translateX(18px); }
.toggle-row input:focus-visible + i { outline: 2px solid var(--cyan); outline-offset: 2px; }
.mobile-backdrop { display: none; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-two, .layout-even, .seo-grid { grid-template-columns: 1fr; }
  .technical-panel { position: static; }
  .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  :root { --sidebar-width: 238px; }
  .shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .shell.menu-open .sidebar { transform: translateX(0); }
  .mobile-backdrop { position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.55); }
  .shell.menu-open .mobile-backdrop { display: block; }
  .main { grid-column: auto; }
  .menu-button { display: grid; place-items: center; }
  .topbar { padding: 0 16px; }
  .status-live { display: none; }
  .content { padding: 18px 16px 34px; }
  .account-grid { grid-template-columns: 1fr; }
  .resource-grid { grid-template-columns: 1fr; }
  .range-control button { padding: 0 8px; }
}

@media (max-width: 480px) {
  .auth-page { padding: 16px; }
  .auth-panel { padding: 24px 20px; }
  .metric-grid { grid-template-columns: 1fr; }
  .topbar { height: auto; min-height: 66px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .top-actions { width: 100%; margin-left: 48px; order: 3; }
  .refresh { margin-left: auto; }
  .theme-toggle + .refresh { margin-left: 0; }
  .metric { min-height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
