/* Tria Logistics — Tria look (blue #3a4f81, purple #3b245d, white and cool greys) */
:root {
  --accent: #3a4f81;
  --accent-2: #3b245d;
  --accent-soft: #e8ecf5;
  --surface: #ffffff;
  --bg: #f4f5f8;
  --line: #d6dae3;
  --fg: #181b26;
  --muted: #5d6475;
  --ok: #2b8a3e;     --ok-bg: #e6f4ea;
  --warn: #b26a00;   --warn-bg: #fff3dc;
  --bad: #c92a2a;    --bad-bg: #fde8e8;
  --info: #3a4f81;   --info-bg: #e8ecf5;
  --off: #6b7280;    --off-bg: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(24,27,38,.06), 0 2px 8px rgba(24,27,38,.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { touch-action: manipulation; -webkit-tap-highlight-color: rgba(58,79,129,.15); }
body {
  background: var(--bg); color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
a:hover { color: var(--accent-2); }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.boot { padding: 60px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* ---------- header ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 500; }
.top::before { content: ""; display: block; height: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.top-in { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--fg); }
.brand img { height: 44px; display: block; }
.brand span { font-weight: 700; font-size: 18px; color: var(--accent); border-left: 1px solid var(--line); padding-left: 12px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a { white-space: nowrap; text-decoration: none; color: var(--muted); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 15px; display: flex; gap: 6px; align-items: center; }
.tabs a:hover { background: var(--bg); color: var(--fg); }
.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.tabs .count { background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.who button { font-size: 14px; }

@media (max-width: 1100px) {
  .who .who-name { display: none; }
  .tabs a { padding: 8px 10px; }
  .top-in { gap: 12px; }
}

/* bottom bar on phones */
.bottom { display: none; }
@media (max-width: 760px) {
  .tabs, .who .who-name { display: none; }
  .top-in { padding: 8px 12px; }
  .brand img { height: 36px; }
  .brand span { font-size: 16px; }
  .who { margin-left: auto; }
  .bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 600; background: var(--surface);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .bottom a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; padding: 8px 0 7px; position: relative; }
  .bottom a .ic { display: flex; justify-content: center; align-items: center; height: 28px; }
  .bottom a .ic svg { width: 30px; height: 24px; fill: currentColor; }
  .bottom a.on { color: var(--accent); }
  .bottom .count { position: absolute; top: 4px; left: 54%; background: var(--bad); color: #fff; border-radius: 10px; font-size: 10px; padding: 0 5px; }
  main { padding-bottom: 80px !important; }
}

main { max-width: 1200px; margin: 0 auto; padding: 18px 16px 40px; }
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.pagehead .grow { flex: 1; }

/* ---------- buttons & inputs ---------- */
button, .btn {
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; border-radius: 8px; padding: 9px 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center; min-height: 40px;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
button.big { font-size: 17px; padding: 12px 20px; min-height: 48px; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; min-height: 0; }
button.link:hover { color: var(--accent-2); text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }

input, select, textarea {
  font: inherit; font-size: 16px; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 76px; resize: vertical; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
label.f > span em { font-style: normal; font-weight: 400; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; gap: 0; } }
.inline-add { display: flex; gap: 6px; }
.inline-add select { flex: 1; }
.search { max-width: 280px; }
@media (max-width: 760px) { .search { max-width: none; } }

/* chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 6px 12px; font-size: 14px; font-weight: 600;
  min-height: 0; color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { opacity: .75; font-weight: 500; margin-left: 2px; }
.pickchips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pickchips .chip { padding: 4px 10px; font-size: 13px; }

/* ---------- summary tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
@media (max-width: 760px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; text-align: left;
  display: block; min-height: 0; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 28px; line-height: 1.1; }
.tile span { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile.bad b { color: var(--bad); } .tile.warn b { color: var(--warn); } .tile.ok b { color: var(--ok); } .tile.info b { color: var(--accent); }

/* ---------- lists ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid;
  grid-template-columns: 1fr auto; gap: 4px 12px; cursor: pointer; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.item:hover { border-color: var(--accent); }
.item .t { font-weight: 700; font-size: 16px; }
.item .t small { font-weight: 500; color: var(--muted); font-size: 13px; margin-left: 4px; }
.item .meta { color: var(--muted); font-size: 14px; display: flex; gap: 4px 14px; flex-wrap: wrap; grid-column: 1 / -1; }
.item .right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .btn, .empty button { margin-top: 10px; }

.badge { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.b-on { background: var(--ok-bg); color: var(--ok); }
.b-soon { background: var(--warn-bg); color: var(--warn); }
.b-over { background: var(--bad-bg); color: var(--bad); }
.b-booked { background: var(--info-bg); color: var(--info); }
.b-ret { background: var(--off-bg); color: var(--off); }
.b-planned { background: var(--info-bg); color: var(--info); }
.b-done { background: var(--ok-bg); color: var(--ok); }
.b-cancelled { background: var(--off-bg); color: var(--off); text-decoration: line-through; }
.kind { font-weight: 700; }
.kind.pickup { color: var(--accent); } .kind.return { color: var(--accent-2); } .kind.move { color: var(--warn); }

/* ---------- rental page ---------- */
.back { display: inline-flex; margin-bottom: 10px; }
.detail { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }
.hero { padding: 16px; }
.hero h1 { font-size: 22px; }
.hero .sub { color: var(--muted); margin-top: 2px; }
.dates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.dates div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.dates small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.dates b { font-size: 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 15px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.section { padding: 16px; margin-top: 16px; }
.section .sh { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.section .sh h2 { margin: 0; }
.map { height: 260px; border-radius: 8px; border: 1px solid var(--line); z-index: 1; }
.map.big { height: calc(100vh - 210px); min-height: 380px; }
.files a.file { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--fg); }
.files a.file:last-child { border-bottom: 0; }
.files .fi { width: 36px; height: 36px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11px; font-weight: 800; flex: none; }
.files .fn { flex: 1; min-width: 0; }
.files .fn b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .fn small { color: var(--muted); }
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 8px 0 8px 16px; border-left: 2px solid var(--line); position: relative; font-size: 14px; }
.history li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.history li.h-extended::before { background: var(--warn); } .history li.h-returned::before { background: var(--off); }
.history li.h-trip::before { background: var(--accent); } .history li.h-created::before { background: var(--ok); }
.history li.h-moved::before { background: var(--accent-2); } .history li.h-note::before { background: var(--fg); }
.history small { display: block; color: var(--muted); font-size: 12px; }
.trip-line { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.trip-line:last-child { border-bottom: 0; }
.trip-line .tl-main { flex: 1 1 240px; min-width: 0; }
.trip-line .tl-main .meta { font-size: 14px; color: var(--muted); }

/* ---------- trips page ---------- */
.day { margin-bottom: 18px; }
.day > h3 { display: flex; align-items: center; gap: 10px; }
.day > h3 .today { background: var(--accent); color: #fff; border-radius: 6px; padding: 1px 7px; font-size: 12px; text-transform: none; letter-spacing: 0; }
.trip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 8px;
  display: grid; grid-template-columns: 78px 1fr auto; gap: 10px; align-items: start; }
.trip .time { font-weight: 700; color: var(--accent); white-space: nowrap; }
.trip .what { font-weight: 700; }
.trip .route { font-size: 14px; color: var(--muted); }
.trip .drv { font-size: 14px; margin-top: 2px; }
.trip .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 250px; }
.trip .acts button { font-size: 14px; padding: 6px 10px; min-height: 36px; }
.trip.done { opacity: .75; }
@media (max-width: 600px) {
  .trip { grid-template-columns: 1fr; }
  .trip .acts { width: auto; }
}
.nodriver { color: var(--bad); font-weight: 600; }

/* ---------- settings ---------- */
.settabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
table.plain { width: 100%; border-collapse: collapse; font-size: 15px; }
table.plain th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.plain td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plain tr:last-child td { border-bottom: 0; }
table.plain tr.off td { color: var(--muted); }
@media (max-width: 700px) {
  table.plain thead { display: none; }
  table.plain tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.plain td { display: block; border: 0; padding: 2px 10px; }
}

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(24,27,38,.45); z-index: 1000; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; flex: 1; }
.modal header button { border: 0; font-size: 24px; padding: 0 6px; min-height: 0; color: var(--muted); }
.modal .mb { padding: 16px 18px; }
.modal footer { padding: 12px 18px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); }
.modal .err { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-weight: 600; }
@media (max-width: 600px) {
  .modal-back { padding: 0; align-items: flex-end; }
  .modal { border-radius: 14px 14px 0 0; max-height: 94vh; overflow-y: auto; }
  .modal footer { position: sticky; bottom: 0; background: var(--surface); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal footer button { flex: 1; }
}
.pickmap { height: 240px; border-radius: 8px; border: 1px solid var(--line); margin-top: 8px; }
.addr-row { display: flex; gap: 6px; }
.addr-row input { flex: 1; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 20px; background: var(--bg); padding: 10px; border-radius: 8px; text-align: center; letter-spacing: 1px; user-select: all; }

/* ---------- sign-in ---------- */
.auth { max-width: 400px; margin: 8vh auto; padding: 0 16px; }
.auth .card { padding: 26px 24px; }
.auth .logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth .logo img { height: 150px; }
.auth .logo b { color: var(--accent); font-size: 20px; }
.auth button.primary { width: 100%; margin-top: 6px; }

/* ---------- home-screen box, update button ---------- */
.install { display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 14px; border-color: var(--accent); background: var(--accent-soft); flex-wrap: wrap; }
.install img { width: 44px; height: 44px; border-radius: 10px; }
.install > div:nth-child(2) { flex: 1 1 220px; }
.install .shareic { display: inline-block; border: 1px solid var(--muted); border-radius: 4px; padding: 0 4px; font-size: 12px; }
.updbar { position: fixed; left: 12px; bottom: 12px; z-index: 1500; background: var(--accent); color: #fff; border-radius: 10px; padding: 8px 8px 8px 14px;
  display: flex; gap: 10px; align-items: center; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.updbar button { background: #fff; color: var(--accent); border: 0; min-height: 34px; padding: 6px 12px; }
@media (max-width: 760px) { .updbar { bottom: calc(72px + env(safe-area-inset-bottom)); } }

/* small solid icons inside the screens */
svg.i { width: 1.05em; height: 1.05em; fill: currentColor; vertical-align: -0.17em; flex: none; }
button svg.i, .btn svg.i { width: 1.15em; height: 1.15em; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--fg); color: #fff; padding: 10px 18px; border-radius: 8px;
  z-index: 2000; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; }
.toast.bad { background: var(--bad); }
@media (max-width: 760px) { .toast { bottom: 84px; } }

/* map pins */
.pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.pin.on { background: var(--ok); } .pin.soon { background: var(--warn); } .pin.over { background: var(--bad); }
.pin { position: relative; }
.pin-n { position: absolute; top: -12px; right: -14px; background: var(--fg); color: #fff; font: 700 11px/16px sans-serif; min-width: 16px; padding: 0 4px; border-radius: 8px; text-align: center; }
.pin.booked { background: var(--accent); } .pin.ret { background: var(--off); } .pin.proj { background: var(--accent-2); border-radius: 4px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 8px 0; align-items: center; }
.legend .pin { display: inline-block; vertical-align: -4px; margin-right: 4px; width: 14px; height: 14px; border-width: 2px; }
.leaflet-popup-content { font: 14px/1.4 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }

/* ---------- print (driver sheet) ---------- */
.printonly { display: none; }
@media print {
  .top, .bottom, .noprint, .toast { display: none !important; }
  .printonly { display: block; }
  body { background: #fff; font-size: 12pt; }
  main { padding: 0; max-width: none; }
  .trip { box-shadow: none; break-inside: avoid; grid-template-columns: 60px 1fr; }
  .trip .acts { display: none; }
  .day { break-inside: avoid-page; }
}
