/* [CORP-PORTAL-01] 驛馬達達企業專屬頁面。品牌藍 #2854DA（跟乘客頁面同一組顏色），辦公室用：桌機側欄、手機上方分頁。 */
:root {
  --canvas: #F4F3EF;
  --surface: #FFFFFF;
  --surface-2: #F8F8F5;
  --ring: rgba(13, 21, 48, .08);
  --hair: rgba(13, 21, 48, .08);
  --ink: #0D1530;
  --ink-2: #3A4262;
  --muted: #747B95;
  --brand: #2854DA;
  --brand-deep: #1830A0;
  --brand-ink: #1F45C4;
  --brand-soft: #E9EEFF;
  --coral: #E8573A;
  --coral-soft: #FFEDE7;
  --sun: #B97800;
  --sun-soft: #FFF5DD;
  --mint: #0E9A73;
  --mint-soft: #E2F7EF;
  --danger: #D93C41;
  --danger-soft: #FDECEC;
  --line-green: #06C755;
  --wa-green: #25D366;
  --r-lg: 18px;
  --r-md: 12px;
  --shadow: 0 1px 1px rgba(13, 21, 48, .03), 0 10px 28px -14px rgba(13, 21, 48, .16);
  --font: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0A0E1B;
    --surface: #121829;
    --surface-2: #171E33;
    --ring: rgba(255, 255, 255, .09);
    --hair: rgba(255, 255, 255, .08);
    --ink: #EEF1FB;
    --ink-2: #BEC4DA;
    --muted: #8A91AB;
    --brand-ink: #8EA6FF;
    --brand-soft: rgba(40, 84, 218, .2);
    --coral-soft: rgba(232, 87, 58, .16);
    --sun: #F2B640;
    --sun-soft: rgba(242, 182, 64, .14);
    --mint: #3DD3A5;
    --mint-soft: rgba(61, 211, 165, .14);
    --danger-soft: rgba(217, 60, 65, .16);
    --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 16px 36px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--canvas); color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; overflow-x: hidden; }
a { color: var(--brand-ink); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }

/* ---- 上方 ---- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--canvas) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--hair); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.logo { border-radius: 50%; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; flex: none; }
.brand-text b { font-size: 15px; }
.brand-text small { font-size: 11.5px; color: var(--muted); }
.corp-mark { display: flex; align-items: center; gap: 10px; min-width: 0; }
.corp-mark > i { width: 1px; height: 26px; background: var(--hair); flex: none; }
.corp-mark img { height: 30px; max-width: 96px; object-fit: contain; border-radius: 6px; }
.corp-mark b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.top-tools { display: flex; gap: 8px; flex: none; }
.chip-btn { border: 1px solid var(--ring); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }

/* ---- 版面：手機上方分頁、桌機側欄 ---- */
.layout { display: block; }
.side { position: sticky; top: calc(env(safe-area-inset-top) + 57px); z-index: 15; display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px;
  background: var(--canvas); border-bottom: 1px solid var(--hair); scrollbar-width: none; }
.side::-webkit-scrollbar { display: none; }
.side a { display: flex; align-items: center; gap: 7px; flex: none; padding: 7px 12px; border-radius: 999px; color: var(--ink-2); font-size: 14px; white-space: nowrap; }
.side a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side a.on { background: var(--brand); color: #fff; }
.side .side-foot { display: none; }
main { padding: 18px 16px 60px; max-width: 1100px; margin: 0 auto; min-height: 60vh; }

@media (min-width: 960px) {
  .layout { display: grid; grid-template-columns: 236px 1fr; }
  .side { flex-direction: column; top: 57px; height: calc(100dvh - 57px); overflow: auto; border-bottom: 0; border-right: 1px solid var(--hair); padding: 18px 14px; gap: 2px; }
  .side a { border-radius: 10px; padding: 9px 12px; }
  .side .side-foot { display: block; margin-top: auto; padding: 12px; font-size: 12px; color: var(--muted); }
  main { padding: 28px 32px 80px; margin: 0; max-width: 1080px; }
}

/* ---- 共用元件 ---- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.card { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px; }
.card + .card, .card + .section, .section + .card, .section + .section { margin-top: 14px; }
.section h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section h2 small { color: var(--muted); font-weight: 500; font-size: 13px; }
.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--r-md); padding: 13px 14px; }
.stat small { display: block; color: var(--muted); font-size: 12.5px; }
.stat b { display: block; font-size: 24px; letter-spacing: -.02em; margin-top: 2px; }
.stat.accent { background: var(--brand); color: #fff; border-color: transparent; }
.stat.accent small { color: rgba(255, 255, 255, .78); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 14px;
  background: var(--brand); color: #fff; cursor: pointer; text-align: center; }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--ring); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.line { background: var(--line-green); }
.btn.wa { background: var(--wa-green); color: #062b14; }
.btn.block { width: 100%; padding: 12px 14px; }
.btn[disabled] { opacity: .55; cursor: default; }
.input { width: 100%; border: 1px solid var(--ring); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; outline: none; }
.input:focus { border-color: var(--brand); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--ring); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--ink-2); font-size: 14px; }
.tabs a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.blue { background: var(--brand-soft); color: var(--brand-ink); }
.pill.green { background: var(--mint-soft); color: var(--mint); }
.pill.amber { background: var(--sun-soft); color: var(--sun); }
.pill.red { background: var(--danger-soft); color: var(--danger); }
.pill.grey { color: var(--muted); }
.pill.plain::before { display: none; }

/* 訂單列 */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: grid; grid-template-columns: 74px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--ring);
  border-radius: var(--r-md); padding: 12px 14px; color: var(--ink); }
