@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #111a2c;
  --surface-2: #162136;
  --surface-3: #1b2941;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, .085);
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 16px;
  --shadow: 0 18px 48px rgba(0, 0, 0, .22);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.skip-link { position: fixed; z-index: 200; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-150%); border-radius: 8px; background: var(--accent); color: #052e16; font-weight: 700; }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.button, .icon-button, .text-button { cursor: pointer; border: 0; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border-radius: 10px; font-weight: 600; transition: background-color .18s ease, border-color .18s ease, opacity .18s ease; }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button--primary { background: var(--accent); color: #052e16; }
.button--primary:hover:not(:disabled) { background: var(--accent-hover); color: #fff; }
.button--secondary { border: 1px solid var(--border); background: var(--surface-2); }
.button--secondary:hover:not(:disabled), .button--ghost:hover:not(:disabled) { background: var(--surface-3); }
.button--ghost { width: 100%; border: 1px solid var(--border); background: transparent; color: var(--muted); }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: transparent; }
.icon-button:hover { background: var(--surface-2); }
.text-button { min-height: 44px; padding: 0 4px; background: transparent; color: var(--accent); font-weight: 600; }
.text-button:hover { color: #4ade80; }
:focus-visible { outline: 3px solid rgba(96, 165, 250, .8); outline-offset: 2px; }

.boot { min-height: 100dvh; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 2px solid rgba(255, 255, 255, .16); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0, rgba(34, 197, 94, .09), transparent 35%), var(--bg); }
.login-card { width: min(100%, 440px); padding: 36px; border: 1px solid var(--border); border-radius: 22px; background: rgba(17, 26, 44, .94); box-shadow: var(--shadow); }
.login-card h1 { margin: 6px 0 8px; font-size: clamp(28px, 5vw, 38px); line-height: 1.15; letter-spacing: -.04em; }
.login-card__lead { margin: 0 0 26px; color: var(--muted); }
.login-form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; color: #cbd5e1; font-weight: 600; }
.field input, .toolbar select { width: 100%; min-height: 46px; border: 1px solid var(--border); border-radius: 10px; background: #0e1728; color: var(--text); padding: 0 13px; outline: none; }
.field input:focus, .toolbar input:focus, .toolbar select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(96, 165, 250, .14); }
.form-message { min-height: 23px; margin: 0; color: var(--red); font-size: 14px; }
.back-link { display: block; margin-top: 22px; color: var(--muted); text-align: center; text-decoration: none; }
.back-link:hover { color: var(--text); }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.brand > span:last-child span { color: var(--accent); }
.brand__mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: rgba(34, 197, 94, .12); color: var(--accent); }
.brand__mark svg { width: 22px; height: 22px; }
.brand--login { margin-bottom: 34px; }

