:root {
  --brand: #0f766e; --brand-d: #115e59; --bg: #f5f7f6; --card: #fff; --text: #1c2b29; --muted: #6b7a77;
  --line: #dfe6e4; --warn: #c2410c; --danger: #b91c1c; --done: #4b5563; --prog: #0f766e; --plan: #94a3b8;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Noto Sans TC", "PingFang TC", sans-serif; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; line-height: 1.25; } h1 { font-size: 1.15rem; } h2 { font-size: 1.05rem; }
button, input, select, textarea { font: inherit; }
button { min-height: 40px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
button.danger { color: var(--danger); }
button.big { min-height: 48px; font-size: 1.05rem; font-weight: 600; padding: 8px 22px; }
button.link { border: 0; background: none; color: var(--brand); min-height: 0; padding: 2px 6px; text-decoration: underline; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
label { display: block; margin: 10px 0; font-size: .9rem; color: var(--muted); } label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .center { text-align: center; }
.error { color: var(--danger); min-height: 1.2em; margin: 6px 0; font-size: .9rem; }

.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); padding-top: max(10px, env(safe-area-inset-top)); }
.bar-title { flex: 1; min-width: 0; } .bar-title h1, .bar-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-title small { color: var(--muted); font-size: .78rem; }
.owner-badge, .readonly-badge { font-size: .75rem; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.owner-badge { background: #ccfbf1; color: var(--brand-d); } .readonly-badge { background: #e0e7ff; color: #3730a3; }

.page { max-width: 760px; margin: 0 auto; padding: 14px; }
.center-card { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; width: 100%; max-width: 420px; }
.cards { display: grid; gap: 12px; } .cards .card { max-width: none; } .cards p { margin: 4px 0; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tab { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; min-width: 64px; padding: 6px 10px; border-radius: 12px; line-height: 1.2; }
.tab small { color: var(--muted); font-size: .72rem; } .tab.on { background: var(--brand); border-color: var(--brand); color: #fff; } .tab.on small { color: #d1fae5; }

.now { background: #ecfdf5; color: var(--brand-d); padding: 8px 14px; font-weight: 600; border-bottom: 1px solid #a7f3d0; }

.seg { display: flex; padding: 8px 12px; gap: 8px; background: #fff; border-bottom: 1px solid var(--line); } .seg button { flex: 1; } .seg button.on { background: #ccfbf1; border-color: var(--brand); font-weight: 600; }
.split[data-pane="list"] #mapPane { display: none; } .split[data-pane="map"] #listPane { display: none; }
#mapPane { position: relative; height: calc(100vh - 170px); min-height: 360px; } #map { position: absolute; inset: 0; }
.fab { position: absolute; left: 10px; bottom: 22px; z-index: 5; box-shadow: 0 2px 8px #0003; }
.map-msg { padding: 20px; color: var(--muted); }
#listPane { padding: 10px 12px 80px; max-width: 760px; margin: 0 auto; }
.pane-actions { display: flex; gap: 8px; margin-bottom: 10px; } .pane-actions .primary { flex: 1; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
.stop { background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--plan); border-radius: 14px; padding: 12px; }
.stop.in_progress { border-left-color: var(--prog); box-shadow: 0 0 0 2px #99f6e4; } .stop.completed { border-left-color: var(--done); }
.stop.hl { outline: 3px solid #fbbf24; } .stop.ghost { opacity: .4; }
.stop-head { display: flex; gap: 10px; align-items: flex-start; }
.drag { cursor: grab; font-size: 1.4rem; line-height: 1; padding: 8px 4px; color: var(--muted); touch-action: none; user-select: none; }
.num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: .85rem; font-weight: 700; }
.stop-main { flex: 1; min-width: 0; cursor: pointer; }
.t-title { font-weight: 700; font-size: 1.05rem; } .t-plan { color: var(--muted); font-size: .9rem; } .t-plan b { color: var(--text); }
.t-actual { color: var(--brand-d); font-weight: 600; font-size: .92rem; } .t-actual em { font-style: normal; font-weight: 400; color: var(--warn); margin-left: 6px; }
.t-addr, .t-notes { font-size: .88rem; color: var(--muted); margin-top: 6px; white-space: pre-wrap; }
.stop-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.badge { display: inline-block; margin-top: 4px; padding: 2px 9px; border-radius: 99px; font-size: .75rem; }
.s-planned { background: #e2e8f0; color: #475569; } .s-in_progress { background: #ccfbf1; color: var(--brand-d); } .s-completed { background: #e5e7eb; color: var(--done); }
.leg { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: #f0fdfa; font-size: .88rem; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.leg.manual { background: #fffbeb; } .leg.muted { background: #f1f5f9; color: var(--muted); } .leg.err { background: #fef2f2; color: var(--danger); }

.pin { width: 30px; height: 30px; padding: 0; min-height: 0; border-radius: 50%; border: 3px solid #fff; background: var(--plan); color: #fff; font-weight: 700; box-shadow: 0 1px 6px #0006; }
.pin.s-in_progress { background: var(--prog); transform: scale(1.2); } .pin.s-completed { background: var(--done); }

dialog { width: min(520px, calc(100vw - 20px)); max-height: 92vh; border: 0; border-radius: 16px; padding: 18px; box-shadow: 0 10px 40px #0005; }
dialog::backdrop { background: #0008; }
.dlg-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.search-row { display: flex; gap: 8px; } .results { list-style: none; margin: 6px 0; padding: 0; } .results button { width: 100%; text-align: left; margin-bottom: 4px; }
#shareUrl { margin: 8px 0; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 30px); opacity: 0; transition: .25s; background: #111827; color: #fff; padding: 10px 16px; border-radius: 99px; z-index: 100; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); } #toast.err { background: var(--danger); }

@media (min-width: 900px) {
  .seg { display: none; }
  .split { display: grid; grid-template-columns: minmax(380px, 480px) 1fr; height: calc(100vh - 128px); }
  .split[data-pane] #mapPane, .split[data-pane] #listPane { display: block !important; }
  #listPane { overflow-y: auto; max-width: none; margin: 0; width: 100%; } #mapPane { height: 100%; }
}
