:root {
  --green:#068443;
  --green-dark:#056b37;
  --green-soft:#e3f3ea;
  --accent:#c55a11;
  --red:#c62828;
  --ink:#1f2a37;
  --muted:#5a6573;
  --line:#e2e6eb;
  --bg:#f2f4f6;
  --card:#ffffff;
  font-family:system-ui,-apple-system,"PingFang TC","Noto Sans TC","Microsoft JhengHei",sans-serif;
  color:var(--ink);
  background:#dfe3e8;
  font-size:16px;
  line-height:1.5;
}
* {
  box-sizing:border-box;
}
body {
  margin:0;
}
button,input,select {
  font:inherit;
  color:inherit;
}
h1,h2,h3,p {
  margin:0;
}

/* ── 按鈕 ── */
button,a.btn {
  min-height:48px;
  border:1px solid #c8ced6;
  border-radius:12px;
  padding:10px 14px;
  background:white;
  cursor:pointer;
  font-size:16px;
}
button:focus-visible,a:focus-visible,select:focus-visible,input:focus-visible,summary:focus-visible {
  outline:3px solid #2b6de0;
  outline-offset:2px;
}
a.btn {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  border-color:#2b6de0;
  color:#1d5bc4;
}
button.primary {
  background:var(--green);
  color:white;
  border-color:var(--green);
  font-weight:600;
}
button.danger {
  color:var(--red);
  border-color:#e3a6a6;
}
button.text-btn {
  min-height:44px;
  border:none;
  background:none;
  color:var(--muted);
  text-decoration:underline;
  padding:8px;
}
.full {
  display:block;
  width:100%;
  margin-top:14px;
}
.actions {
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:10px;
}
.actions>* {
  flex:1 1 0;
  min-width:0;
}
.selected {
  background:var(--accent)!important;
  border-color:var(--accent)!important;
  color:white!important;
}

/* ── 外框 ── */
#app {
  max-width:560px;
  margin:auto;
  height:100vh;
  height:100dvh;
  display:flex;
  flex-direction:column;
  position:relative;
  overflow:hidden;
  background:var(--bg);
}
.banner {
  flex:none;
  height:26px;
  line-height:26px;
  text-align:center;
  font-size:13px;
  font-weight:700;
  background:#ffe08a;
  color:#4d3800;
}
#screen {
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
}
.topbar {
  flex:none;
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 8px 6px 16px;
  background:white;
  border-bottom:1px solid var(--line);
}
.brand {
  flex:1;
  font-size:18px;
  color:var(--green-dark);
}
.me {
  font-weight:700;
}
.segmented {
  flex:none;
  display:flex;
  gap:4px;
  margin:8px 16px 0;
  padding:4px;
  background:#e2e6ea;
  border-radius:12px;
}
.segmented button {
  flex:1;
  min-height:44px;
  border:none;
  border-radius:9px;
  background:none;
  font-weight:600;
  color:var(--muted);
  position:relative;
}
.segmented button.on {
  background:white;
  color:var(--ink);
  box-shadow:0 1px 3px #0002;
}
.page {
  flex:1;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  overscroll-behavior:contain;
  padding:14px 16px 24px;
  overflow-wrap:anywhere;
}
.tabbar {
  flex:none;
  display:flex;
  background:white;
  border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom);
}
.tab {
  flex:1 1 0;
  min-width:0;
  min-height:58px;
  border:none;
  border-radius:0;
  background:none;
  padding:6px 2px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  font-size:13px;
  color:var(--muted);
}
.tab.on {
  color:var(--green);
  font-weight:700;
}
.tab-icon {
  position:relative;
  width:26px;
  height:26px;
}
.tab-icon svg {
  width:26px;
  height:26px;
}
.tab-count {
  position:absolute;
  top:-4px;
  right:-12px;
  min-width:20px;
  height:20px;
  padding:0 5px;
  border-radius:10px;
  background:var(--red);
  color:white;
  font-size:12px;
  line-height:20px;
  font-weight:700;
}
.dot {
  position:absolute;
  top:6px;
  right:10px;
  width:9px;
  height:9px;
  border-radius:50%;
  background:var(--red);
}
.tab-icon .dot {
  top:-1px;
  right:-4px;
}

