/* Light is the default; [data-theme="dark"] flips the palette. */
:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface2: #f7f9fc;
  --ink: #1c2330;
  --muted: #6b7691;
  --line: #e6e9f0;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --good: #1d7a3e;
  --bad: #b3261e;
  --warn: #8a5b00;
  --sidebar-bg: #0d1424;
  --sidebar-ink: #dbe2f0;
  --sidebar-muted: #8b97b3;
  --sidebar-active: #1b2540;
  --shadow: 0 1px 3px rgba(16,23,38,.08), 0 1px 2px rgba(16,23,38,.04);
}
[data-theme="dark"] {
  --bg: #12151c;
  --surface: #1a1f2b;
  --surface2: #222836;
  --ink: #e6ebf3;
  --muted: #9aa6be;
  --line: #2b3242;
  --accent: #4d80ff;
  --accent-ink: #0d1424;
  --good: #45d17e;
  --bad: #ff6b60;
  --warn: #e0a83a;
  --sidebar-bg: #0a0e17;
  --sidebar-ink: #cdd6e6;
  --sidebar-muted: #7c88a4;
  --sidebar-active: #1a2237;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}
* { box-sizing: border-box; margin: 0; }
body { font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
       background: var(--bg); color: var(--ink); }

/* Layout */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-ink);
           display: flex; flex-direction: column; padding: 1rem .75rem;
           position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem 1rem; }
.sidebar-brand .logo { font-size: 1.5rem; }
.sidebar-brand .title { font-weight: 700; font-size: 1rem; }
.sidebar-brand .sub { font-size: .72rem; color: var(--sidebar-muted); }
.side-nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.nav-item { display: flex; align-items: center; gap: .6rem; width: 100%;
            padding: .6rem .7rem; border: none; border-radius: 7px; cursor: pointer;
            background: transparent; color: var(--sidebar-ink); font-size: .9rem;
            text-align: left; transition: background .12s; }
.nav-item .ic { font-size: 1rem; width: 1.2rem; text-align: center; }
.nav-item:hover { background: var(--sidebar-active); }
.nav-item.active { background: var(--sidebar-active); font-weight: 600; }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; font-size: .72rem;
             font-weight: 700; min-width: 20px; text-align: center; padding: .05rem .4rem;
             border-radius: 999px; }
.sidebar-foot { display: flex; flex-direction: column; gap: .5rem; padding-top: .75rem;
                border-top: 1px solid rgba(255,255,255,.08); font-size: .82rem; }
.side-link { background: transparent; border: none; color: var(--sidebar-muted);
             text-align: left; cursor: pointer; padding: .3rem .5rem; border-radius: 6px;
             text-decoration: none; font-size: .82rem; }
.side-link:hover { background: var(--sidebar-active); color: var(--sidebar-ink); }
.product-foot { color: var(--sidebar-muted); padding: .3rem .5rem; font-size: .78rem; }
.product-foot strong { color: var(--sidebar-ink); }
.conn { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem;
        padding: .3rem .5rem; border-radius: 6px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; }
.conn.online { color: var(--good); }
.conn.online .dot { background: var(--good); }
.conn.offline { color: var(--bad); }
.conn.offline .dot { background: var(--bad); }

/* Content */
.content { padding: 1.75rem 2rem 4rem; max-width: 1080px; }
.view { display: none; }
.view.active { display: block; animation: fade .15s ease; }
@keyframes fade { from { opacity: .4; } to { opacity: 1; } }
.view-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.view-head h1 { font-size: 1.4rem; font-weight: 650; }
.view-head .view-help { font-size: .82rem; color: var(--muted); margin-left: auto; }

/* Buttons */
button { padding: .4rem .85rem; border: 1px solid var(--line); border-radius: 6px;
         background: var(--surface); color: var(--ink); cursor: pointer;
         font-size: .85rem; font-weight: 500; transition: background .12s, border-color .12s; }
button:hover { background: var(--surface2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.06); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.small { padding: .22rem .55rem; font-size: .78rem; }
button:disabled { opacity: .55; cursor: default; }

/* Banner + toast */
.banner { padding: .8rem 1.1rem; border-radius: 10px; font-size: .9rem; margin-bottom: 1.25rem; }
.banner.error { background: color-mix(in srgb, var(--bad) 12%, var(--surface));
                border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--surface)); }
.banner strong { display: block; margin-bottom: .15rem; }
.toast { position: fixed; top: 1.25rem; right: 1.25rem; z-index: 30; max-width: 400px;
         padding: .75rem 1.1rem; border-radius: 8px; background: var(--bad); color: #fff;
         box-shadow: 0 6px 20px rgba(0,0,0,.28); font-size: .9rem; }
.toast.ok { background: var(--good); }

