/* ==========================================================================
   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;
}
#events-title { flex-wrap: wrap; row-gap: 4px; }
#events-title .count { text-transform: none; font-weight: 600; white-space: nowrap; }
.card-title .count.ok { background: var(--ok-soft); color: var(--ok); }
.card-title .count.danger { background: var(--danger-soft); color: var(--danger); }
.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; }
.more-link.more-btn {
  width: 100%; height: 40px; padding: 0 12px; font-size: 13.5px; font-weight: 650;
  background: var(--primary-soft); color: var(--primary-strong); border-color: transparent;
}
.more-link.more-btn:hover { filter: brightness(.97); }

/* ---------- 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; touch-action: pan-y; }
.carousel-viewport.dragging { cursor: grabbing !important; user-select: none; }
.carousel-viewport.dragging .carousel-track { transition: none; }
.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(4, 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);
}

/* ---------- global search ---------- */
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 12px; min-width: 220px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  cursor: pointer; font-size: 14px; text-align: left;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger span { flex: 1; }
.search-trigger kbd, .sr-hint kbd {
  font-family: var(--mono); font-size: 11.5px; border: 1px solid var(--border); border-radius: 6px;
  padding: 1px 6px; background: var(--surface-2); color: var(--text-2);
}
@media (max-width: 1250px) { .search-trigger { min-width: 0; } .search-trigger span, .search-trigger kbd { display: none; } }
.modal-backdrop:has(.search-modal) { align-items: flex-start; padding-top: 8vh; }
.sr-input { font-size: 17px; min-height: 48px; }
.sr-hint { font-size: 12.5px; margin: 8px 2px 4px; }
.sr-results { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.sr-group { margin: 10px 2px 4px; }
.sr-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  padding: 8px 10px; border-radius: 12px; border: 1px solid transparent; background: var(--surface-2); color: var(--text);
  font: inherit;
}
.sr-item.p1, .sr-item.p2, .sr-item.p3, .sr-item.p4, .sr-item.p5 { border-left: 4px solid var(--pc); }
.sr-item:hover, .sr-item.active { border-color: var(--primary); background: var(--primary-soft); }
.sr-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface); color: var(--primary); flex-shrink: 0; }
.sr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sr-title { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-note { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sr-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-side { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
@media (max-width: 640px) { .sr-side .chip:first-child:not(:last-child) { display: none; } }

/* ---------- settings ---------- */
.checks { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--primary); flex-shrink: 0; }
.check span { display: flex; flex-direction: column; }
.check small { font-size: 12.5px; }

/* ---------- photos ---------- */
.photo-picker .row { gap: 8px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.photo-grid:empty { display: none; }
.photo-thumb {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--border);
  background: var(--surface-2); padding: 0; cursor: pointer;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-label {
  position: absolute; left: 4px; bottom: 4px; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  background: rgba(0, 0, 0, .6); color: #fff;
}
.photo-remove {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .6); color: #fff; display: grid; place-items: center; padding: 0;
}
.photo-add { margin-top: 10px; gap: 8px; }
.viewer { position: relative; background: #000; border-radius: 12px; overflow: hidden; display: grid; place-items: center; min-height: 240px; }
.viewer img { max-width: 100%; max-height: calc(100dvh - 240px); display: block; }
.viewer-prev, .viewer-next { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, .85); border: 0; }
.viewer-prev { left: 8px; } .viewer-next { right: 8px; }

/* ---------- TPV ---------- */
.tpv-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.tpv-side { position: sticky; top: 0; }
.tpv-totals { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.tpv-totals div { display: flex; justify-content: space-between; font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tpv-totals b { color: var(--text); }
.tpv-totals .total { border-top: 1px solid var(--border-strong); padding-top: 8px; margin-top: 2px; font-size: 22px; font-weight: 750; color: var(--text); }
.tpv-lines { display: flex; flex-direction: column; gap: 6px; }
.tpv-line { display: grid; grid-template-columns: minmax(0, 1fr) 84px 110px 36px; gap: 6px; align-items: center; }
.tpv-cost { text-align: right; font-variant-numeric: tabular-nums; }
.tpv-cost.auto { background: var(--surface-2); color: var(--muted); cursor: help; }
.tpv-totals .tpv-profit { font-size: 13px; }
.tpv-price { text-align: right; font-variant-numeric: tabular-nums; }
.tpv-customer { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--primary); background: var(--primary-soft); flex-wrap: wrap; }
.tpv-customer.warn { border-color: var(--danger); background: var(--danger-soft); }
.tpv-cust-results { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 300px; overflow: auto; }
.btn .btn-text { margin-left: 2px; }
@media (max-width: 900px) { .tpv-grid { grid-template-columns: minmax(0, 1fr); } .tpv-side { position: static; } }

/* ---------- phone fixes ---------- */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
  /* 16px text in fields stops iOS from zooming in (and pushing buttons off-screen) when a field is tapped */
  input, select, textarea, .input { font-size: 16px !important; }

  /* dialogs open from the top and fit the visible screen (dvh accounts for the browser's address bar) */
  .modal-backdrop, .modal-backdrop:has(.search-modal) { padding: 0; align-items: flex-start; }
  .modal, .modal.wide, .modal.narrow {
    width: 100%; max-height: 100vh; max-height: 100dvh; border-radius: 0 0 20px 20px; border-top: 0;
    animation: slide-down .2s ease-out;
  }
  .modal-backdrop:has(.modal.narrow) { align-items: center; padding: 12px; }
  .modal.narrow { border-radius: 20px; border-top: 1px solid var(--border); max-height: calc(100dvh - 24px); }
  .modal-head { padding: calc(12px + env(safe-area-inset-top)) 14px 10px; }
  .modal-body { padding: 14px; }
  .modal-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-foot .spacer { display: none; }

  /* dashboard top bar: icons only so it never gets wider than the phone */
  .topbar { gap: 6px; padding: 0 10px; }
  .topbar .status, #btn-fullscreen { display: none; }
  .topbar .brand { font-size: 0; gap: 0; }
  .topbar > * { flex-shrink: 0; }
  .topbar .spacer { flex-shrink: 1; }
  .topbar .btn { padding: 0 10px; }
  .topbar .btn .btn-text { display: none; }
  .search-trigger { padding: 0; width: 36px; justify-content: center; }

  .clock-wrap { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .clock-time { font-size: 64px; }
  .kpi-slide, .server-slide { grid-template-columns: minmax(0, 1fr); }
  .wx-days { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tpv-line { grid-template-columns: minmax(0, 1fr) 68px 86px 36px; }
}
@keyframes slide-down { from { transform: translateY(-16px); opacity: 0; } }

/* archived photos: only the 100 px mini remains */
.photo-thumb.archived img { filter: saturate(.6); }
.photo-thumb.archived { border-style: dashed; }
.viewer.archived img { width: min(420px, 100%); height: auto; image-rendering: auto; }

/* ---------- business logo + name ---------- */
.brand-logo { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.12; font-size: 16px; font-weight: 750; white-space: nowrap; letter-spacing: -.01em; }
.brand-text small { font-size: 10.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.login-brand { gap: 12px; }
.login-brand .brand-logo { width: 64px; height: 64px; }
.login-brand .brand-text { font-size: 19px; }
.m-top .brand-logo { width: 34px; height: 34px; }
@media (min-width: 1101px) and (max-height: 900px) { .topbar .brand-logo { width: 34px; height: 34px; } }
@media (max-width: 640px) { .topbar .brand-text { display: none; } }
@media (max-width: 420px) {
  .topbar { gap: 4px; padding: 0 8px; }
  .topbar .brand-logo { width: 32px; height: 32px; }
  .topbar .btn, .topbar .btn.icon, .search-trigger { width: 32px; min-width: 32px; height: 32px; padding: 0; }
  .topbar .btn svg, .search-trigger svg { width: 16px; height: 16px; }
}

/* ---------- Servicios menu ---------- */
.services-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.service-card {
  display: flex; gap: 12px; align-items: center; text-align: left; padding: 14px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit;
}
.service-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.service-card > span:last-child { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.service-card b { font-size: 15px; }
.service-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); flex-shrink: 0; }

/* ---------- signature pad ---------- */
.sig-wrap { position: relative; border: 2px dashed var(--border-strong); border-radius: 14px; background: #fff; }
.sig-canvas { display: block; width: 100%; height: min(42vh, 320px); touch-action: none; cursor: crosshair; border-radius: 12px; }
.sig-line { position: absolute; left: 6%; right: 6%; bottom: 22%; border-top: 1px solid #9fb2c9; color: #7187a5; font-size: 12px; padding-top: 4px; pointer-events: none; }
a.photo-thumb { display: block; }
/* tablets: keep the business name, show the top bar buttons as icons only */
@media (max-width: 1100px) { .topbar .btn .btn-text { display: none; } .topbar .btn:not(.icon) { padding: 0 10px; } }

/* Where the device is (orders): wrench = in the workshop, person = the customer still has it, !! = other case */
.custody {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 22px; height: 22px; padding: 0 3px; border-radius: 7px; vertical-align: middle;
  color: var(--primary); background: var(--primary-soft);
}
.custody.c-customer { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.custody.c-other { color: var(--danger); background: var(--danger-soft); }
.custody .bang { font-size: 13px; font-weight: 900; letter-spacing: -1px; line-height: 1; }
.custody-chip { display: inline-flex; align-items: center; gap: 4px; flex: none; height: 22px; padding: 0 8px 0 6px; border-radius: 7px;
  font-size: 12px; font-weight: 700; white-space: nowrap; vertical-align: middle; color: var(--primary); background: var(--primary-soft); }
.custody-chip.c-customer { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.custody-chip.c-other { color: var(--danger); background: var(--danger-soft); }
.custody-chip .bang { font-size: 12px; font-weight: 900; letter-spacing: -1px; line-height: 1; }
.custody-seg button { display: inline-flex; align-items: center; gap: 6px; }
.custody-seg button:not(.active) .custody { opacity: .65; }
.custody-note { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--danger); font-size: 13.5px; font-weight: 600; }
.custody-note svg { flex: none; }
.filter-chips .custody { min-width: 18px; height: 18px; border-radius: 5px; margin-right: 2px; }
.filter-chips button.active .custody { background: var(--surface); }

/* new order: quick pick of a known customer */
.customer-quick { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.customer-quick:empty { display: none; }
.quick-label { font-size: 13px; font-weight: 650; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.quick-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-chips:empty { display: none; }
.quick-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; max-width: 100%; padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.quick-chip:hover { border-color: var(--primary); }
.quick-chip { overflow: hidden; }
.quick-chip b, .quick-chip span { max-width: min(320px, 100%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-chip span { font-size: 12.5px; color: var(--muted); }
.quick-search { font-size: 14px; }
.customer-chosen { display: flex; align-items: center; gap: 8px; color: var(--text); }
.customer-chosen svg { color: var(--primary); flex: none; }
@media (max-width: 600px) {
  .custody-seg { display: flex; flex-direction: column; width: 100%; }
  .custody-seg button { height: 40px; }
}

/* unlock code: typed code or a 3x3 pattern (numbers = order in which the dots are joined) */
.unlock-field { display: flex; flex-direction: column; gap: 8px; }
.unlock-mode { align-self: flex-start; }
.unlock-mode button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; font-size: 13px; }
.pattern-pad { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pattern-box { width: 240px; max-width: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer;
  background: var(--surface-2, var(--surface)); border: 1px solid var(--border); border-radius: 14px; }
.pattern-box svg { display: block; width: 100%; height: auto; }
.pattern-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pattern-seq { min-width: 120px; }
.pattern-seq b { font-family: var(--mono); font-size: 15px; }
.unlock-pattern { display: flex; align-items: center; gap: 12px; }
.unlock-pattern .pattern-svg { flex: none; background: var(--surface-2, transparent); border-radius: 10px; }

/* ---------- morosos ---------- */
.debt-thumb { flex: none; border-radius: 10px; object-fit: cover; display: inline-grid; place-items: center; vertical-align: middle;
  border: 1px solid var(--border); cursor: zoom-in; background: var(--surface-3); }
.debt-initial { cursor: default; font-weight: 800; color: var(--danger); background: var(--danger-soft); border-color: transparent; }
tr.debt-paid td { opacity: .6; }
tr.debt-paid td:last-child { opacity: 1; }
.debt-photo { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 8px; }
.debt-photo img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); cursor: zoom-in; }
.debt-slide { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(0, 2fr); gap: 18px; height: 100%; }
.debt-total { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 14px 16px; border-radius: 14px;
  background: var(--danger-soft); color: var(--danger); }
.debt-total span:first-child { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.debt-total b { font-size: 30px; letter-spacing: -.02em; line-height: 1.1; }
.debt-list { display: flex; flex-direction: column; gap: 6px; overflow: hidden; min-height: 0; }
.debt-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; background: var(--surface-2); }
.debt-row .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.debt-row .who b, .debt-row .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.debt-row .who span { font-size: 12.5px; color: var(--muted); }
.debt-row .amt { color: var(--danger); white-space: nowrap; }
@media (max-width: 1100px) { .debt-slide { grid-template-columns: 1fr; } .debt-total { flex-direction: row; align-items: baseline; padding: 8px 12px; } .debt-total b { font-size: 22px; } }

/* ---------- muro de la vergüenza ---------- */
.shame-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.shame-card { display: flex; flex-direction: column; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: var(--surface); cursor: zoom-in; text-align: left; font: inherit; color: inherit; }
.shame-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #000; }
.shame-card:hover { border-color: var(--primary); }
.shame-title { padding: 8px 10px; font-weight: 650; font-size: 13.5px; line-height: 1.3; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: calc(2 * 1.3em + 16px); }
.shame-upload { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.shame-upload img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); flex: none; }
.viewer-caption { display: none; }
.viewer:fullscreen { border-radius: 0; }
.viewer:fullscreen img { max-height: 100vh; max-width: 100vw; }
.viewer:fullscreen .viewer-caption { display: block; position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 32px 28px; color: #fff;
  font-size: clamp(22px, 3.2vw, 44px); font-weight: 800; text-align: center; background: linear-gradient(transparent, rgba(0, 0, 0, .8)); }

/* slideshow window (/muro) */
.muro-body { margin: 0; background: #000; color: #fff; overflow: hidden; height: 100dvh; }
.muro-body.idle, .muro-body.idle * { cursor: none; }
.muro-stage { position: fixed; inset: 0; }
.muro-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .9s ease; }
.muro-img.on { opacity: 1; }
.muro-caption { position: fixed; left: 0; right: 0; bottom: 0; padding: 70px 5vw 44px; text-align: center; font-weight: 800;
  font-size: clamp(22px, 3.4vw, 54px); line-height: 1.15; text-shadow: 0 2px 12px rgba(0, 0, 0, .7);
  background: linear-gradient(transparent, rgba(0, 0, 0, .78)); pointer-events: none; }
.muro-caption:empty { display: none; }
.muro-empty { position: fixed; inset: 0; display: grid; place-items: center; font-size: 24px; color: #9fb3cc; padding: 24px; text-align: center; }
.muro-controls { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 14px; background: rgba(15, 25, 40, .78); backdrop-filter: blur(6px); transition: opacity .4s; }
.muro-body.idle .muro-controls { opacity: 0; pointer-events: none; }
.muro-btn { width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer; }
.muro-btn:hover { background: rgba(255, 255, 255, .14); }
.muro-btn.active { background: #1f63c6; }
.muro-count { min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; color: #c9d6e8; font-size: 14px; }
.muro-sep { width: 1px; height: 26px; background: rgba(255, 255, 255, .2); margin: 0 4px; }
.muro-label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: #c9d6e8; }
.muro-label select { background: #0f1928; color: #fff; border: 1px solid rgba(255, 255, 255, .25); border-radius: 8px; padding: 6px 8px; font: inherit; }
.muro-progress { position: fixed; left: 0; bottom: 0; height: 3px; width: 0; background: #4f95ec; opacity: .8; }

/* ---------- partner shops (tiendas colaboradoras) ---------- */
.partner-pill { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; height: 22px; padding: 0 8px; border-radius: 7px;
  font-size: 12px; font-weight: 700; color: #fff; background: var(--pc); white-space: nowrap; vertical-align: middle; }
.partner-pill span { overflow: hidden; text-overflow: ellipsis; }
.partner-pill svg { flex: none; }
.partner-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--pc); }
.order.has-partner { box-shadow: inset -5px 0 0 var(--pc); }
.unread-badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 7px; font-size: 12px;
  font-weight: 800; color: #fff; background: var(--danger); vertical-align: middle; }
.partner-pending { padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); margin-bottom: 14px; }
.pending-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 0; }
.pending-row .code { font-family: var(--mono); font-weight: 800; font-size: 16px; letter-spacing: .06em; }
.partner-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.partner-card { border: 1px solid var(--border); border-left: 6px solid var(--pc); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.partner-card.inactive { opacity: .6; }
.partner-head { display: flex; align-items: center; gap: 8px; }
.partner-head b { font-size: 16px; }
.partner-devices { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; border-top: 1px solid var(--border); padding-top: 6px; }
.dev-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.color-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.color-pick button { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; background: var(--pc); cursor: pointer; }
.color-pick button.active { border-color: var(--text); }
.cred-box { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 14px; user-select: all; margin: 0; }
.partner-box { border: 1px solid var(--border); border-left: 5px solid var(--pc); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.partner-note { display: flex; flex-direction: column; gap: 2px; white-space: pre-wrap; }
.partner-note .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.comments { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.comment { max-width: 85%; padding: 8px 11px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.comment.shop { align-self: flex-end; background: var(--primary-soft); border-color: transparent; }
.comment .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.comment .text { white-space: pre-wrap; word-break: break-word; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { flex: 1; min-width: 0; }
.partner-pickup { font-size: 13.5px; padding: 8px 10px; border-radius: 10px; }
.partner-pickup.todo { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); font-weight: 650; }
.partner-pickup.done { background: var(--ok-soft); }
button.unread-badge { border: 0; cursor: pointer; font: inherit; font-size: 12px; font-weight: 800; }
.unread-row { cursor: pointer; align-items: center; }

/* "this customer owes money" */
.debt-warning { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px;
  background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.debt-warning svg { flex: none; margin-top: 1px; }
.debt-warning .dw-main { flex: 1; min-width: 0; }
.debt-warning ul { margin: 4px 0 0; padding-left: 18px; color: var(--text); font-size: 13.5px; }
.debt-slot:empty { display: none; }

/* stickers */
.print-choices { display: flex; flex-direction: column; gap: 8px; }
.print-choices .btn { justify-content: flex-start; }
.label-preview { margin: 0 auto; overflow: hidden; border: 1px dashed var(--border); border-radius: 6px; background: #fff; }
.label-preview iframe { border: 0; transform-origin: top left; background: #fff; display: block; }
.label-text { font-family: var(--mono); font-size: 14px; white-space: pre; }

/* ==========================================================================
   Almacén de piezas (/almacen): racks drawn as they stand in the shop — steel posts and shelf boards, each
   shelf holding an organizer laid out as a rows × columns grid of drawers. Each rack has its own pastel tag.
   ========================================================================== */
:root {
  --stk-steel: #7a849a; --stk-org: #b4bdcd; --stk-drawer: #fcfcfe; --stk-drawer-edge: #b9cfe8; --stk-drawer-hover: #5b8fd0;
  --stk-hit: #ffd978; --stk-hit-edge: #e0ae2e; --stk-tape-ink: #2f3542;
  --stk-p0: #cfe2f6; --stk-p1: #d3eedf; --stk-p2: #f8dccd; --stk-p3: #e2dbf4; --stk-p4: #f5ebc3;
  --stk-bay: 200px; --stk-rackw: 260px; --stk-post: 8px;
}
:root[data-theme="dark"] {
  --stk-steel: #566079; --stk-org: #46506a; --stk-drawer: #172a45; --stk-drawer-edge: #2f4f78; --stk-drawer-hover: #86aee0;
  --stk-hit: #d8b65a; --stk-hit-edge: #f0cf74; --stk-tape-ink: #eef1f6;
  --stk-p0: #33506e; --stk-p1: #2f5646; --stk-p2: #6a4b3d; --stk-p3: #4b4470; --stk-p4: #5d5432;
}
a.chip { text-decoration: none; }
body.stock-page { min-height: 100vh; }
.stock-page .small, .stk-modal .small { font-size: 12.5px; }

/* toolbar */
.stk-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
.stk-brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex-wrap: wrap; }
.stk-brand h1 { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -.01em; }
.stk-stats { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.stk-search { flex: 1 1 280px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 10px; min-width: 0; color: var(--muted); }
.stk-search:focus-within { border-color: var(--primary); }
.stk-search input { flex: 1; border: 0; background: transparent; padding: 9px 0; outline: none; min-width: 0; color: var(--text); }
.stk-search kbd { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.stk-sync { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.stk-sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.stk-sync.ok i { background: var(--ok); }
.stk-sync.busy i { background: var(--stk-hit-edge); }

/* search results strip */
.stk-results { padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.stk-results[hidden] { display: none; }
.stk-res { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 10px; background: var(--surface); min-width: 0; }
.stk-res b { font-weight: 650; }
.stk-loc { font-weight: 750; font-size: 14px; letter-spacing: .02em; background: var(--stk-hit); color: #2f3542; border: 0;
  border-radius: 5px; padding: 2px 8px; cursor: pointer; }
.stk-loc small { font-weight: 400; font-size: 11px; opacity: .75; margin-left: 5px; letter-spacing: 0; }
.stk-loc.zero { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }

/* wall of racks */
.stk-wall { overflow-x: auto; padding: 20px 16px 60px; position: relative; scrollbar-width: thin; }
.stk-wall > .empty { min-height: 200px; }
.stk-edge { position: fixed; top: 0; bottom: 0; width: 56px; pointer-events: none; z-index: 4; opacity: 0; transition: opacity .2s; }
.stk-edge.l { left: 0; background: linear-gradient(90deg, var(--primary-soft), transparent); }
.stk-edge.r { right: 0; background: linear-gradient(270deg, var(--primary-soft), transparent); }
.stk-edge.on { opacity: .9; }
.stk-racks { display: flex; align-items: flex-start; gap: 14px; width: max-content; padding-right: 16px; }
.stk-rack { width: var(--stk-rackw); display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
.stk-rhead { display: flex; align-items: center; gap: 5px; min-height: 30px; flex-wrap: wrap; }
.stk-rname { font-weight: 750; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.stk-rname::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--tag); margin-right: 7px; vertical-align: 0; }
.stk-rname-in.input { width: 128px; height: 30px; padding: 3px 8px; font-weight: 650; }
.stk-rbody { border: var(--stk-post) solid var(--stk-steel); border-bottom: 0; border-radius: 4px 4px 0 0; display: flex; flex-direction: column; }
.stk-bay { height: var(--stk-bay); padding: 8px 6px; border-bottom: var(--stk-post) solid var(--stk-steel); position: relative; display: flex; }
.stk-bay:last-child { border-bottom-width: calc(var(--stk-post) + 2px); }
.stk-feet { display: flex; justify-content: space-between; height: 14px; margin-top: -8px; }
.stk-feet i { width: var(--stk-post); background: var(--stk-steel); display: block; border-radius: 0 0 3px 3px; }
.stk-org { flex: 1; display: grid; gap: 4px; padding: 4px; border: 2px solid var(--stk-org); border-radius: 3px; background: var(--surface-2); min-width: 0; }
.stk-emptybay { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.stk-addorg { border: 1.5px dashed var(--primary); color: var(--primary); background: var(--primary-soft); border-radius: 8px; flex: 1; font-weight: 650; cursor: pointer; }
.stk-baytools { position: absolute; top: 2px; right: 2px; display: flex; gap: 4px; z-index: 2; }
.stk-baytools .btn { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); height: 24px; padding: 0 8px; font-size: 11.5px; }

.stk-drawer { container-type: size; position: relative; min-width: 0; min-height: 0; background: var(--stk-drawer); color: var(--text);
  border: 1.5px solid var(--stk-drawer-edge); border-radius: 3px; text-align: left; padding: 3px 4px 7px; display: flex; flex-direction: column;
  gap: 1px; overflow: hidden; cursor: pointer; transition: opacity .15s, box-shadow .15s; font: inherit; }
.stk-drawer::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 30%; max-width: 34px; height: 3px; transform: translateX(-50%);
  border-radius: 2px; background: var(--stk-drawer-edge); }
.stk-drawer:hover { border-color: var(--stk-drawer-hover); }
.stk-dtop { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-width: 0; }
.stk-tape { font-weight: 800; font-size: 15px; line-height: 1.25; letter-spacing: .02em; background: var(--tag, var(--surface-3)); color: var(--stk-tape-ink);
  padding: 0 4px; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-variant-numeric: tabular-nums; }
.stk-tape.big { font-size: 22px; padding: 1px 10px; border-radius: 5px; }
.stk-cnt { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stk-dsum { font-size: 10.5px; color: var(--muted); line-height: 1.25; overflow: hidden; display: none; }
@container (min-height: 44px) and (min-width: 80px) { .stk-dsum { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; } }
@container (min-height: 70px) and (min-width: 80px) { .stk-dsum { -webkit-line-clamp: 4; font-size: 11.5px; } }
@container (max-width: 52px) { .stk-cnt { display: none; } .stk-tape { font-size: 12px; padding: 0 2px; letter-spacing: 0; } }
@container (min-height: 60px) and (min-width: 90px) { .stk-tape { font-size: 17px; } }
.stk-wall.searching .stk-drawer { opacity: .25; }
.stk-wall.searching .stk-drawer.hit { opacity: 1; box-shadow: 0 0 0 3px var(--stk-hit); border-color: var(--stk-hit-edge); }
.stk-drawer.flash { animation: stk-flash 1.2s; }
@keyframes stk-flash { 0% { box-shadow: 0 0 0 5px var(--primary); } 100% { box-shadow: 0 0 0 0 transparent; } }

.stk-addrack { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px;
  width: 220px; align-self: stretch; justify-content: center; margin-top: 38px; }
.stk-addrack h3 { margin: 0; font-size: 16px; }
.stk-addrack p { margin: 0; }
.stk-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stk-emptywall { max-width: 520px; padding: 40px 0; display: flex; flex-direction: column; gap: 10px; }
.stk-emptywall h2 { margin: 0; font-size: 24px; }
.stk-emptywall p { margin: 0; color: var(--text-2); }

/* drawer and organizer dialogs */
.modal.stk-modal { width: min(600px, 100%); }
.stk-where { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.stk-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.stk-tab { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 9px 4px; font-weight: 650; font-size: 14px; cursor: pointer; }
.stk-tab[aria-selected="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.stk-tab.put[aria-selected="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.stk-tab.take[aria-selected="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.stk-pane { display: flex; flex-direction: column; gap: 12px; }
.stk-pane[hidden] { display: none; }
.stk-pane p { margin: 0; }
.stk-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.stk-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--border); }
.stk-row:first-child { border-top: 0; }
.stk-row.zero .stk-nm { color: var(--muted); text-decoration: line-through; }
.stk-nm { font-weight: 550; overflow-wrap: anywhere; }
.stk-code { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.stk-qty { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.stk-n { min-width: 30px; text-align: center; font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.stk-ib { min-width: 30px; height: 30px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 0; font-size: 16px;
  line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.stk-ib:disabled { opacity: .4; cursor: default; }
.stk-ib.t { padding: 0 8px; font-size: 12px; color: var(--muted); }
.stk-addrow { display: grid; grid-template-columns: 1.6fr 1fr 74px auto; gap: 6px; align-items: end; }
.stk-scanbox { border: 2px solid var(--ok); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.stk-scanbox.take { border-color: var(--danger); }
.stk-scanmode { font-weight: 800; font-size: 17px; letter-spacing: .03em; text-transform: uppercase; color: var(--ok); }
.stk-scanbox.take .stk-scanmode { color: var(--danger); }
.stk-scanline { display: grid; grid-template-columns: 74px minmax(0, 1fr) 140px; gap: 8px; align-items: end; }
.stk-scanline [data-order-field][hidden] { display: none; }
.stk-scanbox:not(.take) .stk-scanline { grid-template-columns: 74px minmax(0, 1fr); }
.stk-scanline [data-code] { font-family: var(--mono); font-size: 16px; }
.stk-order-hint:empty, .stk-order-hint[hidden] { display: none; }
.stk-msg { min-height: 22px; font-size: 14px; }
.stk-msg.ok { color: var(--ok); }
.stk-msg.err { color: var(--danger); }
.stk-newform { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; background: var(--primary-soft); border-radius: 10px; padding: 10px; }
.stk-newform[hidden] { display: none; }
.stk-newform p { grid-column: 1 / -1; font-size: 13.5px; }
.stk-slog { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.stk-slog > div { display: flex; gap: 8px; align-items: center; }
.d-put, .d-take { font-family: var(--mono); font-weight: 650; min-width: 34px; }
.d-put { color: var(--ok); }
.d-take { color: var(--danger); }
.stk-moves { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.stk-move { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stk-move-part { flex: 1; min-width: 0; }
.stk-move .chip { border: 0; cursor: pointer; }
.stk-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin: 6px 0 12px; }
.stk-pre { border: 1.5px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; font-weight: 650; font-family: var(--mono); font-size: 13px; cursor: pointer; }
.stk-pre[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.stk-mini { width: 64px; height: 46px; display: grid; gap: 2px; padding: 2px; border: 1.5px solid var(--stk-org); border-radius: 2px; }
.stk-mini i { border: 1px solid var(--stk-drawer-edge); background: var(--surface); border-radius: 1px; }
.stk-rc { display: flex; align-items: end; gap: 8px; margin-bottom: 12px; }
.stk-rc .field { width: 100px; }
.stk-prevbig { height: 150px; max-width: 260px; width: 100%; display: grid; gap: 3px; padding: 3px; border: 2px solid var(--stk-org); border-radius: 3px; background: var(--surface-2); }
.stk-prevbig i { border: 1.5px solid var(--stk-drawer-edge); background: var(--surface); border-radius: 2px; }
.stk-warn { color: var(--danger); font-size: 13.5px; margin: 10px 0 0; }
.stk-warn[hidden] { display: none; }

@media (max-width: 640px) {
  :root { --stk-rackw: 220px; --stk-bay: 180px; }
  .stk-bar { position: static; }
  .stk-brand h1 { font-size: 18px; }
  .stk-addrow { grid-template-columns: 1fr 1fr; }
  .stk-addrow .btn { grid-column: 1 / -1; }
  .stk-scanline, .stk-scanbox:not(.take) .stk-scanline { grid-template-columns: 74px minmax(0, 1fr); }
  .stk-scanline [data-order-field] { grid-column: 1 / -1; }
  .stk-tab { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .stk-drawer.flash { animation: none; } }

/* ==========================================================================
   Inventario, compras (shopping list) and stock alerts
   ========================================================================== */
.track-star { display: inline-flex; color: #e3a008; margin-right: 4px; vertical-align: -2px; }
.track-star svg { fill: currentColor; }
:root[data-theme="dark"] .track-star { color: #f5c542; }

/* top bar button with the number of things to order */
[data-cart] { position: relative; }
.cart-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.cart-badge.muted-badge { background: var(--surface-3); color: var(--text-2); }
.m-top [data-cart] .btn-text { display: none; }
.m-top [data-cart] .cart-badge { position: absolute; top: 2px; right: 0; }

/* almacén page: view switch and inventory list */
.stk-views button { min-width: 104px; }
.inv-view { padding: 14px 16px 60px; }
.inv-view[hidden], .stk-wall[hidden], #stk-edit[hidden] { display: none; }
.inv-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.inv-toolbar .spacer { flex: 1; }
.inv-toolbar .inv-cat { width: auto; max-width: 220px; }
.inv-toolbar label.btn { cursor: pointer; }
.filter-chips button .n { font-weight: 700; opacity: .7; margin-left: 2px; }
.filter-chips button.alert:not(.active) { border-color: color-mix(in srgb, var(--danger) 50%, transparent); color: var(--danger); }
.inv-sum { margin: 0 0 8px; }
.inv-tbl td { vertical-align: middle; }
.inv-tbl th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.inv-tbl .inv-star { width: 22px; padding-right: 0; }
.inv-tbl .inv-name { min-width: 200px; }
.inv-tbl .inv-where { min-width: 150px; }
.inv-tbl .inv-where .stk-loc, .stk-loc.sm { font-size: 12.5px; padding: 1px 6px; margin: 1px 4px 1px 0; }
.inv-qty { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; }
.inv-qty.low { color: var(--warn); }
.inv-qty.out { color: var(--danger); }
.inv-row.out td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.inv-row.low td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.chip.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.stk-loc.unplaced { background: color-mix(in srgb, var(--warn) 22%, var(--surface)); }

/* part record */
.inv-price-row { display: flex; gap: 6px; align-items: center; }
.inv-price-row input { flex: 1; min-width: 0; }
.inv-price-row [data-use-sug][hidden] { display: none; }
.inv-track { align-self: end; }
.inv-track svg { color: #e3a008; fill: currentColor; vertical-align: -2px; }
[data-min-field][hidden] { display: none; }
.inv-sups { display: flex; flex-direction: column; gap: 6px; }
.inv-sup-row { display: grid; grid-template-columns: minmax(130px, 1.2fr) minmax(90px, .8fr) 90px minmax(120px, 1.2fr) auto 30px; gap: 6px; align-items: center; }
.inv-pref { font-size: 12.5px; display: flex; gap: 4px; align-items: center; white-space: nowrap; color: var(--text-2); }
.inv-locs { flex-wrap: wrap; gap: 6px; align-items: center; }
.inv-unplaced { display: inline-flex; gap: 6px; align-items: center; padding: 3px 8px; border-radius: 8px;
  background: color-mix(in srgb, var(--warn) 12%, transparent); }
.inv-photo img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in; }
.inv-photo { align-items: center; gap: 10px; }
.money-with-part { display: flex; gap: 6px; align-items: center; }
.money-with-part input { flex: 1; min-width: 0; }
.stock-vdate { gap: 6px; font-size: 13.5px; color: var(--text-2); }
.stock-vdate .input { width: auto; }

/* part picker */
.pick-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 55vh; overflow: auto; }
.pick-item { display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font: inherit; color: inherit; }
.pick-item:hover, .pick-item:focus-visible { border-color: var(--primary); }
.pick-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pick-side { display: flex; gap: 8px; align-items: center; white-space: nowrap; }

/* shopping list */
.cart-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.cart-free { display: flex; gap: 6px; flex: 1 1 320px; min-width: 0; }
.cart-free .input:first-child { flex: 1; min-width: 0; }
.cart-qty { width: 72px; flex: none; }
.cart-sug { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px;
  background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--text); }
.cart-sug > svg { color: var(--warn); flex: none; }
.cart-sug > div { flex: 1; min-width: 0; font-size: 13.5px; }
.cart-sec { margin: 14px 0 6px; }
.cart-group { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.cart-ghead { display: flex; gap: 6px; align-items: center; padding: 8px 10px; background: var(--surface-2); flex-wrap: wrap; }
.cart-ghead .spacer { flex: 1; }
.cart-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px minmax(120px, 170px) auto; gap: 8px; align-items: center;
  padding: 8px 10px; border-top: 1px solid var(--border); }
.cart-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cart-acts { display: flex; gap: 4px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.cart-sup { min-width: 0; }
.cart-row.received { grid-template-columns: minmax(0, 1fr) auto; color: var(--text-2); }
.cart-received { margin-top: 10px; }
.cart-received summary { cursor: pointer; margin-bottom: 6px; }

/* dashboard: stock slide and the automatic low-stock note */
#carousel-dots button.alert::before { background: var(--danger); }
.stock-slide { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; height: 100%; }
.stock-col { display: flex; flex-direction: column; min-height: 0; gap: 8px; }
.stock-head { font-weight: 750; display: flex; align-items: center; gap: 6px; font-size: 14px; }
.stock-head.bad { color: var(--danger); }
.stock-head.good { color: var(--ok); }
.stock-list { display: flex; flex-direction: column; gap: 6px; overflow: hidden; min-height: 0; flex: 1; }
.stock-item { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2);
  font-size: 13.5px; }
.stock-item b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-item span { color: var(--muted); white-space: nowrap; font-size: 12.5px; }
.stock-item.out { background: var(--danger-soft); }
.stock-item.out span { color: var(--danger); }
.stock-item.low { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.stock-item.ordered { opacity: .75; }
.note.stock-note { cursor: pointer; border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface)); display: flex; flex-direction: column; gap: 3px; }
.stock-note-head { color: var(--danger); font-weight: 800; display: flex; align-items: center; gap: 6px; }
.stock-note-item { font-size: 13px; }
.stock-note-item.out b { color: var(--danger); }
.stock-note-box { height: auto; }

/* TPV line that is a part of the almacén */
.tpv-line.has-part { grid-template-columns: minmax(0, 1fr) auto 84px 110px 36px; }
.tpv-part { display: inline-flex; align-items: center; gap: 4px; color: var(--primary); }
.tpv-part .input { width: 64px; }

@media (max-width: 1100px) { .stock-slide { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .inv-sup-row { grid-template-columns: 1fr 1fr; }
  .inv-sup-row [data-k="url"] { grid-column: 1 / -1; }
  .cart-row { grid-template-columns: minmax(0, 1fr) 72px; }
  .cart-row .cart-sup { grid-column: 1 / 2; }
  .cart-row .cart-acts { grid-column: 2 / 3; }
  .tpv-line.has-part { grid-template-columns: minmax(0, 1fr) auto 68px 86px 36px; }
  .stk-views button { min-width: 0; }
}

/* ==========================================================================
   Gramática: brand / model autocomplete, "primer registro" dialog, Ajustes → Gramática
   ========================================================================== */
.sg-wrap { position: relative; }
.sg-list { position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 30; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 260px; overflow: auto; padding: 4px; display: flex; flex-direction: column; }
.sg-list[hidden] { display: none; }
.sg-item { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; text-align: left; border: 0; background: transparent;
  padding: 7px 9px; border-radius: 7px; cursor: pointer; font: inherit; color: var(--text); }
.sg-item:hover, .sg-item.active { background: var(--primary-soft); }
.sg-item small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.dev-number[hidden] { display: none; }
.dev-sugs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 12px; }
.dev-sug { border: 1px solid var(--border); cursor: pointer; height: 28px; font-size: 13px; }
.dev-sug.active, .dev-sug:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
.dev-rules { margin-top: 14px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); }
.dev-rules ol { margin: 6px 0 0; padding-left: 20px; font-size: 13.5px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }
.gr-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.gr-head .spacer { flex: 1; }
.gr-q { width: 220px; }
.gr-new { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.gr-new .input { flex: 1 1 140px; min-width: 0; }
.gr-brands { display: flex; flex-direction: column; gap: 6px; }
.gr-brand { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.gr-brand > summary { display: flex; gap: 8px; align-items: center; padding: 8px 10px; cursor: pointer; list-style: none; flex-wrap: wrap; }
.gr-brand > summary::-webkit-details-marker { display: none; }
.gr-brand > summary::before { content: "▸"; color: var(--muted); }
.gr-brand[open] > summary::before { content: "▾"; }
.gr-brand > summary .spacer { flex: 1; }
.gr-models { padding: 0 10px 10px; }
.dev-review { display: flex; flex-direction: column; gap: 8px; }
.dev-group { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.dev-variants { display: flex; flex-wrap: wrap; gap: 6px; }
.dev-fix { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto; gap: 6px; align-items: center; }
@media (max-width: 640px) {
  .dev-fix { grid-template-columns: 1fr 1fr; }
  .gr-q { width: 100%; }
}

/* ==========================================================================
   Informes técnicos (editor in the panel; the printed report is static/portal/informe.css)
   ========================================================================== */
.rep-link { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.rep-link .input { width: 130px; }
.rep-lines { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.rep-line { display: grid; grid-template-columns: minmax(0, 1fr) 70px 110px 90px 32px; gap: 6px; align-items: center; }
.rep-line-head { font-size: 12px; font-weight: 600; color: var(--text-2); }
.rep-line .r, .rep-line-head .r { text-align: right; }
.rep-line-total { font-variant-numeric: tabular-nums; font-weight: 600; }
.rep-line-btns { gap: 6px; margin-top: 8px; }
.rep-sum { display: grid; grid-template-columns: 110px 120px minmax(0, 1fr); gap: 10px; align-items: end; margin: 12px 0; }
.rep-totals { justify-self: end; min-width: 240px; display: flex; flex-direction: column; gap: 2px; }
.rep-totals div { display: flex; justify-content: space-between; gap: 20px; font-variant-numeric: tabular-nums; }
.rep-totals .total { border-top: 1px solid var(--border-strong); padding-top: 4px; font-size: 16px; }
.rep-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 6px 0 12px; }
.rep-photo { position: relative; border: 2px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; display: block; opacity: .55; }
.rep-photo.on { border-color: var(--primary); opacity: 1; }
.rep-photo input { position: absolute; top: 6px; left: 6px; width: 18px; height: 18px; }
.rep-photo img { width: 100%; height: 90px; object-fit: cover; display: block; }
.rep-photo span { display: block; font-size: 11.5px; padding: 2px 6px; color: var(--text-2); }
.rep-mini { display: flex; flex-direction: column; gap: 6px; }
.rep-mini-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.rep-mini-row .spacer { flex: 1; }
form[data-f] > .section-label { margin: 14px 0 6px; }
@media (max-width: 640px) {
  .rep-line { grid-template-columns: minmax(0, 1fr) 60px 90px 32px; }
  .rep-line .rep-line-total, .rep-line-head span:nth-child(4) { display: none; }
  .rep-sum { grid-template-columns: 1fr 1fr; }
  .rep-totals { grid-column: 1 / -1; justify-self: stretch; }
}

/* ==========================================================================
   Gastos
   ========================================================================== */
.exp-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.exp-head .spacer { flex: 1; }
.exp-month { font-size: 18px; min-width: 150px; text-align: center; text-transform: capitalize; }
.exp-due { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px;
  background: color-mix(in srgb, var(--warn) 12%, transparent); }
.exp-due > svg { color: var(--warn); flex: none; }
.exp-due > div { flex: 1; min-width: 0; }
.exp-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.exp-tile { border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); }
.exp-tile span { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.exp-tile b { font-size: 22px; font-variant-numeric: tabular-nums; }
.exp-tile small { color: var(--muted); font-size: 12px; }
.exp-tile.pos b { color: var(--ok); }
.exp-tile.neg b { color: var(--danger); }
.exp-photo { align-items: center; gap: 10px; flex-wrap: wrap; }
.exp-photo img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in; }
.exp-cats { display: flex; flex-direction: column; gap: 6px; }
.exp-cat { display: flex; gap: 6px; align-items: center; }
.exp-cat .input { flex: 1; }
.exp-cat.off .input { opacity: .5; }
.exp-day.input { width: 64px; display: inline-block; height: 30px; padding: 2px 6px; }
.exp-due-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto auto; gap: 8px; align-items: center; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 12px; margin-bottom: 6px; }
.exp-due-name { display: flex; flex-direction: column; min-width: 0; }
.note.exp-note { border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
.exp-note-head { color: var(--warn); }
@media (max-width: 640px) {
  .exp-tiles { grid-template-columns: 1fr; }
  .exp-due-row { grid-template-columns: 1fr 1fr; }
  .exp-due-name { grid-column: 1 / -1; }
}
.exp-dups { border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 6%, var(--surface));
  border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 8px; }
.exp-dups-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; color: var(--danger); }
.exp-dups-head .muted { color: var(--muted); }
.exp-dup { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13.5px; }
.exp-dup .spacer { flex: 1; }
.exp-autos { border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 7%, var(--surface));
  border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.exp-autos .section-label { color: var(--ok); display: flex; gap: 6px; align-items: center; }
.exp-auto-row { display: flex; gap: 8px; align-items: center; padding: 4px 0; flex-wrap: wrap; }
.exp-auto-row .spacer { flex: 1; }

/* presupuestos rápidos */
.ev.qq { --pc: var(--warn); background: color-mix(in srgb, var(--warn) 7%, var(--surface-2)); }
.empty.compact { height: auto; padding: 10px; }
.qq-new { display: flex; gap: 8px; }
.qq-new .input { flex: 1; min-width: 0; font-size: 16px; }
.qq-list { display: flex; flex-direction: column; gap: 4px; }
.qq-row { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.qq-row.hl { box-shadow: 0 0 0 2px var(--primary); }
.qq-date { color: var(--muted); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.qq-text { flex: 1; min-width: 0; font-weight: 550; overflow-wrap: anywhere; }
.qq-text .input { width: 100%; }

/* Ajustes → Servicios: order of the menu */
.svc-order { display: flex; flex-direction: column; gap: 6px; }
.svc-row { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.svc-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.svc-name .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-show { margin: 0; white-space: nowrap; }
.service-ico.sm { width: 30px; height: 30px; }

/* Chat con Claude (claude.js) */
.modal.claude-modal { width: min(1100px, 100%); height: min(860px, calc(100vh - 48px)); }
.claude-modal .modal-title .spacer { flex: 1; }
.claude-modal .modal-title .chip { font-size: 12px; font-weight: 600; }
.claude-modal .modal-body { padding: 0; display: flex; min-height: 0; }
.cl-wrap { flex: 1; display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 0; position: relative; }
.cl-side { border-right: 1px solid var(--border); background: var(--surface-2); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.cl-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 4px; margin: 0 -4px; padding: 0 4px; }
.cl-none { font-size: 13px; padding: 6px 2px; }
.cl-item { display: flex; align-items: center; gap: 2px; border-radius: var(--radius-sm); }
.cl-item:hover, .cl-item.active { background: var(--surface-3); }
.cl-item .cl-open { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 7px 8px; cursor: pointer; color: var(--text); display: flex; flex-direction: column; gap: 2px; font: inherit; }
.cl-item .t { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-item .d { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-item .d b { color: var(--warn); font-weight: 600; }
.cl-side-toggle { display: none; }
.cl-main { display: flex; flex-direction: column; min-height: 0; }
.cl-msgs { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.cl-msg { max-width: 82%; padding: 10px 14px; border-radius: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.cl-msg.me { align-self: flex-end; background: var(--primary); color: var(--primary-ink); border-bottom-right-radius: 6px; }
.cl-msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.cl-msg code { background: var(--surface-3); padding: 1px 5px; border-radius: 6px; font-size: .92em; }
.cl-li { display: block; padding-left: 16px; position: relative; }
.cl-li:not(.num)::before { content: "•"; position: absolute; left: 3px; color: var(--muted); }
.cl-li.num { padding-left: 4px; }
.cl-li .n { color: var(--muted); }
.cl-msg.typing { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.cl-msg.typing .dots { display: inline-flex; gap: 3px; }
.cl-msg.typing .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: cl-dot 1s infinite ease-in-out; }
.cl-msg.typing .dots i:nth-child(2) { animation-delay: .15s; }
.cl-msg.typing .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes cl-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.cl-tool { align-self: flex-start; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; padding: 0 6px; }
.cl-tool.err { color: var(--warn); }
.cl-card { align-self: flex-start; width: min(560px, 100%); border: 1px solid var(--border-strong); border-left: 4px solid var(--primary); border-radius: 14px; background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.cl-card.s-accepted { border-left-color: var(--ok); }
.cl-card.s-failed { border-left-color: var(--danger); }
.cl-card.s-rejected, .cl-card.s-cancelled { border-left-color: var(--border-strong); opacity: .75; }
.cl-card-head { display: flex; align-items: center; gap: 8px; }
.cl-card-head .chip { margin-left: auto; }
.cl-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: 14px; padding: 4px 0; border-top: 1px dashed var(--border); }
.cl-line .w { color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.cl-line .v { overflow-wrap: anywhere; }
.cl-line .old, .cl-log-row .old { color: var(--muted); text-decoration: line-through; }
.cl-card-note { font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 6px 8px; }
.cl-card-note.danger { color: var(--danger); background: var(--danger-soft); }
.cl-card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }
.cl-all { align-self: flex-start; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.cl-notice { align-self: center; font-size: 13px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; text-align: center; }
.cl-notice.danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.cl-empty { margin: auto; width: 100%; max-width: 520px; box-sizing: border-box; padding: 0 6px; text-align: center; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cl-empty svg { opacity: .6; }
.cl-examples { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.cl-examples .btn { white-space: normal; text-align: center; height: auto; min-height: 32px; max-width: 100%; }
.cl-input { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px 4px; border-top: 1px solid var(--border); }
.cl-input textarea { flex: 1; resize: none; min-height: 44px; max-height: 180px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; line-height: 1.4; }
.cl-input textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.cl-input .btn.icon { height: 44px; width: 44px; }
.cl-hint { font-size: 12px; padding: 2px 16px 10px; }
.cl-log { display: flex; flex-direction: column; }
.cl-log-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) minmax(0, 1fr); gap: 4px 14px; padding: 8px 2px; border-top: 1px solid var(--border); font-size: 14px; align-items: start; }
.cl-log-row .when { color: var(--muted); font-size: 13px; }
.cl-log-row .what { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.cl-log-row .v { overflow-wrap: anywhere; }
.cl-set-block { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 18px; }
.cl-key-state { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.cl-key-state code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
.cl-small { font-size: 13px; }
.cl-key-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cl-key-row .input { flex: 1 1 260px; min-width: 0; }
.cl-usage-big { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cl-bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.cl-bar i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
@media (max-width: 760px) {
  .cl-wrap { grid-template-columns: minmax(0, 1fr); }
  .cl-side { display: none; position: absolute; inset: 0; z-index: 2; border-right: 0; }
  .cl-wrap.show-side .cl-side { display: flex; }
  .cl-side-toggle { display: inline-flex; }
  .cl-msg { max-width: 92%; }
  .cl-msgs { padding: 12px; }
  .cl-log-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .modal.claude-modal { height: 100vh; height: 100dvh; }
  .claude-modal .cl-usage { display: none; }
  .cl-input { padding-bottom: 4px; }
  .cl-hint { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}

/* Order form: folded optional section (the device's account) */
.field-group { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.field-group > summary { cursor: pointer; padding: 10px 12px; font-weight: 650; font-size: 14px; display: flex; align-items: center; gap: 6px; list-style: none; }
.field-group > summary::-webkit-details-marker { display: none; }
.field-group > summary::after { content: "▸"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.field-group[open] > summary::after { transform: rotate(90deg); }
.field-group > .form-grid { padding: 0 12px 12px; }

/* Customer record and list (Servicios → Clientes) */
.cust-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.cust-photo { width: 84px; height: 84px; flex: none; border-radius: 18px; border: 1px solid var(--border); background: var(--surface-2);
  display: grid; place-items: center; color: var(--muted); overflow: hidden; padding: 0; cursor: pointer; }
.cust-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cust-photo-full { display: block; max-width: 100%; max-height: 75vh; margin: 0 auto; border-radius: 12px; }
.cust-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cust-name { font-size: 20px; font-weight: 750; overflow-wrap: anywhere; }
.cust-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cust-sell { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.cust-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cust-toolbar .search { flex: 1 1 220px; }
.cust-toolbar .search, .m-search { position: relative; }
.cust-toolbar .search input, .m-search input { padding-left: 36px; width: 100%; }
.cust-toolbar .search svg, .m-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.cust-list { display: flex; flex-direction: column; gap: 6px; }
.cust-line { display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.cust-line:hover { background: var(--surface-2); }
.cust-line .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; overflow-wrap: anywhere; }
.cust-line .main .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-line .side { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.cust-mini { width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center;
  color: var(--muted); overflow: hidden; }
.cust-mini img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 640px) {
  .cust-line { flex-wrap: wrap; }
  .cust-line .side { width: 100%; justify-content: flex-start; }
  .cust-photo { width: 72px; height: 72px; }
}

/* Scanning (escaner.js): flash on an unknown code, status line, receiving list */
@keyframes scan-flash-warn { 0%, 30%, 60% { box-shadow: 0 0 0 6px #f5b400, 0 0 40px 10px rgba(245, 180, 0, .55); } 15%, 45%, 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes scan-flash-bad { 0%, 30%, 60% { box-shadow: 0 0 0 6px #e5484d, 0 0 40px 10px rgba(229, 72, 77, .5); } 15%, 45%, 100% { box-shadow: 0 0 0 0 transparent; } }
.scan-flash-warn .modal, .scan-flash-warn.modal, .modal.scan-flash-warn { animation: scan-flash-warn 1.4s ease-out; }
.scan-flash-bad .modal, .scan-flash-bad.modal, .modal.scan-flash-bad { animation: scan-flash-bad 1.4s ease-out; }
.scan-input { font-size: 18px; height: 46px; }
.scan-status { min-height: 22px; margin: 6px 0 10px; font-size: 13.5px; color: var(--muted); }
.scan-status.ok { color: var(--ok); font-weight: 600; }
.scan-status.warn { color: var(--warn); font-weight: 700; }
.scan-status.bad { color: var(--danger); font-weight: 700; }
.scan-status.dup { color: var(--muted); font-style: italic; }
.scan-unknown { display: flex; gap: 10px; align-items: center; padding: 10px 12px; margin-bottom: 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); font-weight: 600; }
.recv-tbl .recv-qty { width: 64px; text-align: center; display: inline-block; margin: 0 4px; }
.recv-tbl .recv-cost { width: 96px; text-align: right; }
.recv-tbl .recv-cost.need::placeholder { color: var(--danger); }
.recv-tbl tr.recv-new td { animation: recv-new 1s ease-out; }
@keyframes recv-new { from { background: color-mix(in srgb, var(--ok) 25%, transparent); } to { background: transparent; } }
.recv-total { text-align: right; margin-top: 10px; font-size: 15px; }
.inv-kinds { margin-bottom: 8px; }
.inv-kind { white-space: nowrap; }
.inv-kind.k-venta { background: var(--ok-soft); color: var(--ok); }
.inv-kind.k-interno { background: var(--surface-2); color: var(--muted); }
.inv-kind.k-segunda_mano { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.tpv-scan { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; }
.tpv-scan .input { flex: 1; }
.tpv-vat { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Resumen del negocio → Inventario y ventas (negocio.js) */
.kpi-stock { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.kpi-stock:hover b { text-decoration: underline; }
.neg-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.neg-base { margin: 0; }
.neg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.neg-rank .card-body { display: flex; flex-direction: column; gap: 4px; }
.neg-row { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: center;
  padding: 5px 8px; border-radius: 8px; overflow: hidden; }
.neg-row > * { position: relative; z-index: 1; }
.neg-row .neg-bar-bg { position: absolute; z-index: 0; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--primary) 12%, transparent); border-radius: 8px; }
.neg-row.loss .neg-bar-bg { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.neg-row.loss .neg-val { color: var(--danger); }
.neg-n { color: var(--muted); font-size: 12px; text-align: right; }
.neg-name { display: flex; flex-direction: column; min-width: 0; }
.neg-title { display: flex; min-width: 0; align-items: baseline; }
.neg-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.neg-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.value.neg-loss, .neg-loss-row td b { color: var(--danger); }
.neg-tbl th.sortable { cursor: pointer; }

/* Compra sin contrato: first picture in the list */
.bought-mini { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; display: block; border: 1px solid var(--border); }
.bought-mini.none { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); background: var(--surface-2); }

/* Phone: history tab */
.m-search { margin-bottom: 12px; }
.m-item.m-done { cursor: pointer; }
.m-more { width: 100%; justify-content: center; margin: 4px 0 12px; }

/* TPV on a phone: the concept gets its own row (with cost, price and «quitar» below), so the name stays readable */
@media (max-width: 600px) {
  .tpv-line, .tpv-line.has-part { grid-template-columns: minmax(0, 1fr) 72px 88px 36px; row-gap: 4px; }
  .tpv-line > [data-concept] { grid-column: 1 / -1; }
  .tpv-line > .tpv-part { grid-column: 1; justify-self: start; }
  .tpv-line > .tpv-cost { grid-column: 2; }
  .tpv-line > .tpv-price { grid-column: 3; }
  .tpv-line > [data-rm-line] { grid-column: 4; }
  .tpv-lines { gap: 12px; }
}
/* ---------- pantalla de firma (panel side) ---------- */
.sign-wait { text-align: center; padding: 8px 4px; }
.sign-pulse { width: 64px; height: 64px; border-radius: 50%; margin: 4px auto 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); animation: sign-pulse 1.6s ease-in-out infinite; }
@keyframes sign-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: .7; } }
.sign-item { display: flex; gap: 14px; align-items: center; padding: 8px 0; }
.sign-item + .sign-item { border-top: 1px solid var(--border); }
.sign-item img { width: 180px; height: 64px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 10px; flex: none; }
.sign-item.old { opacity: .7; }
.sign-item .btn { margin-top: 6px; }
.sign-img { display: block; max-width: 420px; width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.sign-terms { white-space: pre-wrap; font-size: 14px; color: var(--text-2); }
.firma-steps { margin: 0 0 14px; padding-left: 20px; color: var(--text-2); }
.firma-steps li { margin: 4px 0; }
.firma-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); margin-bottom: 6px; }
.firma-slides { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.firma-slide { position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-2); aspect-ratio: 16 / 10; }
.firma-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.firma-slide-btns { position: absolute; left: 6px; right: 6px; bottom: 6px; display: flex; gap: 4px; justify-content: flex-end; }
.firma-slide.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  color: var(--muted); border-style: dashed; }

/* Demo copy: a strip above everything (the server adds it to every page). */
.demo-banner { background: #fff4d6; color: #7a4b00; border-bottom: 1px solid #f0d48a; text-align: center;
  font-size: 13px; font-weight: 600; padding: 6px 12px; line-height: 1.35; }
:root[data-theme="dark"] .demo-banner { background: #3a2a05; color: #ffd27a; border-color: #5c4310; }
