/* Provisioning panel. Colour carries meaning: teal is downstream, violet upstream,
   amber "changed, not published yet", red errors. Everything else stays quiet. */

@font-face { font-family: "Plex Sans"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Sans"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Sans"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Sans"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-latin-ext-500-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Sans"; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Sans"; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-latin-ext-600-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Mono"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Mono"; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Plex Mono"; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --paper: #edf1f5;
  --sheet: #ffffff;
  --ink: #12233b;
  --ink-2: #4a5a70;
  --ink-3: #7a889b;
  --rule: #d3dbe4;
  --rule-2: #e4e9ef;
  --ds: #0e7c72;
  --ds-soft: #d5eeeb;
  --us: #6d3fc0;
  --us-soft: #e8e0f7;
  --pending: #a86200;
  --pending-soft: #fbefd8;
  --danger: #b42318;
  --danger-soft: #fce9e7;
  --ok: #1f7a3a;
  --ok-soft: #e3f3e6;
  --radius: 6px;
  --sans: "Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 15px/1.5 var(--sans); font-feature-settings: "ss02";
}
a { color: var(--ink); text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--ds); outline-offset: 2px; border-radius: 3px; }
h1 { font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 6px; }
h2 { font-size: 18px; font-weight: 600; margin: 32px 0 10px; }
p { margin: 0 0 12px; max-width: 72ch; }
.lead { color: var(--ink-2); margin-bottom: 22px; }
.num { font-variant-numeric: tabular-nums; }
.file { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); }
.quiet { color: var(--ink-3); }

