/* NexAAA UI - no build step, no framework */
:root{
  --brand:#0f766e;
  --bg:#f1f5f9; --panel:#fff; --ink:#0f172a; --muted:#64748b; --line:#e2e8f0;
  --ok:#059669; --warn:#d97706; --bad:#dc2626; --info:#2563eb;
  --radius:10px; --shadow:0 1px 2px rgba(15,23,42,.06),0 4px 12px rgba(15,23,42,.04);
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  background:var(--bg); color:var(--ink); -webkit-font-smoothing:antialiased;
}
a{color:var(--brand);text-decoration:none}
a:hover{text-decoration:underline}
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}

/* ---------------------------------------------------------------- shell -- */
.shell{display:flex;min-height:100vh}
.sidebar{
  width:236px;flex:0 0 236px;background:#0b1220;color:#cbd5e1;
  display:flex;flex-direction:column;position:sticky;top:0;height:100vh;overflow-y:auto;
}
.brand{display:flex;align-items:center;gap:10px;padding:16px 18px;border-bottom:1px solid #1e293b}
.brand-mark{
  width:30px;height:30px;border-radius:8px;background:var(--brand);color:#fff;
  display:grid;place-items:center;font-weight:700;font-size:15px;flex:0 0 30px;
}
.brand-text{font-weight:600;color:#f8fafc;font-size:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sidebar nav{padding:8px 0;flex:1}
.nav-section{
  padding:14px 18px 6px;font-size:10.5px;letter-spacing:.09em;text-transform:uppercase;color:#64748b;font-weight:600;
}
.nav-item{
  display:flex;align-items:center;gap:10px;padding:8px 18px;color:#cbd5e1;font-size:13.5px;
  border-left:3px solid transparent;
}
.nav-item:hover{background:#111c33;color:#fff;text-decoration:none}
.nav-item.active{background:#111c33;color:#fff;border-left-color:var(--brand);font-weight:500}
.sidebar-foot{padding:12px 18px;font-size:11px;color:#475569;border-top:1px solid #1e293b}
.ic{width:6px;height:6px;flex:0 0 6px;border-radius:50%;background:currentColor;opacity:.35}
.nav-item.active .ic{opacity:1;background:var(--brand)}

.main{flex:1;min-width:0;display:flex;flex-direction:column}

/* --------------------------------------------------------------- topbar -- */
.topbar{
  display:flex;align-items:center;gap:14px;background:var(--panel);
  padding:0 20px;height:56px;border-bottom:1px solid var(--line);position:sticky;top:0;z-index:20;
}
.page-title{font-size:16px;font-weight:600;margin:0;white-space:nowrap}
.hamburger{display:none;background:none;border:0;font-size:20px;cursor:pointer;color:var(--ink)}
.quick-search{flex:1;max-width:420px;margin-left:auto}
.quick-search input{
  width:100%;padding:7px 12px;border:1px solid var(--line);border-radius:20px;background:#f8fafc;font-size:13px;
}
.quick-search input:focus{outline:2px solid color-mix(in srgb,var(--brand) 30%,transparent);background:#fff}
.topbar-right{display:flex;align-items:center;gap:14px;margin-left:auto}
.wallet{background:#ecfdf5;color:#065f46;padding:5px 10px;border-radius:16px;font-weight:600;font-size:12.5px;white-space:nowrap}
.usermenu{position:relative}
.usermenu summary{list-style:none;display:flex;align-items:center;gap:8px;cursor:pointer;padding:4px}
.usermenu summary::-webkit-details-marker{display:none}
.avatar{width:28px;height:28px;border-radius:50%;background:var(--brand);color:#fff;display:grid;place-items:center;font-weight:600;font-size:13px}
.uname{font-size:13px;font-weight:500}
.usermenu-panel{
  position:absolute;right:0;top:40px;background:#fff;border:1px solid var(--line);
  border-radius:var(--radius);box-shadow:var(--shadow);min-width:210px;padding:6px;z-index:30;
}
.um-meta{padding:10px;border-bottom:1px solid var(--line);display:flex;flex-direction:column;gap:2px;margin-bottom:4px}
.um-meta span{font-size:12px;color:var(--muted)}
.usermenu-panel a{display:block;padding:8px 10px;border-radius:6px;color:var(--ink);font-size:13px}
.usermenu-panel a:hover{background:#f1f5f9;text-decoration:none}

.content{padding:20px;flex:1}

/* ---------------------------------------------------------------- cards -- */
.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);margin-bottom:18px}
.card-head{display:flex;align-items:center;gap:12px;padding:13px 16px;border-bottom:1px solid var(--line);flex-wrap:wrap}
.card-head h2{margin:0;font-size:14.5px;font-weight:600}
.card-head .spacer{flex:1}
.card-body{padding:16px}
.card-body.tight{padding:0}

/* ------------------------------------------------------------- stat kpis -- */
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px;margin-bottom:18px}
.kpi{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px;box-shadow:var(--shadow)}
.kpi .k-label{font-size:11.5px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);font-weight:600}
.kpi .k-value{font-size:24px;font-weight:700;margin-top:4px;letter-spacing:-.02em}
.kpi .k-sub{font-size:12px;color:var(--muted);margin-top:2px}
.kpi.ok .k-value{color:var(--ok)} .kpi.bad .k-value{color:var(--bad)}
.kpi.warn .k-value{color:var(--warn)} .kpi.info .k-value{color:var(--info)}

/* --------------------------------------------------------------- tables -- */
.table-wrap{overflow-x:auto}
table.data{width:100%;border-collapse:collapse;font-size:13px}
table.data th{
  text-align:left;padding:9px 12px;background:#f8fafc;border-bottom:1px solid var(--line);
  font-weight:600;font-size:11.5px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);white-space:nowrap;
}
table.data td{padding:9px 12px;border-bottom:1px solid #f1f5f9;vertical-align:middle}
table.data tbody tr:hover{background:#f8fafc}
table.data td.num,table.data th.num{text-align:right;font-variant-numeric:tabular-nums}
table.data .empty{text-align:center;color:var(--muted);padding:34px 12px}
.sub{display:block;font-size:11.5px;color:var(--muted)}

/* --------------------------------------------------------------- badges -- */
.badge{display:inline-block;padding:2px 8px;border-radius:10px;font-size:11px;font-weight:600;text-transform:capitalize;white-space:nowrap}
.badge.ok{background:#dcfce7;color:#166534}
.badge.warn{background:#fef3c7;color:#92400e}
.badge.bad{background:#fee2e2;color:#991b1b}
.badge.info{background:#dbeafe;color:#1e40af}
.badge.mute{background:#e2e8f0;color:#475569}

/* -------------------------------------------------------------- buttons -- */
.btn{
  display:inline-flex;align-items:center;gap:6px;padding:7px 13px;border-radius:7px;border:1px solid var(--line);
  background:#fff;color:var(--ink);font-size:13px;font-weight:500;cursor:pointer;white-space:nowrap;
}
.btn:hover{background:#f8fafc;text-decoration:none}
.btn.primary{background:var(--brand);border-color:var(--brand);color:#fff}
.btn.primary:hover{filter:brightness(1.08)}
.btn.danger{background:var(--bad);border-color:var(--bad);color:#fff}
.btn.danger:hover{filter:brightness(1.08)}
.btn.sm{padding:4px 9px;font-size:12px}
.btn[disabled]{opacity:.5;cursor:not-allowed}
.btn-row{display:flex;gap:8px;flex-wrap:wrap}

/* ---------------------------------------------------------------- forms -- */
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:14px}
.field{display:flex;flex-direction:column;gap:5px}
.field.full{grid-column:1/-1}
.field label{font-size:12.5px;font-weight:600;color:#334155}
.field label .req{color:var(--bad)}
.field input,.field select,.field textarea{
  padding:8px 10px;border:1px solid var(--line);border-radius:7px;font-size:13.5px;font-family:inherit;background:#fff;color:var(--ink);
}
.field input:focus,.field select:focus,.field textarea:focus{
  outline:none;border-color:var(--brand);box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 15%,transparent);
}
.field .hint{font-size:11.5px;color:var(--muted)}
.field input[readonly]{background:#f8fafc;color:var(--muted)}
.checkline{display:flex;align-items:center;gap:8px;font-size:13px}
.checkline input{width:16px;height:16px}
fieldset{border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px;margin:0 0 16px}
legend{font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);padding:0 6px}
.form-actions{display:flex;gap:10px;border-top:1px solid var(--line);margin-top:16px;padding-top:16px}

.filters{display:flex;gap:10px;flex-wrap:wrap;align-items:flex-end}
.filters .field{min-width:150px}

/* --------------------------------------------------------------- alerts -- */
.alert{padding:11px 14px;border-radius:var(--radius);margin-bottom:14px;font-size:13.5px;border:1px solid transparent}
.alert.success{background:#dcfce7;border-color:#86efac;color:#14532d}
.alert.error{background:#fee2e2;border-color:#fca5a5;color:#7f1d1d}
.alert.warning{background:#fef3c7;border-color:#fcd34d;color:#78350f}
.alert.info{background:#dbeafe;border-color:#93c5fd;color:#1e3a8a}

/* --------------------------------------------------------------- pager --- */
.pager{display:flex;align-items:center;gap:5px;padding:12px 16px;flex-wrap:wrap;border-top:1px solid var(--line)}
.pager-info{font-size:12.5px;color:var(--muted);margin-right:auto}
.pg{padding:5px 10px;border:1px solid var(--line);border-radius:6px;font-size:12.5px;color:var(--ink);background:#fff}
.pg:hover{background:#f1f5f9;text-decoration:none}
.pg.active{background:var(--brand);border-color:var(--brand);color:#fff}

/* ---------------------------------------------------------------- login -- */
.login-wrap{min-height:100vh;display:grid;place-items:center;background:linear-gradient(135deg,#0b1220,#123)}
.login-card{background:#fff;border-radius:14px;padding:30px;width:min(400px,92vw);box-shadow:0 20px 50px rgba(0,0,0,.3)}
.login-card h1{margin:0 0 4px;font-size:20px}
.login-card .tag{color:var(--muted);font-size:13px;margin:0 0 20px}
.login-card .field{margin-bottom:14px}
.login-card .btn{width:100%;justify-content:center;padding:10px}
.login-foot{text-align:center;margin-top:16px;font-size:12px;color:var(--muted)}

/* --------------------------------------------------------------- misc ---- */
.two-col{display:grid;grid-template-columns:2fr 1fr;gap:18px;align-items:start}
.dl{display:grid;grid-template-columns:auto 1fr;gap:7px 16px;font-size:13px}
.dl dt{color:var(--muted);font-weight:500}
.dl dd{margin:0;font-weight:500}
.bar{height:7px;background:#e2e8f0;border-radius:4px;overflow:hidden;min-width:80px}
.bar > span{display:block;height:100%;background:var(--brand)}
.bar.over > span{background:var(--bad)}
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);padding:0 16px;flex-wrap:wrap}
.tabs a{padding:10px 12px;font-size:13px;color:var(--muted);border-bottom:2px solid transparent;font-weight:500}
.tabs a.active{color:var(--brand);border-bottom-color:var(--brand)}
.tabs a:hover{text-decoration:none;color:var(--ink)}
.code{background:#0b1220;color:#a5f3fc;padding:12px 14px;border-radius:8px;font-family:ui-monospace,monospace;font-size:12.5px;overflow-x:auto;white-space:pre-wrap;word-break:break-all}
.muted{color:var(--muted)}
.right{text-align:right}
.nowrap{white-space:nowrap}

/* --------------------------------------------------------------- print --- */
.invoice-sheet{max-width:820px;margin:20px auto;background:#fff;padding:38px;box-shadow:var(--shadow);font-size:13px}
.invoice-sheet h1{font-size:22px;margin:0 0 2px}
.inv-head{display:flex;justify-content:space-between;gap:24px;border-bottom:2px solid var(--ink);padding-bottom:16px;margin-bottom:18px}
.inv-parties{display:flex;justify-content:space-between;gap:24px;margin-bottom:18px}
.inv-total-row td{font-weight:700;border-top:2px solid var(--ink)}
@media print{
  .sidebar,.topbar,.no-print{display:none!important}
  body{background:#fff}
  .invoice-sheet{box-shadow:none;margin:0;padding:0;max-width:none}
}

/* ------------------------------------------------------------ responsive -- */
@media (max-width:900px){
  .two-col{grid-template-columns:1fr}
  .sidebar{position:fixed;left:-236px;transition:left .2s;z-index:50}
  .sidebar.open{left:0}
  .hamburger{display:block}
  .quick-search{display:none}
  .uname{display:none}
}

/* ---------------------------------------------------------------- branding -- */
.brand-logo      { max-height:34px; max-width:150px; width:auto; height:auto;
                   object-fit:contain; display:block; }
.brand-logo-lg   { max-height:80px; max-width:260px; width:auto; height:auto;
                   object-fit:contain; background:#fff; border:1px solid var(--line,#e5e7eb);
                   border-radius:8px; padding:8px; }
.brand-preview   { display:flex; align-items:center; gap:16px; margin-bottom:18px;
                   flex-wrap:wrap; }

.sidebar-foot    { display:flex; flex-direction:column; gap:2px; font-size:11px;
                   line-height:1.35; opacity:.75; padding:10px 14px; }
.sidebar-foot .credit a { color:inherit; text-decoration:none; border-bottom:1px dotted currentColor; }
.sidebar-foot .credit a:hover { opacity:1; }
.sidebar-foot .ver { opacity:.6; }

.portal-credit   { margin:32px auto 20px; padding:16px 12px 0; max-width:900px;
                   text-align:center; font-size:12px; color:var(--muted,#6b7280);
                   border-top:1px solid var(--line,#e5e7eb); }
.portal-credit .small { font-size:11px; opacity:.85; margin-top:3px; }
.portal-credit a { color:inherit; }

/* Login screens: centre the logo above the card title. */
.login-card .brand-logo,
.login-card .brand-logo-lg { margin:0 auto 12px; max-height:56px; }

/* ------------------------------------------------------------------ charts -- */
.chart{width:100%;height:auto;display:block;color:currentColor}
.chart-key{display:flex;gap:18px;align-items:center;margin-top:10px;font-size:12.5px;flex-wrap:wrap}
.chart-key i{display:inline-block;width:11px;height:11px;border-radius:3px;margin-right:6px;
             vertical-align:-1px}
.chart-empty{padding:26px;text-align:center;color:var(--muted,#6b7280);font-size:14px;
             border:1px dashed var(--line,#e5e7eb);border-radius:10px}

/* ==========================================================================
   Forms - v2
   --------------------------------------------------------------------------
   The design system expects <div class="field"><label>..</label><input></div>,
   but most screens were written as <label>text <input></label>. Rather than
   rewrite every view, this styles that pattern to the same specification, so
   the two markup styles are visually identical and neither looks unfinished.

   :has() is used to tell a text field apart from a checkbox row. It is
   supported in every browser this runs on; where it is not, labels simply fall
   back to inline flow rather than breaking.
   ========================================================================== */

/* -- the block field: a label wrapping a control ------------------------- */
.card-body > form > label,
.card-body > label,
form > label,
fieldset > label,
.form-grid > label {
  display: block;
  margin: 0 0 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  line-height: 1.45;
}

/* Controls inside those labels get the full field treatment. */
.card-body label > input:not([type="checkbox"]):not([type="radio"]),
.card-body label > select,
.card-body label > textarea,
form label > input:not([type="checkbox"]):not([type="radio"]),
form label > select,
form label > textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--ink);
  background: #fff;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.card-body label > textarea,
form label > textarea { min-height: 76px; resize: vertical; }

.card-body label > input:focus,
.card-body label > select:focus,
.card-body label > textarea:focus,
form label > input:focus,
form label > select:focus,
form label > textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}

.card-body label > input[readonly],
.card-body label > input:disabled,
form label > input[readonly] { background: #f8fafc; color: var(--muted); }

/* Native select needs its own arrow once we restyle it. */
.card-body label > select,
form label > select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}

/* -- checkbox and radio rows stay inline -------------------------------- */
form label:has(> input[type="checkbox"]),
form label:has(> input[type="radio"]),
.card-body label:has(> input[type="checkbox"]),
.card-body label:has(> input[type="radio"]) {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
form label:has(> input[type="checkbox"]):hover,
form label:has(> input[type="radio"]):hover { border-color: var(--brand); background: #f8fafc; }

/* The selected option should be obvious without hunting for the dot. */
form label:has(> input[type="radio"]:checked),
form label:has(> input[type="checkbox"]:checked) {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 6%, #fff);
}
form label > input[type="checkbox"],
form label > input[type="radio"] { margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--brand); }

/* A radio row that also contains a text input (e.g. "set it manually: [___]") */
form label:has(> input[type="radio"]) > input[type="text"],
form label:has(> input[type="radio"]) > input[type="password"] {
  margin: 0 0 0 auto;
  width: auto;
  min-width: 200px;
  padding: 6px 9px;
  font-size: 13px;
}

/* -- helper text --------------------------------------------------------- */
.hint,
.card-body > p.hint {
  display: block;
  margin: -8px 0 15px;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted);
}
label > .hint, label .hint { margin: 5px 0 0; }
.req { color: var(--bad); font-weight: 700; }

/* -- sections: the thing that turns a long form into a readable one ------ */
.fset { border: 0; margin: 0 0 4px; padding: 0; }
.fset + .fset { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.fset > legend,
.fset-head {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.1px;
}
.fset-desc { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.fset-num {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; margin-right: 8px;
  border-radius: 50%; background: var(--brand); color: #fff;
  font-size: 11px; font-weight: 700; vertical-align: 1px;
}

/* -- two and three column layouts --------------------------------------- */
.grid-2, .grid-3 { display: grid; gap: 0 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.span-2 { grid-column: 1 / -1; }

/* -- actions bar --------------------------------------------------------- */
.form-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 22px -16px -16px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 0 0 var(--radius) var(--radius);
}
.form-actions .spacer { flex: 1 }
.form-actions .note { font-size: 12px; color: var(--muted); }

/* -- inline callout inside a form --------------------------------------- */
.fnote {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 18px; padding: 12px 14px;
  border: 1px solid var(--line); border-left: 3px solid var(--info);
  border-radius: 8px; background: #f8fafc;
  font-size: 12.5px; line-height: 1.55; color: #475569;
}
.fnote.warn { border-left-color: var(--warn); background: #fffbeb; }
.fnote.bad  { border-left-color: var(--bad);  background: #fef2f2; }
.fnote strong { color: var(--ink); }

/* -- read-only summary rows (review before submit) ---------------------- */
.sumgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.sumcell { padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
.sumcell .k { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.sumcell .v { font-size: 15px; font-weight: 700; margin-top: 3px; }

@media (max-width: 700px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; justify-content: center; }
  form label:has(> input[type="radio"]) > input[type="text"] { min-width: 0; width: 100%; margin: 8px 0 0; }
  form label:has(> input[type="radio"]) { flex-wrap: wrap; }
}

/* ==========================================================================
   Tables - v2
   --------------------------------------------------------------------------
   The design system styles `table.data`, but the newer screens were written as
   `class="table"`, so they rendered unstyled - rows running together with no
   separation. This makes the two class names equivalent rather than leaving
   half the application looking unfinished.
   ========================================================================== */

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.table th {
  text-align: left;
  padding: 10px 13px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  white-space: nowrap;
}

table.table td {
  padding: 11px 13px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr:hover td { background: #f8fafc; }

/* Key-value tables (a th in the first column) read better narrow and muted. */
table.table tbody tr > th:first-child:not(:only-child) {
  width: 190px;
  background: transparent;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid #f1f5f9;
}

/* A table as the direct child of a card should meet the card edges cleanly. */
.card > table.table:last-child tbody tr:last-child td { border-bottom: 0; }
.card > table.table th:first-child,
.card > table.table td:first-child { padding-left: 16px; }
.card > table.table th:last-child,
.card > table.table td:last-child  { padding-right: 16px; }

/* Numbers line up when right-aligned; text does not. */
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Utilisation bar: constrained so it reads as a meter, not an underline. */
.meter {
  height: 5px; width: 100%; max-width: 150px;
  border-radius: 3px; background: #e2e8f0;
  margin-top: 5px; overflow: hidden;
}
.meter > span { display: block; height: 100%; border-radius: 3px; }

/* Pills */
.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  background: #f1f5f9; color: #475569; border: 1px solid var(--line);
  white-space: nowrap;
}
.pill.ok  { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.pill.bad { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

/* Long identifier columns should not push the table sideways. */
table.table td .mono, table.table td .code { font-size: 11.5px; }

@media (max-width: 800px) {
  .card > table.table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ------------------------------------------------- collapsible sidebar --- */
.nav-group { border: 0; }
.nav-group > summary.nav-section {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; list-style: none; user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { color: #e2e8f0; }
.nav-caret {
  width: 0; height: 0; margin-right: 2px;
  border-left: 4px solid currentColor;
  border-top: 3.5px solid transparent; border-bottom: 3.5px solid transparent;
  opacity: .55; transition: transform .15s ease;
}
.nav-group[open] > summary .nav-caret { transform: rotate(90deg); }
.nav-items { padding-bottom: 4px; }

/* ---------------------------------------------------- fibre distribution --- */
/* The tree is drawn with borders rather than SVG so it reflows on a phone,
   which is where an engineer standing at a pole will actually read it. */

.ftree { margin-top: 4px; }

.fnode {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px solid #e2e8f0; border-radius: 8px;
  background: #fff; margin: 6px 0;
}
.fnode.olt      { background: #0f172a; color: #e6edf7; border-color: #0f172a; }
.fnode.olt .sub { color: #94a3b8; }
.fnode.splitter { background: #f0fdfa; border-color: #99f6e4; }
.fnode.splitter.warnbg { background: #fffaf5; border-color: #fed7aa; }
.fnode.onu      { margin-left: 28px; position: relative; }
.fnode.onu.empty{ background: #f8fafc; }

/* Connector elbows. Drawn on the ONU rows so the line only appears where a
   child actually exists, rather than trailing past the last one. */
.fnode.onu::before {
  content: ""; position: absolute; left: -16px; top: 50%;
  width: 14px; height: 1px; background: #cbd5e1;
}
.fnode.onu::after {
  content: ""; position: absolute; left: -16px; top: -7px;
  width: 1px; height: calc(50% + 7px); background: #cbd5e1;
}

.fbranch { margin: 10px 0 14px 18px; padding-left: 12px; border-left: 2px solid #e2e8f0; }
.fbranch.unmapped { border-left-color: #fed7aa; }

.ficon {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 24px; padding: 0 6px; border-radius: 5px;
  background: #0f766e; color: #fff; font-size: 11px; font-weight: 700;
  letter-spacing: .3px;
}
.ficon.sm { min-width: 30px; height: 20px; font-size: 10px; background: #64748b; }
.fnode.olt .ficon { background: #22d3ee; color: #06202c; }
.fnode.splitter.warnbg .ficon { background: #f97316; }

.chip {
  font-size: 11px; padding: 2px 7px; border-radius: 10px;
  background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; white-space: nowrap;
}
.chip.muted { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.chip.ok    { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.chip.warn  { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.chip.bad   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.frow-actions { margin-left: auto; display: flex; gap: 6px; }

.pon-head { display: flex; align-items: baseline; justify-content: space-between;
            gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }

table.data tr.total td { border-top: 2px solid #cbd5e1; background: #f8fafc; }

dialog { border: none; border-radius: 10px; padding: 20px; max-width: 760px; width: 92%;
         box-shadow: 0 20px 60px rgba(15,23,42,.25); }
dialog::backdrop { background: rgba(15,23,42,.45); }
dialog h3 { margin-bottom: 10px; }

@media (max-width: 640px) {
  .fnode.onu { margin-left: 14px; }
  .frow-actions { margin-left: 0; width: 100%; }
}

/* ------------------------------------------------- fibre design centre --- */

.chassis-head { display:flex; justify-content:space-between; align-items:flex-start;
                gap:16px; flex-wrap:wrap; margin-bottom:14px; }
.chassis-stats { display:flex; gap:22px; flex-wrap:wrap; }
.chassis-stats div { text-align:center; }
.chassis-stats strong { display:block; font-size:20px; color:#0f172a; line-height:1.1; }
.chassis-stats span { font-size:11px; color:#64748b; text-transform:uppercase; letter-spacing:.5px; }

/* The port strip is a stylised chassis face - blocks in slot/port order, so the
   page reads like the equipment looks when you are standing in front of it. */
.portstrip { display:flex; gap:6px; flex-wrap:wrap; padding:12px; border-radius:8px;
             background:#0f172a; }
.port { position:relative; width:52px; height:46px; border-radius:6px; text-decoration:none;
        display:flex; flex-direction:column; align-items:center; justify-content:center;
        background:#1e293b; border:1px solid #334155; color:#94a3b8; transition:.12s; }
.port:hover { transform:translateY(-2px); border-color:#22d3ee; }
.port .pnum  { font-size:15px; font-weight:700; color:#e2e8f0; line-height:1; }
.port .pslot { font-size:9px; color:#64748b; margin-top:2px; }
.port.active { background:#064e3b; border-color:#10b981; }
.port.active .pnum { color:#6ee7b7; }
.port.spare  { background:#1e293b; }
.port.planned{ background:#422006; border-color:#f59e0b; }
.port.faulty { background:#450a0a; border-color:#ef4444; }
.port.faulty .pnum { color:#fca5a5; }
.port .pdot { position:absolute; top:4px; right:4px; width:8px; height:8px;
              border-radius:50%; border:1px solid rgba(255,255,255,.5); }

/* blueprint rows: link on the left, node on the right, indented per depth */
.blueprint { margin-top:10px; }
.bp-branch { margin-left:calc(var(--d) * 26px); }
.bp-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin:7px 0; }
.bp-row.leaf { margin-left:30px; }

.bp-node { display:inline-flex; align-items:center; gap:8px; flex-wrap:wrap;
           padding:7px 11px; border-radius:8px; border:1px solid #e2e8f0; background:#fff; }
.bp-node.olt      { background:#0f172a; color:#e6edf7; border-color:#0f172a; font-weight:600; }
.bp-node.splitter { background:#f0fdfa; border-color:#99f6e4; }
.bp-node.onu.on   { background:#ffffff; border-color:#cbd5e1; }
.bp-node.onu.off  { background:#f8fafc; border-color:#e2e8f0; opacity:.75; }
.bp-node.spare    { background:#f8fafc; border-style:dashed; color:#94a3b8; font-size:12px; }
.bp-node.empty    { background:#fffaf5; border-color:#fed7aa; color:#9a3412; }
.bp-node .ratio   { background:#0f766e; color:#fff; padding:2px 7px; border-radius:5px;
                    font-size:11px; font-weight:700; }
.bp-node .leg     { background:#64748b; color:#fff; padding:2px 6px; border-radius:4px;
                    font-size:10px; }

/* The link between two nodes: cable name, then tube and core swatches. */
.bp-link { min-width:210px; }
.corechip { display:inline-flex; align-items:center; gap:5px; flex-wrap:wrap;
            padding:3px 8px; border-radius:20px; background:#f1f5f9;
            border:1px solid #e2e8f0; font-size:11px; }
.corechip.none { color:#94a3b8; font-style:italic; background:transparent; border-style:dashed; }
.corechip .cable { font-weight:700; color:#0f172a; }
.corechip .cn    { color:#475569; }
.corechip .cnum  { color:#0f172a; font-weight:700; }
.corechip .sw    { width:12px; height:12px; border-radius:3px; display:inline-block;
                   border:1px solid rgba(15,23,42,.25); }

@media (max-width:700px) {
  .bp-link { min-width:0; width:100%; }
  .bp-branch { margin-left:calc(var(--d) * 12px); }
  .bp-row.leaf { margin-left:12px; }
}

/* --------------------------------------- design centre: tools and legs --- */

.viewswitch { display:inline-flex; border:1px solid #cbd5e1; border-radius:7px; overflow:hidden; }
.viewswitch .vs { border:0; background:#fff; padding:6px 13px; font-size:13px; cursor:pointer;
                  color:#475569; border-right:1px solid #e2e8f0; }
.viewswitch .vs:last-child { border-right:0; }
.viewswitch .vs.on { background:#0f766e; color:#fff; font-weight:600; }

.toolbar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-top:12px;
           padding-top:12px; border-top:1px solid #e2e8f0; }
.toolbar #q { flex:1 1 280px; min-width:200px; }
.toolbar .tgl { display:inline-flex; align-items:center; gap:6px; font-size:13px; color:#475569; }
.toolbar .dragtip { margin-left:auto; font-style:italic; }
.chassis-stats .free { color:#0f766e; }

/* PON sections collapse, so a 16-port OLT is still readable on one screen. */
details.ponsec { margin-bottom:12px; }
details.ponsec > summary { display:flex; align-items:center; gap:10px; flex-wrap:wrap;
                           cursor:pointer; list-style:none; padding:13px 16px; }
details.ponsec > summary::-webkit-details-marker { display:none; }
details.ponsec > summary::before { content:"\25B8"; color:#94a3b8; transition:.15s; }
details.ponsec[open] > summary::before { transform:rotate(90deg); }
details.ponsec .ponname { font-weight:700; color:#0f172a; }
details.ponsec .grow { flex:1; }
.card-body.pt0 { padding-top:0; }
details.ponsec.flash { outline:2px solid #22d3ee; outline-offset:2px; }

/* Empty legs are real controls, not placeholders. */
.bp-node.leg-free, .bp-node.leg-reserved, .bp-node.leg-faulty {
  border-style:dashed; background:#f8fafc; color:#64748b; width:100%;
}
.bp-node.leg-reserved { background:#fffbeb; border-color:#fde68a; color:#92400e; }
.bp-node.leg-faulty   { background:#fef2f2; border-color:#fecaca; color:#991b1b; }
.bp-node .leg.dim { background:#cbd5e1; color:#475569; }
.bp-node.droptarget.ok-target { border-color:#0f766e; background:#ecfdf5; }
.bp-node.droptarget.no-target { opacity:.35; }
.bp-node.droptarget.over { border-color:#0f766e; background:#a7f3d0;
                           box-shadow:0 0 0 3px rgba(15,118,110,.18); }
.bp-node.droptarget.saving { opacity:.5; pointer-events:none; }
.bp-node.onu[draggable="true"] { cursor:grab; }
.bp-node.onu.dragging { opacity:.45; }

.rbtn { border:0; background:transparent; cursor:pointer; color:#94a3b8; font-size:13px;
        padding:0 4px; }
.rbtn:hover { color:#0f766e; }
.routenote { font-size:11px; color:#475569; background:#f8fafc; border:1px dashed #cbd5e1;
             padding:2px 8px; border-radius:10px; }

.unmapped { display:flex; flex-direction:column; gap:7px; }

/* rack view */
.rackgrid { display:grid; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); gap:12px; }
.rackcard { border:1px solid #e2e8f0; border-radius:9px; padding:12px; background:#fff; }
.rackcard.faulty { border-color:#fecaca; background:#fef2f2; }
.rackcard.planned{ border-color:#fde68a; background:#fffbeb; }
.rc-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.rc-bar  { height:7px; border-radius:4px; background:#e2e8f0; overflow:hidden; }
.rc-bar i{ display:block; height:100%; background:#0f766e; }
.rc-meta { display:flex; justify-content:space-between; gap:6px; margin-top:7px;
           font-size:11px; color:#64748b; }
.rc-core { margin-top:8px; }

@media (max-width:700px) {
  .toolbar .dragtip { display:none; }
  .viewswitch { width:100%; }
  .viewswitch .vs { flex:1; }
}

.bp-node.onu.orphan { border-color:#fecaca; background:#fef2f2; }
.bp-node .leg.warnleg { background:#dc2626; }

/* ---- audited additions: used in views, previously defined nowhere ---------
   Found by sweeping every view for classes with no rule anywhere. Each one below
   was the only class on its element, so that element rendered unstyled. */

/* Page header: an <h1> with its actions pushed to the right. */
.page-head{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:18px}
.page-head h1{margin:0;font-size:20px;font-weight:650;letter-spacing:-.01em}
.head-actions{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:wrap}

/* Heading inside a card. Matches .card-head h2 so the two read alike. */
.card-title{margin:0 0 10px;font-size:14.5px;font-weight:600}

/* Horizontal group; .end pushes it right, which is what dialog footers want. */
.row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.row.end{justify-content:flex-end}

.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px}

/* Checkbox/radio labels: without this the control detaches from its text. */
.check{display:flex;align-items:center;gap:8px;font-size:13px}
.check input{width:16px;height:16px;flex:none}
label.inline{display:inline-flex;align-items:center;gap:7px;font-size:13px;margin-right:16px}
label.inline input{width:16px;height:16px;flex:none}

/* Panel around a fault-localisation result. */
.pain{padding:14px 16px;border:1px solid var(--line);border-radius:var(--radius);
      background:var(--panel);margin-bottom:14px}
.pain h3{margin:0 0 6px;font-size:14.5px;font-weight:600}

/* Body of a topology node card. */
.node-body{padding:10px 12px}
