/* Demstos Sales — layout: sidebar + content on desktop, bottom tab bar on phone. One light theme. */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafc;
  --line: #e6e6eb;
  --line-2: #d2d2d7;
  --fg: #1d1d1f;
  --fg-2: #5f5f66;
  --fg-3: #8a8a91;
  --accent: #1e4689;
  --accent-soft: #e6eefb;
  --accent-ink: #ffffff;
  --green: #1a8a4a;   --green-soft: #e7f6ed;
  --orange: #b25e00;  --orange-soft: #fdf1e2;
  --red: #c8202f;     --red-soft: #fdebec;
  --indigo: #5452d6;  --indigo-soft: #eeeefc;
  --grey-soft: #f0f0f3;
  --shadow: 0 1px 2px rgba(20,20,40,.05), 0 6px 24px rgba(20,20,40,.06);
  --shadow-lg: 0 20px 60px rgba(20,20,40,.18);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 14px; --r-sm: 10px;
  --side: 232px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.num, td.n, .kpi-value { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login {
  min-height: 100%; display: grid; place-items: center;
  padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: radial-gradient(1200px 600px at 50% -10%, #e6eefb 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow);
  padding: 36px 30px 30px; display: grid; gap: 22px; text-align: center;
}
.brand-mark {
  width: 56px; height: 56px; border-radius: 15px; margin: 0 auto; display: grid; place-items: center;
  background: linear-gradient(160deg, #1d1d1f, #3a3a40); color: #fff; font: 700 22px/1 var(--font-display); letter-spacing: -.04em;
}
.login h1 { font: 700 26px/1.15 var(--font-display); letter-spacing: -.025em; margin: 0; }
.login p.sub { margin: 4px 0 0; color: var(--fg-2); }
.field-user {
  width: 100%; padding: 14px 16px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface-2); font-size: 17px; text-align: center;
}
.field-user:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.pin-label { font-size: 13px; color: var(--fg-2); font-weight: 600; }
.pin-row { display: flex; justify-content: center; gap: 10px; position: relative; }
.pin-row input.pin-hidden { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; font-size: 16px; caret-color: transparent; }
.pin-dot {
  width: 44px; height: 54px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2);
  display: grid; place-items: center; transition: border-color .15s, background .15s;
}
.pin-dot::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--fg); transform: scale(0); transition: transform .12s; }
.pin-dot.filled::after { transform: scale(1); }
.pin-dot.active { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.pin-row.shake { animation: shake .35s; }
@keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }
.login-error { color: var(--red); background: var(--red-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.login-foot { color: var(--fg-3); font-size: 12.5px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100%; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px;
  background: color-mix(in srgb, var(--surface) 70%, var(--bg)); border-right: 1px solid var(--line);
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.side-brand .brand-mark { width: 34px; height: 34px; border-radius: 9px; font-size: 14px; margin: 0; }
.side-brand b { font: 650 15px/1.1 var(--font-display); letter-spacing: -.01em; display: block; }
.side-brand small { color: var(--fg-3); font-size: 12px; }
.nav-btn {
  display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: none; padding: 9px 12px; border-radius: 9px;
  color: var(--fg-2); font-weight: 550; text-align: left;
}
.nav-btn svg { width: 19px; height: 19px; flex: none; }
.nav-btn:hover { background: var(--grey-soft); color: var(--fg); }
.nav-btn.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.nav-btn.on svg { color: var(--accent); }
.nav-btn .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.me { display: flex; gap: 10px; align-items: center; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12.5px;
}
.me b { font-size: 13.5px; display: block; line-height: 1.2; }
.me small { color: var(--fg-3); font-size: 12px; text-transform: capitalize; }

.main { min-width: 0; padding-block: 26px 60px; padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); }
.page { max-width: 1240px; margin: 0 auto; display: grid; gap: 22px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.topbar h1 { font: 700 30px/1.1 var(--font-display); letter-spacing: -.028em; margin: 0; text-wrap: balance; }
.topbar .eyebrow { color: var(--fg-3); font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.tabbar { display: none; }
.show-sm { display: none !important; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 980px;
  padding: 9px 16px; font-weight: 600; font-size: 14px; background: var(--grey-soft); color: var(--fg); white-space: nowrap;
  transition: background .15s, transform .08s;
}
.btn:hover { background: #e7e7ec; }
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red-soft); color: var(--red); }
.btn.ghost { background: none; color: var(--accent); padding-inline: 10px; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { border: 0; background: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--fg-2); }
.icon-btn:hover { background: var(--grey-soft); color: var(--fg); }

.search {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 980px;
  padding: 7px 14px; min-width: 0; width: 280px; max-width: 100%;
}
.search svg { width: 16px; height: 16px; color: var(--fg-3); flex: none; }
.search input { border: 0; outline: 0; background: none; width: 100%; min-width: 0; font-size: 14px; }

.seg { display: inline-flex; background: var(--grey-soft); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 550; color: var(--fg-2); }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

select.pill-select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 980px; padding: 7px 30px 7px 14px; font-size: 14px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8a91' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* ---------- Cards & KPIs ---------- */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-h h2 { font: 650 17px/1.2 var(--font-display); letter-spacing: -.012em; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-h .sub { color: var(--fg-3); font-size: 13px; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1600px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1280px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi { display: grid; gap: 6px; align-content: start; }
.kpi-label { color: var(--fg-2); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-value { font: 700 34px/1.05 var(--font-display); letter-spacing: -.03em; }
.kpi-value small { font-size: 18px; font-weight: 600; color: var(--fg-3); letter-spacing: -.01em; }
.kpi-foot { color: var(--fg-3); font-size: 13px; }
.kpi-foot b { color: var(--fg-2); font-weight: 600; }
.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring { width: 76px; height: 76px; flex: none; }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: var(--grey-soft); }
.ring .bar { stroke: var(--green); stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1); }
.ring text { font: 700 17px var(--font-display); fill: var(--fg); }
.progress { height: 8px; border-radius: 6px; background: var(--grey-soft); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .8s cubic-bezier(.2,.8,.2,1); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }

/* ---------- Lists ---------- */
.list { display: grid; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 4px;
  border-top: 1px solid var(--line); cursor: pointer; border-radius: 8px;
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { color: var(--fg-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-right { text-align: right; display: grid; gap: 4px; justify-items: end; }
.row-amt { font-weight: 650; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; }
.empty { color: var(--fg-3); padding: 22px 6px; text-align: center; font-size: 14px; display: grid; gap: 6px; justify-items: center; }
.empty svg { width: 28px; height: 28px; color: var(--green); }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 980px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.lead { background: var(--grey-soft); color: var(--fg-2); }
.chip.bidding { background: var(--indigo-soft); color: var(--indigo); }
.chip.sent { background: var(--accent-soft); color: var(--accent); }
.chip.won { background: var(--green-soft); color: var(--green); }
.chip.lost { background: var(--red-soft); color: var(--red); }
.chip.passed { background: var(--grey-soft); color: var(--fg-3); }
.chip.warn { background: var(--orange-soft); color: var(--orange); }
.chip.danger { background: var(--red-soft); color: var(--red); }
.chip.plain::before { display: none; }
.badge { min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 700; background: var(--red); color: #fff; }
.badge.soft { background: var(--orange-soft); color: var(--orange); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; font-weight: 650; color: var(--fg-3); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr { cursor: pointer; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t .n { text-align: right; white-space: nowrap; }
table.t td.title { font-weight: 600; max-width: 320px; }
table.t td.title small { display: block; color: var(--fg-3); font-weight: 400; font-size: 12.5px; }
.rank { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--grey-soft); color: var(--fg-2); }
.rank.r1 { background: #fff4d6; color: #8a6100; }
.bar-inline { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-inline .progress { width: 70px; height: 6px; }
.bar-inline .progress > i { background: var(--green); }

/* ---------- Chart ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .lbl { fill: var(--fg-3); font-size: 11px; }
.chart .colbar { fill: color-mix(in srgb, var(--green) 30%, var(--surface)); }
.chart .colbar.now { fill: var(--green); }
.chart .val { fill: var(--fg-2); font-size: 11px; font-weight: 600; }

/* ---------- Pipeline board ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: color-mix(in srgb, var(--grey-soft) 70%, var(--bg)); border-radius: var(--r); padding: 10px; display: grid; gap: 8px; min-height: 120px; align-content: start; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.col-h { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 6px; gap: 8px; }
.col-h b { font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.col-h span { color: var(--fg-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bcard { background: var(--surface); border-radius: 11px; padding: 11px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); display: grid; gap: 6px; cursor: grab; border: 1px solid transparent; }
.bcard:hover { border-color: var(--line-2); }
.bcard.dragging { opacity: .4; }
.bcard .t { font-weight: 600; font-size: 14px; line-height: 1.3; }
.bcard .m { color: var(--fg-3); font-size: 12.5px; display: flex; justify-content: space-between; gap: 8px; }
.bcard .a { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 14px; }
.bcard .flags { display: flex; gap: 5px; flex-wrap: wrap; }

/* ---------- Detail ---------- */
.detail-head { display: grid; gap: 14px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); background: none; border: 0; padding: 0; font-weight: 550; }
.back svg { width: 16px; height: 16px; }
.big-amt { font: 700 40px/1 var(--font-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px 24px; }
.fact small { display: block; color: var(--fg-3); font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.fact span { font-weight: 550; overflow-wrap: anywhere; }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.timeline { display: grid; gap: 0; }
.tl { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; padding-bottom: 16px; position: relative; }
.tl::before { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl i { width: 20px; height: 20px; border-radius: 50%; background: var(--grey-soft); border: 4px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.tl i.stage { background: var(--accent); } .tl i.followup { background: var(--orange); } .tl i.note { background: var(--fg-3); }
.tl b { font-size: 14px; font-weight: 600; display: block; }
.tl p { margin: 2px 0 0; color: var(--fg-2); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl small { color: var(--fg-3); font-size: 12px; }
.gc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
.gc-row:first-child { border-top: 0; }
.trophy { color: #b58400; }

/* ---------- Sheet (modal) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20,20,30,.32); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.sheet {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); width: 100%; max-width: 620px; max-height: min(90vh, 900px);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; animation: pop .2s cubic-bezier(.2,.9,.3,1.2); overflow: hidden;
}
.sheet.narrow { max-width: 440px; }
.sheet-h { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 12px; gap: 12px; }
.sheet-h h3 { font: 700 20px/1.2 var(--font-display); letter-spacing: -.02em; margin: 0; }
.sheet-b { padding: 6px 22px 18px; overflow: auto; display: grid; gap: 16px; align-content: start; }
.sheet-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); }
.sheet-f .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form .full { grid-column: 1 / -1; }
.fl { display: grid; gap: 6px; min-width: 0; }
.fl > span { font-size: 12.5px; font-weight: 650; color: var(--fg-2); }
.fl input, .fl select, .fl textarea {
  width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); font-size: 15px;
}
.fl textarea { min-height: 84px; resize: vertical; }
.fl input:focus, .fl select:focus, .fl textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.hint { color: var(--fg-3); font-size: 12.5px; }
.err-box { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.gc-edit { display: grid; gap: 8px; }
.gc-line { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .8fr) 34px; gap: 8px; align-items: center; }
.gc-line input { padding: 9px 10px; border: 1px solid var(--line-2); border-radius: 9px; width: 100%; min-width: 0; font-size: 14px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { border: 1px solid var(--line-2); background: var(--surface); padding: 9px 14px; border-radius: 980px; font-weight: 550; font-size: 14px; }
.choice.on { background: var(--fg); border-color: var(--fg); color: var(--surface); }

.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 80;
  background: #1d1d1f; color: #fff; padding: 11px 18px; border-radius: 980px; font-weight: 550; font-size: 14px; box-shadow: var(--shadow-lg);
  animation: pop .2s; max-width: calc(100% - 32px);
}
.demo-banner { background: #1d1d1f; color: #fff; font-size: 13px; padding: 8px 16px; text-align: center; }
.demo-banner b { color: #ffd60a; }
.skeleton { color: var(--fg-3); padding: 40px; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .main { padding-block: 18px calc(96px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .topbar h1 { font-size: 26px; }
  .search { width: 100%; }
  .tabbar {
    display: grid; grid-template-columns: repeat(var(--tabs, 4), 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--line); padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .tabbar button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--fg-3); padding: 4px 0; position: relative; }
  .tabbar button svg { width: 24px; height: 24px; }
  .tabbar button.on { color: var(--accent); }
  .tabbar .badge { position: absolute; top: 0; left: calc(50% + 6px); }
  .board { grid-template-columns: repeat(5, 78vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .scrim { align-items: end; padding: 0; }
  .sheet { border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .hide-sm { display: none !important; }
  .show-sm { display: grid !important; }
  .big-amt { font-size: 34px; }
}
@media (max-width: 520px) {
  .kpis { gap: 10px; }
  .kpi.card { padding: 16px; }
  .kpis > .kpi:first-child { grid-column: 1 / -1; }
  .chart { min-width: 560px; }
  .kpi-value { font-size: 27px; }
  .ring { width: 62px; height: 62px; }
  .form { grid-template-columns: minmax(0, 1fr); }
  .gc-line { grid-template-columns: minmax(0, 1fr) minmax(0, .8fr) 34px; }
  .gc-line .gc-contact { grid-column: 1 / 3; grid-row: 2; }
  .row { grid-template-columns: minmax(0, 1fr); }
  .row-right { justify-items: start; text-align: left; grid-auto-flow: column; justify-content: start; align-items: center; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Demstos logo */
.login-logo { display: block; width: 190px; max-width: 70%; height: auto; margin: 0 auto; }
.side-brand { flex-direction: column; align-items: flex-start; gap: 4px; }
.side-logo { display: block; width: 150px; height: auto; }
.side-brand small { font-weight: 650; letter-spacing: .14em; text-transform: uppercase; padding-left: 2px; }
.login-card::before { content: ""; display: block; height: 4px; margin: -36px -30px 0; border-radius: 22px 22px 0 0; background: linear-gradient(90deg, #1e4689 0 70%, #e2342b 70% 100%); }
.login-card { overflow: hidden; }

/* =================== T&M sheets (PO.demstos.com) =================== */
.page-narrow { max-width: 860px; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: var(--mono); font-size: .94em; letter-spacing: -.01em; }
.muted { color: var(--fg-3); font-weight: 500; }
.center { text-align: center; }
.spacer { flex: 1; }
.pad { padding: 4px 2px 10px; }
.only-sm { display: none; }
.seg-full { display: grid; grid-template-columns: 1fr 1fr; }
.seg-full button { padding: 9px 12px; font-size: 14.5px; }
.login-card .fl { text-align: left; }
.login-card .fl > span { padding-left: 4px; }
.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card-h h2 .muted { font-size: 14px; }
.prose { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* line items */
.lis { display: grid; gap: 10px; }
.li { position: relative; display: grid; gap: 10px; padding: 14px 44px 14px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.li-main { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
.li-nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.li-line { display: grid; grid-template-columns: minmax(0, 1fr) 90px 100px; gap: 10px; }
.li .fl > span { font-size: 11.5px; }
.li .fl input { padding: 9px 10px; font-size: 15px; }
.li-del { position: absolute; top: 8px; right: 6px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.fact.full { grid-column: 1 / -1; }

/* photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--grey-soft); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.ph-del { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(0,0,0,.55); color: #fff; }
.ph-del.armed { background: var(--red); }
.ph-add { display: grid; place-content: center; justify-items: center; gap: 6px; cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; border: 1.5px dashed color-mix(in srgb, var(--accent) 40%, var(--line-2)); background: var(--accent-soft); }
.ph-add svg { width: 26px; height: 26px; }
.ph-add.busy { opacity: .6; pointer-events: none; }
.lightbox { background: rgba(0,0,0,.88); }
.lb-in { max-width: 96vw; max-height: 90vh; display: grid; place-items: center; }
.lb-in img { max-width: 96vw; max-height: 90vh; border-radius: 10px; }
.lb-x { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px; background: rgba(255,255,255,.18); color: #fff; }

/* sticky bottom actions on the edit page */
.sticky-actions {
  position: sticky; bottom: 14px; z-index: 30; display: flex; gap: 10px; align-items: center; padding: 10px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-radius: 980px; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.sticky-actions .btn { padding: 11px 18px; font-size: 15px; }
.sticky-actions .btn.sm { padding: 9px 14px; font-size: 13.5px; }
.btn.big { width: 100%; padding: 15px; font-size: 17px; border-radius: 14px; }

/* crew picker */
.checks { display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.check { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.check:first-child { border-top: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.check b { display: block; font-weight: 600; }
.check small { color: var(--fg-3); font-size: 12.5px; }
.check.dim { opacity: .5; }

/* signing */
.agree { margin: 0 0 16px; color: var(--fg-2); font-size: 14.5px; line-height: 1.5; }
.pad-wrap { position: relative; margin: 16px 0 14px; border-radius: 14px; border: 1px solid var(--line-2); background: #fff; height: 220px; touch-action: none; overflow: hidden; }
.pad-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; z-index: 2; }
.pad-line { position: absolute; left: 22px; right: 22px; bottom: 46px; display: flex; align-items: flex-end; gap: 8px; color: var(--fg-3); pointer-events: none; }
.pad-line i { flex: 1; border-bottom: 1.5px solid var(--line-2); }
.pad-hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--fg-3); font-size: 15px; pointer-events: none; padding-bottom: 40px; }
.pad-clear { position: absolute; top: 10px; right: 10px; z-index: 3; }
.sig-show { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; place-items: center; }
.sig-show img { max-width: 100%; max-height: 180px; }
table.t.ro tbody tr { cursor: default; }
table.t.ro tbody tr:hover td { background: none; }
table.t tr.tot td { font-weight: 700; border-top: 1px solid var(--line-2); }
.banner { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--r); }
.banner svg { width: 24px; height: 24px; flex: none; }
.banner.ok { background: var(--green-soft); color: #11603a; }

/* crew list */
.crew { display: grid; }
.crew-row { display: grid; grid-template-columns: 32px minmax(0, 1.3fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.crew-row:first-child { border-top: 0; }
.crew-row > div:nth-child(2):last-child { grid-column: 2 / -1; }
.ci { border: 1px solid transparent; background: none; border-radius: 9px; padding: 8px 10px; width: 100%; min-width: 0; font-weight: 600; }
.ci-trade { font-weight: 400; color: var(--fg-2); }
.ci:hover { border-color: var(--line); }
.ci:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.crew-add { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 14px; background: var(--line-2); transition: background .18s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .18s; }
.switch input:checked + i { background: #34c759; }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

@media (max-width: 820px) {
  .only-sm { display: inline-flex; }
  .sticky-actions { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .app:has(.tabbar) .sticky-actions { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .main:only-of-type { padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 600px) {
  .kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kpis.kpis-3 .kpi { padding: 12px; }
  .kpis.kpis-3 .kpi-value { font-size: 24px; }
  .kpis.kpis-3 .kpi-label { font-size: 11.5px; }
  .kpis.kpis-3 > .kpi:first-child { grid-column: auto; }
  .li-main { grid-template-columns: minmax(0, 1fr); }
  .li-nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .li-line { grid-template-columns: minmax(0, 1fr) 70px 80px; }
  .crew-add { grid-template-columns: minmax(0, 1fr); }
  .crew-row { grid-template-columns: 32px minmax(0, 1fr) auto; }
  .crew-row .ci-trade { grid-column: 2; grid-row: 2; padding-top: 0; }
  .crew-row .switch { grid-row: 1 / 3; grid-column: 3; }
  .sticky-actions { border-radius: 18px; }
  .sticky-actions .btn { padding: 11px 14px; }
  .pad-wrap { height: 200px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
}
.page { grid-template-columns: minmax(0, 1fr); }
.fl input, .li input { min-width: 0; max-width: 100%; }
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; min-height: 42px; }
.danger-link { color: var(--red); }
.danger-link:hover { background: var(--red-soft); }
.sticky-actions #signBtn { flex: 0 1 auto; }
.sign-need { margin: 0 0 10px; color: var(--red); background: var(--red-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 600; }
.btn.big.dim { opacity: .55; }
/* keep the phone tab bar clear of the "Powered by Netlify" badge in the bottom-right */
@media (max-width: 820px) { .tabbar { padding-right: max(180px, env(safe-area-inset-right, 0px)); } }
@media (max-width: 820px) {
  .sticky-actions { bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }
  .app:has(.tabbar) .sticky-actions { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .main { padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)); }
}
