@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root,
html[data-theme="light"] {
  --bg: #F3F5F6;
  --grid-line: rgba(11,61,100,0.07);
  --panel: #FFFFFF;
  --panel-2: #F6F8F9;
  --ink: #10161C;
  --ink-soft: #3C4750;
  --muted: #6B7680;
  --border: #D8DFE4;
  --border-strong: #B8C4CC;
  --blue: #0B5FA8;
  --blue-ink: #FFFFFF;
  --e90: #C2402C;
  --e90-ink: #FFFFFF;
  --e91: #0B5FA8;
  --e91-ink: #FFFFFF;
  --amber: #B5750F;
  --amber-ink: #FFFFFF;
  --green: #2E7D4F;
  --red: #C2402C;
  --titleblock-bg: #0B2A45;
  --titleblock-ink: #EAF2FA;
  --titleblock-muted: #8FAFC9;
  --shadow: 0 1px 2px rgba(16,22,28,0.06), 0 8px 20px -10px rgba(16,22,28,0.12);
  --crosshair: rgba(11,61,100,0.28);
}

html[data-theme="dark"] {
  --bg: #0B2340;
  --grid-line: rgba(234,242,250,0.055);
  --panel: #0F2E52;
  --panel-2: #123156;
  --ink: #EAF2FA;
  --ink-soft: #C3D6E8;
  --muted: #8FAFC9;
  --border: rgba(234,242,250,0.14);
  --border-strong: rgba(234,242,250,0.24);
  --blue: #5FC7E8;
  --blue-ink: #0B2340;
  --e90: #FF7A5C;
  --e90-ink: #0B2340;
  --e91: #5FC7E8;
  --e91-ink: #0B2340;
  --amber: #F2B341;
  --amber-ink: #0B2340;
  --green: #6FD19A;
  --red: #FF7A5C;
  --titleblock-bg: #071A2E;
  --titleblock-ink: #EAF2FA;
  --titleblock-muted: #6E8CA6;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 26px -12px rgba(0,0,0,0.55);
  --crosshair: rgba(234,242,250,0.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  transition: background-color .25s ease, color .25s ease;
}
.hidden { display: none !important; }

.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--muted);
}
h1, .h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.num { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.req { color: var(--red); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow);
  position: relative;
}
/* corner registration marks: a small L-bracket top-left & bottom-right, like a cropped detail frame */
.card.frame::before, .card.frame::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border-color: var(--border-strong);
  border-style: solid;
  opacity: .9;
}
.card.frame::before { top: -1px; left: -1px; border-width: 1.5px 0 0 1.5px; }
.card.frame::after { bottom: -1px; right: -1px; border-width: 0 1.5px 1.5px 0; }

/* Dimension-line section label, like extension lines in a technical drawing */
.dim-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.dim-label .txt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.dim-label .rule {
  flex: 1;
  height: 1px;
  background: var(--border-strong);
  position: relative;
}
.dim-label .rule::before, .dim-label .rule::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 1px;
  height: 7px;
  background: var(--border-strong);
}
.dim-label .rule::before { left: 0; }
.dim-label .rule::after { right: 0; }

.label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}
.input, select.input {
  font-family: 'Inter', sans-serif; font-weight: 500;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  border-radius: 3px;
  padding: 9px 10px;
  font-size: 14px;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11,95,168,0.14); }
.input::placeholder { color: var(--muted); }
.input.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(194,64,44,0.14); }

.btn {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  padding: 11px 0;
  width: 100%;
  transition: filter .15s ease, transform .08s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn-blue { background: var(--blue); color: var(--blue-ink); }
.btn-ghost {
  background: transparent; border: 1px solid var(--border-strong); color: var(--ink);
  width: auto; padding: 8px 14px; font-size: 13px;
}
.btn-danger { background: var(--red); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--ink); width: auto; padding: 8px 16px; font-size: 13px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.del { background: transparent; border: none; color: var(--muted); cursor: pointer; font-family: 'JetBrains Mono', monospace; font-size: 12px; padding: 4px 6px; border-radius: 3px; }
.del:hover { color: var(--red); background: rgba(194,64,44,0.1); }
.err { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }
.scroll { overflow-y: auto; }
.scroll::-webkit-scrollbar { width: 6px; }
.scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* Theme toggle */
.switch-wrap { display: flex; align-items: center; gap: 8px; }
.switch {
  position: relative;
  width: 46px; height: 24px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  cursor: pointer;
}
.switch .knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--blue);
  transition: left .2s ease;
}
html[data-theme="dark"] .switch .knob { left: 24px; }

/* Corner crosshairs on the page shell */
.crosshair { position: fixed; width: 16px; height: 16px; pointer-events: none; z-index: 5; }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: var(--crosshair); }
.crosshair::before { top: 7px; left: 0; width: 16px; height: 1px; }
.crosshair::after { top: 0; left: 7px; width: 1px; height: 16px; }
.crosshair.tl { top: 14px; left: 14px; }
.crosshair.tr { top: 14px; right: 14px; }
.crosshair.bl { bottom: 14px; left: 14px; }
.crosshair.br { bottom: 14px; right: 14px; }

