:root {
  --navy-900: #0b1330;
  --navy-800: #101a3d;
  --navy-700: #172352;
  --pink-500: #ff2d78;
  --pink-600: #e6236a;
  --blue-500: #2f7dff;
  --green-500: #17b978;
  --orange-500: #ff9f2f;
  --red-500: #ff4757;
  --bg: #f3f5fb;
  --card: #ffffff;
  --text-900: #16192c;
  --text-500: #6b7290;
  --border: #e7e9f3;
  --border-strong: #aab0d6;
  --text-700: #33384f; --link: #3b4bcf;
  --surface: #ffffff; --surface-2: #f6f7fd; --surface-3: #eef0ff; --hover: #eaeeff; --warn-bg: #fff7e6; --bad-bg: #fdecec;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(160deg, #eef1ff 0%, #f3f5fb 40%, #fdeef5 100%);
  background-attachment: fixed;
  color: var(--text-900);
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
  color: #cfd4ec;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
}

.brand-badge {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--pink-500), var(--blue-500));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; font-size: 14px;
}

.brand-text .t1 { font-weight: 700; font-size: 14px; color: #fff; line-height: 1.1; }
.brand-text .t2 { font-size: 11px; color: #8d93bb; }

.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7e84ad; margin: 16px 8px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; font-size: 13.5px;
  color: #c7cbe8; cursor: pointer; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: rgba(255,45,120,0.16); color: #fff; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: #565c86; }
.nav-item.active .dot { background: var(--pink-500); }

.sidebar-footer {
  margin-top: auto; padding-top: 16px; text-align: center; color: #6b7099; font-size: 11px;
}
.sidebar-footer .badge {
  display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 20px;
  background: rgba(255,45,120,.15); color: var(--pink-500); font-size: 11px; font-weight: 600;
}

/* ---------- Topbar ---------- */
.main { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 60px; background: var(--navy-900); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; border-bottom: 1px solid rgba(255,255,255,.06);
}
.topbar .crumbs { font-size: 13px; color: #aab0d6; }
.topbar .crumbs b { color: #fff; }
.topbar .right { display: flex; align-items: center; gap: 18px; font-size: 12.5px; color: #aab0d6; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px;
  padding: 4px 10px; border-radius: 20px;
}

/* ---------- Content ---------- */
.content { padding: 22px; flex: 1; min-width: 0; max-width: 100%; overflow-x: hidden; }

.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--text-500); font-size: 13px; margin: 0 0 18px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-box {
  flex: 1; min-width: 200px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px;
}

.btn {
  border: none; border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--blue-500); color: #fff; }
.btn-danger { background: var(--red-500); color: #fff; }
.btn-success { background: var(--green-500); color: #fff; }
.btn-outline { background: var(--surface); border: 1px solid var(--border); color: var(--text-900); }
.btn:disabled { opacity: .55; cursor: default; }

/* device table */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: 0 2px 10px rgba(23,30,70,.05); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: #fff; font-weight: 700; padding: 11px 12px; border-bottom: 2px solid var(--navy-900); background: linear-gradient(90deg, var(--navy-800), var(--navy-700)); white-space: nowrap; }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
td { padding: 12px; border-bottom: 2px solid var(--border-strong); vertical-align: middle; text-align: left; }
tr:last-child td { border-bottom: none; }
tr.device-row { cursor: pointer; }
tr.device-row:nth-child(even) { background: var(--surface-2); }
tr.device-row:hover { background: var(--hover); }
tbody tr:nth-child(even) { background: var(--surface-2); }
tbody tr:hover { background: var(--hover); }

.badge-online { color: #fff; background: var(--green-500); }
.badge-offline { color: #fff; background: var(--red-500); }
.badge-pill { padding: 4px 12px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }

.metric-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.metric-label { font-size: 13px; color: var(--text-500); font-weight: 600; }
.metric-value { font-size: 13px; font-weight: 700; color: var(--text-900); }

.pppoe-user-pill {
  font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; font-weight: 600;
  color: var(--link); background: var(--surface-3); padding: 3px 9px; border-radius: 6px; display: inline-block;
}
.data-model-pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--blue-500); background: rgba(47,125,255,.1); padding: 3px 9px; border-radius: 6px; display: inline-block;
}

.empty { text-align: center; color: var(--text-500); padding: 40px 0; font-size: 13.5px; }

/* device detail */
.device-header {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px;
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.device-header h2 { margin: 0 0 4px; font-size: 18px; }
.device-header .meta { color: var(--text-500); font-size: 12.5px; }
.device-header .actions { display: flex; gap: 8px; }

.note-banner {
  background: var(--warn-bg); border: 1px solid #ffe4a8; color: #8a6300; font-size: 12.5px;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px;
}

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  display: flex; align-items: center; gap: 12px;
}
.tile-icon {
  width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; flex-shrink: 0;
}
.tile-label { font-size: 11px; color: var(--text-500); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tile-value { font-size: 15px; font-weight: 700; word-break: break-word; }

.section-title { font-size: 14px; font-weight: 700; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }

.param-table td.name { color: var(--text-500); font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }
.param-table td.value { font-weight: 600; font-size: 12.5px; }
.param-table td.name, .param-table td.value { word-break: break-all; max-width: 420px; }
.table-scroll { overflow-x: auto; max-width: 100%; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.inline-form input {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; flex: 1; min-width: 180px;
}

.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--navy-900); color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.2);
  opacity: 0; transform: translateY(8px); transition: all .25s ease; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }

.back-link { color: var(--blue-500); font-size: 13px; cursor: pointer; margin-bottom: 12px; display: inline-block; }

/* ---------- Device detail tabs ---------- */
.tab-bar {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border);
  margin: 18px 0 18px; flex-wrap: wrap; background: var(--card); border-radius: 10px 10px 0 0; padding: 0 4px;
}
.tab-btn {
  background: none; border: none; padding: 12px 16px; font-size: 13px; font-weight: 600;
  color: var(--text-500); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab-btn:hover { color: var(--text-900); }
.tab-btn.active { color: var(--pink-500); border-bottom-color: var(--pink-500); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Main dashboard: stat cards ---------- */
.stat-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-left: 5px solid var(--border);
  border-radius: 12px; padding: 16px 18px; box-shadow: 0 2px 10px rgba(23,30,70,.06);
}
.stat-card .stat-label {
  font-size: 11px; color: var(--text-500); font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 8px;
}
.stat-card .stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-card .stat-value.muted { font-size: 15px; color: var(--text-500); font-weight: 600; }
.stat-card .stat-sub { font-size: 11px; color: var(--text-500); margin-top: 4px; }
.stat-card.total { border-left-color: var(--blue-500); background: linear-gradient(135deg, rgba(47,125,255,.10), var(--card) 55%); }
.stat-card.online { border-left-color: var(--green-500); background: linear-gradient(135deg, rgba(23,185,120,.12), var(--card) 55%); }
.stat-card.online .stat-value { color: var(--green-500); }
.stat-card.offline { border-left-color: var(--red-500); background: linear-gradient(135deg, rgba(255,71,87,.14), var(--card) 55%); }
.stat-card.offline .stat-value { color: var(--red-500); }
.stat-card.firmware { border-left-color: #7a5cff; background: linear-gradient(135deg, rgba(122,92,255,.12), var(--card) 55%); }
.stat-card.tickets { border-left-color: var(--pink-500); background: linear-gradient(135deg, rgba(255,45,120,.10), var(--card) 55%); }

/* ---------- Main Dashboard (rollup page): colorful section cards ---------- */
.dash-sections {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 22px;
}
.dash-section-card {
  position: relative; overflow: hidden; border-radius: 16px; padding: 20px 22px; text-decoration: none;
  color: #fff; display: block; box-shadow: 0 8px 24px rgba(23,30,70,.16); transition: transform .15s ease, box-shadow .15s ease;
}
.dash-section-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(23,30,70,.22); }
.dash-section-card .dash-icon {
  font-size: 22px; width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.dash-section-card .dash-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .92; }
.dash-section-card .dash-total { font-size: 34px; font-weight: 800; line-height: 1.1; margin-top: 6px; }
.dash-section-card .dash-split { display: flex; gap: 14px; margin-top: 12px; font-size: 13px; font-weight: 700; }
.dash-section-card .dash-split span { background: rgba(255,255,255,.20); padding: 3px 10px; border-radius: 20px; }
.dash-section-card.dash-tr069 { background: linear-gradient(135deg, #2f7dff, #7a5cff); }
.dash-section-card.dash-olts { background: linear-gradient(135deg, #17b978, #0d9488); }
.dash-section-card.dash-switches { background: linear-gradient(135deg, #ff9f2f, #ff6b35); }
.dash-section-card.dash-mikrotiks { background: linear-gradient(135deg, #ff2d78, #c026d3); }
.dash-section-card.dash-ports { background: linear-gradient(135deg, #06b6d4, #2f7dff); }

.dash-pon-card { border-radius: 16px; padding: 22px; background: linear-gradient(180deg, #fff, #f7f8fe); border: 1px solid var(--border); box-shadow: 0 4px 16px rgba(23,30,70,.06); }
.dash-pon-card .card-head h3 { font-size: 16px; }
.dash-pon-table th:nth-child(1) { color: #fbd6ea; }
.dash-pon-olt-pill {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-weight: 700; font-size: 12px;
  background: linear-gradient(135deg, rgba(47,125,255,.15), rgba(122,92,255,.15)); color: var(--blue-500);
}
.dash-pon-bar-wrap { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.dash-pon-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.dash-pon-bar-fill { height: 100%; background: linear-gradient(90deg, var(--green-500), #0d9488); border-radius: 4px; }

/* ---------- Per-PON summary rows (Live Dashboard) ---------- */
.pon-summary { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.pon-summary-row {
  display: flex; align-items: center; gap: 22px; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 18px; font-size: 13px;
}
.pon-summary-label { font-weight: 700; color: var(--text-900); min-width: 110px; }
.pon-summary-stat { color: var(--text-500); }
.pon-summary-stat b { color: var(--text-900); }

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }

.select-box {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; color: var(--text-900);
}

.nav-item.disabled { opacity: .45; cursor: default; }

/* ---------- Device detail: Configuration tab (sub-nav + pane) ---------- */
.config-layout { display: flex; gap: 16px; align-items: flex-start; }
.config-nav {
  width: 220px; flex-shrink: 0; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.config-nav-item { padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border); }
.config-nav-item:last-child { border-bottom: none; }
.config-nav-item:hover { background: var(--surface-2); }
.config-nav-item.active { background: rgba(255,45,120,.08); border-left: 3px solid var(--pink-500); padding-left: 13px; }
.config-nav-title { font-size: 13.5px; font-weight: 600; color: var(--text-900); }
.config-nav-item.active .config-nav-title { color: var(--pink-500); }
.config-nav-sub { font-size: 11px; color: var(--text-500); margin-top: 2px; }
.config-content { flex: 1; min-width: 0; }
.config-pane { display: none; }
.config-pane.active { display: block; }

/* ---------- Configuration > Internet: detailed field-row card ---------- */
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-badges { display: flex; gap: 6px; align-items: center; }
.card-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; background: var(--surface-3); color: var(--text-500); }
.card-badge.pppoe { background: var(--surface-3); color: var(--link); }
.card-badge.connected { background: rgba(23,185,120,.12); color: var(--green-500); }

.field-row {
  display: flex; align-items: flex-start; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--border);
}
.field-row:last-child { border-bottom: none; }
.field-label { width: 180px; flex-shrink: 0; font-size: 13px; font-weight: 600; color: var(--text-900); padding-top: 8px; }
.field-control { flex: 1; min-width: 0; font-size: 13.5px; }
.field-control input, .field-control select {
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; width: 100%; max-width: 380px;
}
.field-hint { font-size: 11.5px; color: var(--text-500); margin-top: 4px; }
.field-warn { font-size: 11.5px; color: #8a6300; margin-top: 6px; display: flex; gap: 5px; align-items: flex-start; }

.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; font-weight: 600; }
.toggle input { display: none; }
.toggle .track {
  width: 38px; height: 20px; border-radius: 20px; background: #d7dae8; position: relative; transition: background .2s; flex-shrink: 0;
}
.toggle .track::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); top: 2px; left: 2px; transition: transform .2s;
}
.toggle input:checked + .track { background: var(--green-500); }
.toggle input:checked + .track::after { transform: translateX(18px); }


/* ---------- Dashboard charts (donut / bars / trends) ----------
   Light surface only (the dashboard has no dark theme). online/offline use the fixed
   status pair; every green/red mark also has an icon + text label (see app.js). */
.viz-root {
  --viz-surface: #ffffff; --viz-ink: #0b0b0b; --viz-ink-2: #52514e; --viz-muted: #898781;
  --viz-grid: #e1e0d9; --viz-axis: #c3c2b7; --viz-track: #eeece6;
  --viz-series-1: #2a78d6; --viz-good: #0ca30c; --viz-bad: #d03b3b;
  display: grid; gap: 16px; margin: 6px 0 22px; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.viz-grid2 { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; }
.viz-card { background: var(--viz-surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; box-shadow: 0 2px 10px rgba(23,30,70,.05); min-width: 0; }
.viz-title { font-size: 15px; font-weight: 700; color: var(--viz-ink); }
.viz-sub { font-size: 12px; color: var(--viz-ink-2); margin-top: 2px; }
.viz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.viz-ico-good { color: var(--viz-good); font-weight: 800; }
.viz-ico-bad { color: var(--viz-bad); font-weight: 800; }

.viz-donut-wrap { display: flex; align-items: center; gap: 22px; margin-top: 10px; flex-wrap: wrap; }
.viz-donut { width: 168px; height: 168px; flex: none; }
.viz-donut circle[data-tip-value] { cursor: default; transition: stroke-width .12s ease; outline: none; }
.viz-donut circle[data-tip-value]:hover, .viz-donut circle[data-tip-value]:focus { stroke-width: 26; }
.viz-good { stroke: var(--viz-good); background: var(--viz-good); }
.viz-bad { stroke: var(--viz-bad); background: var(--viz-bad); }
.viz-donut .viz-good, .viz-donut .viz-bad { background: none; }
.viz-track { stroke: var(--viz-track); }
.viz-donut-num { font-size: 30px; font-weight: 700; fill: var(--viz-ink); }
.viz-donut-sub { font-size: 12px; fill: var(--viz-ink-2); }
.viz-legend { display: grid; gap: 8px; font-size: 14px; color: var(--viz-ink-2); }
.viz-legend b { color: var(--viz-ink); font-size: 18px; margin-left: 4px; }

.viz-bars { display: grid; gap: 10px; margin-top: 12px; }
.viz-bar-row { display: grid; grid-template-columns: minmax(96px, 190px) 1fr auto; align-items: center; gap: 12px; }
.viz-bar-label { font-size: 13px; color: var(--viz-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-bar-track-wrap { min-width: 0; }
.viz-bar-track { display: flex; gap: 2px; height: 16px; }
.viz-seg { height: 100%; min-width: 3px; outline: none; transition: filter .12s ease; }
.viz-seg:first-child { border-radius: 0; }
.viz-seg:last-child { border-radius: 0 4px 4px 0; }
.viz-seg:hover, .viz-seg:focus { filter: brightness(1.12) saturate(1.1); }
.viz-empty { background: var(--viz-track); flex: 1; }
.viz-bar-val { font-size: 12.5px; color: var(--viz-ink); white-space: nowrap; min-width: 150px; text-align: right; }
.viz-pct { color: var(--viz-ink-2); margin-left: 4px; }
.viz-scroll { max-height: 380px; overflow: auto; }

.viz-ranges { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.viz-range { border: 0; background: var(--surface); padding: 6px 12px; font-size: 12.5px; color: var(--viz-ink-2); cursor: pointer; }
.viz-range + .viz-range { border-left: 1px solid var(--border); }
.viz-range:hover { background: var(--surface-2); }
.viz-range.active { background: var(--navy-800); color: #fff; font-weight: 700; }
.viz-trends { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px 24px; margin-top: 8px; }
.viz-trend-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; min-height: 42px; }
.viz-trend-title { font-size: 13px; font-weight: 700; color: var(--viz-ink); }
.viz-trend-num { font-size: 22px; font-weight: 700; color: var(--viz-ink); }
.viz-line { width: 100%; height: auto; display: block; margin-top: 4px; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-baseline { stroke: var(--viz-axis); stroke-width: 1; }
.viz-axis { font-size: 11px; fill: var(--viz-muted); }
.viz-line-path { fill: none; stroke: var(--viz-series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-area { fill: var(--viz-series-1); fill-opacity: .10; stroke: none; }
.viz-dot { fill: var(--viz-series-1); }
.viz-dot-ring, .viz-hover-ring { fill: var(--viz-surface); }
.viz-hover-dot { fill: var(--viz-series-1); }
.viz-cross { stroke: var(--viz-axis); stroke-width: 1; }
.viz-hit { fill: transparent; cursor: crosshair; }
.viz-empty-note { color: var(--viz-ink-2); font-size: 13px; padding: 26px 4px; grid-column: 1 / -1; }
.viz-table { grid-column: 1 / -1; margin-top: 4px; font-size: 13px; color: var(--viz-ink-2); }
.viz-table summary { cursor: pointer; }
.viz-table .viz-scroll { max-height: 240px; margin-top: 8px; }

.viz-tip { position: fixed; z-index: 9999; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 11px; box-shadow: 0 8px 24px rgba(23,30,70,.18); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.viz-tip-value { font-size: 14px; font-weight: 700; color: var(--text-900); display: flex; align-items: center; gap: 6px; }
.viz-tip-key { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }
.viz-tip-label { font-size: 12px; color: var(--text-700); margin-top: 2px; }

@media (max-width: 900px) {
  .viz-grid2 { grid-template-columns: 1fr; }
  .viz-bar-row { grid-template-columns: 1fr; gap: 4px; }
  .viz-bar-val { text-align: left; }
}

/* ---------- ONU down-history modal ---------- */
tr.onu-row { cursor: pointer; }
tr.onu-row:hover { background: var(--hover) !important; }
.onuh-overlay { position: fixed; inset: 0; z-index: 9000; background: rgba(11,19,48,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow: auto; }
.onuh-card { background: var(--surface); border-radius: 16px; width: min(760px, 100%); padding: 20px 22px; box-shadow: 0 20px 60px rgba(11,19,48,.35); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.onuh-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; font-size: 16px; color: var(--text-900); }
.onuh-sub { font-size: 12px; color: var(--text-700); margin-top: 2px; font-weight: 400; }
.onuh-x { border: 0; background: var(--surface-2); border-radius: 8px; width: 30px; height: 30px; font-size: 14px; cursor: pointer; color: var(--text-700); }
.onuh-x:hover { background: var(--hover); }
.onuh-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 12px; }
.onuh-tile { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.onuh-num { font-size: 26px; font-weight: 700; color: var(--text-900); }
.onuh-lbl { font-size: 12px; color: var(--text-700); margin-top: 2px; }
.onuh-reasons { display: grid; gap: 6px; margin-bottom: 14px; }
.onuh-reason { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--text-900); padding: 7px 12px; background: var(--surface-2); border-radius: 8px; }
.onuh-note { color: var(--text-700); font-size: 13.5px; padding: 18px 4px; }
@media (max-width: 600px) { .onuh-tiles { grid-template-columns: 1fr; } }

/* ---------- ONU search page ---------- */
.search-bar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0 18px; }
.search-big { flex: 1 1 380px; min-width: 260px; font-size: 16px !important; padding: 12px 16px !important; }
.search-chips { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.search-chip { border: 0; background: var(--surface); padding: 9px 14px; font-size: 13px; color: var(--text-700); cursor: pointer; }
.search-chip + .search-chip { border-left: 1px solid var(--border); }
.search-chip:hover { background: var(--surface-2); }
.search-chip.active { background: var(--navy-800); color: #fff; font-weight: 700; }
.search-chip.active .viz-ico-good, .search-chip.active .viz-ico-bad { color: #fff; }
.search-cnt { opacity: .75; margin-left: 4px; }

/* ---------- Uptime Monitor ---------- */
.up-strip { display: flex; gap: 2px; align-items: center; }
.up-cell { width: 9px; height: 22px; border-radius: 2px; flex: none; }
.up-cell:hover { filter: brightness(1.12); outline: 1px solid #0b0b0b33; }
.up-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--viz-ink-2); padding: 10px 4px 0; }
.up-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }
@media (max-width: 800px) { .onuh-tiles { grid-template-columns: repeat(2, 1fr) !important; } }

/* ---------- Audit Log ---------- */
tr.audit-fail td { background: rgba(255, 71, 87, .05); }
.audit-detail { max-width: 320px; color: var(--text-700); font-size: 12px; word-break: break-word; }

/* ---------- Settings ---------- */
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
.set-card { padding: 16px 20px !important; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 12px 0; border-top: 1px solid var(--border); }
.set-text { min-width: 0; flex: 1; }
.set-label { font-size: 13.5px; font-weight: 700; color: var(--text-900); }
.set-help { font-size: 12px; color: #6b7290; margin-top: 2px; line-height: 1.45; }
.set-default { color: #898781; margin-left: 4px; white-space: nowrap; }
.set-ctl { display: flex; align-items: center; gap: 8px; flex: none; }
.set-input { width: 200px; }
.set-num { width: 96px; text-align: right; }
.set-unit { font-size: 12px; color: #6b7290; }
.set-changed { font-size: 10.5px; font-weight: 700; background: rgba(47,125,255,.12); color: #2f7dff; border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.set-reset { border: 0; background: none; color: #2f7dff; font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0; }
.set-switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.set-switch input { opacity: 0; width: 0; height: 0; }
.set-switch span { position: absolute; inset: 0; background: #c3c2b7; border-radius: 24px; transition: .15s; cursor: pointer; }
.set-switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.set-switch input:checked + span { background: #17b978; }
.set-switch input:checked + span::before { transform: translateX(18px); }
.set-switch input:focus-visible + span { outline: 2px solid #2f7dff; outline-offset: 2px; }
.set-testmsg { font-size: 12px; margin-left: 8px; }
.set-sys { display: grid; gap: 8px; font-size: 13px; }
.set-sys span { color: #6b7290; display: inline-block; min-width: 170px; }
.set-savebar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 12px 0; background: linear-gradient(180deg, transparent, #f3f5fb 40%); }
@media (max-width: 560px) { .set-grid { grid-template-columns: 1fr; } .set-row { flex-direction: column; align-items: stretch; } }

/* ---------- Phone layout for the whole app ---------- */
.tb-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.nav-toggle { display: none; background: rgba(255,255,255,.08); color: #fff; border: 0; border-radius: 10px; width: 40px; height: 40px; font-size: 20px; cursor: pointer; flex: none; }
.nav-backdrop { display: none; }
@media (max-width: 820px) {
  .app { display: block; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 272px; z-index: 8000; overflow-y: auto; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 8px 0 30px rgba(0,0,0,.3); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(11,19,48,.5); z-index: 7999; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 0 12px; height: 56px; }
  .topbar .right { gap: 10px; font-size: 12px; }
  .topbar #clock, .topbar .tb-pw { display: none; }
  .content { padding: 14px 12px; }
  .card { overflow-x: auto; }
  .page-title { font-size: 20px; }
}

/* ---------- Field View ---------- */
.fv { max-width: 720px; margin: 0 auto; }
.fv-search { width: 100%; font-size: 17px; padding: 14px 16px; border: 1.5px solid var(--border-strong); border-radius: 14px; background: var(--surface); outline: none; }
.fv-search:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(47,125,255,.15); }
.fv-chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 6px; scrollbar-width: none; }
.fv-chips::-webkit-scrollbar { display: none; }
.fv-chip { flex: none; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 14px; color: var(--text-900); cursor: pointer; white-space: nowrap; }
.fv-chip.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); font-weight: 700; }
.fv-cnt { opacity: .7; margin-left: 4px; }
.fv-scope { margin: 6px 2px 0; padding: 8px 14px; border-radius: 20px; border: 1px solid var(--blue-500); background: rgba(47,125,255,.08); color: var(--text-900); font-size: 13px; font-weight: 700; cursor: pointer; }
.fv-sec { font-size: 13px; font-weight: 700; color: var(--text-900); margin: 14px 2px 6px; }
.fv-hint { font-weight: 400; color: #6b7290; margin-left: 6px; }
.fv-pons { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.fv-pons::-webkit-scrollbar { display: none; }
.fv-pon { flex: none; width: 168px; text-align: left; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 12px; padding: 10px 12px; font-size: 12.5px; color: var(--text-700); cursor: pointer; }
.fv-pon b { color: var(--text-900); font-size: 14px; }
.fv-pon.active { border-color: var(--blue-500); box-shadow: 0 0 0 2px rgba(47,125,255,.2); }
.fv-bar { height: 6px; background: #eeece6; border-radius: 3px; margin: 8px 0 6px; overflow: hidden; }
.fv-bar i { display: block; height: 100%; background: #d03b3b; border-radius: 3px; }
.fv-pon-n { display: block; font-size: 12px; }
.fv-count { font-size: 12.5px; color: #6b7290; margin: 12px 2px 8px; }
.fv-empty { color: #6b7290; padding: 30px 6px; text-align: center; }
.fv-card { background: var(--surface); border-radius: 14px; padding: 14px 14px 12px; margin-bottom: 10px; box-shadow: 0 2px 10px rgba(23,30,70,.06); border-left: 5px solid #17b978; cursor: pointer; }
.fv-card-off { border-left-color: #d03b3b; }
.fv-card-warn { border-left-color: #fab219; }
.fv-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.fv-badge { font-size: 12px; font-weight: 800; letter-spacing: .3px; padding: 4px 10px; border-radius: 12px; white-space: nowrap; }
.fv-on { background: rgba(23,185,120,.14); color: #0a7a4d; }
.fv-off { background: rgba(208,59,59,.14); color: #b02a2a; }
.fv-warn { background: rgba(250,178,25,.2); color: #8a5b00; }
.fv-time { text-align: right; font-size: 13px; }
.fv-name { font-size: 17px; font-weight: 700; color: var(--text-900); margin-top: 8px; word-break: break-word; }
.fv-where { font-size: 13.5px; color: var(--text-700); margin-top: 3px; }
.fv-where b { color: var(--text-900); }
.fv-why { display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 700; color: #b02a2a; }
.fv-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; font-size: 13.5px; }
.fv-lbl { color: #6b7290; margin-right: 4px; }
.fv-id { font-family: monospace; font-size: 12px; color: var(--text-700); word-break: break-all; text-align: right; }
.fv-actions { display: flex; gap: 8px; margin-top: 12px; }
.fv-btn { flex: 1; min-height: 42px; border: 1px solid var(--border-strong); background: var(--surface-2); border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--text-900); cursor: pointer; }
.fv-btn:active { background: var(--hover); }
.fv-more { width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 15px; font-weight: 600; cursor: pointer; margin: 4px 0 20px; }

.fv-searchrow { display: flex; gap: 8px; align-items: stretch; }
.fv-searchrow .fv-search { flex: 1; min-width: 0; }
.fv-scan { border: 0; border-radius: 10px; padding: 0 16px; font-weight: 700; font-size: 15px; background: #1f6feb; color: #fff; cursor: pointer; }

/* Subscribers */
.sub-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.sub-chip { min-height: 34px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; color: var(--text-900); cursor: pointer; }
.sub-chip.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); font-weight: 700; }
.sub-cnt { opacity: .7; margin-left: 4px; }
.sub-scroll { overflow-x: auto; }
.sub-table { width: 100%; min-width: 900px; }
.sub-row { cursor: pointer; }
.sub-row:hover { background: var(--surface-2); }
.sub-note { font-size: 11.5px; font-weight: 400; color: var(--text-500); }

/* Network Map */
.nm-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 14px; }
.nm-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 12.5px; color: var(--text-500); }
.nm-num { font-size: 26px; font-weight: 700; color: var(--text-900); }
.nm-olt { margin-bottom: 14px; }
.nm-pon { border-top: 1px solid var(--border); }
.nm-pon-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; cursor: pointer; }
.nm-pon-head:hover { background: var(--surface-2); }
.nm-caret { display: inline-block; transition: transform .15s; color: var(--text-500); }
.nm-pon.open .nm-caret { transform: rotate(90deg); }
.nm-pon-stat { font-size: 13px; color: var(--text-500); flex: 1; min-width: 200px; }
.nm-unassigned { color: #b26a00; font-weight: 600; }
.nm-offcount { color: var(--red-500); font-weight: 600; }
.nm-okcount { color: var(--green-500); font-weight: 600; }
.nm-addbtn, .nm-actions button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--text-900); }
.nm-addbtn:hover, .nm-actions button:hover { background: var(--surface-3); }
.nm-pon-body { padding: 4px 16px 16px 30px; }
.nm-root { font-size: 12.5px; font-weight: 600; color: var(--text-500); margin: 4px 0 8px; }
.nm-sp { border-left: 3px solid #c9d4ff; padding: 6px 0 6px 12px; margin: 8px 0; }
.nm-sp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.nm-sp-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.nm-sp-ico { color: var(--link); font-size: 16px; }
.nm-ratio { background: var(--surface-3); color: var(--link); border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; }
.nm-used, .nm-loc { font-size: 12px; color: var(--text-500); }
.nm-full { font-size: 11px; background: var(--warn-bg); color: #9a5b00; border-radius: 6px; padding: 1px 6px; }
.nm-sp-stat { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--text-500); }
.nm-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.nm-alert { margin: 8px 0 2px; padding: 8px 12px; background: var(--bad-bg); color: #b3261e; border-radius: 8px; font-size: 13px; font-weight: 600; }
.nm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.nm-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 16px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; color: var(--text-900); }
.nm-chip i, .nm-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #999; flex: none; }
.nm-on i, .nm-dot.nm-on { background: #22a559; }
.nm-off { background: var(--bad-bg); border-color: #f3b7b3; }
.nm-off i, .nm-dot.nm-off { background: #e5484d; }
.nm-warn i { background: #f59e0b; }
.nm-warn { background: var(--warn-bg); border-color: #f5d9a3; }
.nm-hl { outline: 2px solid #1f6feb; }
.nm-sub { font-size: 11px; color: var(--text-500); margin-left: 2px; }
.nm-empty { font-size: 13px; color: var(--text-500); padding: 6px 0; }
.nm-unas { margin-top: 10px; font-size: 13px; }
.nm-unas summary { cursor: pointer; color: #b26a00; font-weight: 600; }
.nm-form { display: grid; gap: 12px; margin-top: 14px; }
.nm-form label { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-500); }
.nm-pick { max-height: 44vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; }
.nm-form .nm-pickrow { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; color: var(--text-900); }
.nm-count { font-size: 13px; font-weight: 600; }

.nm-chipgrp { display: inline-flex; align-items: center; gap: 3px; }
.nm-cont { color: var(--link); font-weight: 700; }
.nm-after { border: 1px dashed #9db4ff; background: var(--surface-2); color: var(--link); border-radius: 10px; padding: 1px 6px; font-size: 11px; cursor: pointer; }
.nm-after:hover { background: var(--hover); }
.nm-afterblock { margin: 6px 0 6px 6px; padding-left: 10px; border-left: 2px dashed #9db4ff; }
.nm-aftertitle { font-size: 12.5px; color: var(--text-500); margin-top: 4px; }

.nm-plan { background: var(--surface-2); border: 1px solid #d5e1ff; border-radius: 10px; padding: 10px 14px; margin: 6px 0 12px; font-size: 13px; line-height: 1.55; }
.nm-plan-title { font-weight: 700; margin-bottom: 2px; }
.nm-fit { display: inline-block; background: var(--surface); border: 1px solid #c9d8ff; border-radius: 8px; padding: 1px 8px; margin: 2px 4px 2px 0; font-size: 12px; }
.nm-good { color: var(--green-500); }
.nm-bad { color: var(--red-500); }
.nm-planline { margin: 6px 0 2px; font-size: 12.5px; color: var(--text-700); line-height: 1.55; }
.nm-planwarn { margin-top: 4px; padding: 6px 10px; background: #fff3e0; border-radius: 8px; color: #8a4b00; font-weight: 600; }
.nm-plannote { margin-top: 3px; color: var(--text-500); }

.onuh-dist { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; padding: 8px 12px; background: var(--surface-2); border-radius: 10px; font-size: 13.5px; }
.onuh-distbtn { border: 1px solid #9db4ff; background: var(--surface); color: var(--link); border-radius: 8px; padding: 4px 12px; font-size: 12.5px; cursor: pointer; }

.nm-distbtn { border-style: solid; }

/* Network Map tabs + Switch Map */
.nm-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.nm-tab { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-900); font-weight: 600; font-size: 14px; text-decoration: none; }
.nm-tab .nm-sub { font-weight: 400; }
.nm-tab.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.nm-tab.active .nm-sub { color: #cfd6ee; }
.sm-node { margin: 8px 0; border-left: 2px solid #d5deff; padding-left: 10px; }
.sm-card { background: var(--surface); border: 1px solid var(--border); border-left-width: 5px; border-radius: 12px; padding: 10px 14px; }
.sm-card.sm-up { border-left-color: #22a559; }
.sm-card.sm-down { border-left-color: #e5484d; background: #fff8f8; }
.sm-hit { outline: 2px solid #1f6feb; }
.sm-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sm-caret { border: 0; background: transparent; cursor: pointer; color: var(--text-500); font-size: 14px; width: 20px; transition: transform .15s; }
.sm-caret.open { transform: rotate(90deg); }
.sm-caret-sp { display: inline-block; width: 20px; }
.sm-ico { font-size: 18px; }
.sm-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14.5px; }
.sm-host { font-size: 12px; color: var(--text-500); }
.sm-type { font-size: 11px; color: var(--text-500); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; }
.sm-info { font-size: 12.5px; color: var(--text-500); margin-left: auto; }
.sm-link { font-size: 12.5px; color: var(--text-700); margin: 4px 0 0 30px; }
.sm-alert { margin: 8px 0 2px 30px; padding: 6px 10px; background: var(--bad-bg); color: #b3261e; border-radius: 8px; font-size: 13px; font-weight: 600; }
.sm-behind { margin: 4px 0 0 30px; font-size: 12.5px; color: #9a5b00; }
.sm-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 0 30px; }
.sm-actions button, .sm-un button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--text-900); }
.sm-actions button:hover, .sm-un button:hover { background: var(--surface-3); }
.nm-unas-card { padding: 12px 16px; margin-top: 14px; }
.nm-unas-card summary { cursor: pointer; font-weight: 700; }
.sm-unlinked { display: grid; gap: 6px; margin-top: 10px; }
.sm-un { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 12px; border: 1px solid var(--border); border-left-width: 4px; border-radius: 10px; font-size: 13.5px; flex-wrap: wrap; }
.sm-un.sm-up { border-left-color: #22a559; }
.sm-un.sm-down { border-left-color: #e5484d; }

/* Switch Map: live link traffic + port picker */
.sm-traf { margin: 6px 0 0 30px; }
.sm-traf-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.sm-dotl { width: 10px; height: 10px; border-radius: 50%; background: #9aa0b5; flex: none; }
.sm-lv-green .sm-dotl { background: #22a559; }
.sm-lv-yellow .sm-dotl { background: #f5b300; }
.sm-lv-red .sm-dotl, .sm-lv-down .sm-dotl { background: #e5484d; }
.sm-traf-port { font-weight: 600; color: var(--text-900); }
.sm-traf-txt { color: var(--text-700); }
.sm-sub2 { color: var(--text-500); }
.sm-bar { width: 120px; height: 8px; background: #e9ecf6; border-radius: 6px; overflow: hidden; flex: none; }
.sm-bar i { display: block; height: 100%; background: #9aa0b5; transition: width .4s; }
.sm-lv-green .sm-bar i { background: #22a559; }
.sm-lv-yellow .sm-bar i { background: #f5b300; }
.sm-lv-red .sm-bar i, .sm-lv-down .sm-bar i { background: #e5484d; }
.sm-lv-yellow .sm-traf-txt b, .sm-lv-yellow.sm-lvtxt { color: #a87500; }
.sm-lv-red .sm-traf-txt b, .sm-lv-down .sm-traf-txt, .sm-lv-red.sm-lvtxt { color: #d02f34; }
.sm-busy { font-size: 18px !important; display: flex; gap: 10px; }
.sm-picker { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; }
.sm-picker-h { font-size: 12.5px; color: var(--text-500); font-weight: 600; }
.sm-picker select[size] { height: auto; }

.sm-chosen { display: flex; flex-wrap: wrap; gap: 6px; }
.sm-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border: 1px solid var(--border-strong); border-radius: 14px; font-size: 12.5px; background: var(--surface); }
.sm-chip-mon { background: #eef6ff; border-color: #b7d0ff; }
.sm-chip button { border: 0; background: transparent; cursor: pointer; color: #7a7f96; font-size: 12px; padding: 0 6px; }
.sm-typed { display: flex; gap: 6px; }
.sm-typed input { flex: 1; min-width: 0; }
.sm-picker select[multiple] { height: auto; }

/* Firmware */
.fw-warn { padding: 12px 16px; margin-bottom: 14px; background: var(--warn-bg); border-color: #f5d9a3; color: #7a4b00; font-size: 13.5px; }
.fw-versions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.fw-ver { border: 1px solid var(--border); border-radius: 12px; padding: 2px 10px; font-size: 12.5px; background: var(--surface); }
.fw-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 8px 0 12px; }
.fw-sendbar { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.fw-pill { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.fw-st-wait { background: var(--surface-3); color: #55597a; }
.fw-st-run { background: #e3efff; color: var(--link); }
.fw-st-ok { background: #e2f6ea; color: #17803d; }
.fw-st-bad { background: var(--bad-bg); color: #b3261e; }
.fw-ok { color: var(--green-500); font-weight: 600; font-size: 12.5px; }
.fw-mis { color: #b26a00; font-weight: 600; font-size: 12.5px; cursor: help; }
.fw-nomodel { color: var(--red-500); font-weight: 600; }
.fw-upform { padding: 12px 0; max-width: 560px; }
.fw-upform details { font-size: 13px; }
.fw-upform details label { margin-top: 8px; }
.fw-prog { align-items: center; gap: 10px; font-size: 12.5px; }
.fw-prog-bar { flex: 1; height: 10px; background: #e9ecf6; border-radius: 6px; overflow: hidden; }
.fw-prog-bar i { display: block; height: 100%; width: 0; background: #1f6feb; transition: width .2s; }
.fw-badlist { background: var(--bad-bg); border-radius: 8px; padding: 8px 12px; font-size: 12.5px; display: grid; gap: 4px; }
.fw-result { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.fw-bad { color: var(--red-500); margin-top: 4px; }

.fw-advsum { font-size: 13px; padding: 8px 12px; border-radius: 8px; background: #f3f5fb; color: #55597a; margin-bottom: 10px; }
.fw-advsum-yes { background: var(--warn-bg); color: #7a4b00; }
.fw-adv { font-size: 12.5px; font-weight: 600; }
.fw-adv-avail { color: #a05a00; }
.fw-adv-ok { color: var(--green-500); }
.fw-adv-peer { color: #a05a00; }
.fw-adv-none, .fw-adv-unknown, .fw-adv-newer { color: var(--text-500); font-weight: 400; }

/* WiFi & connection diagnosis */
.dg-sum { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; padding: 8px 12px; background: #f3f5fb; border-radius: 10px; margin-bottom: 12px; }
.dg-block { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.dg-h { font-weight: 700; font-size: 14.5px; margin-bottom: 6px; }
.dg-facts { font-weight: 400; font-size: 12.5px; color: var(--text-500); margin-left: 6px; }
.dg-f { display: flex; gap: 8px; padding: 5px 0; font-size: 13.5px; }
.dg-ico { flex: none; }
.dg-d { font-size: 12.5px; color: var(--text-500); margin-top: 1px; }
.dg-a { font-size: 13px; color: var(--link); margin-top: 2px; font-weight: 600; }
.dg-bad b { color: #b3261e; } .dg-warn b { color: #a05a00; }
.dg-apply { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.dg-todo { background: var(--surface-2); border-color: #d5e1ff; }
.dg-todo ol { margin: 4px 0 0 20px; padding: 0; font-size: 13.5px; line-height: 1.6; }
.dg-note { font-size: 12.5px; color: var(--text-500); margin-top: 6px; }

.dg-verdict { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border: 1px solid var(--border); border-left-width: 6px; border-radius: 12px; margin-bottom: 10px; }
.dg-vlabel { font-size: 16px; font-weight: 800; }
.dg-vhead { font-size: 13.5px; color: var(--text-500); }

/* Customer Health */
.hb-pill { display: inline-block; padding: 2px 12px; border-radius: 12px; font-size: 12.5px; font-weight: 700; }
.hb-fault { background: var(--bad-bg); color: #b3261e; }
.hb-issue { background: #fff3e0; color: #a05a00; }
.hb-ok { background: #e2f6ea; color: #17803d; }
.hb-none { background: var(--surface-3); color: #55597a; font-weight: 500; }
.hb-row { cursor: pointer; }
.hb-row:hover { background: var(--surface-2); }
.hb-issue { font-size: 12.5px; padding: 1px 0; }
.hb-insight { padding: 10px 16px; margin-bottom: 10px; background: var(--warn-bg); border-color: #f5d9a3; color: #7a4b00; font-size: 13.5px; }
.hb-table { width: 100%; min-width: 820px; }
.hb-last { font-size: 13.5px; }


/* =====================================================================================================================
   Theme (dark = "control room", the default; light = the original look) + main Dashboard status banner + phone layout
   ===================================================================================================================== */
:root[data-theme="dark"] {
  --bg: #070c1c; --card: #101830; --surface: #101830; --surface-2: #0c1328; --surface-3: #18224a; --hover: #1b2652;
  --text-900: #e8ecff; --text-700: #b9c2e6; --text-500: #8e99c4; --link: #8aa4ff;
  --border: #1f2a52; --border-strong: #2c3a6e; --warn-bg: #3a2d0b; --bad-bg: #3a1218;
  --green-500: #22d68f; --red-500: #ff5d6c; --orange-500: #ffb04a; --blue-500: #4d8dff;
  --viz-surface: #101830; --viz-ink: #eef1ff; --viz-ink-2: #aab3d8; --viz-muted: #7d88b3; --viz-grid: #1f2a52; --viz-axis: #33427a;
  --viz-track: #1a2347; --viz-good: #2ee59d; --viz-bad: #ff5d6c; --viz-series-1: #4d8dff;
  color-scheme: dark;
}
:root[data-theme="dark"] body { background: radial-gradient(1200px 600px at 80% -10%, #14214f 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #2a0f33 0%, transparent 55%), #070c1c; background-attachment: fixed; }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background: var(--surface-2); color: var(--text-900); border-color: var(--border-strong); }
:root[data-theme="dark"] input::placeholder, :root[data-theme="dark"] textarea::placeholder { color: var(--text-500); }
:root[data-theme="dark"] .card, :root[data-theme="dark"] .viz-card, :root[data-theme="dark"] .tile, :root[data-theme="dark"] .stat-card { box-shadow: 0 0 0 1px rgba(255,255,255,.02), 0 8px 24px rgba(0,0,0,.35); }
:root[data-theme="dark"] .stat-card.total, :root[data-theme="dark"] .stat-card.online, :root[data-theme="dark"] .stat-card.offline,
:root[data-theme="dark"] .stat-card.firmware, :root[data-theme="dark"] .stat-card.tickets { background: var(--card); }
:root[data-theme="dark"] .note-banner { background: var(--warn-bg); border-color: #6b5316; color: #f1d27a; }
:root[data-theme="dark"] tbody tr:nth-child(even), :root[data-theme="dark"] tr.device-row:nth-child(even) { background: rgba(255,255,255,.025); }
:root[data-theme="dark"] tbody tr:hover, :root[data-theme="dark"] tr.device-row:hover, :root[data-theme="dark"] tr.onu-row:hover { background: var(--hover) !important; }
:root[data-theme="dark"] td { border-bottom-color: var(--border); }
:root[data-theme="dark"] .btn-outline { background: var(--surface-2); color: var(--text-900); border-color: var(--border-strong); }
:root[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #060a18, #0a1128); border-right: 1px solid var(--border); }
:root[data-theme="dark"] .topbar { background: #060a18; border-bottom-color: var(--border); }
:where(:root[data-theme="dark"] .content a:not([class])) { color: var(--link); }
:root[data-theme="dark"] th { color: #fff; }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn-danger, :root[data-theme="dark"] .btn-success, :root[data-theme="dark"] .badge-online, :root[data-theme="dark"] .badge-offline { color: #fff; }
:root[data-theme="dark"] .onuh-overlay { background: rgba(2,5,16,.72); }
:root[data-theme="dark"] .toast { background: #1b2652; color: #fff; }

/* theme switch in the top bar */
.theme-btn { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.14); border-radius: 20px; height: 32px; padding: 0 12px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.theme-btn:hover { background: rgba(255,255,255,.16); }

/* main Dashboard: the five big cards as "control room" tiles in the dark theme (coloured glow, big number); the light theme keeps its gradients */
:root[data-theme="dark"] .dash-section-card { background: linear-gradient(160deg, #131d40, #0c1330); border: 1px solid var(--border-strong); box-shadow: 0 10px 30px rgba(0,0,0,.4); --acc: #4d8dff; }
:root[data-theme="dark"] .dash-section-card::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--acc); box-shadow: 0 0 18px var(--acc); }
:root[data-theme="dark"] .dash-section-card.dash-tr069 { --acc: #6c8cff; background: linear-gradient(160deg, #131d40, #0c1330); }
:root[data-theme="dark"] .dash-section-card.dash-olts { --acc: #22d68f; background: linear-gradient(160deg, #0f2a2c, #0a1a24); }
:root[data-theme="dark"] .dash-section-card.dash-switches { --acc: #ffb04a; background: linear-gradient(160deg, #2c2012, #1a1410); }
:root[data-theme="dark"] .dash-section-card.dash-mikrotiks { --acc: #ff5fa8; background: linear-gradient(160deg, #2d1330, #1a0f22); }
:root[data-theme="dark"] .dash-section-card.dash-ports { --acc: #35d0ee; background: linear-gradient(160deg, #0e2634, #0b1624); }
:root[data-theme="dark"] .dash-section-card .dash-total { color: var(--acc); text-shadow: 0 0 22px color-mix(in srgb, var(--acc) 55%, transparent); }
:root[data-theme="dark"] .dash-section-card .dash-title { color: var(--text-700); }
:root[data-theme="dark"] .dash-section-card .dash-split span { background: rgba(255,255,255,.07); }
:root[data-theme="dark"] .dash-section-card:hover { box-shadow: 0 14px 36px rgba(0,0,0,.55); border-color: var(--acc); }

/* status banner at the top of the main Dashboard */
.dash-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(220px, 1fr); gap: 18px; align-items: center; border-radius: 18px; padding: 18px 22px; margin-bottom: 16px;
  border: 1px solid var(--hero-line); background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); box-shadow: 0 0 0 1px rgba(255,255,255,.02), 0 10px 34px var(--hero-glow); color: var(--text-900); }
.dash-hero.ok   { --hero-line: rgba(34,214,143,.45); --hero-a: rgba(34,214,143,.14); --hero-b: rgba(34,214,143,.04); --hero-glow: rgba(34,214,143,.16); --hero-ink: #12a56e; }
.dash-hero.warn { --hero-line: rgba(255,176,74,.55); --hero-a: rgba(255,176,74,.18); --hero-b: rgba(255,176,74,.05); --hero-glow: rgba(255,176,74,.18); --hero-ink: #d98200; }
.dash-hero.crit { --hero-line: rgba(255,93,108,.65); --hero-a: rgba(255,93,108,.22); --hero-b: rgba(255,93,108,.06); --hero-glow: rgba(255,93,108,.26); --hero-ink: #e63950; }
:root[data-theme="dark"] .dash-hero.ok { --hero-ink: #22d68f; } :root[data-theme="dark"] .dash-hero.warn { --hero-ink: #ffb04a; } :root[data-theme="dark"] .dash-hero.crit { --hero-ink: #ff5d6c; }
.dash-hero .hero-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.dash-hero .hero-ico { font-size: 40px; line-height: 1; flex: none; }
.dash-hero .hero-title { font-size: 22px; font-weight: 800; color: var(--hero-ink); line-height: 1.15; }
.dash-hero.crit .hero-ico { animation: heroPulse 1.6s ease-in-out infinite; }
@keyframes heroPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .dash-hero.crit .hero-ico { animation: none; } }
.dash-hero .hero-sub { font-size: 13.5px; color: var(--text-700); margin-top: 4px; }
.dash-hero .hero-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.dash-hero .hero-chip { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; background: rgba(255,255,255,.08); border: 1px solid var(--hero-line); color: var(--text-900); text-decoration: none; }
:root:not([data-theme="dark"]) .dash-hero .hero-chip { background: rgba(255,255,255,.7); }
.dash-hero .hero-spark { min-width: 0; }
.dash-hero .hero-spark-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; color: var(--text-500); }
.dash-hero .hero-spark-top b { font-size: 20px; color: var(--text-900); }
.dash-hero svg { width: 100%; height: 64px; display: block; margin-top: 4px; }
.dash-hero .hero-spark-lbl { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-500); }

/* phone layout */
@media (max-width: 640px) {
  .content { padding: 12px; }
  .page-title { font-size: 18px; }
  .dash-hero { grid-template-columns: 1fr; padding: 14px 16px; gap: 12px; }
  .dash-hero .hero-ico { font-size: 32px; } .dash-hero .hero-title { font-size: 18px; }
  .dash-sections { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dash-section-card { padding: 14px 14px; }
  .dash-section-card .dash-total { font-size: 28px; }
  .dash-section-card .dash-split { flex-direction: column; gap: 6px; font-size: 12px; }
  .viz-grid2 { grid-template-columns: 1fr; }
  .card, .viz-card { overflow-x: auto; }
  .topbar .theme-btn { padding: 0 10px; }
}