/* ---- top bar ---- */
.top { background: var(--ink); color: #fff; }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 24px; display: flex; align-items: stretch; gap: 32px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; font-size: 16px; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; flex: none; }
.nav { display: flex; gap: 4px; align-items: stretch; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 0 12px; color: #b9c4d3; text-decoration: none; border-bottom: 3px solid transparent; font-weight: 500; }
.nav a:hover { color: #fff; }
.nav a[aria-current="page"] { color: #fff; border-bottom-color: #5fc9bd; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #f0a830; }
.who { margin-left: auto; display: flex; align-items: center; gap: 14px; color: #b9c4d3; font-size: 14px; }
.who button { background: none; border: 1px solid #3a4c66; color: #dfe6ef; border-radius: var(--radius); padding: 5px 10px; font: inherit; cursor: pointer; }
.who button:hover { border-color: #8597af; }

main { max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; }

/* ---- messages ---- */
.msg { border-radius: var(--radius); padding: 10px 14px; margin: 0 0 20px; max-width: 900px; }
.msg.ok { background: var(--ok-soft); color: #134d26; }
.msg.err { background: var(--danger-soft); color: #7a170f; }
.msg.pend { background: var(--pending-soft); color: #6b3f00; }

/* ---- buttons and inputs ---- */
button, .btn {
  font: 500 14px/1 var(--sans); border-radius: var(--radius); padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: #fff; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: #22395a; }
button.ghost, .btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
button.ghost:hover, .btn.ghost:hover { border-color: var(--ink-2); background: transparent; }
button.danger { background: transparent; color: var(--danger); border-color: #efc4bf; }
button:disabled, button:disabled:hover { cursor: default; background: transparent; color: var(--ink-3); border-color: var(--rule-2); }
button.big { padding: 12px 20px; font-size: 15px; }
input[type=text], input[type=password], select, textarea {
  font: inherit; color: var(--ink); background: var(--sheet); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 7px 9px;
}
input:hover, select:hover { border-color: #b7c3d0; }

/* ---- tariff ladder ---- */
.summary { display: flex; gap: 28px; margin: 0 0 18px; color: var(--ink-2); }
.summary b { color: var(--ink); font-weight: 600; font-size: 20px; display: block; line-height: 1.1; }
.ladder { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.lrow {
  display: grid; align-items: center; gap: 14px;
  grid-template-columns: minmax(170px, 1.3fr) 64px 178px 96px 96px minmax(200px, 2fr) 124px;
  padding: 12px 18px; border-top: 1px solid var(--rule-2);
}
.lrow:first-child { border-top: 0; }
.lhead { font-size: 13px; color: var(--ink-3); padding-top: 10px; padding-bottom: 8px; background: #f7f9fb; }
.lrow.pending { box-shadow: inset 3px 0 0 var(--pending); }
.lrow:target { background: #f5fbfa; }
.tname { font-weight: 600; line-height: 1.25; }
.tname small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.tname .file { font-size: 11.5px; }
.orphan { color: var(--pending); font-weight: 500; }
.modems { text-align: right; font-weight: 500; }
.modems small { display: block; color: var(--ink-3); font-weight: 400; font-size: 12px; }
.kind select { width: 100%; }
.speed { position: relative; }
.speed input { width: 100%; text-align: right; padding-right: 9px; font-variant-numeric: tabular-nums; font-weight: 500; }
.speed.ds input { border-left: 3px solid var(--ds); }
.speed.us input { border-left: 3px solid var(--us); }
.speed input[aria-invalid=true] { border-color: var(--danger); background: var(--danger-soft); }
.unit { display: block; font-size: 11.5px; color: var(--ink-3); text-align: right; margin-top: 2px; }
/* Bars double as sliders. Position f (0..1) is log10(Mbit/s) / log10(2000); the fill ends
   where the range thumb's centre sits, i.e. 7px + f * (width - 14px), and the ticks use
   the same mapping so 10/100/1000 line up with the handle. */
.bars { position: relative; height: 40px; --fd: 0; --fu: 0; }
.bars .tick { position: absolute; top: 3px; bottom: 3px; width: 1px; background: var(--rule-2); }
.bar { position: absolute; left: 0; height: 9px; border-radius: 0 5px 5px 0; pointer-events: none; }
.bar.ds { top: 9px; width: calc(7px + var(--fd) * (100% - 14px)); background: var(--ds); }
.bar.us { top: 22px; width: calc(7px + var(--fu) * (100% - 14px)); background: var(--us); }
.sl { position: absolute; left: 0; width: 100%; height: 14px; margin: 0; padding: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: ew-resize; }
.sl.ds { top: 6.5px; --c: var(--ds); }
.sl.us { top: 19.5px; --c: var(--us); }
.sl:focus { outline: none; }
.sl::-webkit-slider-runnable-track { height: 14px; background: transparent; }
.sl::-moz-range-track { height: 14px; background: transparent; }
.sl::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--c); box-shadow: 0 1px 3px rgba(18, 35, 59, .3); opacity: 0; transition: opacity .12s; }
.sl::-moz-range-thumb { box-sizing: border-box; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--c); box-shadow: 0 1px 3px rgba(18, 35, 59, .3); opacity: 0; transition: opacity .12s; }
.lrow:hover .sl::-webkit-slider-thumb, .sl:active::-webkit-slider-thumb { opacity: 1; }
.lrow:hover .sl::-moz-range-thumb, .sl:active::-moz-range-thumb { opacity: 1; }
.sl:active::-webkit-slider-thumb { transform: scale(1.15); }
.sl:active::-moz-range-thumb { transform: scale(1.15); }
@media (hover: none) {
  .sl::-webkit-slider-thumb { opacity: 1; }
  .sl::-moz-range-thumb { opacity: 1; }
}
.t10 { left: calc(7px + 0.30293 * (100% - 14px)); } .t100 { left: calc(7px + 0.60586 * (100% - 14px)); } .t1000 { left: calc(7px + 0.90879 * (100% - 14px)); }
.scale { position: relative; height: 16px; font-size: 11.5px; color: var(--ink-3); }
.scale span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.scale .s10 { left: calc(7px + 0.30293 * (100% - 14px)); } .scale .s100 { left: calc(7px + 0.60586 * (100% - 14px)); } .scale .s1000 { left: calc(7px + 0.90879 * (100% - 14px)); transform: translateX(-70%); }
.legend i.bar-ds { background: var(--ds); } .legend i.bar-us { background: var(--us); }
.save { text-align: right; }
.legend { display: flex; gap: 18px; font-size: 13px; color: var(--ink-2); margin: 14px 2px 0; flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; height: 8px; border-radius: 0 4px 4px 0; margin-right: 6px; vertical-align: 1px; }
.legend .pend { border-left: 3px solid var(--pending); padding-left: 8px; }
.missing { margin-top: 30px; }
.missing .lrow { background: #fbfcfd; }
.rowtools { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
/* the reset button only shows on a row with unsaved changes (app.js sets .dirty) */
button.reset { visibility: hidden; display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; background: transparent; color: var(--ink-2); border-color: var(--rule); }
button.reset:hover { background: transparent; color: var(--ink); border-color: var(--ink-2); }
.lrow.dirty button.reset { visibility: visible; }

/* ---- templates ---- */
.tlist { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; }
.tlist a.titem { display: grid; grid-template-columns: 1fr 160px 120px 220px; gap: 16px; padding: 16px 20px; border-top: 1px solid var(--rule-2); text-decoration: none; align-items: baseline; }
.tlist a.titem:first-child { border-top: 0; }
.tlist a.titem:hover { background: #f7f9fb; }
.tlist .tl { font-weight: 600; }
.tlist .thint { display: block; color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
textarea.code {
  width: 100%; min-height: 62vh; font: 13px/1.55 var(--mono); tab-size: 8; white-space: pre;
  padding: 14px 16px; background: #fbfcfe; resize: vertical;
}
.side { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 16px 18px; }
.side h2 { margin-top: 0; font-size: 15px; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li { padding: 7px 0; border-top: 1px solid var(--rule-2); font-size: 14px; }
.side li:first-child { border-top: 0; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.actions label { color: var(--ink-2); font-size: 14px; }
.hint { font-size: 13.5px; color: var(--ink-2); }
.hint code, p code { font-family: var(--mono); font-size: 12.5px; background: var(--rule-2); padding: 1px 5px; border-radius: 4px; }
.check { margin-top: 22px; }
pre.decoded { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 16px; font: 12.5px/1.55 var(--mono); max-height: 60vh; overflow: auto; tab-size: 4; margin: 0; }
pre.bad { background: var(--danger-soft); border-color: #efc4bf; color: #7a170f; white-space: pre-wrap; }

/* ---- publication ---- */
.pubbar { display: flex; align-items: center; gap: 18px; background: var(--sheet); border: 1px solid var(--rule); border-left: 4px solid var(--pending); border-radius: 10px; padding: 16px 20px; margin-bottom: 22px; flex-wrap: wrap; }
.pubbar .what { font-size: 18px; font-weight: 600; }
.pubbar form { margin-left: auto; }
.empty { background: var(--sheet); border: 1px solid var(--rule); border-left: 4px solid var(--ok); border-radius: 10px; padding: 20px 22px; }
.empty .what { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
details.f { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; margin-bottom: 10px; }
details.f > summary { display: grid; grid-template-columns: 250px 1fr 120px 120px; gap: 14px; padding: 13px 18px; cursor: pointer; list-style: none; align-items: baseline; }
details.f > summary::-webkit-details-marker { display: none; }
details.f > summary .file { font-size: 13.5px; color: var(--ink); font-weight: 500; }
details.f[open] > summary { border-bottom: 1px solid var(--rule-2); }
.badge { display: inline-block; font-size: 12.5px; border-radius: 999px; padding: 2px 9px; font-weight: 500; }
.badge.changed { background: var(--pending-soft); color: #6b3f00; }
.badge.new { background: var(--ds-soft); color: #08534c; }
.badge.error { background: var(--danger-soft); color: #7a170f; }
.diff { font: 12.5px/1.6 var(--mono); padding: 10px 0; overflow-x: auto; tab-size: 4; }
.hunk + .hunk { border-top: 1px dashed var(--rule); margin-top: 6px; padding-top: 6px; }
.dl { display: block; white-space: pre; padding: 0 18px; }
.dl.del { background: var(--danger-soft); color: #7a170f; }
.dl.add { background: var(--ok-soft); color: #134d26; }
.dl.ctx { color: var(--ink-3); }
.pad { padding: 12px 18px; margin: 0; }
.samelist { columns: 3 220px; font: 12.5px/1.8 var(--mono); color: var(--ink-2); padding: 12px 18px; }

/* ---- history ---- */
table.hist { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
table.hist td { padding: 10px 16px; border-top: 1px solid var(--rule-2); vertical-align: top; }
table.hist tr:first-child td { border-top: 0; }
table.hist td.when { white-space: nowrap; color: var(--ink-2); width: 150px; }
table.hist td.by { white-space: nowrap; width: 110px; font-weight: 500; }
table.hist td.act { width: 150px; white-space: nowrap; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.login { width: 100%; max-width: 380px; background: var(--sheet); border-radius: 12px; padding: 32px 30px 28px; }
.login h1 { font-size: 24px; display: flex; align-items: center; gap: 10px; }
.login label { display: block; font-size: 14px; color: var(--ink-2); margin: 14px 0 5px; }
.login input { width: 100%; padding: 10px 11px; }
.login button { width: 100%; margin-top: 22px; padding: 12px; font-size: 15px; }
.login .msg { margin: 16px 0 0; }

@media (max-width: 980px) {
  .top-in { flex-wrap: wrap; gap: 0 18px; padding: 8px 16px 0; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .nav a { padding: 10px 10px; }
  main { padding: 22px 16px 48px; }
  .lrow { grid-template-columns: 1fr 1fr; gap: 10px 14px; }
  .lhead { display: none; }
  .tname, .bars, .save { grid-column: 1 / -1; }
  .modems { text-align: left; }
  .save { text-align: left; }
  .editor-grid { grid-template-columns: 1fr; }
  .tlist a.titem { grid-template-columns: 1fr; gap: 2px; }
  details.f > summary { grid-template-columns: 1fr; gap: 2px; }
}

/* ---- devices: DHCP rules ---- */
.status { margin-bottom: 22px; }
.rules { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; }
.rlist { list-style: none; margin: 0; padding: 0; counter-reset: rule; }
.rrow {
  display: grid; gap: 8px 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--rule-2);
  grid-template-columns: 24px minmax(190px, 1.2fr) minmax(200px, 1.5fr) minmax(160px, 1fr) 118px 104px;
}
.rhead { border-top: 0; font-size: 13px; color: var(--ink-3); background: #f7f9fb; padding-top: 10px; padding-bottom: 8px; border-radius: 10px 10px 0 0; }
.rlist .rrow { counter-increment: rule; }
.rlist .rnum::before { content: counter(rule); }
.rnum { font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rrow input[type=text], .rrow select { width: 100%; min-width: 0; }
.rrow input[name^="fw."] { font-family: var(--mono); font-size: 12.5px; }
.rmodel { display: grid; grid-template-columns: 1fr 104px; gap: 6px; }
.ropt { font-size: 13.5px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.rtools { display: flex; gap: 4px; justify-content: flex-end; }
button.icon { width: 30px; height: 30px; padding: 0; background: transparent; color: var(--ink-2); border-color: var(--rule); font-size: 15px; }
button.icon:hover { background: transparent; color: var(--ink); border-color: var(--ink-2); }
button.icon.del:hover { color: var(--danger); border-color: #efc4bf; }
.rnote { grid-column: 2 / -1; font-size: 13px; border-color: transparent !important; background: transparent !important; color: var(--ink-2); padding: 2px 9px !important; }
.rnote:hover, .rnote:focus { border-color: var(--rule) !important; background: var(--sheet) !important; }
.rrow.hit { background: #f5fbfa; box-shadow: inset 3px 0 0 var(--ds); }
.rrow.rest { color: var(--ink-2); background: #fbfcfd; border-radius: 0 0 10px 10px; }
.rhelp { margin-top: 26px; max-width: 78ch; }
.rhelp h2 { font-size: 15px; margin-top: 0; }
.rhelp p { margin-bottom: 8px; }
.editor-grid aside { display: grid; gap: 18px; }
.tester label { display: block; font-size: 13.5px; color: var(--ink-2); margin: 8px 0 4px; }
.tester input { width: 100%; }
.tester button { margin-top: 12px; }
.tres { margin-top: 14px; padding: 10px 12px; background: var(--ds-soft); border-radius: var(--radius); font-size: 14px; }
.small { font-size: 12.5px; margin-top: 10px; }
.side .badge { font-size: 11.5px; padding: 1px 7px; }
@media (max-width: 980px) {
  .rhead { display: none; }
  .rrow { grid-template-columns: 24px 1fr 1fr; }
  .rmodel, .rrow > input[name^="fw."], .rrow > select { grid-column: 2 / -1; }
  .ropt { grid-column: 2; }
  .rtools { grid-column: 3; }
}
.devside { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 0.8fr); gap: 18px; margin-top: 26px; align-items: start; }
.devside .rhelp { margin-top: 0; }
.rnote::placeholder { color: transparent; }
.rrow:hover .rnote::placeholder, .rnote:focus::placeholder { color: var(--ink-3); }
@media (max-width: 980px) { .devside { grid-template-columns: 1fr; } }
