:root {
  --bg: #0d1015;
  --bg-top: rgba(13, 16, 21, 0.86);
  --card: #161a21;
  --card-2: #1d222b;
  --line: rgba(255, 255, 255, 0.07);
  --text: #eef1f6;
  --muted: #8a93a3;
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.16);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, 0.14);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --purple: #a78bfa;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --radius: 20px;
}

:root[data-theme="light"] {
  --bg: #f2f4f8;
  --bg-top: rgba(242, 244, 248, 0.9);
  --card: #ffffff;
  --card-2: #f0f2f7;
  --line: rgba(15, 23, 42, 0.08);
  --text: #101828;
  --muted: #667085;
  --accent: #3b74e8;
  --accent-soft: rgba(59, 116, 232, 0.12);
  --green: #12a874;
  --green-soft: rgba(18, 168, 116, 0.12);
  --red: #e5484d;
  --red-soft: rgba(229, 72, 77, 0.1);
  --amber: #d98a00;
  --amber-soft: rgba(217, 138, 0, 0.12);
  --purple: #7c5cf0;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--text); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

#app { max-width: 720px; margin: 0 auto; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  padding: 14px 16px 0;
  background: var(--bg-top);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.top-row { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff;
  background: linear-gradient(135deg, #5b8def, #34d399);
  box-shadow: 0 6px 18px rgba(91, 141, 239, 0.4);
}
.hello { font-weight: 700; font-size: 17px; }
.range { color: var(--muted); font-size: 13px; margin-top: 1px; }
.demo-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; padding: 5px 9px;
  border-radius: 999px; color: var(--amber); background: var(--amber-soft);
}

.chips { display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 0; cursor: pointer; padding: 8px 14px; border-radius: 999px;
  font: inherit; font-weight: 600; font-size: 13.5px; color: var(--muted); background: var(--card);
  transition: transform .15s ease, background .2s, color .2s;
}
.chip:active { transform: scale(0.95); }
.chip.active { color: #fff; background: var(--accent); box-shadow: 0 6px 16px rgba(91, 141, 239, 0.35); }

.custom { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); }
.custom input {
  flex: 1; min-width: 0; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; color-scheme: dark;
}
:root[data-theme="light"] .custom input { color-scheme: light; }
.custom button {
  border: 0; padding: 10px 14px; border-radius: 12px; font: inherit; font-weight: 700; cursor: pointer;
  color: #fff; background: var(--accent);
}

.tabs { display: flex; gap: 4px; margin: 12px -16px 0; padding: 0 16px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line); }
.tab {
  flex: 0 0 auto; border: 0; background: none; cursor: pointer; padding: 11px 12px 12px; font: inherit;
  font-weight: 600; font-size: 14px; color: var(--muted); position: relative; transition: color .2s;
}
.tab.active { color: var(--text); }
.tab.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px;
  background: var(--accent); animation: grow .25s ease;
}