a.item:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--ring)); }
.item .when b { display: block; font-size: 15px; }
.item .when small { color: var(--muted); font-size: 12.5px; }
.item .what { min-width: 0; }
.item .route { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .side-r { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.item .side-r b { font-size: 14px; }
@media (max-width: 560px) { .item { grid-template-columns: 1fr auto; } .item .when { grid-column: 1 / -1; display: flex; gap: 8px; align-items: baseline; } }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--hair); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; margin: -4px -6px; padding: 0 6px; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13.5px; }
.kv dd { margin: 0; word-break: break-word; }

.steps { display: flex; gap: 6px; margin: 4px 0 2px; }
.steps i { flex: 1; height: 5px; border-radius: 3px; background: var(--hair); }
.steps i.on { background: var(--brand); }
.steps.done i { background: var(--mint); }
.steps.off i { background: var(--danger-soft); }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; margin: 0 auto 8px; display: block; opacity: .5; fill: none; stroke: currentColor; stroke-width: 1.5; }
.notice { border-radius: var(--r-md); padding: 11px 13px; font-size: 13.5px; background: var(--brand-soft); color: var(--ink-2); }
.notice.warn { background: var(--sun-soft); }
.notice.err { background: var(--danger-soft); }

.page-error { border: 1px dashed var(--ring); border-radius: var(--r-lg); padding: 28px 18px; text-align: center; background: var(--surface); }
.page-error b { display: block; margin-bottom: 4px; }
.page-error p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }

.skeleton { display: grid; gap: 10px; }
.skeleton i { display: block; height: 62px; border-radius: var(--r-md); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite linear; border: 1px solid var(--ring); }
@keyframes sk { to { background-position: -200% 0; } }

/* 開機／登入 */
.splash { display: grid; place-items: center; gap: 14px; padding-top: 22vh; }
.splash img { border-radius: 50%; }
.dots { display: flex; gap: 6px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: dot 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { opacity: .25; transform: translateY(-3px); } }
.login { max-width: 420px; margin: 6vh auto 0; }
.login h1 { font-size: 24px; margin-bottom: 6px; }
.login .lead { color: var(--muted); margin: 0 0 20px; }
.login .or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 18px 0; }
.login .or::before, .login .or::after { content: ""; flex: 1; height: 1px; background: var(--hair); }
.phone-row { display: grid; grid-template-columns: 96px 1fr; gap: 8px; margin-bottom: 10px; }

/* 權限勾選 */
.perm-grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .perm-grid { grid-template-columns: 1fr 1fr; } }
.perm { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--ring); border-radius: 10px; padding: 9px 11px; cursor: pointer; background: var(--surface-2); }
.perm input { margin-top: 3px; accent-color: var(--brand); }
.perm b { display: block; font-size: 14px; }
.perm small { color: var(--muted); font-size: 12.5px; }
.perm.locked { opacity: .5; cursor: not-allowed; }
.preset-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

/* QR */
.qr { width: 220px; max-width: 100%; aspect-ratio: 1; background: #fff; border-radius: 14px; padding: 8px; border: 1px solid var(--ring); }
.qr svg { width: 100%; height: 100%; display: block; }
.copy-field { display: flex; gap: 8px; }
.copy-field .input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* 下方面板 */
.sheet { border: 0; padding: 0; background: transparent; max-width: 560px; width: calc(100% - 24px); margin: auto; }
.sheet::backdrop { background: rgba(8, 11, 22, .5); backdrop-filter: blur(2px); }
.sheet-inner { background: var(--surface); color: var(--ink); border-radius: 20px; padding: 20px; max-height: 86dvh; overflow: auto; box-shadow: var(--shadow); }
.sheet-inner h2 { font-size: 18px; margin-bottom: 12px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.inv-img { width: 100%; border-radius: 10px; border: 1px solid var(--ring); background: #fff; }
.driver-text { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--ring); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin: 0; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 22px); transform: translateX(-50%); background: var(--ink); color: var(--canvas);
  padding: 9px 16px; border-radius: 999px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

@media print {
  .top, .side, .toast, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
}
