/* ==========================================================================
   Panel — shared styles (dashboard, history, mobile, login)
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #e8eff8;
  --bg-glow: radial-gradient(1200px 600px at 10% -10%, #d6e5f8 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 110%, #dce9f9 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f3f7fc;
  --surface-3: #e7eff9;
  --border: #d6e2f0;
  --border-strong: #b9cce4;
  --text: #0e2340;
  --text-2: #3f5878;
  --muted: #7187a5;
  --primary: #1f63c6;
  --primary-strong: #164f9f;
  --primary-soft: #dce9fb;
  --primary-ink: #ffffff;
  --accent: #0b8fd6;
  --danger: #d23a3a;
  --danger-soft: #fde8e8;
  --warn: #c77700;
  --ok: #1f8f4e;
  --ok-soft: #e1f4e8;
  --p1: #e03131;
  --p2: #f08c00;
  --p3: #2f9e44;
  --p4: #1098ad;
  --p5: #1c64f2;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid-line: #e3eaf3;
  --sun: #f4b400;
  --cloud: #c9d6e6;
  --cloud-dark: #9fb2c9;
  --rain: #2a78d6;
  --shadow: 0 1px 2px rgba(15, 45, 90, .05), 0 6px 20px rgba(15, 45, 90, .07);
  --shadow-lg: 0 20px 60px rgba(10, 30, 60, .25);
  --radius: 18px;
  --radius-sm: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08111f;
  --bg-glow: radial-gradient(1200px 600px at 10% -10%, #0f2342 0%, transparent 60%),
             radial-gradient(900px 500px at 110% 110%, #0c1d38 0%, transparent 55%);
  --surface: #0f1d33;
  --surface-2: #14263f;
  --surface-3: #1a3050;
  --border: #1f3557;
  --border-strong: #2c4a75;
  --text: #e5eefa;
  --text-2: #a9bdd9;
  --muted: #7289ab;
  --primary: #4f95ec;
  --primary-strong: #78afff;
  --primary-soft: #183259;
  --primary-ink: #04101f;
  --accent: #38b6f0;
  --danger: #ff6b6b;
  --danger-soft: #3a1820;
  --warn: #ffb347;
  --ok: #4cc77d;
  --ok-soft: #12321f;
  --p1: #ff5c5c;
  --p2: #ffa53d;
  --p3: #4fcf6c;
  --p4: #34c3d6;
  --p5: #4f9bff;
  --series-1: #3987e5;
  --series-2: #d95926;
  --grid-line: #1c304e;
  --sun: #ffc93c;
  --cloud: #7f93ae;
  --cloud-dark: #5d7190;
  --rain: #4f9bff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.hidden { display: none !important; }
svg { flex-shrink: 0; }

/* priority colour plumbing: any element with .p1..p5 exposes --pc */
.p1 { --pc: var(--p1); } .p2 { --pc: var(--p2); } .p3 { --pc: var(--p3); } .p4 { --pc: var(--p4); } .p5 { --pc: var(--p5); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 550; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ok { color: var(--ok); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.icon { width: 36px; padding: 0; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.sm.icon { width: 30px; padding: 0; }
.btn.lg { height: 48px; font-size: 16px; padding: 0 20px; border-radius: 12px; }

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.chip.stage { background: var(--primary-soft); color: var(--primary-strong); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.prio {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px 0 6px; border-radius: 999px;
  font-size: 12px; font-weight: 650; white-space: nowrap;
  color: var(--pc);
  background: color-mix(in srgb, var(--pc) 13%, transparent);
}
.prio::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--pc); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pc, var(--muted)); display: inline-block; flex-shrink: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}
.card.clickable { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.card.clickable:hover { border-color: var(--border-strong); }
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px 6px;
  min-height: 46px;
}
.card-title {
  font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-2); display: flex; align-items: center; gap: 8px; min-width: 0;
}
.card-title svg { color: var(--primary); }
.card-title .count {
  background: var(--primary-soft); color: var(--primary-strong);
  border-radius: 999px; padding: 1px 8px; font-size: 12px; letter-spacing: 0;
}
.card-head .spacer { flex: 1; }
.card-body { padding: 4px 16px 14px; flex: 1; min-height: 0; position: relative; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); text-align: center; padding: 18px; height: 100%; font-size: 14px;
}
.empty svg { opacity: .55; }

