/* ============================================================
   CloudWorks Demonstration Portal — dark dashboard theme
   ============================================================ */

:root {
  color-scheme: dark;

  /* brand */
  --brand:        #29abe2;
  --brand-deep:   #1b4a5f;

  /* surfaces */
  --page:         #0a1017;
  --surface:      #111a24;
  --surface-2:    #16222e;
  --surface-3:    #1c2a38;
  --border:       rgba(255,255,255,0.08);
  --border-soft:  rgba(255,255,255,0.05);

  /* ink */
  --ink:          #f2f6f9;
  --ink-2:        #b9c6d0;
  --ink-3:        #7f8f9c;
  --grid:         rgba(255,255,255,0.07);
  --axis:         rgba(255,255,255,0.16);

  /* categorical series (dark-surface steps) */
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;

  /* status (fixed) */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;

  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ambient glow behind the header */
body::before {
  content: "";
  position: fixed;
  top: -340px; left: 50%;
  width: 1100px; height: 620px;
  transform: translateX(-50%);
  background:
    radial-gradient(closest-side, rgba(41,171,226,0.16), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.wrap { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 0 24px 64px; }

/* ---------------- header ---------------- */

header.top {
  display: flex; align-items: center; gap: 18px;
  padding: 20px 0 14px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand svg.mark { width: 58px; height: 47px; display: block; }
.brand .word { font-size: 1.72rem; font-weight: 700; letter-spacing: -0.5px; line-height: 1; }
.brand .word .c1 { color: var(--brand); }
.brand .word .c2 { color: var(--ink); }
.brand .tag { font-size: 0.74rem; color: var(--ink-3); letter-spacing: 0.14em; text-transform: uppercase; margin-top: 4px; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.conn {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px;
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.conn.ok .dot { background: var(--good); box-shadow: 0 0 0 0 rgba(12,163,12,0.5); animation: pulse 2.4s infinite; }
.conn.bad .dot { background: var(--critical); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(12,163,12,0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(12,163,12,0); }
  100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); }
}

button.icon-btn, a.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 13px; font: inherit; font-size: 0.84rem;
  cursor: pointer; text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
button.icon-btn:hover, a.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: rgba(255,255,255,0.16); }
button.icon-btn svg, a.icon-btn svg { width: 16px; height: 16px; }
button.icon-btn.spin svg { animation: rot 0.9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------------- error banner ---------------- */

#error-banner {
  display: none; align-items: flex-start; gap: 10px;
  background: rgba(208,59,59,0.12); border: 1px solid rgba(208,59,59,0.4);
  color: #ffd9d9; border-radius: var(--radius);
  padding: 12px 16px; margin: 10px 0; font-size: 0.9rem;
}

/* ---------------- KPI strip ---------------- */

.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin: 18px 0 8px;
}

.kpi {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px 14px;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.55;
}
.kpi .k-label { font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.kpi .k-value { font-size: 1.9rem; font-weight: 700; margin-top: 2px; line-height: 1.15; }
.kpi .k-value small { font-size: 1rem; font-weight: 600; color: var(--ink-2); }
.kpi .k-sub { font-size: 0.78rem; color: var(--ink-3); margin-top: 2px; min-height: 1.1em; }
.kpi.alarm .k-value { color: var(--critical); }
.kpi.calm  .k-value { color: var(--good); }

/* ---------------- application sections ---------------- */

.app-section { margin-top: 30px; animation: rise 0.35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.app-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.app-head .app-icon {
  width: 42px; height: 42px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.app-head .app-icon svg { width: 24px; height: 24px; }
.app-head h2 { font-size: 1.06rem; font-weight: 650; }
.app-head .app-sub { font-size: 0.78rem; color: var(--ink-3); }
.app-head .count-pill {
  margin-left: auto; font-size: 0.75rem; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--border);
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}

.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }

/* ---------------- device card ---------------- */

.dev-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px 14px;
  cursor: pointer; text-align: left; color: inherit; font: inherit;
  text-decoration: none;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.16s ease, border-color 0.16s, background 0.16s, box-shadow 0.16s;
}
.dev-card:hover {
  transform: translateY(-3px);
  border-color: rgba(41,171,226,0.45);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.dev-top { display: flex; align-items: flex-start; gap: 10px; }
.dev-name { font-weight: 650; font-size: 1rem; line-height: 1.25; }
.dev-serial { font-size: 0.76rem; color: var(--ink-3); margin-top: 1px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.pill .pd { width: 6px; height: 6px; border-radius: 50%; }
.pill.online   { background: rgba(12,163,12,0.14);  color: #6fdc6f; }
.pill.online .pd { background: var(--good); }
.pill.sleep    { background: rgba(121,140,153,0.16); color: var(--ink-2); }
.pill.sleep .pd { background: var(--ink-3); }
.pill.offline  { background: rgba(208,59,59,0.16); color: #f19a9a; }
.pill.offline .pd { background: var(--critical); }
.pill.alarmpill { background: rgba(208,59,59,0.16); color: #f4a3a3; }
.pill.configpill { background: rgba(240,194,75,0.14); color: #f0c24b; }
.pill.configpill .pd { background: #f0c24b; }

.dev-pills { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }

.dev-spark { display: flex; align-items: flex-end; gap: 12px; min-height: 52px; }
.dev-spark svg { flex: 1; height: 46px; display: block; }
.spark-val { text-align: right; }
.spark-val .sv { font-size: 1.28rem; font-weight: 700; line-height: 1.05; }
.spark-val .sv small { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); margin-left: 2px; }
.spark-val .sl { font-size: 0.72rem; color: var(--ink-3); }

.dev-meta {
  display: flex; align-items: center; gap: 14px;
  font-size: 0.75rem; color: var(--ink-3);
  border-top: 1px solid var(--border-soft); padding-top: 9px;
  flex-wrap: wrap;
}
.dev-meta .m { display: inline-flex; align-items: center; gap: 5px; }
.dev-meta svg { width: 13px; height: 13px; opacity: 0.85; }

.gsm { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 12px; }
.gsm i { width: 3px; background: rgba(255,255,255,0.18); border-radius: 1px; display: block; }
.gsm i.on { background: var(--brand); }
.gsm i:nth-child(1){height:4px}.gsm i:nth-child(2){height:6px}
.gsm i:nth-child(3){height:9px}.gsm i:nth-child(4){height:12px}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 45%, var(--surface-2) 65%);
  background-size: 300% 100%; animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ---------------- detail view ---------------- */

.back-row { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; flex-wrap: wrap; }
a.back-link {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--ink-2); text-decoration: none; font-size: 0.86rem;
  padding: 7px 13px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface);
  transition: color 0.15s, border-color 0.15s;
}
a.back-link:hover { color: var(--ink); border-color: rgba(255,255,255,0.2); }

.detail-head { display: flex; align-items: center; gap: 14px; margin: 14px 0 4px; flex-wrap: wrap; }
.detail-head .app-icon {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
}
.detail-head .app-icon svg { width: 30px; height: 30px; }
.detail-head h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.detail-head .d-sub { color: var(--ink-3); font-size: 0.84rem; }
.detail-head .d-pills { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.alarm-banner {
  display: flex; align-items: center; gap: 10px;
  background: rgba(208,59,59,0.12); border: 1px solid rgba(208,59,59,0.45);
  border-radius: var(--radius); padding: 11px 16px; margin: 12px 0;
  color: #ffdcdc; font-size: 0.9rem;
}
.alarm-banner svg { width: 18px; height: 18px; flex: none; color: var(--critical); }

.range-row { display: flex; align-items: center; gap: 8px; margin: 16px 0 14px; flex-wrap: wrap; }
.range-row .lbl { font-size: 0.8rem; color: var(--ink-3); margin-right: 4px; }
.chip {
  font: inherit; font-size: 0.82rem; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 15px; cursor: pointer;
  transition: all 0.14s;
}
.chip:hover { color: var(--ink); border-color: rgba(255,255,255,0.2); }
.chip.sel {
  color: #fff; background: linear-gradient(180deg, #2f89c9, #1f6fa8);
  border-color: transparent; font-weight: 600;
}

.detail-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.dk {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 16px 11px;
}
.dk .k-label { font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); }
.dk .k-value { font-size: 1.5rem; font-weight: 700; margin-top: 1px; }
.dk .k-value small { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin-left: 2px; }
.dk .k-sub { font-size: 0.74rem; color: var(--ink-3); }
.dk.status-bad .k-value { color: var(--critical); }
.dk.status-good .k-value { color: var(--good); }

/* fuel tank visual (application 044) */
.detail-kpis.with-tank { grid-template-columns: 265px repeat(auto-fit, minmax(185px, 1fr)); }
.fuel-card {
  grid-row: 1 / span 2;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; gap: 16px; align-items: center; justify-content: center;
}
.fuel-svg { width: 100px; flex: 0 0 auto; }
.fuel-wave { animation: fuelwave 3.2s ease-in-out infinite; }
@keyframes fuelwave { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
.fuel-facts { min-width: 0; }
.ff-pct { font-size: 2.1rem; font-weight: 700; line-height: 1.1; }
.ff-pct small { font-size: 1.05rem; font-weight: 600; color: var(--ink-2); margin-left: 2px; }
.ff-cap { font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); margin: 1px 0 10px; }
.ff-row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.8rem; color: var(--ink-3); padding: 3px 0; }
.ff-row b { color: var(--ink); font-weight: 600; white-space: nowrap; }
@media (max-width: 700px) {
  .detail-kpis.with-tank { grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }
  .fuel-card { grid-row: auto; grid-column: 1 / -1; }
}

.chart-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 940px) {
  .chart-grid.two { grid-template-columns: 1fr 1fr; }
  .chart-grid .span2 { grid-column: 1 / -1; }
}

.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px 10px;
  min-width: 0;
}
.chart-card h3 { font-size: 0.92rem; font-weight: 650; }
.chart-card .c-sub { font-size: 0.75rem; color: var(--ink-3); margin-bottom: 8px; }
.chart-card .legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 6px 0 2px; }
.chart-card .legend .li { display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--ink-2); }
.chart-card .legend .sw { width: 14px; height: 3px; border-radius: 2px; }
.chart-empty { color: var(--ink-3); font-size: 0.85rem; padding: 34px 0; text-align: center; }