.app { min-height: 100dvh; }
.sidebar { position: fixed; z-index: 60; inset: 0 auto 0 0; width: 264px; display: flex; flex-direction: column; padding: 22px 16px; border-right: 1px solid var(--border); background: #0d1627; }
.sidebar__top { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 24px; }
.sidebar__close { display: none; }
.nav { display: grid; gap: 6px; }
.nav__item { min-height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; transition: background-color .18s ease, color .18s ease; }
.nav__item:hover { background: var(--surface); color: var(--text); }
.nav__item.is-active { background: rgba(34, 197, 94, .11); color: #86efac; }
.nav__item svg { width: 19px; height: 19px; }
.sidebar__footer { margin-top: auto; display: grid; gap: 14px; padding: 16px 8px 0; border-top: 1px solid var(--border); }
.admin-person { min-width: 0; display: flex; align-items: center; gap: 10px; }
.admin-person__avatar { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); color: #86efac; font-weight: 700; }
.admin-person > span:last-child { min-width: 0; display: grid; }
.admin-person strong { overflow: hidden; color: #e2e8f0; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.admin-person small { color: var(--muted); }
.nav-scrim { display: none; }

.main { min-height: 100dvh; margin-left: 264px; }
.topbar { min-height: 92px; display: flex; align-items: center; gap: 16px; padding: 18px clamp(20px, 3vw, 40px); border-bottom: 1px solid var(--border); background: rgba(11, 18, 32, .84); backdrop-filter: blur(14px); position: sticky; z-index: 30; top: 0; }
.topbar h1 { margin: 1px 0 0; font-size: 26px; line-height: 1.2; letter-spacing: -.035em; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.menu-button { display: none; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.sync-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.sync-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(34, 197, 94, .1); }
.sync-status.is-loading i { animation: pulse 1s ease infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.content { padding: clamp(20px, 3vw, 40px); }
.panel-view { display: grid; gap: 22px; animation: enter .2s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric { min-width: 0; display: flex; align-items: flex-start; gap: 14px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 28px rgba(0, 0, 0, .1); }
.metric__icon, .node-card__icon { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: rgba(34, 197, 94, .1); color: #4ade80; }
.metric p { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.metric strong { display: block; overflow: hidden; font-size: clamp(21px, 2.1vw, 29px); line-height: 1.15; letter-spacing: -.04em; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.metric small { display: block; margin-top: 7px; color: #64748b; font-size: 11px; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 22px; }
.panel { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel__head { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.panel__head h2 { margin: 3px 0 0; font-size: 17px; letter-spacing: -.02em; }
.panel__head > span { color: #cbd5e1; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-chart { height: 258px; display: flex; align-items: flex-end; gap: clamp(5px, 1vw, 12px); padding: 36px 20px 20px; }
.bar-chart__item { min-width: 0; height: 100%; flex: 1; display: flex; align-items: center; flex-direction: column; justify-content: flex-end; position: relative; }
.bar-chart__item i { width: min(100%, 30px); min-height: 4px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, #4ade80, #15803d); transition: height .25s ease; }
.bar-chart__item small { margin-top: 8px; color: #64748b; font-size: 10px; font-variant-numeric: tabular-nums; }
.bar-chart__value { display: none; position: absolute; bottom: calc(100% + 6px); padding: 4px 7px; border-radius: 6px; background: #020617; color: #e2e8f0; font-size: 10px; white-space: nowrap; }
.bar-chart__item:hover .bar-chart__value { display: block; }
.node-summary > div:last-child { padding: 8px 18px; }
.node-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 2px; border-bottom: 1px solid var(--border); }
.node-line:last-child { border: 0; }
.node-line > span:first-child { display: grid; }
.node-line small { color: var(--muted); font-size: 11px; }

.toolbar { display: flex; align-items: center; gap: 12px; }
.search { min-width: 250px; max-width: 480px; flex: 1; position: relative; }
.search svg { position: absolute; z-index: 1; top: 13px; left: 13px; width: 18px; color: var(--muted); }
.toolbar input { width: 100%; min-height: 46px; padding: 0 14px 0 42px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); outline: none; }
.toolbar select { width: auto; min-width: 180px; background: var(--surface); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: #64748b; background: rgba(255, 255, 255, .012); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
td { color: #cbd5e1; font-size: 13px; font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color .15s ease; }
tbody tr:hover { background: rgba(255, 255, 255, .022); }
tbody tr:last-child td { border-bottom: 0; }
td strong { color: var(--text); }
code { color: #93c5fd; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.identity { display: grid; max-width: 250px; }
.identity strong, .identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity small { color: var(--muted); font-size: 11px; }
.admin-tag { padding: 2px 5px; border-radius: 5px; background: rgba(96, 165, 250, .14); color: #93c5fd; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok { background: rgba(34, 197, 94, .1); color: #86efac; }
.badge--info { background: rgba(96, 165, 250, .12); color: #93c5fd; }
.badge--warn { background: rgba(251, 191, 36, .1); color: #fde68a; }
.badge--bad { background: rgba(248, 113, 113, .1); color: #fca5a5; }
.badge--muted { background: rgba(148, 163, 184, .1); color: #cbd5e1; }
.table-footer { padding: 12px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.empty { min-height: 120px; display: grid; place-items: center; color: var(--muted); text-align: center; }
td.empty { display: table-cell; height: 120px; }

.node-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.node-card { min-width: 0; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.node-card__head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 14px; }
.node-card__head h2 { margin: 3px 0 0; font-size: 21px; }
.node-card__head code { display: block; margin-top: 3px; }
.node-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 22px 0 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--border); }
.node-card dl div { padding: 13px; background: var(--surface-2); }
.node-card dt { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.node-card dd { margin: 4px 0 0; overflow: hidden; color: #e2e8f0; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }

.toast { position: fixed; z-index: 120; right: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 32px)); padding: 12px 16px; transform: translateY(12px); opacity: 0; border: 1px solid rgba(34, 197, 94, .25); border-radius: 10px; background: #12281d; color: #bbf7d0; box-shadow: var(--shadow); transition: opacity .18s ease, transform .18s ease; }
.toast.is-show { transform: translateY(0); opacity: 1; }
.toast.is-error { border-color: rgba(248, 113, 113, .25); background: #31191f; color: #fecaca; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-105%); box-shadow: var(--shadow); transition: transform .22s ease; }
  .sidebar__close, .menu-button { display: grid; }
  .nav-scrim { position: fixed; z-index: 50; inset: 0; display: block; visibility: hidden; opacity: 0; border: 0; background: rgba(2, 6, 23, .68); transition: opacity .2s ease, visibility .2s ease; }
  .nav-open .sidebar { transform: translateX(0); }
  .nav-open .nav-scrim { visibility: visible; opacity: 1; }
  .main { margin-left: 0; }
  .node-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .topbar { min-height: 78px; padding: 13px 16px; }
  .topbar h1 { font-size: 21px; }
  .topbar__actions { gap: 7px; }
  .sync-status { display: none; }
  .topbar .button { width: 44px; padding: 0; }
  .topbar .button svg { margin: 0; }
  .topbar .button { font-size: 0; }
  .content { padding: 16px; }
  .metric-grid { grid-template-columns: 1fr; gap: 10px; }
  .metric { padding: 16px; }
  .metric strong { font-size: 24px; }
  .panel-view { gap: 16px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search, .toolbar select { width: 100%; max-width: none; }
  .table-wrap { overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  tbody { padding: 8px; }
  tbody tr { margin-bottom: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
  tbody tr:last-child { margin-bottom: 0; }
  td { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 4px; border-bottom: 1px solid var(--border); white-space: normal; text-align: right; }
  td::before { content: attr(data-label); flex: 0 0 auto; color: #64748b; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
  td:last-child { border-bottom: 0; }
  td.empty { display: grid; height: 100px; }
  td.empty::before { content: none; }
  .identity { max-width: 65vw; text-align: right; }
  .bar-chart { height: 220px; padding-inline: 12px; }
  .bar-chart__item small { transform: rotate(-45deg); margin-top: 13px; }
  .node-card { padding: 16px; }
  .node-card__head { grid-template-columns: auto minmax(0, 1fr); }
  .node-card__head > .badge { grid-column: 2; justify-self: start; }
  .node-card dl { grid-template-columns: 1fr; }
  .login-card { padding: 26px 20px; }
}

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