/* ---------- top bar ---------- */
.topbar {
  height: 56px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; letter-spacing: -.01em; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: #fff;
}
.topbar .spacer { flex: 1; }
.topbar .status { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.status .live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status.offline .live { background: var(--danger); }

/* ---------- dashboard grid ---------- */
body.dash { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.dash-grid {
  flex: 1; min-height: 0;
  display: grid; gap: 16px; padding: 0 16px 16px;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 1.12fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, .92fr) minmax(0, 1.22fr);
  grid-template-areas:
    "clock events orders"
    "carousel carousel orders"
    "weather weather orders";
}
#clock-card { grid-area: clock; }
#events-card { grid-area: events; }
#orders-card { grid-area: orders; }
#carousel-card { grid-area: carousel; }
#weather-card { grid-area: weather; }

@media (max-width: 1100px) {
  body.dash { height: auto; overflow: auto; }
  .dash-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "clock" "events" "orders" "carousel" "weather";
  }
  .dash-grid > .card { min-height: 300px; }
  #orders-card { min-height: 520px; }
  #weather-card { min-height: 420px; }
}

/* ---------- clock card ---------- */
.clock-wrap { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; height: 100%; padding: 18px 20px; }
.clock-main { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.clock-time {
  font-size: clamp(48px, 7.4vh, 96px); font-weight: 750; letter-spacing: -.035em; line-height: .95;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.clock-time .sec { font-size: .42em; font-weight: 600; color: var(--primary); letter-spacing: 0; margin-left: 4px; }
.clock-date { margin-top: 12px; font-size: clamp(16px, 2.1vh, 22px); font-weight: 600; color: var(--text); }
.clock-sub { margin-top: 6px; font-size: 13.5px; color: var(--muted); }
.clock-sub b { color: var(--text-2); font-weight: 600; }

.mini-cal { display: flex; flex-direction: column; min-width: 0; align-self: center; }
.mini-cal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 6px; text-transform: capitalize; }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.mini-cal-grid .wd { font-size: 11px; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.mini-cal-grid .d {
  font-size: 13px; font-variant-numeric: tabular-nums;
  height: clamp(22px, 3.2vh, 32px); display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 8px; position: relative; color: var(--text);
}
.mini-cal-grid .d.out { color: var(--muted); opacity: .45; }
.mini-cal-grid .d.weekend { color: var(--text-2); }
.mini-cal-grid .d.today { background: var(--primary); color: var(--primary-ink); font-weight: 700; }
.mini-cal-grid .d .marks { position: absolute; bottom: 2px; display: flex; gap: 2px; }
.mini-cal-grid .d .marks i { width: 4px; height: 4px; border-radius: 50%; background: var(--pc); }
.mini-cal-grid .d.today .marks i { background: var(--primary-ink); }

/* ---------- list rows (events / generic) ---------- */
.list { display: flex; flex-direction: column; gap: 6px; height: 100%; overflow: hidden; position: relative; }
.ev {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid transparent; cursor: pointer; min-width: 0; flex-shrink: 0;
}
.ev:hover { border-color: var(--border-strong); }
.ev .bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--pc); flex-shrink: 0; }
.ev .ev-main { flex: 1; min-width: 0; }
.ev .ev-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev .ev-meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ev .ev-when { text-align: right; font-size: 12.5px; font-weight: 650; color: var(--text-2); white-space: nowrap; }
.ev .ev-when.overdue { color: var(--danger); }
.ev .ev-when.today { color: var(--primary); }
.more-link { font-size: 13px; font-weight: 600; color: var(--primary); text-align: center; padding: 4px 0 0; flex-shrink: 0; }

