:root {
  --deep: #06345a;
  --deep-ink: #021e36;
  --blue: #1d6bbf;
  --blue-bright: #2f8dd8;
  --aqua: #3fc3d4;
  --aqua-soft: #a8e3ea;
  --sand: #f4faff;
  --sand-soft: #e7f1f9;
  --line: #dae6f0;
  --ink: #0b1d2e;
  --slate: #4a5b6b;
  --slate-soft: #6b7c8c;
  --ok: #1f9d6b;
  --ok-soft: #e3f6ee;
  --warn: #c7741a;
  --warn-soft: #fdf1e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(6, 52, 90, .06), 0 4px 16px rgba(6, 52, 90, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--sand); }
body { min-height: 100vh; font-size: 15px; line-height: 1.4; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; color: var(--deep); letter-spacing: -.01em; }
h2 { font-size: 1.02rem; font-weight: 650; }
h3 { font-size: 1.15rem; }
.muted { color: var(--slate-soft); margin: 2px 0 0; }
.small { font-size: .82rem; }
.fine { font-size: .78rem; color: var(--slate-soft); margin: 10px 0 0; }
.error { color: #b3261e; font-size: .88rem; min-height: 1.2em; margin: 8px 0 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.btn { font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid transparent; padding: 9px 14px; cursor: pointer; min-height: 40px; touch-action: manipulation; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--deep); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; color: var(--deep); border-color: var(--line); }
.btn-ghost:hover { background: var(--sand-soft); }
.btn-soft { background: var(--sand-soft); color: var(--blue); }
.btn-soft:hover { background: #d8e9f6; }
.btn-link { background: none; border: 0; color: var(--blue); padding: 6px 0; min-height: 0; font-weight: 600; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; min-height: 34px; font-size: .86rem; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--blue); color: #fff; white-space: nowrap; }
.pill-soft { background: var(--sand-soft); color: var(--blue); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-mute { background: #eef2f5; color: var(--slate); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #d7ecfa 0%, transparent 60%), linear-gradient(180deg, var(--sand), #e4f1fa); }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 20px; padding: 32px 28px 22px; box-shadow: 0 10px 40px rgba(6, 52, 90, .12); text-align: center; }
.login-logo { display: block; margin: 0 auto 14px; }
.login-card h1 { font-size: 1.45rem; }
.login-card input { width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; margin: 20px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--sand); }
.login-card input:focus { outline: 2px solid var(--aqua); border-color: transparent; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); background: var(--deep); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 9px; }
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.brand-sub { font-size: .78rem; color: var(--aqua-soft); }
.top-right { display: flex; align-items: center; gap: 8px; }
.today { font-size: .88rem; color: #d7e7f5; margin-right: 6px; }
.top .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .25); min-height: 36px; padding: 6px 12px; }
.top .btn-ghost:hover { background: rgba(255, 255, 255, .1); }

.wrap { max-width: 1400px; margin: 0 auto; padding: 16px 20px 28px; }
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }

.kpis { display: grid; grid-template-columns: 1.5fr repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.kpi-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-soft); font-weight: 650; }
.kpi-value { font-size: 1.75rem; font-weight: 750; color: var(--deep); margin-top: 4px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: .95rem; font-weight: 600; color: var(--slate-soft); }
.kpi-sub { font-size: .8rem; color: var(--slate); margin-top: 4px; }
.kpi-hero { background: linear-gradient(135deg, var(--deep) 0%, var(--blue) 70%, var(--aqua) 140%); color: #fff; position: relative; overflow: hidden; }
.kpi-hero .kpi-label { color: var(--aqua-soft); }
.kpi-hero .kpi-value { color: #fff; font-size: 2.05rem; }
.kpi-hero .kpi-sub { color: #d5ebf8; }
.kpi-hero::after { content: ""; position: absolute; right: -28px; bottom: -34px; width: 120px; height: 120px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: rgba(255, 255, 255, .08); }
.bump { animation: bump .7s ease; }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.06); } 100% { transform: scale(1); } }

.grid-main { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; align-items: start; }
.col { display: grid; gap: 14px; min-width: 0; }
.grid-lower { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-top: 14px; }

