:root {
  --brand: #1E6F5C;
  --brand-on: #ffffff;
  --accent: #1D9E75;
  --bg: #f6f7f6;
  --surface: #ffffff;
  --surface-2: #eef1ef;
  --text: #1a1c1b;
  --text-2: #5b615e;
  --text-3: #888f8b;
  --border: rgba(0,0,0,0.10);
  --danger: #b3261e;
  --warn-bg: #faeeda;
  --warn-fg: #854f0b;
  --radius: 12px;
  --radius-sm: 8px;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #6FD8BF; --brand-on: #04342c;
    --accent: #5DCAA5;
    --bg: #101413; --surface: #181d1b; --surface-2: #222825;
    --text: #e7eae8; --text-2: #aab2ae; --text-3: #828b86;
    --border: rgba(255,255,255,0.12);
    --warn-bg: #3a2e16; --warn-fg: #f0c97a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.5;
}

.app {
  max-width: 480px; margin: 0 auto; min-height: 100%;
  background: var(--bg); display: flex; flex-direction: column;
  position: relative;
}

.appbar {
  position: sticky; top: 0; z-index: 5;
  height: 56px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 0.5px solid var(--border);
  font-size: 18px; font-weight: 500;
  padding-top: env(safe-area-inset-top);
}
.appbar-right { display: flex; align-items: center; gap: 10px; }
.net { color: var(--accent); font-size: 12px; }
.net.off { color: var(--text-3); }
.iconbtn { background: transparent; border: none; color: var(--text-2); cursor: pointer; padding: 6px; border-radius: 50%; display: inline-flex; }
.iconbtn[hidden] { display: none; }
.iconbtn:active { background: var(--surface-2); }

.view { flex: 1; padding: 14px 16px calc(var(--nav-h) + 16px); }

.bottomnav {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; background: var(--surface);
  border-top: 0.5px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav button {
  flex: 1; background: transparent; border: none; cursor: pointer;
  padding: 8px 2px 10px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-3); font-size: 11px; font-family: inherit;
}
.bottomnav button.on { color: var(--accent); }
.nic svg, .nic { width: 24px; height: 24px; }
svg { display: block; }

h1 { font-size: 22px; font-weight: 500; margin: 0; }
h2 { font-size: 16px; font-weight: 500; margin: 0; }
.muted { color: var(--text-2); font-size: 13px; }
.hint { color: var(--text-3); font-size: 12px; }
.sec { font-size: 12px; color: var(--text-2); margin: 16px 0 4px; }

.chiprow { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 999px; padding: 7px 13px; font-size: 13px; color: var(--text-2); border: none; cursor: pointer; font-family: inherit; }
.chip svg { width: 16px; height: 16px; }