/* ---------- layout ---------- */
main { padding: 16px 16px 40px; }
.view { display: grid; gap: 14px; animation: rise .35s ease both; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: 0.01em; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (min-width: 560px) { .kpis.four { grid-template-columns: repeat(4, 1fr); } }

.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px;
  box-shadow: var(--shadow); min-width: 0;
}
.kpi .k-lbl { color: var(--muted); font-size: 12.5px; }
.kpi .k-val { font-size: 21px; font-weight: 750; margin-top: 4px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.kpi .k-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.k-val.pos { color: var(--green); } .k-val.neg { color: var(--red); }

/* ---------- hero ---------- */
.hero {
  border-radius: 24px; padding: 20px; border: 1px solid var(--line); box-shadow: var(--shadow);
  background: radial-gradient(120% 120% at 0% 0%, rgba(91, 141, 239, 0.22), transparent 55%),
              radial-gradient(90% 90% at 100% 0%, rgba(52, 211, 153, 0.16), transparent 50%), var(--card);
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lbl { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.delta { font-size: 12.5px; font-weight: 700; padding: 5px 9px; border-radius: 999px; white-space: nowrap; }
.delta.up { color: var(--green); background: var(--green-soft); }
.delta.down { color: var(--red); background: var(--red-soft); }
.big { font-size: 38px; font-weight: 800; letter-spacing: -0.02em; margin: 8px 0 2px; }
.big.neg { color: var(--red); }
.hero-sub { color: var(--muted); font-size: 13px; }
.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.mini { background: rgba(255, 255, 255, 0.04); border-radius: 14px; padding: 10px 11px; min-width: 0; }
:root[data-theme="light"] .mini { background: rgba(16, 24, 40, 0.04); }
.mini .m-lbl { color: var(--muted); font-size: 12px; }
.mini .m-val { font-weight: 700; font-size: 15px; margin-top: 2px; overflow-wrap: anywhere; }
.after-tax {
  margin-top: 12px; padding: 10px 12px; border-radius: 14px; font-size: 13.5px; display: flex;
  justify-content: space-between; background: var(--accent-soft); color: var(--text);
}

/* ---------- charts ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.tip {
  position: absolute; top: -6px; left: 0; right: 0; text-align: center; font-size: 12.5px; font-weight: 600;
  color: var(--text); pointer-events: none; min-height: 18px; opacity: .95;
}
.bar { transform-box: fill-box; transform-origin: center bottom; animation: bar-up .6s cubic-bezier(.2, .8, .2, 1) both; cursor: pointer; }
.bar.sel { filter: brightness(1.25); }
.axis text, .x-lbl { fill: var(--muted); font-size: 9.5px; }
.zero-line { stroke: var(--line); stroke-width: 1; }
.seg { animation: seg-in .7s ease both; transform-origin: 70px 70px; }
.center-top { fill: var(--muted); font-size: 8.5px; }
.center-val { fill: var(--text); font-size: 13px; font-weight: 700; }
.area-line { stroke-dasharray: 1200; animation: draw 1.1s ease both; }

.donut-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; }
@media (max-width: 420px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .donut-wrap .legend { width: 100%; } }
.legend { display: grid; gap: 9px; min-width: 0; }
.leg-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 9px; align-items: center; font-size: 13.5px; }
.dot { width: 10px; height: 10px; border-radius: 4px; }
.leg-val { font-weight: 700; white-space: nowrap; }
.leg-sub { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 4px; }

/* ---------- lists ---------- */
.rows { display: grid; gap: 14px; }
.row { display: grid; gap: 7px; }
.row-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.row-top b { font-weight: 700; white-space: nowrap; }
.track { height: 8px; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.fill { height: 100%; border-radius: 6px; transform-origin: left; animation: fill-in .8s cubic-bezier(.2, .8, .2, 1) both; }

.tap { cursor: pointer; transition: transform .15s ease, border-color .2s; }
.tap:active { transform: scale(0.985); border-color: var(--accent); }
.chev { margin-left: auto; color: var(--accent); font-size: 12.5px; font-weight: 600; align-self: center; }
.back {
  justify-self: start; border: 0; cursor: pointer; padding: 8px 14px 8px 10px; border-radius: 999px; font: inherit;
  font-weight: 600; font-size: 14px; color: var(--accent); background: var(--accent-soft);
}
.ops { display: grid; gap: 0; }
.op { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; padding: 11px 0;
  border-bottom: 1px solid var(--line); }
.op:last-child { border-bottom: 0; padding-bottom: 0; }
.op:first-child { padding-top: 0; }
.op-time { color: var(--muted); font-size: 12.5px; }
.op-label { font-weight: 600; }
.op-note { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.op b.pos { color: var(--green); } .op b.neg { color: var(--red); }

.shift { display: grid; gap: 10px; }
.shift-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.shift-date { font-weight: 700; font-size: 15px; }
.shift-time { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.shift-net { font-weight: 800; font-size: 18px; text-align: right; }
.shift-rate { color: var(--muted); font-size: 12px; text-align: right; margin-top: 2px; }
.shift-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--card-2);
  color: var(--muted);
}
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.soon { background: var(--amber-soft); color: var(--amber); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.expired { background: var(--red-soft); color: var(--red); }
.pill.none { background: var(--card-2); color: var(--muted); }

.doc { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0;
  border-bottom: 1px solid var(--line); }
.doc:last-child { border-bottom: 0; padding-bottom: 0; }
.doc:first-child { padding-top: 0; }
.doc-name { font-weight: 600; }
.doc-date { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.car-hero { display: flex; align-items: center; gap: 14px; }
.car-icon {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 28px;
  background: var(--accent-soft);
}
.car-name { font-size: 20px; font-weight: 800; }
.car-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.plate {
  display: inline-block; padding: 3px 9px; border-radius: 8px; border: 1.5px solid var(--text);
  font-weight: 700; font-size: 12.5px; letter-spacing: 0.06em; margin-right: 6px;
}

.ring-wrap { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; }
.ring-stats { display: grid; gap: 10px; }
.stat-line { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.stat-line span { color: var(--muted); }
.stat-line b { font-weight: 700; text-align: right; }

.note { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .e-ico { font-size: 40px; margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.btn {
  display: inline-block; margin-top: 14px; border: 0; cursor: pointer; padding: 12px 18px; border-radius: 14px;
  font: inherit; font-weight: 700; color: #fff; background: var(--accent); text-decoration: none;
}

/* ---------- skeleton ---------- */
.skel { display: grid; gap: 14px; }
.skel > div { border-radius: var(--radius); height: 120px; background: linear-gradient(90deg, var(--card) 25%, var(--card-2) 50%, var(--card) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
.skel > div:first-child { height: 200px; }

/* ---------- animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes bar-up { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes fill-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes seg-in { from { opacity: 0; transform: rotate(-30deg) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes draw { from { stroke-dashoffset: 1200; } to { stroke-dashoffset: 0; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
