/* merge-lab — SN97/SN120 merge assistant. Shares the minelab palette; uses a
   grouped sidebar instead of a tab row so the menu scales as pages are added. */

:root {
  color-scheme: light;
  --page:        #f9f9f7;
  --surface-1:   #fcfcfb;
  --surface-2:   #f2f1ed;
  --text-1:      #0b0b0b;
  --text-2:      #52514e;
  --muted:       #898781;
  --grid:        #e1e0d9;
  --border:      rgba(11, 11, 11, 0.10);
  --accent:      #2a78d6;
  --series-2:    #eb6834;
  --series-3:    #1baf7a;
  --good:        #0ca30c;
  --warning:     #fab219;
  --serious:     #ec835a;
  --critical:    #d03b3b;
  --shadow:      0 1px 2px rgba(11, 11, 11, .06), 0 8px 24px rgba(11, 11, 11, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav-w: 216px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #232322;
    --text-1: #ffffff; --text-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --border: rgba(255,255,255,0.10);
    --accent: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #232322;
  --text-1: #ffffff; --text-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --border: rgba(255,255,255,0.10);
  --accent: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page); color: var(--text-1);
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ------------------------------------------------------------- header */
header {
  position: sticky; top: 0; z-index: 40; height: 52px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  padding: 0 16px; display: flex; align-items: center; gap: 14px;
}
header .brand { display: flex; align-items: baseline; gap: 9px; min-width: var(--nav-w); }
header h1 { font-size: 15px; margin: 0; letter-spacing: .2px; }
header .sub { color: var(--muted); font-size: 11.5px; }
.spacer { flex: 1; }
.hdr-meta { color: var(--text-2); font-size: 12px; font-family: var(--mono); }

/* subnet switcher — the primary axis: state is isolated per subnet */
.subnet-bar { display: flex; gap: 4px; align-items: center; }
.subnet-bar button {
  border-radius: 999px; padding: 3px 12px; font-size: 12.5px;
  background: transparent; border: 1px solid var(--border); color: var(--text-2);
}
.subnet-bar button .uid { font-family: var(--mono); font-size: 10.5px; opacity: .7; margin-left: 5px; }
.subnet-bar button.on {
  background: var(--accent); color: #fff; border-color: transparent; font-weight: 600;
}
.subnet-bar button.on .uid { opacity: .85; }

button, .btn {
  font: inherit; font-size: 13px; cursor: pointer;
  background: var(--surface-2); color: var(--text-1);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 11px;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff; border-color: transparent; }
button.danger  { background: var(--critical); color: #fff; border-color: transparent; }
button.sm { padding: 2px 8px; font-size: 12px; }

input, select, textarea {
  font: inherit; font-size: 13px; background: var(--surface-1); color: var(--text-1);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 9px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }

/* --------------------------------------------------------------- shell */
.shell { display: flex; align-items: flex-start; }

nav.side {
  position: sticky; top: 52px; align-self: flex-start;
  width: var(--nav-w); flex: 0 0 var(--nav-w);
  height: calc(100vh - 52px); overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--surface-1);
  padding: 12px 10px 24px;
}
nav.side .grp { margin: 14px 0 5px; padding: 0 8px; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
nav.side .grp:first-child { margin-top: 2px; }
nav.side a.item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; border-radius: 7px; color: var(--text-2);
  font-size: 13.5px; text-decoration: none; position: relative;
}
nav.side a.item:hover { background: var(--surface-2); color: var(--text-1); text-decoration: none; }
nav.side a.item.active { background: var(--surface-2); color: var(--text-1); font-weight: 600; }
nav.side a.item.active::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 2px; background: var(--accent);
}
nav.side .ic { width: 17px; text-align: center; opacity: .85; }
nav.side .badge {
  margin-left: auto; font-family: var(--mono); font-size: 10.5px;
  color: var(--muted); background: var(--page);
  border: 1px solid var(--border); border-radius: 999px; padding: 0 6px;
}

main { flex: 1; min-width: 0; padding: 20px 24px 60px; }
.view { display: none; }
.view.active { display: block; }
h2 { font-size: 15px; margin: 0 0 3px; }
.hint { color: var(--text-2); margin: 0 0 14px; max-width: 76ch; font-size: 13px; }
.note { color: var(--muted); font-weight: 400; font-size: 12px; }

.panel {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 11px; padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel > h2 { margin-bottom: 10px; }
.controls { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 11px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 4px; }
.col > span { font-size: 11.5px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }

/* --------------------------------------------------------------- tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 11px; margin-bottom: 16px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 11px; padding: 11px 13px; box-shadow: var(--shadow);
}
.tile .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.tile .v { font-size: 21px; font-family: var(--mono); margin-top: 3px; }
.tile .s { color: var(--text-2); font-size: 11.5px; }

/* -------------------------------------------------------------- tables */
.scroll-x { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 5px 9px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; font-size: 11.5px;
     position: sticky; top: 0; background: var(--surface-1); z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
td.num, th.num { text-align: right; font-family: var(--mono); }
tbody tr:hover { background: var(--surface-2); }
.tbl-wrap { max-height: 62vh; overflow: auto; }

.pill { display: inline-block; padding: 0 7px; border-radius: 999px;
        font-size: 11px; border: 1px solid var(--border); color: var(--text-2); }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.warn { color: var(--warning); border-color: var(--warning); }
.pill.bad  { color: var(--critical); border-color: var(--critical); }
.pill.king { color: var(--series-2); border-color: var(--series-2); }

/* ------------------------------------------------------------- checks */
.check { display: flex; gap: 9px; padding: 6px 0; border-bottom: 1px solid var(--grid); align-items: baseline; }
.check .mark { width: 16px; font-family: var(--mono); }
.check.ok .mark { color: var(--good); }
.check.no .mark { color: var(--critical); }
.check.wn .mark { color: var(--warning); }
.check .nm { font-family: var(--mono); font-size: 12px; min-width: 190px; }
.check .dt { color: var(--text-2); font-size: 12.5px; }

/* --------------------------------------------------------------- misc */
.log {
  font-family: var(--mono); font-size: 12px; background: var(--page);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
  max-height: 46vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.log .t { color: var(--muted); }
.log .warn { color: var(--warning); }
.log .err { color: var(--critical); }
.bar { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.matrix td, .matrix th { font-family: var(--mono); font-size: 11px; padding: 3px 6px; text-align: center; }
.matrix td.self { color: var(--muted); }
.empty { color: var(--muted); padding: 22px; text-align: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--mono); }
.callout {
  border-left: 3px solid var(--warning); background: var(--surface-2);
  padding: 9px 13px; border-radius: 0 8px 8px 0; margin: 10px 0; font-size: 13px;
}
.callout.info { border-left-color: var(--accent); }
.callout.bad { border-left-color: var(--critical); }
.callout b { display: block; margin-bottom: 3px; }
ul.tight { margin: 6px 0; padding-left: 20px; }
ul.tight li { margin: 3px 0; }

@media (max-width: 820px) {
  :root { --nav-w: 60px; }
  nav.side .lbl, nav.side .grp, nav.side .badge { display: none; }
  header .brand { min-width: auto; }
  main { padding: 16px 12px 50px; }
}
