:root {
  --brand: #0b7a3e; --brand-d: #075c2e; --brand-l: #e3f4ea;
  --bg: #f4f6f8; --card: #fff; --ink: #1d2733; --muted: #66727f; --line: #e2e6ea;
  --blue: #1c64d1; --amber: #b8860b; --red: #c92a2a; --green: #2b8a3e;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* top bar */
.topbar { background: var(--brand); color: #fff; display: flex; align-items: center; gap: 12px; padding: 10px 16px; position: sticky; top: 0; z-index: 1000; }
.topbar .logo { font-weight: 800; letter-spacing: .06em; font-size: 1.05rem; }
.topbar .logo small { font-weight: 500; opacity: .85; letter-spacing: 0; margin-left: 6px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .85rem; opacity: .9; }
.topbar button { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35); }

/* layout */
.wrap { max-width: 1200px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 560px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 860px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }

/* forms */
label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #c9d0d6; border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover:not(:disabled) { background: var(--brand-d); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-ghost { background: transparent; }
.btn-big { width: 100%; padding: 15px; font-size: 1.05rem; border-radius: 10px; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.b-green { background: #e3f6e8; color: #1e6b30; }
.b-amber { background: #fff3d6; color: #8a6100; }
.b-red { background: #fde6e6; color: #a51d1d; }
.b-blue { background: #e1ecfc; color: #1550a8; }
.b-grey { background: #eceff2; color: #4c5662; }
.b-purple { background: #efe5fd; color: #5f2fb0; }

/* stats tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.tile .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font-size: 1.5rem; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: .85rem; font-weight: 600; color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f7faf8; }
.table-wrap { overflow-x: auto; }
.kv th { width: 40%; text-transform: none; font-size: .92rem; color: var(--ink); letter-spacing: 0; }

/* map */
.map { height: 420px; border-radius: 10px; border: 1px solid var(--line); z-index: 1; }
.map.tall { height: 520px; }
.pin { background: none; border: none; }
.pin-dot { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin-veh { width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(28,100,209,.25); font-size: 13px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 18px; height: 5px; border-radius: 3px; vertical-align: middle; margin-right: 5px; }

/* chart */
.chart { width: 100%; height: auto; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .grid { stroke: #e7ebee; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2; }
.chart .area { fill: rgba(11,122,62,.12); }
.chart .unit { font-weight: 700; }

/* checks */
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: none; }
.checks .ic { width: 22px; height: 22px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 800; margin-top: 1px; }
.checks .ok .ic { background: var(--green); } .checks .bad .ic { background: var(--red); }

/* banners */
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: .92rem; }
.banner.warn { background: #fff3d6; color: #6b4b00; border: 1px solid #f0d58a; }
.banner.err { background: #fde6e6; color: #8a1717; border: 1px solid #f3b4b4; }
.banner.ok { background: #e3f6e8; color: #1e6b30; border: 1px solid #a8dcb5; }
.banner.info { background: #e1ecfc; color: #1550a8; border: 1px solid #b5cdf3; }

/* login */
.login-bg { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, #0b7a3e 0%, #064d27 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .brand { font-size: 1.8rem; font-weight: 900; letter-spacing: .08em; color: var(--brand); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* checklist (engineer) */
.cl-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.cl-item .t { font-weight: 600; margin-bottom: 6px; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 8px 4px; font-size: .9rem; }
.seg button.on.pass { background: var(--green); border-color: var(--green); color: #fff; }
.seg button.on.fail { background: var(--red); border-color: var(--red); color: #fff; }
.seg button.on.na { background: #6c757d; border-color: #6c757d; color: #fff; }
.cl-item input { margin-top: 8px; }

/* live tracking screen */
.live-head { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.live-head .tile .v { font-size: 1.7rem; }
.rec { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--red); }
.rec::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.map.phone { height: 300px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: #1d2733; color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 5000; transition: transform .25s; max-width: calc(100% - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }
#toast.ok { background: var(--green); }

/* print report */
@media print {
  .topbar, .tabs, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  .card { border: none; padding: 0; break-inside: avoid; }
  .wrap { max-width: none; padding: 0; }
  .map { height: 380px; }
}