/* ── 下一層（蓋上來的整頁）── */
#overlay {
  position:absolute;
  inset:26px 0 0;
  background:var(--bg);
  z-index:20;
  display:flex;
  flex-direction:column;
  animation:slide .18s ease-out;
}
#overlay[hidden] {
  display:none;
}
.subbar {
  flex:none;
  display:grid;
  grid-template-columns:96px 1fr 96px;
  align-items:center;
  background:white;
  border-bottom:1px solid var(--line);
  padding:4px 8px;
}
.subbar strong {
  text-align:center;
  font-size:17px;
}
.back-btn {
  border:none;
  background:none;
  color:var(--green-dark);
  font-weight:600;
  text-align:left;
  padding:8px;
}
.sub-body {
  flex:1;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:14px 16px 32px;
  overflow-wrap:anywhere;
}
@keyframes slide {
  from {
    transform:translateX(30px);
    opacity:.6;
  }
  to {
    transform:none;
    opacity:1;
  }
}
@media(prefers-reduced-motion:reduce) {
  #overlay {
    animation:none;
  }
}

/* ── 登入頁 ── */
.login {
  flex:1;
  overflow-y:auto;
  padding:40px 20px 24px;
}
.login-brand {
  text-align:center;
  margin-bottom:32px;
}
.login-brand h1 {
  font-size:30px;
  color:var(--green-dark);
}
.login-brand p {
  color:var(--muted);
  margin-top:4px;
}
.login h2 {
  font-size:16px;
  color:var(--muted);
  margin-bottom:10px;
}
.login-person {
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  min-height:72px;
  margin-bottom:10px;
  padding:12px 16px;
  text-align:left;
  border-color:var(--line);
  box-shadow:0 1px 2px #0001;
}
.login-text {
  flex:1;
  min-width:0;
}
.login-text strong {
  display:block;
  font-size:20px;
}
.login-text span {
  color:var(--muted);
  font-size:15px;
}
.count-badge {
  flex:none;
  background:var(--red);
  color:white;
  border-radius:999px;
  padding:2px 10px;
  font-size:13px;
  font-weight:700;
}
.chev {
  flex:none;
  color:#8a94a1;
  font-size:22px;
  line-height:1;
}
.fine {
  font-size:13px;
  color:var(--muted);
  margin-top:10px;
}
.login .fine {
  text-align:center;
  margin-top:24px;
}
.login .text-btn {
  display:block;
  margin:4px auto 0;
  font-size:14px;
}

/* ── 頁面共用 ── */
.page-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:12px;
}
.page-head h2 {
  font-size:20px;
}
.section-title {
  font-size:16px;
  color:var(--muted);
  margin:18px 2px 8px;
}
.card {
  background:var(--card);
  border-radius:14px;
  padding:14px;
  margin-bottom:12px;
  box-shadow:0 1px 2px #0000000f;
}
.muted,small {
  color:var(--muted);
}
.muted {
  font-size:15px;
}
small {
  font-size:14px;
}
.empty {
  text-align:center;
  color:var(--muted);
  padding:18px 0;
}
.place {
  font-size:15px;
  color:#3d4855;
}
.badge {
  display:inline-block;
  border-radius:6px;
  color:white;
  background:#2b6de0;
  padding:1px 7px;
  font-size:14px;
}
.badge.send {
  background:#c4510a;
}
.badge.both {
  background:#7046c9;
}
.urgent {
  color:#9a4f00;
  font-weight:700;
}
.progress-line {
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:8px;
  margin-bottom:6px;
}
.progress-line strong {
  font-size:18px;
}
.progress-line span {
  color:#4a5560;
  font-size:15px;
}
.progress {
  height:10px;
  border-radius:5px;
  background:#e3e7eb;
  overflow:hidden;
  margin-bottom:12px;
}
.progress span {
  display:block;
  height:100%;
  border-radius:5px;
  background:#068443;
}
.stats {
  display:flex;
  gap:8px;
  margin:10px 0;
}
.stats>div {
  flex:1;
  min-width:0;
  text-align:center;
  background:#f2f4f6;
  padding:8px 4px;
  border-radius:10px;
}
.stats small {
  display:block;
}
.stats strong {
  display:block;
  font-size:20px;
}
.tabs {
  display:flex;
  gap:8px;
  margin-bottom:12px;
}
.tabs button {
  flex:1;
}
.notice {
  background:#fff3cd;
  border-radius:12px;
  padding:12px;
  margin:10px 0;
}
.row {
  padding:10px 0;
  border-bottom:1px solid var(--line);
}
.row:last-child {
  border-bottom:none;
}
.row-main {
  display:flex;
  flex-direction:column;
  min-width:0;
}
.receipt {
  display:flex;
  justify-content:space-between;
  gap:8px;
}
.receipt strong {
  white-space:nowrap;
}
.total {
  font-weight:700;
  padding-top:10px;
  text-align:right;
}
.error {
  color:#b22424;
  margin:10px 0 0;
}
.error:empty {
  display:none;
}
.toast {
  position:absolute;
  left:16px;
  right:16px;
  bottom:calc(76px + env(safe-area-inset-bottom));
  z-index:40;
  background:#1f2a37;
  color:white;
  border-radius:12px;
  padding:12px 16px;
  font-size:15px;
  text-align:center;
  opacity:0;
  transform:translateY(8px);
  transition:opacity .2s,transform .2s;
  pointer-events:none;
}
.toast.show {
  opacity:1;
  transform:none;
}

