:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --ink: #17252b;
  --muted: #5d7079;
  --line: #dde5e8;
  --brand: #0d6e6e;
  --brand-dark: #095353;
  --brand-soft: #e3f2f2;
  --ok: #1f7a4d;
  --ok-soft: #e4f4ec;
  --warn: #a15c07;
  --warn-soft: #fdf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--brand-dark);
  color: #d6ecec;
  padding: 1.25rem .9rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: .7rem; align-items: center; font-weight: 700; color: #fff; line-height: 1.15; margin: 0 .4rem 1.5rem; }
.brand .cross { background: #fff; color: var(--brand); width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 1.2rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: #cfe6e6; padding: .55rem .75rem; border-radius: 8px; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.sidebar nav a.active { background: rgba(255, 255, 255, .16); color: #fff; }
.sidebar .me { margin-top: auto; padding: .8rem .6rem 0; border-top: 1px solid rgba(255, 255, 255, .15); font-size: .88rem; }
.sidebar .me strong { color: #fff; display: block; }
.sidebar .me a, .sidebar .me button.linklike { color: #cfe6e6; }
main { padding: 1.75rem 2rem 3rem; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* cards & tables */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.1rem; }
.grid { display: grid; gap: 1rem; }
.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; }
.stat .n { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: .85rem; }
.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafcfc; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 1rem .2rem; }

/* badges */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #e8eef0; color: #3b4f58; }
.badge.ok, .badge.paid, .badge.completed, .badge.dispensed { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.partial, .badge.checked_in, .badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.void, .badge.cancelled, .badge.no_show { background: var(--bad-soft); color: var(--bad); }
.badge.scheduled, .badge.unpaid { background: var(--brand-soft); color: var(--brand-dark); }

/* forms */
label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number],
input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid #c4d1d6; border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .9rem 1.1rem; }
.form-grid .full { grid-column: 1 / -1; }
.inline-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form > div { min-width: 120px; }
.inline-form .grow { flex: 1; min-width: 170px; }
.checkline { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.checkline input { width: auto; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--brand); background: var(--brand);
  color: #fff; padding: .5rem .95rem; border-radius: 8px; display: inline-block; line-height: 1.3;
}
button:hover, .btn:hover { background: var(--brand-dark); text-decoration: none; }
button.secondary, .btn.secondary { background: #fff; color: var(--brand-dark); border-color: #b7cdd1; }
button.secondary:hover, .btn.secondary:hover { background: var(--brand-soft); }
button.danger { background: #fff; color: var(--bad); border-color: #e3b5b1; }
button.danger:hover { background: var(--bad-soft); }
button.small, .btn.small { padding: .22rem .6rem; font-size: .82rem; }
button.linklike { background: none; border: 0; padding: 0; font-weight: 500; color: var(--brand); }
button.linklike:hover { background: none; text-decoration: underline; }
form.inline { display: inline; }

/* flashes */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .6rem; border: 1px solid; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: #b9dfca; }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: #efc2be; }

.alert { background: var(--bad-soft); border: 1px solid #efc2be; color: var(--bad); padding: .55rem .9rem; border-radius: 8px; font-weight: 600; margin-bottom: 1rem; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.note { border-left: 3px solid var(--brand); padding: .2rem 0 .2rem .9rem; margin-bottom: 1rem; }
.note .meta { color: var(--muted); font-size: .82rem; }
.low { color: var(--bad); font-weight: 700; }
.tabs-anchor { scroll-margin-top: 1rem; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, #e3f2f2, #f4f7f8 60%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 2rem; box-shadow: 0 10px 30px rgba(13, 110, 110, .08); }
.login-card .brand { color: var(--brand-dark); margin-left: 0; }
.login-card .brand .cross { background: var(--brand); color: #fff; }
.login-card form > div { margin-bottom: .9rem; }
.login-card button { width: 100%; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  main { padding: 1.25rem 1rem 2rem; }
  .kv { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .no-print, .flash { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
}

/* fleet & parcels extras */
.badge.available, .badge.delivered, .badge.arrived { background: var(--ok-soft); color: var(--ok); }
.badge.on_trip, .badge.in_transit, .badge.maintenance, .badge.soon { background: var(--warn-soft); color: var(--warn); }
.badge.retired, .badge.returned, .badge.expired { background: var(--bad-soft); color: var(--bad); }
.badge.planned, .badge.registered { background: var(--brand-soft); color: var(--brand-dark); }
.bar { height: 10px; background: #e6edef; border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); }
.bar.full > span { background: var(--bad); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid var(--line); margin-left: .4rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.timeline li:first-child::before { box-shadow: 0 0 0 4px var(--brand-soft); }
.timeline li:last-child { border-left-color: transparent; }
.track-box { max-width: 560px; margin: 0 auto; }
.waybill { max-width: 640px; margin: 0 auto; background: #fff; border: 2px solid var(--ink); padding: 1.25rem 1.5rem; }
.waybill h1 { font-size: 1.3rem; }
.waybill .big { font-size: 1.6rem; font-weight: 800; letter-spacing: .08em; font-family: ui-monospace, Menlo, Consolas, monospace; }
.waybill table td, .waybill table th { border-bottom: 1px dashed #aaa; }
.code-box { border: 2px dashed var(--ink); padding: .6rem 1rem; text-align: center; margin: 1rem 0; }
.code-box .big { font-size: 2rem; }