.progress-wrap { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.progress { flex: 1; height: 8px; border-radius: 99px; background: var(--sand-soft); overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--aqua)); border-radius: 99px; transition: width .5s ease; }
.progress-label { font-size: .8rem; font-weight: 700; color: var(--deep); white-space: nowrap; }

.map { border-radius: 12px; overflow: hidden; background: #eef6fc; border: 1px solid var(--line); }
.map svg { display: block; width: 100%; height: auto; }
.map .area-label { font-size: 2.4px; fill: var(--slate-soft); font-weight: 600; letter-spacing: .08px; }
.map .lake-label { font-size: 2.6px; fill: #5b9cc9; font-style: italic; }
.map .stop-num { font-size: 2.1px; font-weight: 700; fill: #fff; text-anchor: middle; dominant-baseline: central; }
.map .next-ring { fill: none; stroke: var(--aqua); stroke-width: .6; animation: pulse 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(2.2); } }

.stops { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 2px; }
.stop { display: grid; grid-template-columns: 30px 1fr auto auto; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; }
.stop:nth-child(odd) { background: #fafcfe; }
.stop-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; background: var(--sand-soft); color: var(--blue); }
.stop.done .stop-n { background: var(--blue); color: #fff; }
.stop.next { background: #eaf8fa; box-shadow: inset 3px 0 0 var(--aqua); }
.stop-name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-addr { font-size: .8rem; color: var(--slate-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-main { min-width: 0; }
.stop-meta { text-align: right; font-size: .8rem; color: var(--slate); white-space: nowrap; }
.stop-meta b { color: var(--deep); font-size: .92rem; }
.stop-act { min-width: 118px; text-align: right; }
.done-time { font-size: .8rem; color: var(--ok); font-weight: 650; white-space: nowrap; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--sand-soft); }
.list li:first-child { border-top: 0; padding-top: 2px; }
.li-main { min-width: 0; }
.li-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: .8rem; color: var(--slate-soft); }
.li-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.bal { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .82rem; padding: 3px 8px; border-radius: 8px; background: var(--sand-soft); color: var(--deep); }
.bal.low { background: var(--warn-soft); color: var(--warn); }

.approval { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; background: linear-gradient(180deg, #fff, #fbfdff); }
.approval:first-child { margin-top: 0; }
.approval-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.approval-name { font-weight: 650; }
.approval-why { font-size: .8rem; color: var(--slate-soft); }
.bubble { margin: 8px 0 10px; padding: 10px 12px; background: var(--sand); border-radius: 4px 12px 12px 12px; font-size: .88rem; color: var(--slate); }
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.approval.approved { padding: 10px 12px; background: #fff; }
.approval.approved .bubble, .approval.approved .approval-actions { display: none; }
.empty { color: var(--slate-soft); font-size: .88rem; padding: 6px 0; }

.feed { list-style: none; margin: 0; padding: 0; max-height: 330px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.feed li { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--sand-soft); font-size: .86rem; color: var(--slate); }
.feed li:first-child { border-top: 0; padding-top: 0; }
.feed time { font-variant-numeric: tabular-nums; color: var(--slate-soft); font-size: .78rem; padding-top: 2px; }
.tag { display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 5px; margin-right: 6px; background: var(--sand-soft); color: var(--blue); }
.tag-delivery { background: #e6f0fb; color: var(--blue); }
.tag-reminder { background: #e5f7f9; color: #148a99; }
.tag-low_stock { background: var(--warn-soft); color: var(--warn); }
.tag-sale { background: var(--ok-soft); color: var(--ok); }
.tag-approval { background: #ece9fb; color: #5b48c2; }
.tag-route { background: #eef2f5; color: var(--slate); }
.feed li.fresh { animation: fresh 2.4s ease; }
@keyframes fresh { 0% { background: #e5f7f9; } 100% { background: transparent; } }

.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 130px; padding-top: 18px; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bar-fill { width: 100%; max-width: 34px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--blue-bright), var(--blue)); min-height: 3px; position: relative; }
.bar.today .bar-fill { background: linear-gradient(180deg, var(--aqua), var(--blue-bright)); }
.bar-amt { font-size: .66rem; color: var(--slate); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-day { font-size: .72rem; color: var(--slate-soft); font-weight: 600; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--sand); border-radius: 10px; padding: 9px 10px; min-width: 0; }
.stat-v { font-weight: 750; color: var(--deep); font-size: 1.12rem; font-variant-numeric: tabular-nums; }
.stat-l { font-size: .72rem; color: var(--slate-soft); }
.rnl-card .stat-row { margin-top: 0; }
.hbars { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 7px; }
.hbars li { display: grid; grid-template-columns: 1fr 1.3fr 26px; align-items: center; gap: 8px; font-size: .82rem; }
.hbars .hb-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--slate); }
.hbars .hb-track { height: 8px; background: var(--sand-soft); border-radius: 99px; overflow: hidden; }
.hbars .hb-fill { height: 100%; background: linear-gradient(90deg, #36b37e, var(--aqua)); border-radius: 99px; }
.hbars .hb-n { text-align: right; font-weight: 700; color: var(--deep); font-variant-numeric: tabular-nums; }
.stock li .li-title { font-weight: 550; }
.stock-n { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--deep); }

.foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; font-size: .78rem; color: var(--slate-soft); }
.foot .btn-link { font-size: .78rem; color: var(--slate-soft); }

.dlg { border: 0; border-radius: 18px; padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(2, 30, 54, .3); color: var(--ink); }
.dlg::backdrop { background: rgba(2, 30, 54, .45); }
.dlg h3 { margin-bottom: 2px; }
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0 14px; }
.stepper { background: var(--sand); border-radius: 12px; padding: 10px; text-align: center; }
.stepper-label { font-size: .78rem; color: var(--slate-soft); font-weight: 600; }
.stepper-ctl { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 6px; }
.stepper-ctl button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 1.35rem; color: var(--blue); cursor: pointer; touch-action: manipulation; }
.stepper-ctl output { font-size: 1.6rem; font-weight: 750; min-width: 34px; color: var(--deep); font-variant-numeric: tabular-nums; }
.field { display: grid; gap: 6px; font-size: .82rem; color: var(--slate); font-weight: 600; }
.field input, .field textarea { font: inherit; font-size: 16px; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--aqua); border-color: transparent; }
.card-note { font-size: .84rem; color: var(--slate); margin: 12px 0 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast { visibility: hidden; opacity: 0; position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 140%); background: var(--deep-ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: .9rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transition: transform .3s ease, opacity .3s ease, visibility .3s; max-width: calc(100vw - 32px); z-index: 20; }
.toast.show { transform: translate(-50%, 0); visibility: visible; opacity: 1; }

@media (max-width: 1240px) {
  .kpis { grid-template-columns: 1.4fr repeat(4, 1fr); gap: 10px; }
  .kpi { padding: 12px 13px; }
  .kpi-value { font-size: 1.5rem; }
  .kpi-hero .kpi-value { font-size: 1.75rem; }
  .wrap { padding: 14px 16px 24px; }
  .grid-lower { grid-template-columns: 1fr 1fr; }
  .grid-lower .card:last-child { grid-column: span 2; }
  .stock { columns: 2; column-gap: 24px; }
  .stock li { break-inside: avoid; }
  .stock li:nth-child(4) { border-top: 0; padding-top: 2px; }
}
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi-hero { grid-column: span 2; }
  .grid-main { grid-template-columns: 1fr; }
  .grid-lower { grid-template-columns: 1fr; }
  .grid-lower .card:last-child { grid-column: auto; }
  .stock { columns: 1; }
}
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .wrap { padding: 12px 12px 24px; }
  .top { padding: 9px 12px; }
  .brand-sub, .today, #refresh { display: none; }
  .kpi-value { font-size: 1.35rem; }
  .kpi-hero .kpi-value { font-size: 1.7rem; }
  .card { padding: 14px 12px; }
  .card-head { flex-direction: column; gap: 6px; }
  .progress-wrap { width: 100%; }
  .stop { grid-template-columns: 26px 1fr auto; gap: 8px; }
  .stop-meta { display: none; }
  .stop-act { min-width: 0; }
  .stop-act .btn { padding: 6px 10px; }
  .bar-amt { display: none; }
  .stat-v { font-size: 1rem; }
}