/* ── 表單 ── */
label {
  display:block;
  margin:14px 0 6px;
  font-weight:600;
}
.form label:first-child {
  margin-top:0;
}
select,input[type=text],input[type=search] {
  display:block;
  width:100%;
  min-height:48px;
  background:#fff;
  border:1px solid #a9b1bc;
  border-radius:10px;
  padding:10px;
}
label.check {
  display:flex;
  align-items:center;
  gap:8px;
  min-height:44px;
  font-weight:500;
}
input[type=checkbox] {
  width:22px;
  height:22px;
}
.who-row {
  display:block;
  width:100%;
  text-align:left;
  margin:8px 0;
  padding:12px 14px;
  min-height:64px;
}
.who-name {
  display:flex;
  align-items:center;
  gap:8px;
  font-size:17px;
}
.who-detail {
  display:block;
  font-size:14px;
  color:var(--muted);
  margin-top:3px;
}
.who-row.selected .who-detail {
  color:white;
}
.who-row.auto-card {
  border:2px solid var(--green);
}
.who-sub {
  margin:14px 0 4px;
  font-weight:600;
}
.who-hint {
  margin:0;
}
.near-badge,.off-badge,.duty {
  border-radius:6px;
  padding:1px 8px;
  font-size:13px;
  font-weight:700;
}
.near-badge,.duty.on {
  background:var(--green);
  color:white;
}
.off-badge,.duty.off {
  background:#e2e6ea;
  color:#4a5563;
}
.who-row.selected .near-badge,.who-row.selected .off-badge {
  background:white;
  color:var(--ink);
}
.result-card .result-line {
  font-size:18px;
  font-weight:700;
  margin-bottom:4px;
}

/* ── 通知與提醒 ── */
.notices,.alerts {
  margin-bottom:12px;
}
.notice-card {
  background:white;
  border-left:5px solid var(--green);
  border-radius:12px;
  padding:12px 14px;
  margin-bottom:10px;
  box-shadow:0 1px 3px #0000001a;
}
.notice-card.hot {
  border-left-color:#d9480f;
  background:#fff6ef;
}
.notice-card p {
  font-weight:600;
}
.notice-foot {
  display:flex;
  align-items:flex-end;
  gap:10px;
}
.notice-foot .actions {
  flex:1;
  justify-content:flex-end;
}
.notice-foot .actions>* {
  flex:0 1 auto;
  min-width:84px;
}
.alert {
  display:flex;
  align-items:center;
  justify-content:space-between;
  width:100%;
  margin-bottom:8px;
  text-align:left;
  background:#fff3cd;
  border-color:#f0d58a;
  font-weight:600;
}

/* ── 路線 ── */
.duty-toggle {
  flex:none;
  min-height:44px;
  border-radius:999px;
  padding:6px 16px;
  font-weight:700;
}
.duty-toggle.on {
  background:var(--green-soft);
  border-color:var(--green);
  color:var(--green-dark);
}
.duty-toggle.off {
  background:#e2e6ea;
  color:#4a5563;
}
.route-map {
  display:block;
  width:100%;
  height:140px;
  background:#eef4f1;
  border-radius:10px;
}
.summary .fine {
  margin-top:4px;
}
.stop-card {
  background:white;
  border-radius:14px;
  padding:14px;
  margin-bottom:10px;
  box-shadow:0 1px 2px #0000000f;
}
.stop-card.current {
  border:2px solid var(--green);
}
.next-label {
  color:var(--green-dark);
  font-size:14px;
  font-weight:700;
  margin-bottom:6px;
}
.stop-heading {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:6px;
  margin-bottom:4px;
}
.stop-heading strong {
  font-size:17px;
}
.stop-number {
  min-width:28px;
  height:28px;
  border-radius:50%;
  background:#2b6de0;
  color:white;
  text-align:center;
  line-height:28px;
  font-size:14px;
}
.stop-number.hot {
  background:#c25e00;
}
.stop-number.unplaced {
  background:#6b7480;
  border-radius:14px;
  padding:0 6px;
}
.stop-card .actions {
  flex-wrap:nowrap;
}
.inline-panel {
  background:#f2f4f6;
  border-radius:10px;
  padding:12px;
  margin-top:10px;
}
.inline-panel .actions {
  margin-top:6px;
}
.count-row button {
  padding:10px 2px;
  white-space:nowrap;
}
details.adjust summary {
  min-height:44px;
  padding:12px 0 0;
  color:var(--muted);
  font-size:15px;
  cursor:pointer;
}
.route-footer {
  display:flex;
  gap:8px;
  margin-top:14px;
}
.route-footer>* {
  flex:1;
  min-width:0;
  text-align:center;
}