/* Cards / sections in views */
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr));
               gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
        padding: .8rem .95rem; display: flex; flex-direction: column; gap: .4rem;
        box-shadow: var(--shadow); }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat-row { display: flex; align-items: center; gap: .6rem; }
.value { font-weight: 650; font-size: 1rem; }
.value.big { font-size: 1.7rem; font-weight: 700; }
.value.good { color: var(--good); }
.value.bad { color: var(--bad); }

.help-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
             padding: 1.1rem 1.35rem; box-shadow: var(--shadow); }
.help-card h2 { font-size: 1.02rem; margin-bottom: .5rem; }
.help-steps { margin: .6rem 0 .6rem 1.2rem; display: grid; gap: .5rem; }
.muted { color: var(--muted); font-size: .88rem; margin-top: .6rem; }
.muted a, .help-card a { color: var(--accent); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .88rem;
        background: var(--surface); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
     color: var(--muted); padding: .55rem .7rem; border-bottom: 2px solid var(--line);
     background: var(--surface2); }
td { padding: .65rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td code { font-size: .8rem; background: var(--surface2); padding: .12rem .35rem;
          border-radius: 4px; word-break: break-all; }
td select { padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 5px;
            margin-right: .35rem; background: var(--surface); color: var(--ink); }
.count-badge { background: var(--bad); color: #fff; font-size: .78rem; font-weight: 700;
               min-width: 22px; text-align: center; padding: .1rem .5rem; border-radius: 999px; }

/* Empty states */
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--muted);
               background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
               box-shadow: var(--shadow); }
.empty-state .empty-icon { font-size: 2rem; margin-bottom: .4rem; }
.empty-state p { margin: .2rem auto; max-width: 460px; }
.empty-state strong { color: var(--ink); }

/* Badges */
.badge { display: inline-block; padding: .12rem .6rem; border-radius: 999px;
         font-size: .74rem; font-weight: 650; }
.badge.l1 { background: color-mix(in srgb, var(--muted) 22%, var(--surface)); color: var(--ink); }
.badge.l2 { background: color-mix(in srgb, var(--warn) 24%, var(--surface)); color: var(--warn); }
.badge.l3 { background: color-mix(in srgb, var(--good) 22%, var(--surface)); color: var(--good); }

/* Settings */
.cfg-group { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
             color: var(--muted); margin: 1.4rem 0 .2rem; border-bottom: 1px solid var(--line);
             padding-bottom: .3rem; }
.field { margin: 1rem 0; max-width: 560px; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.field input { width: 100%; padding: .5rem .7rem; font-size: .95rem; border: 1px solid var(--line);
               border-radius: 6px; background: var(--surface); color: var(--ink); }
.field input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
                     border-color: var(--accent); }
.hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.hint code, .field code { background: var(--surface2); padding: .05rem .3rem; border-radius: 4px; }
.settings-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.test-result { font-size: .85rem; }
.test-result.ok { color: var(--good); }
.test-result.bad { color: var(--bad); }

/* Report */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
          padding: 1.1rem 1.35rem; box-shadow: var(--shadow); }
.report h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
             margin: 1rem 0 .35rem; color: var(--muted); }
.report > p:first-child { color: var(--muted); font-size: .88rem; }
.report ul { padding-left: 1.2rem; margin: .2rem 0; }
.report table { margin-top: .3rem; }
.report .empty { color: var(--muted); font-style: italic; }
.report .empty-state { box-shadow: none; border: none; background: transparent; }

/* Self-explanatory report */
.report-meta { color: var(--muted); font-size: .82rem; }
.report-summary { font-size: 1.02rem; margin: .5rem 0 .9rem; }
.attention { background: color-mix(in srgb, var(--warn) 12%, var(--surface));
             border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--surface));
             border-radius: 8px; padding: .8rem 1.1rem; margin: .8rem 0 1rem; }
.attention h4 { font-size: .9rem; margin-bottom: .4rem; color: var(--warn); }
.attention ul { padding-left: 1.2rem; }
.attention li { margin: .35rem 0; }
.raw-detail { color: var(--muted); font-size: .78rem; margin-top: .15rem;
              font-family: ui-monospace, "SF Mono", Consolas, monospace; word-break: break-all; }
.h3-hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); }
.cell-sub { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.badge.bad { background: color-mix(in srgb, var(--bad) 18%, var(--surface)); color: var(--bad); }

.hidden { display: none !important; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap;
             align-items: center; gap: .5rem; }
  .sidebar-brand { padding: .3rem; }
  .side-nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; }
  .sidebar-foot { flex-direction: row; flex-wrap: wrap; border-top: none; padding-top: 0; }
  .content { padding: 1.25rem; }
}