/* Login screen */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; position: relative; overflow: hidden; }
.login-box { width: 100%; max-width: 380px; padding: 34px 32px; z-index: 2; }
.login-box h1 { font-size: 32px; margin-bottom: 2px; }
.login-box .eyebrow { margin-bottom: 8px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-box .field { margin-bottom: 14px; }
.login-theme-toggle { position: fixed; top: 18px; right: 18px; z-index: 3; }
.circuit-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0.5; pointer-events: none;
}
.circuit-bg path { fill: none; stroke: var(--border-strong); stroke-width: 1.4; }
.login-partners {
  margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
}
.login-partners .chip { display: inline-flex; align-items: center; justify-content: center; padding: 4px 10px; border-radius: 3px; opacity: .82; transition: opacity .2s ease; }
.login-partners .chip:hover { opacity: 1; }
.login-partners .chip.dark { background: #0B2A45; }
.login-partners .chip.light { background: #FFFFFF; border: 1px solid var(--border); }
.login-partners .chip img { height: 11px; width: auto; display: block; }
.login-partners .chip.light img { height: 15px; }

/* App shell */
#app { max-width: 1020px; margin: 0 auto; padding: 26px 20px 0; }
header.topbar { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 14px; margin-bottom: 24px; }
header.topbar h1 { font-size: 32px; }
header.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.who { font-size: 12px; color: var(--muted); text-align: right; margin-bottom: 6px; }
.top-controls { display: flex; gap: 14px; align-items: flex-end; }
.rate-display { text-align: right; }
.rate-display .val { font-size: 15px; font-weight: 600; }
.rate-display .meta { font-size: 10px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.rate-refresh { background: none; border: none; color: var(--blue); cursor: pointer; font-family: 'JetBrains Mono', monospace; font-size: 10px; padding: 0; text-decoration: underline; }

.overview { padding: 26px 24px 22px; margin-bottom: 16px; display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: center; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat-val { font-size: 22px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; }
.stat-sub { font-size: 12px; color: var(--muted); }
.split-bar { margin-top: 18px; height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; position: relative; border: 1px solid var(--border); }
.split-bar > span { position: absolute; top: 0; bottom: 0; }
.split-caption { margin-top: 7px; font-size: 12px; color: var(--muted); }

.cars-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.car-card { padding: 18px 18px 16px; }
.car-card .h1 { font-size: 19px; }
.car-card .tag {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 2px; text-transform: uppercase;
}
.car-card.e90 .tag { background: rgba(194,64,44,0.12); color: var(--e90); }
.car-card.e91 .tag { background: rgba(11,95,168,0.12); color: var(--e91); }
.car-card .spent { display: flex; align-items: baseline; gap: 10px; margin-top: 8px; }
.car-card .spent .big { font-size: 24px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; }
.car-bar { margin-top: 12px; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; border: 1px solid var(--border); }
.car-bar > span { display: block; height: 100%; }
.car-card .foot { margin-top: 6px; font-size: 11px; color: var(--muted); }

.main-grid, .budget-grid, .users-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-card, .log-card { padding: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.grid-amt { display: grid; grid-template-columns: 1fr 90px; gap: 10px; margin-bottom: 10px; }

.log-list { max-height: 300px; margin-top: -4px; }
.log-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--border); gap: 10px; }
.log-item .left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.log-item .title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-item .meta { font-size: 11px; color: var(--muted); }
.log-item .right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.log-empty { color: var(--muted); font-size: 13px; padding: 20px 0; text-align: center; }

.users-list { max-height: 220px; }
.user-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.badge { font-family: 'JetBrains Mono', monospace; font-size: 10px; padding: 2px 6px; border-radius: 2px; background: rgba(11,95,168,0.14); color: var(--blue); margin-left: 6px; }

/* Gauge */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; position: relative; }
.gauge-detail-tag {
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.1em;
  color: var(--muted); text-transform: uppercase; display: flex; align-items: center; gap: 5px;
}
.gauge-detail-tag .circled {
  width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--ink-soft);
}
.gauge-pct { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 700; margin-top: -2px; }
.gauge-tick-label { font-family: 'JetBrains Mono', monospace; font-size: 8px; fill: var(--muted); }

/* Title block footer */
.titleblock {
  margin: 30px 0 0;
  background: var(--titleblock-bg);
  color: var(--titleblock-ink);
  border-top: 1px solid var(--border-strong);
}
.titleblock-inner {
  max-width: 1020px; margin: 0 auto; padding: 16px 20px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
}
.tb-cell {
  padding: 6px 18px;
  border-left: 1px solid rgba(234,242,250,0.14);
}
.tb-cell:first-child { border-left: none; padding-left: 0; }
.tb-cell .tb-label {
  font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--titleblock-muted); margin-bottom: 4px;
}
.tb-cell .tb-value { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.tb-partners { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tb-partners img { display: block; opacity: 0.92; }
.tb-partners .logo-ramplast { height: 16px; width: auto; }
.tb-partners .logo-apex { height: 20px; width: auto; border-radius: 2px; background: #fff; padding: 3px 6px; }

/* Confirm-delete modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(8,16,24,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 4px;
  max-width: 360px; width: 100%; padding: 22px; box-shadow: var(--shadow);
}
.modal-box .h1 { font-size: 17px; margin-bottom: 8px; }
.modal-box p { font-size: 13px; color: var(--muted); margin: 0 0 20px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { width: auto; flex: 1; padding: 10px 0; font-size: 13px; }

@media (max-width: 720px) {
  .overview { grid-template-columns: 1fr; text-align: center; }
  .cars-grid, .main-grid, .budget-grid, .users-grid { grid-template-columns: 1fr; }
  .titleblock-inner { grid-template-columns: 1fr 1fr; gap: 14px 0; }
  .tb-cell:nth-child(3) { border-left: none; }
  .crosshair { display: none; }
}