/* ── 總覽、各人路線 ── */
.zone-block h3 {
  font-size:17px;
}
.person-row {
  display:flex;
  align-items:center;
  gap:8px;
  width:100%;
  text-align:left;
  border:none;
  border-top:1px solid var(--line);
  border-radius:0;
  background:none;
  padding:10px 2px;
  min-height:56px;
}
.person-row .row-main {
  flex:1;
}
details.person summary {
  min-height:48px;
  cursor:pointer;
  list-style:none;
}
details.person summary::-webkit-details-marker {
  display:none;
}
.person-head {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:8px;
}
.person-head strong {
  font-size:17px;
}
.where {
  display:block;
  margin-top:4px;
}
button.duty-for {
  min-height:44px;
  margin:10px 0 4px;
}

/* ── 記帳、交款 ── */
.cash-heading {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
}
.cash-heading .wait {
  color:#9a4f00;
  font-weight:700;
}
.cash-stats {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px;
  margin:12px 0 0;
}
.cash-stats small,.cash-stats strong {
  display:block;
}
.cash-stats strong {
  font-size:19px;
  overflow-wrap:anywhere;
}
.ok-line {
  font-weight:700;
  color:var(--green-dark);
  margin-top:8px;
}

/* ── 送達的收款面板（從下方升起）── */
.panel-wrap {
  position:absolute;
  inset:0;
  z-index:30;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
}
.panel-backdrop {
  position:absolute;
  inset:0;
  background:#0f172a80;
}
.panel {
  position:relative;
  max-height:88%;
  overflow-y:auto;
  overscroll-behavior:contain;
  background:white;
  border-radius:18px 18px 0 0;
  padding:8px 16px calc(18px + env(safe-area-inset-bottom));
  animation:rise .2s ease-out;
}
@keyframes rise {
  from {
    transform:translateY(40px);
    opacity:.6;
  }
  to {
    transform:none;
    opacity:1;
  }
}
@media(prefers-reduced-motion:reduce) {
  .panel {
    animation:none;
  }
}
.panel-head {
  display:grid;
  grid-template-columns:48px 1fr 48px;
  align-items:center;
  margin-bottom:6px;
}
.panel-head h2 {
  text-align:center;
  font-size:21px;
}
.icon-btn {
  min-height:48px;
  width:48px;
  padding:0;
  border:none;
  background:none;
  font-size:22px;
  color:var(--muted);
}
.item-list {
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
}
.item-row {
  display:flex;
  align-items:center;
  gap:12px;
  width:100%;
  min-height:52px;
  border:none;
  border-bottom:1px solid var(--line);
  border-radius:0;
  text-align:left;
  color:var(--muted);
}
.item-row:last-child {
  border-bottom:none;
}
.item-row.on {
  color:var(--ink);
}
.box {
  flex:none;
  width:24px;
  height:24px;
  border:2px solid #8a94a1;
  border-radius:6px;
  line-height:20px;
  text-align:center;
  font-weight:800;
  color:white;
}
.item-row.on .box {
  background:var(--green);
  border-color:var(--green);
}
.item-name {
  flex:1;
  min-width:0;
}
.item-price {
  font-weight:700;
  white-space:nowrap;
}
.panel input#dv-amount,.form input#rc-amount {
  font-size:22px;
  font-weight:700;
}
.chip {
  min-height:44px;
  margin-top:8px;
  padding:6px 14px;
  border-radius:999px;
  font-size:15px;
  color:var(--muted);
}
.chip.on {
  background:var(--green-soft);
  border-color:var(--green);
  color:var(--green-dark);
  font-weight:700;
}
.chips {
  display:flex;
  gap:8px;
}
.reason-list button {
  display:block;
  width:100%;
  margin-top:10px;
  font-size:17px;
}

/* ── 待收（藍色）── */
.is-pending,.is-pending strong {
  color:#1d5bc4;
}
.owed-line {
  font-size:14px;
  margin-top:8px;
}

/* ── 補記一筆 ── */
.field-title {
  font-weight:600;
  margin-bottom:8px;
}
.shop-chips {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:12px;
}
.shop-chip {
  flex:1 1 40%;
  min-width:0;
  min-height:52px;
  font-weight:600;
}
.search-hits {
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:6px;
}
.search-hit {
  text-align:left;
}
.picked {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  background:var(--green-soft);
  border-radius:12px;
  padding:4px 4px 4px 14px;
}
.small-link {
  display:block;
  margin-top:6px;
  padding-left:0;
  font-size:15px;
}