/* ---------- order cards ---------- */
.orders-list { display: flex; flex-direction: column; gap: 10px; height: 100%; overflow: hidden; position: relative; }
.order {
  flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 5px solid var(--pc);
  border-radius: 14px; padding: 10px 12px 10px 12px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  transition: border-color .15s, transform .1s;
}
.order:hover { border-color: var(--border-strong); border-left-color: var(--pc); }
.order.overdue { box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 45%, transparent); }
.order-top { display: flex; align-items: center; gap: 8px; }
.order-num { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--text-2); }
.order-top .spacer { flex: 1; }
.order-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-line { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; }
.order-line span { overflow: hidden; text-overflow: ellipsis; }
.order-issue { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.deadline-chip { font-size: 12px; font-weight: 650; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.deadline-chip.overdue { color: var(--danger); }
.deadline-chip.today { color: var(--primary); }

/* ---------- carousel ---------- */
.carousel-viewport { flex: 1; min-height: 0; overflow: hidden; position: relative; }
.carousel-track { display: flex; height: 100%; transition: transform .6s cubic-bezier(.4, .1, .2, 1); }
.slide { flex: 0 0 100%; height: 100%; min-width: 0; padding: 4px 16px 6px; overflow: hidden; }
.carousel-dots { display: flex; justify-content: center; gap: 4px; padding: 4px 0 10px; }
.carousel-dots button {
  width: 26px; height: 18px; border: 0; background: transparent; cursor: pointer; padding: 0;
  display: grid; place-items: center;
}
.carousel-dots button::before {
  content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--border-strong);
  transition: width .3s, background .3s;
}
.carousel-dots button.active::before { width: 22px; background: var(--primary); }
.carousel-progress { position: absolute; left: 0; top: 0; height: 2px; background: var(--primary); opacity: .5; width: 0; }

/* KPI slide */
.kpi-slide { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; height: 100%; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  background: var(--surface-2); border-radius: 14px; padding: 10px 12px;
  display: flex; flex-direction: column; justify-content: center; min-width: 0;
}
.tile .label { font-size: 12.5px; color: var(--text-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.tile .value { font-size: clamp(22px, 3.3vh, 34px); font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tile .value small { font-size: .5em; font-weight: 600; color: var(--muted); margin-left: 2px; }
.tile.alert .value { color: var(--danger); }
.tile.alert .label svg { color: var(--danger); }
.chart-box { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chart-box .chart-head { display: flex; align-items: baseline; gap: 10px; font-size: 13px; font-weight: 650; color: var(--text-2); margin-bottom: 4px; flex-wrap: wrap; }
.chart-box .chart { flex: 1; min-height: 0; position: relative; }

/* Server slide */
.server-slide { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 22px; height: 100%; align-items: center; }
.meters { display: flex; flex-direction: column; gap: 12px; }
.meter-row { display: grid; grid-template-columns: 96px 1fr 70px; align-items: center; gap: 10px; font-size: 14px; }
.meter-row .name { color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.meter-row .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter { height: 10px; border-radius: 999px; background: var(--primary-soft); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width .6s; }
.meter.warn > i { background: var(--warn); }
.meter.danger > i { background: var(--danger); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Notes slide */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; height: 100%; align-content: start; overflow: hidden; }
.note {
  background: var(--primary-soft); border-radius: 14px; padding: 12px 14px; font-size: 14.5px;
  white-space: pre-wrap; word-break: break-word; position: relative; min-height: 70px;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.note .pin { position: absolute; top: 8px; right: 8px; color: var(--primary); }
.note-date { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* Activity */
.act-list { display: flex; flex-direction: column; gap: 2px; }
.act { display: grid; grid-template-columns: 54px 26px 1fr auto; gap: 8px; align-items: center; padding: 5px 4px; border-radius: 8px; font-size: 14px; }
.act .when { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.act .ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.act .ico.completed { background: var(--ok-soft); color: var(--ok); }
.act .ico.deleted { background: var(--danger-soft); color: var(--danger); }
.act .ico.created { background: var(--primary-soft); color: var(--primary); }
.act .what { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.act .what b { font-weight: 650; }
.act .tag { font-size: 12px; color: var(--muted); }

/* ---------- weather ---------- */
.wx-head-now { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); min-width: 0; white-space: nowrap; overflow: hidden; }
.wx-head-now b { color: var(--text); font-size: 15px; }
.wx-days { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; height: 100%; }
.wx-day {
  background: var(--surface-2); border-radius: 14px; padding: 10px 12px;
  display: flex; flex-direction: column; align-items: center; min-width: 0; min-height: 0; overflow: hidden;
}
.wx-day.today { background: linear-gradient(180deg, var(--primary-soft), var(--surface-2)); }
.wx-day .dname { font-weight: 700; font-size: 14.5px; text-transform: capitalize; }
.wx-day .ddate { font-size: 12px; color: var(--muted); }
.wx-day .wx-icon { margin: 2px 0; width: clamp(40px, 6vh, 64px); height: clamp(40px, 6vh, 64px); }
.wx-day .desc { font-size: 12.5px; color: var(--text-2); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.wx-day .temps { font-size: clamp(18px, 2.4vh, 24px); font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0 6px; }
.wx-day .temps .min { color: var(--muted); font-weight: 600; margin-left: 6px; }
.wx-rows { width: 100%; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.wx-row { display: flex; align-items: center; gap: 6px; color: var(--text-2); white-space: nowrap; min-width: 0; }
.wx-row svg { color: var(--muted); }
.wx-row .v { margin-left: auto; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 4px; }
.wind-arrow { color: var(--primary); transition: transform .3s; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6, 18, 38, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  z-index: 100; animation: fade .15s ease-out;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg);
  width: min(720px, 100%); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border);
  animation: pop .18s ease-out;
}
.modal.wide { width: min(1100px, 100%); }
.modal.narrow { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 16px 18px; overflow: auto; flex: 1; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field > label .req { color: var(--danger); margin-left: 2px; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 76px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
.field.error input, .field.error textarea, .field.error select { border-color: var(--danger); }
.field .hint { font-size: 12px; color: var(--muted); }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 12px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; height: 34px; padding: 0 14px; border-radius: 9px; cursor: pointer;
  font-weight: 600; font-size: 14px; color: var(--text-2);
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg.yesno button.active[data-v="true"] { color: var(--ok); }
.seg.yesno button.active[data-v="false"] { color: var(--danger); }

.prio-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.prio-picker button {
  height: 38px; min-width: 38px; padding: 0 10px; border-radius: 10px; cursor: pointer;
  border: 2px solid color-mix(in srgb, var(--pc) 35%, transparent);
  background: color-mix(in srgb, var(--pc) 10%, transparent);
  color: var(--pc); font-weight: 700; font-size: 14px;
}
.prio-picker button.active { background: var(--pc); border-color: var(--pc); color: #fff; }
.prio-picker .lbl { font-size: 12.5px; color: var(--muted); align-self: center; margin-left: 4px; }

.customer-match {
  border: 1px solid var(--primary); background: var(--primary-soft);
  border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; font-size: 14px;
}
.customer-match .opts { display: flex; gap: 6px; flex-wrap: wrap; }
.customer-match .opts .btn.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.customer-match ul { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13px; }

/* ---------- detail view ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.detail-item .k { font-size: 12px; font-weight: 600; color: var(--muted); }
.detail-item .v { font-size: 15px; font-weight: 550; white-space: pre-wrap; word-break: break-word; }
.detail-item.full { grid-column: 1 / -1; }
.detail-section { margin-top: 18px; }
.detail-section h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stepper { display: flex; gap: 4px; flex-wrap: wrap; }
.stepper button {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  height: 32px; padding: 0 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.stepper button.done { background: var(--primary-soft); color: var(--primary-strong); border-color: transparent; }
.stepper button.current { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.stepper button:disabled { cursor: default; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.timeline li { display: grid; grid-template-columns: 128px 1fr; gap: 10px; font-size: 13.5px; }
.timeline .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.completion-box { background: var(--ok-soft); border-radius: 12px; padding: 12px 14px; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 14px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 700; padding: 10px 12px; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; z-index: 1;
}
.tbl td { padding: 10px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .nowrap { white-space: nowrap; }

/* ---------- calendar modal ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-head h3 { margin: 0; font-size: 18px; text-transform: capitalize; flex: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-grid .wd { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px; }
.cal-cell {
  min-height: 96px; border: 1px solid var(--border); border-radius: 12px; padding: 6px; cursor: pointer;
  background: var(--surface); display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.cal-cell:hover { border-color: var(--border-strong); }
.cal-cell.out { opacity: .45; }
.cal-cell.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-cell.selected { background: var(--primary-soft); }
.cal-cell .n { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-item {
  font-size: 11.5px; padding: 1px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--pc) 14%, transparent); color: var(--text); border-left: 3px solid var(--pc);
}
.cal-item.done { opacity: .5; text-decoration: line-through; }
.cal-item.projected { border-left-style: dashed; opacity: .7; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast {
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow-lg); animation: pop .2s ease-out; pointer-events: auto; max-width: 90vw;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* ---------- tooltip (charts) ---------- */
.tip {
  position: fixed; pointer-events: none; z-index: 300;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 10px; padding: 8px 10px; font-size: 12.5px; min-width: 120px;
}
.tip .tt { font-weight: 700; margin-bottom: 4px; }
.tip .tr { display: flex; align-items: center; gap: 6px; }
.tip .tr .sw { width: 10px; height: 10px; border-radius: 3px; }
.tip .tr .tv { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; padding-left: 10px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); align-items: center; flex-wrap: wrap; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.chart svg text { fill: var(--muted); font-size: 11px; font-family: var(--font); }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; }
.toolbar .search input { padding-left: 36px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chips button {
  height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2);
}
.filter-chips button.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.filter-chips button .c { opacity: .7; margin-left: 4px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); padding: 28px; gap: 16px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; color: var(--muted); font-size: 14px; }
.login-err { color: var(--danger); font-size: 14px; min-height: 20px; }

/* ---------- history page ---------- */
body.history .page { max-width: 1400px; margin: 0 auto; padding: 0 16px 40px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; }
.tabs button {
  border: 0; background: transparent; padding: 10px 16px; font-weight: 650; font-size: 15px; color: var(--text-2);
  cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tiles .tile { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 14px 16px; }
.stat-tiles .tile .value { font-size: 28px; }
.stat-tiles .tile .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.charts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; margin-bottom: 16px; }
.charts-grid .card { min-height: 280px; }
.charts-grid .card-body { display: flex; flex-direction: column; }
.charts-grid .chart { flex: 1; min-height: 200px; position: relative; }
.hbars { display: flex; flex-direction: column; gap: 7px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.hbar .l { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-2); }
.hbar .track { height: 14px; }
.hbar .track i { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .v { min-width: 40px; white-space: nowrap; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.date-range { display: flex; align-items: center; gap: 6px; }
.date-range input { width: 150px; }

/* ---------- mobile app ---------- */
body.mobile { min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.m-top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.m-top h1 { font-size: 20px; margin: 0; flex: 1; }
.m-page { padding: 4px 16px 20px; }
.m-page .form-grid { grid-template-columns: minmax(0, 1fr); }
.m-page .field input, .m-page .field select, .m-page .field textarea { min-height: 48px; font-size: 16px; }
.m-tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.m-tabs button {
  border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px; font-weight: 650; color: var(--muted); padding: 6px; border-radius: 12px; cursor: pointer;
}
.m-tabs button.active { color: var(--primary); background: var(--primary-soft); }
.m-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.m-item {
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--pc); border-radius: 14px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px;
}
.m-item .actions { display: flex; gap: 8px; margin-top: 8px; }
.m-item .actions .btn { flex: 1; height: 42px; }
.m-submit { width: 100%; height: 52px; font-size: 17px; border-radius: 14px; margin-top: 6px; }
.m-section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }

@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.wide, .modal.narrow { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; }
  .form-grid, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .timeline li { grid-template-columns: 1fr; gap: 0; }
  .charts-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.customer-slot:empty { display: none; }

/* compact mode for shorter screens (e.g. 1366x768): keep everything visible without scrolling */
@media (min-width: 1101px) and (max-height: 900px) {
  .topbar { height: 46px; }
  .dash-grid { gap: 10px; padding: 0 10px 10px; grid-template-rows: minmax(0, .85fr) minmax(0, 1fr) minmax(0, 1.15fr); }
  .card-head { padding: 8px 12px 2px; min-height: 34px; }
  .card-body { padding: 2px 12px 10px; }
  .clock-wrap { padding: 10px 14px; gap: 12px; }
  .slide { padding: 2px 12px 2px; }
  .tiles { gap: 6px; }
  .tile { padding: 4px 10px; border-radius: 10px; }
  .tile .value { font-size: 20px; }
  .tile .label { font-size: 11.5px; }
  .kpi-slide { gap: 12px; }
  .carousel-dots { padding: 0 0 4px; }
  .wx-days { gap: 8px; }
  .wx-day { padding: 6px 8px; }
  .wx-row.opt { display: none; }
  .ev { padding: 6px 8px; }
  .order { padding: 8px 10px; gap: 2px; }
  .order-title { font-size: 15px; }
  .meter-row { font-size: 13px; }
  .meters { gap: 8px; }
}

/* ---------- device approval (login) ---------- */
.approval-code {
  font-family: var(--mono); font-size: 40px; font-weight: 750; letter-spacing: .12em; text-align: center;
  padding: 14px; border-radius: 14px; background: var(--primary-soft); color: var(--primary-strong);
}
.approval-help { display: grid; gap: 4px; font-size: 13.5px; color: var(--text-2); }
.approval-help code {
  font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; color: var(--text);
}