.card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.card.flat { background: var(--surface-2); border: none; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 0.5px solid var(--border); }
.row:last-child { border-bottom: none; }
.row .lead { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row .lead svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
.right { text-align: right; }

.banner { background: var(--warn-bg); color: var(--warn-fg); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 12px; display: flex; gap: 8px; align-items: center; margin: 8px 0; }

.fab { position: fixed; right: 0; left: 0; max-width: 480px; margin: 0 auto; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); pointer-events: none; }
.fab > button { pointer-events: auto; position: absolute; right: 16px; width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: #fff; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.fab svg { width: 26px; height: 26px; }

button.primary { background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); padding: 12px 16px; font-size: 15px; font-weight: 500; width: 100%; cursor: pointer; font-family: inherit; }
button.primary:disabled { opacity: .5; }
button.ghost { background: transparent; color: var(--accent); border: 0.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; cursor: pointer; font-family: inherit; }
.pill { background: var(--accent); color: #fff; border: none; border-radius: 999px; padding: 7px 14px; font-size: 12px; display: inline-flex; gap: 5px; align-items: center; cursor: pointer; font-family: inherit; }
.pill svg { width: 15px; height: 15px; }

label { font-size: 13px; color: var(--text-2); display: block; margin: 10px 0 4px; }
input, select { width: 100%; height: 44px; border: 0.5px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 0 12px; font-size: 15px; font-family: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.addrow { display: flex; gap: 8px; margin-top: 12px; }
.addrow input { flex: 1; }
.addrow button { white-space: nowrap; }

.daychips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.daychip { border: 0.5px solid var(--border); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--text-2); background: transparent; cursor: pointer; white-space: nowrap; font-family: inherit; }
.daychip.on { background: #E1F5EE; color: #0F6E56; border-color: #9FE1CB; }
@media (prefers-color-scheme: dark) { .daychip.on { background: #0F6E56; color: #E1F5EE; border-color: #1D9E75; } }

.check { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: #fff; cursor: pointer; flex: none; }
.check.on { background: var(--accent); border-color: var(--accent); }
.check svg { width: 14px; height: 14px; }

.arrows button { background: transparent; border: none; color: var(--text-3); cursor: pointer; padding: 2px 4px; }
.arrows svg { width: 18px; height: 18px; }

.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty svg { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 8px; }

.ringwrap { display: flex; align-items: center; gap: 16px; margin: 14px 2px 6px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 80px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.appbar-left { display: flex; align-items: center; gap: 4px; min-width: 0; }
.app.is-list .bottomnav { display: none; }
.app.is-list .view { padding-bottom: 24px; }

.tripcard { display: block; width: 100%; text-align: left; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; cursor: pointer; font-family: inherit; color: var(--text); }
.tripcard:active { background: var(--surface-2); }
.tripcard-title { font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.tripcard-title svg { width: 18px; height: 18px; color: var(--accent); }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); text-transform: capitalize; }
.badge-active { background: #E1F5EE; color: #0F6E56; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.tripmap { height: 200px; border-radius: var(--radius); overflow: hidden; border: 0.5px solid var(--border); background: var(--surface-2); }
.tripmap-empty { height: auto; min-height: 0; }
.leaflet-container { font: inherit; background: var(--surface-2); }

.modebar { position: sticky; top: 56px; z-index: 4; background: var(--surface); border-bottom: 0.5px solid var(--border); padding: 8px 16px; }
.app.is-list .modebar { display: none; }
.segwrap { display: flex; gap: 6px; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.seg { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; background: transparent; color: var(--text-2); padding: 8px; border-radius: 999px; font-size: 13px; font-family: inherit; cursor: pointer; }
.seg svg { width: 16px; height: 16px; }
.seg.on { background: var(--surface); color: var(--accent); font-weight: 500; }
@media (prefers-color-scheme: dark) { .seg.on { background: #0c1311; } }

.chip.mini { padding: 5px 10px; font-size: 12px; gap: 4px; }
.chip.mini svg { width: 14px; height: 14px; }
.chip.mini.on { background: var(--accent); color: #fff; }
.chip[disabled] { opacity: .4; pointer-events: none; }

.numdot { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.tag { font-size: 10px; padding: 2px 7px; border-radius: 999px; vertical-align: middle; }
.tag-added { background: #E6F1FB; color: #0C447C; }
.tag-done { background: #E1F5EE; color: #0F6E56; }
.tag-skip { background: var(--surface-2); color: var(--text-3); }
.row.exec.is-skip .lead { opacity: .55; text-decoration: line-through; }

.metricgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
.metric { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 8px; text-align: center; }
.metric-l { font-size: 11px; color: var(--text-2); }
.metric-v { font-size: 20px; font-weight: 500; }

textarea { width: 100%; border: 0.5px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 15px; font-family: inherit; resize: vertical; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.mb-cover { text-align: center; padding: 22px 16px; background: var(--surface-2); border-radius: var(--radius); margin-bottom: 12px; }
.mb-cover svg { width: 28px; height: 28px; color: var(--accent); }
.mb-dest { font-size: 24px; font-weight: 500; margin-top: 4px; }
.mb-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.mb-actions { display: flex; gap: 8px; margin-top: 18px; }

.jr-photo { display: block; max-width: 100%; border-radius: var(--radius-sm); margin-top: 8px; }
.mapped { color: var(--accent); margin-left: 4px; display: inline-flex; }
.mapped svg { width: 14px; height: 14px; }
input[type=file] { width: 100%; font-size: 13px; color: var(--text-2); padding: 8px 0; height: auto; border: none; background: transparent; }

.app.is-auth .appbar, .app.is-auth .modebar, .app.is-auth .bottomnav { display: none; }
.auth { max-width: 360px; margin: 0 auto; padding: 28px 2px; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand svg { width: 40px; height: 40px; color: var(--accent); }
.auth-title { font-size: 22px; font-weight: 500; margin-top: 8px; }
.auth-sub { color: var(--text-2); font-size: 14px; }
.auth-err { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 16px; }
.linkish { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

.member-pick { display: flex; align-items: center; gap: 8px; padding: 7px 0; cursor: pointer; }
.member-pick input { width: auto; height: auto; }

.driver { text-align: center; padding: 24px 16px 40px; display: flex; flex-direction: column; align-items: center; }
.driver-label { color: var(--text-2); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.driver-label svg { width: 18px; height: 18px; }
.driver-local { font-size: 30px; font-weight: 500; line-height: 1.35; margin: 14px 0; }
.driver-en { color: var(--text-2); font-size: 15px; }
.driver-name { margin-top: 12px; font-size: 14px; color: var(--text-3); }

@media print {
  .appbar, .modebar, .bottomnav, .fab, .mb-actions, #install, #settings-btn, #back-btn, #net { display: none !important; }
  .app { max-width: none; }
  .view { padding: 0 !important; }
  body { background: #fff; color: #000; }
}