.chart-holder { position: relative; }
.chart-holder svg { display: block; width: 100%; height: auto; }

.viz-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #0c141c; border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px; padding: 8px 11px; font-size: 0.76rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  white-space: nowrap; display: none;
}
.viz-tip .tt { color: var(--ink-3); margin-bottom: 3px; }
.viz-tip .tr { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.viz-tip .tr b { color: var(--ink); font-weight: 650; margin-left: auto; padding-left: 12px; }
.viz-tip .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ---------------- info + table ---------------- */

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.info-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 18px;
}
.info-card h3 { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.info-card dl .row { display: flex; justify-content: space-between; gap: 14px; padding: 4.5px 0; border-bottom: 1px solid var(--border-soft); }
.info-card dl .row:last-child { border-bottom: 0; }
.info-card dt { color: var(--ink-3); font-size: 0.8rem; }
.info-card dd { font-size: 0.82rem; text-align: right; }
.info-card a { color: var(--brand); text-decoration: none; }
.info-card a:hover { text-decoration: underline; }

.table-card { margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table-card summary {
  cursor: pointer; padding: 14px 18px; font-size: 0.9rem; font-weight: 600;
  color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 8px;
}
.table-card summary::-webkit-details-marker { display: none; }
.table-card summary::after { content: "▾"; margin-left: auto; color: var(--ink-3); transition: transform 0.2s; }
.table-card[open] summary::after { transform: rotate(180deg); }
.table-scroll { overflow-x: auto; padding: 0 10px 12px; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.79rem; }
table.data th {
  text-align: right; color: var(--ink-3); font-weight: 600; white-space: nowrap;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td { padding: 6px 12px; text-align: right; white-space: nowrap; color: var(--ink-2); border-bottom: 1px solid var(--border-soft); font-variant-numeric: tabular-nums; }
table.data td:first-child { color: var(--ink); }
table.data tr:hover td { background: rgba(255,255,255,0.025); }

/* ---------------- settings modal ---------------- */

.modal-veil {
  position: fixed; inset: 0; background: rgba(4,8,12,0.7);
  display: none; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal-veil.open { display: flex; }
.modal {
  width: min(440px, calc(100vw - 40px));
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px 24px; box-shadow: var(--shadow);
}
.modal h2 { font-size: 1.05rem; margin-bottom: 14px; }
.modal label { display: block; font-size: 0.78rem; color: var(--ink-3); margin: 10px 0 4px; }
.modal input {
  width: 100%; font: inherit; font-size: 0.9rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 12px; outline: none;
}
.modal input:focus { border-color: var(--brand); }
.modal .m-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.modal .m-note { font-size: 0.78rem; margin-left: auto; }
.modal .m-note.ok { color: var(--good); }
.modal .m-note.bad { color: var(--critical); }
button.primary {
  font: inherit; font-size: 0.88rem; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, #2f89c9, #1f6fa8);
  border: 0; border-radius: 10px; padding: 10px 20px; cursor: pointer;
}
button.primary:hover { filter: brightness(1.1); }

/* ---------------- footer ---------------- */

footer {
  margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--border-soft);
  color: var(--ink-3); font-size: 0.78rem;
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
}
footer .f-right { margin-left: auto; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  .brand .word { font-size: 1.4rem; }
  .kpi .k-value { font-size: 1.5rem; }
}

/* ============================================================
   Online shell (v2): topbar + sidebar + login + admin forms
   ============================================================ */

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px;
  background: rgba(13, 20, 28, 0.85);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(8px);
}
.topbar .brand svg.mark { width: 52px; height: 31px; }
.topbar .brand .word { font-size: 1.35rem; }
.topbar .brand .tag { margin-top: 1px; font-size: 0.64rem; }

.user-box { display: flex; align-items: center; gap: 8px; margin-left: 6px; padding-left: 14px; border-left: 1px solid var(--border); }
#user-chip .uc-name { font-size: 0.84rem; font-weight: 600; line-height: 1.2; }
#user-chip .uc-type { font-size: 0.7rem; color: var(--ink-3); }

.body-row { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 250px; flex: none;
  border-right: 1px solid var(--border-soft);
  padding: 14px 10px 24px;
  background: rgba(10, 16, 23, 0.6);
  overflow-y: auto;
  position: sticky; top: 57px;
  align-self: flex-start;
  max-height: calc(100vh - 57px);
}
.login-mode .sidebar { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; border-radius: 9px;
  color: var(--ink-2); text-decoration: none; font-size: 0.86rem;
  margin-bottom: 2px;
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.sel { background: rgba(41, 171, 226, 0.12); color: var(--brand); }
.nav-item.sub { padding-left: 30px; font-size: 0.8rem; }
.nav-item .nav-count {
  margin-left: auto; font-size: 0.68rem; color: var(--ink-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 1px 8px;
}
.nav-sep {
  font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); padding: 14px 12px 6px;
}
.tree-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.tree-dot.alarm { background: var(--critical); }

/* collapsible zone rows */
.zone-row { padding: 0; gap: 0; background: none; }
.zone-row:hover { background: none; }
.nav-caret {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 24px; align-self: stretch; padding: 0; margin: 0;
  background: none; border: none; cursor: pointer; color: var(--ink-3);
  border-radius: 9px 0 0 9px;
}
.nav-caret svg { width: 14px; height: 14px; transition: transform 0.15s ease; }
.zone-row.open .nav-caret svg { transform: rotate(90deg); }
.nav-caret:hover:not(:disabled) { color: var(--brand); background: var(--surface-2); }
.nav-caret:disabled { opacity: 0; cursor: default; }
.zone-link {
  display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0;
  padding: 8px 12px 8px 3px; border-radius: 0 9px 9px 0;
  color: var(--ink-2); text-decoration: none; font-size: 0.86rem;
}
.zone-link:hover { background: var(--surface-2); color: var(--ink); }
.zone-link.sel { background: rgba(41, 171, 226, 0.12); color: var(--brand); }
.zone-link > span:not(.tree-dot):not(.nav-count) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-link .nav-count {
  margin-left: auto; font-size: 0.68rem; color: var(--ink-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 1px 8px;
}

.content { flex: 1; min-width: 0; }
.content .wrap { padding-top: 18px; }

.page-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.4rem; }
.page-head .page-sub { color: var(--ink-3); font-size: 0.8rem; }
.page-head .primary, .page-head button { margin-left: auto; }
.page-head h1 + .page-sub { margin-left: 0; }
.page-head .page-sub { margin-left: auto; }

.crumb { color: var(--brand); text-decoration: none; }
.crumb:hover { text-decoration: underline; }

.warn-text { color: var(--warning) !important; }
.icon-btn.sm { padding: 4px 9px; font-size: 0.74rem; border-radius: 7px; }
.icon-btn.danger { color: #f0a0a0; border-color: rgba(208, 59, 59, 0.4); }
.icon-btn.danger:hover { background: rgba(208, 59, 59, 0.15); color: #ffc9c9; }
button.primary.danger { background: linear-gradient(180deg, #d04343, #a83232); }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------------- login ---------------- */

.login-wrap { display: flex; justify-content: center; padding: 9vh 12px 40px; }
.login-card {
  width: min(380px, 100%);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: 18px;
  padding: 30px 32px 26px; box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo .word { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.5px; }
.login-logo .tag { display: block; font-size: 0.72rem; color: var(--ink-3); letter-spacing: 0.14em; text-transform: uppercase; margin-top: 5px; }
.login-card label { display: block; font-size: 0.76rem; color: var(--ink-3); margin: 12px 0 4px; }
.login-card input {
  width: 100%; font: inherit; font-size: 0.95rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 13px; outline: none;
}
.login-card input:focus { border-color: var(--brand); }
.login-card .primary { width: 100%; margin-top: 18px; padding: 11px; }
.login-msg { min-height: 1.3em; margin-top: 12px; text-align: center; font-size: 0.8rem; color: var(--serious); }

/* ---------------- admin forms ---------------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 6px; }
.form-grid label { font-size: 0.72rem; color: var(--ink-3); display: block; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select {
  width: 100%; margin-top: 3px; font: inherit; font-size: 0.86rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; outline: none;
}
.form-grid input:focus, .form-grid select:focus { border-color: var(--brand); }
.form-grid input[readonly] { opacity: 0.6; }

.m-intro { font-size: 0.8rem; color: var(--ink-2); margin: 4px 0 8px; line-height: 1.5; }
.danger-box {
  background: rgba(208, 59, 59, 0.1); border: 1px solid rgba(208, 59, 59, 0.4);
  border-radius: 9px; padding: 9px 12px; color: #ffd9d9;
}
#adm-veil .modal { max-height: 86vh; overflow-y: auto; width: min(560px, calc(100vw - 40px)); }
#adm-veil input { font: inherit; font-size: 0.86rem; color: var(--ink); background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; outline: none; }

.ops-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ops-list .icon-btn { justify-content: flex-start; }

.cmd-out {
  margin-top: 12px; background: var(--page); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px; min-height: 70px; max-height: 240px; overflow: auto;
  font-family: ui-monospace, Consolas, monospace; font-size: 0.78rem; color: var(--ink-2);
  white-space: pre-wrap;
}

#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #10331a; color: #9fe8ae; border: 1px solid rgba(12, 163, 12, 0.5);
  border-radius: 99px; padding: 10px 22px; font-size: 0.85rem; z-index: 90;
  opacity: 0; transition: all 0.25s ease; pointer-events: none;
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .sidebar { display: none; }
}

/* ---------------- theme toggle ---------------- */

#btn-theme .ic-moon { display: none; }
:root[data-theme="light"] #btn-theme .ic-sun { display: none; }
:root[data-theme="light"] #btn-theme .ic-moon { display: inline; }

/* ---------------- sidebar add button ---------------- */

.nav-sep { display: flex; align-items: center; gap: 8px; }
.nav-add {
  margin-left: auto; width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--ink-3);
  border: 1px solid var(--border); border-radius: 6px;
  font: inherit; font-size: 0.9rem; line-height: 1; cursor: pointer;
}
.nav-add:hover { color: var(--brand); border-color: rgba(41, 171, 226, 0.5); }

/* ---------------- tank table editor ---------------- */

.tt-layout { display: grid; grid-template-columns: 1fr 230px 320px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .tt-layout { grid-template-columns: 1fr; } }

.tt-grid-scroll { max-height: 420px; overflow-y: auto; border: 1px solid var(--border-soft); border-radius: 8px; }
table.tt-grid { width: 100%; }
table.tt-grid th { position: sticky; top: 0; z-index: 2; }
table.tt-grid tbody tr { cursor: pointer; user-select: none; }
table.tt-grid tr.captured td { color: #7ab5f5; font-weight: 600; }
table.tt-grid tr.captured td:first-child { box-shadow: inset 3px 0 0 #3987e5; }
table.tt-grid tr.sel td { background: rgba(41, 171, 226, 0.16) !important; }

.tt-warning {
  background: rgba(250, 178, 25, 0.1); border: 1px solid rgba(250, 178, 25, 0.4);
  color: #e8bd66; border-radius: 8px; padding: 8px 12px; font-size: 0.8rem; margin-bottom: 10px;
}
.tt-dirty {
  font-size: 0.74rem; color: var(--warning); background: rgba(250, 178, 25, 0.1);
  border: 1px solid rgba(250, 178, 25, 0.35); border-radius: 99px; padding: 3px 12px;
}

.tt-lbl { display: block; font-size: 0.74rem; color: var(--ink-3); margin: 10px 0 4px; }
.tt-input {
  width: 100%; font: inherit; font-size: 0.9rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 11px; outline: none;
}
.tt-input:focus { border-color: var(--brand); }
.tt-act { width: 100%; margin-top: 8px; justify-content: center; }

.tt-shapes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.tt-shape {
  min-width: 0;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 10px 8px;
  cursor: pointer; display: block; background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.tt-shape:hover { border-color: rgba(41, 171, 226, 0.45); }
.tt-shape.sel { border-color: var(--brand); background: rgba(41, 171, 226, 0.07); }
.tt-shape input[type="radio"] { display: none; }
.tt-shape svg { width: 60px; height: 54px; display: block; margin: 0 auto; }
.tt-shape-line { fill: none; stroke: var(--ink-3); stroke-width: 2; }
.tt-shape.sel .tt-shape-line { stroke: var(--brand); }
.tt-shape-fill { fill: rgba(41, 171, 226, 0.35); stroke: none; }
.tt-shape-name { text-align: center; font-size: 0.72rem; color: var(--ink-2); margin: 6px 0 6px; }
.tt-dims { display: flex; flex-direction: column; gap: 4px; }
.tt-dim { display: flex; align-items: center; gap: 6px; font-size: 0.74rem; color: var(--ink-3); }
.tt-dim b { width: 10px; text-align: center; color: var(--ink-2); }
.tt-dim input {
  flex: 1; min-width: 0; font: inherit; font-size: 0.78rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 7px; outline: none;
}
.tt-dim input:focus { border-color: var(--brand); }
.tt-dim input:disabled { opacity: 0.4; }
.tt-dim i { font-style: normal; }

/* 3D-ish tank shape drawings */
.tt-shape-back { fill: none; stroke: var(--ink-3); stroke-width: 1.6; opacity: 0.45; }
.tt-shape.sel .tt-shape-back { stroke: var(--brand); }
.tt-shape-surface { fill: rgba(41, 171, 226, 0.55); stroke: none; }

/* capsule straight-section band + dimension markings */
.tt-shape-band { fill: rgba(41, 171, 226, 0.13); stroke: none; }
.tt-dim-mark { stroke: var(--ink-2); stroke-width: 1.1; fill: none; opacity: 0.75; }
.tt-dim-arrow { fill: var(--ink-2); stroke: none; opacity: 0.9; }
.tt-dim-text { fill: var(--ink-2); font: italic 700 10.5px Georgia, "Times New Roman", serif; }

/* live comms row selection */
tr.ops-row { cursor: pointer; }
tr.ops-row.sel td { background: rgba(41, 171, 226, 0.12) !important; }

/* login logo mark */
.login-logo .login-mark { width: 170px; height: 102px; display: block; margin: 0 auto 10px; }
.login-logo .word .c1 { color: var(--brand); }
.login-logo .word .c2 { color: var(--ink); }

/* the real logo file (white cloud interior works on both themes) */
img.mark, img.login-mark { object-fit: contain; }
.topbar .brand img.mark { width: 52px; height: 31px; }

/* ---------------- logger configuration page ---------------- */

.cf-modebar {
  border-radius: 10px; padding: 10px 16px; font-size: 0.85rem; margin: 4px 0 14px;
}
.cf-modebar.direct { background: rgba(12, 163, 12, 0.1); border: 1px solid rgba(12, 163, 12, 0.35); color: #7fd58a; }
.cf-modebar.script { background: rgba(250, 178, 25, 0.09); border: 1px solid rgba(250, 178, 25, 0.35); color: #e0b566; }

.cf-layout { display: grid; grid-template-columns: 1fr 380px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .cf-layout { grid-template-columns: 1fr; } }

.cf-sect { margin-bottom: 14px; }
.cf-sect h3 { margin-bottom: 10px; }
.cf-busy { opacity: 0.55; pointer-events: none; }

.cf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px 14px; }
.cf-field { display: block; min-width: 0; }
.cf-field.wide { grid-column: 1 / -1; }
.cf-field > span { display: block; font-size: 0.71rem; color: var(--ink-3); margin-bottom: 3px; }
.cf-field input, .cf-field select {
  width: 100%; font: inherit; font-size: 0.85rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; outline: none;
}
.cf-field input:focus, .cf-field select:focus { border-color: var(--brand); }
.cf-field input[readonly] { opacity: 0.65; border-style: dashed; }
.cf-field input:disabled { opacity: 0.4; }

.cf-genrow { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px 14px; }

.cf-radios { display: flex; gap: 12px; flex-wrap: wrap; padding-top: 6px; }
.cf-radio { display: inline-flex; align-items: center; gap: 6px; font-size: 0.83rem; color: var(--ink-2); cursor: pointer; }

.cf-side { position: sticky; top: 70px; }
.cf-console {
  background: var(--page); border: 1px solid var(--border); border-radius: 9px;
  height: 380px; overflow-y: auto; padding: 10px 12px;
  font-family: ui-monospace, Consolas, monospace; font-size: 0.72rem; line-height: 1.5;
}
.cf-line { white-space: pre-wrap; word-break: break-all; }
.cf-cmd { color: #6da7ec; }
.cf-resp { color: #6fdc6f; }
.cf-err { color: #f19a9a; }
.cf-queued { color: #e0b566; }
.cf-done { color: var(--ink); font-weight: 600; }
.cf-grid-2 { grid-template-columns: 1fr 1fr; }

/* ---------------- map modal (OpenStreetMap) ---------------- */

.map-modal {
  width: min(1000px, calc(100vw - 40px));
  height: min(700px, calc(100vh - 60px));
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.map-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
.map-head h2 { font-size: 1.02rem; }
#map-holder { flex: 1; min-height: 0; }


/* branded Leaflet popup bubble */
.leaflet-popup-content-wrapper {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--surface-2); border: 1px solid var(--border); }
.leaflet-popup-content { margin: 14px 16px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-3); }

.map-pop { font: 0.78rem/1.45 system-ui, "Segoe UI", sans-serif; min-width: 270px; }
.map-pop .mp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.map-pop .mp-icon { width: 32px; height: 32px; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.map-pop .mp-icon svg { width: 19px; height: 19px; }
.map-pop .mp-name { font-weight: 700; font-size: 0.9rem; line-height: 1.2; }
.map-pop .mp-site { color: var(--ink-3); font-size: 0.7rem; }
.map-pop .mp-head .pill { margin-left: auto; }
.map-pop .mp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px;
  border-top: 1px solid var(--border-soft); padding-top: 8px; }
.map-pop .mp-row { display: flex; flex-direction: column; }
.map-pop .mp-row.wide { grid-column: 1 / -1; }
.map-pop .mp-row span { color: var(--ink-3); font-size: 0.66rem; letter-spacing: 0.04em; text-transform: uppercase; }
.map-pop .mp-row b { font-weight: 600; color: var(--ink-2); }
.map-pop .mp-row.bad b { color: #e06666; }
.map-pop .mp-row.good b { color: #6fbf6f; }
.map-pop .mp-row .gsm i { background: rgba(127, 143, 156, 0.35); }
.map-pop .mp-row .gsm i.on { background: var(--brand); }
.map-pop a.mp-link { display: inline-block; margin-top: 10px; color: var(--brand); font-weight: 650; text-decoration: none; }
.map-pop a.mp-link:hover { text-decoration: underline; }

/* dome map markers, coloured by status */
.map-dot {
  display: block; width: 18px; height: 18px; margin: 2px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  background: radial-gradient(circle at 35% 28%, #9fc7e8, #29abe2 55%, #1273a3);
  cursor: pointer;
}
.map-dot.online { background: radial-gradient(circle at 35% 28%, #8fe39a, #21b02c 55%, #0a7a12); }
.map-dot.sleep  { background: radial-gradient(circle at 35% 28%, #b9c9d6, #6e8494 55%, #465966); }
.map-dot.offline, .map-dot.alarm {
  background: radial-gradient(circle at 35% 28%, #f0a0a0, #d63c3c 55%, #8f1f1f);
}
.map-dot.alarm { animation: map-dot-pulse 1.6s infinite; }
.map-dot.focus { width: 22px; height: 22px; margin: 0; }
@keyframes map-dot-pulse {
  0%   { box-shadow: 0 2px 6px rgba(0,0,0,0.45), 0 0 0 0 rgba(214, 60, 60, 0.55); }
  70%  { box-shadow: 0 2px 6px rgba(0,0,0,0.45), 0 0 0 11px rgba(214, 60, 60, 0); }
  100% { box-shadow: 0 2px 6px rgba(0,0,0,0.45), 0 0 0 0 rgba(214, 60, 60, 0); }
}

/* full lock-up logo (cloudworks_logo.png) in topbar + login */
.topbar .brand .logo-full { height: 42px; width: auto; display: block; }
.topbar .brand .logo-tag { align-self: flex-end; margin: 0 0 4px 2px; }
.login-logo .login-logo-full { width: 230px; max-width: 80%; display: block; margin: 0 auto 10px; }
.mark-light { display: none !important; }
:root[data-theme="light"] .mark-dark { display: none !important; }
:root[data-theme="light"] .topbar .mark-light { display: block !important; }
:root[data-theme="light"] .login-logo .mark-light { display: block !important; }

/* first-run commissioning notice */
#notice-banner {
  display: none; align-items: flex-start; gap: 8px;
  background: rgba(250, 178, 25, 0.1); border: 1px solid rgba(250, 178, 25, 0.4);
  color: #e8bd66; border-radius: var(--radius);
  padding: 12px 16px; margin: 10px 0; font-size: 0.88rem;
}
#notice-banner a { color: var(--brand); font-weight: 600; }

/* update-available banner (managers only) */
.update-banner {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(41, 171, 226, 0.09); border: 1px solid rgba(41, 171, 226, 0.4);
  color: var(--ink-2); border-radius: var(--radius);
  padding: 12px 16px; margin: 10px 0; font-size: 0.88rem;
}
.update-banner svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; color: var(--brand); }
.update-banner b { color: var(--ink); }
.update-banner a { color: var(--brand); font-weight: 600; }
.update-banner.critical { background: rgba(208, 75, 75, 0.1); border-color: rgba(208, 75, 75, 0.45); }
.update-banner.critical svg { color: #d04b4b; }
.update-banner .ub-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--ink-3); font-size: 1.1rem; line-height: 1; padding: 2px 4px;
}
.update-banner .ub-close:hover { color: var(--ink); }

.login-ver { text-align: center; margin-top: 14px; font-size: 0.72rem; color: var(--ink-3); }
.login-msg.info { color: #7fd58a; }

/* forgot-password link on the sign-in card */
.forgot-link {
  display: block; text-align: center; margin-top: 12px;
  font-size: 0.76rem; color: var(--ink-3); text-decoration: none;
}
.forgot-link:hover { color: var(--brand); text-decoration: underline; }

/* signed-in user chip with initials avatar */
#user-chip { display: flex; align-items: center; gap: 9px; }
.uc-avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #2f89c9, #1b5f8f);
  color: #fff; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em;
}
#user-chip .uc-name { font-size: 0.88rem; }
