* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: light;
  --page: #f3f1e9;
  --surface: #fffef9;
  --surface-2: #eae7dd;
  --ink: #111713;
  --ink-2: #4f5751;
  --muted: #7a817b;
  --line: #d9d7cd;
  --dark: #0c1712;
  --acid: #c7ff52;
  --green: #16815b;
  --blue: #3f6ef2;
  --orange: #ff6b3d;
  --red: #c64538;
  --shadow: 0 18px 50px rgba(12, 23, 18, .07);
}

html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: "Noto Sans TC", system-ui, sans-serif;
  padding-bottom: 94px;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }

.topbar {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 9px; font-family: "DM Sans", sans-serif; font-weight: 700; font-size: 19px; letter-spacing: -.4px; }
.brand-mark { width: 29px; height: 29px; border-radius: 9px; display: grid; place-items: center; background: var(--dark); color: var(--acid); font-size: 16px; }
.date { color: var(--muted); font-size: 12px; font-weight: 600; }

main { width: min(1080px, calc(100% - 24px)); margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; animation: tabIn .28s ease both; }
@keyframes tabIn { from { opacity: 0; transform: translateY(5px); } }

.hero-card {
  position: relative;
  overflow: hidden;
  background: var(--dark);
  color: #fff;
  border-radius: 26px;
  padding: 22px;
  margin-bottom: 28px;
  box-shadow: 0 24px 60px rgba(12, 23, 18, .17);
}
.hero-card::after { content: ""; position: absolute; width: 160px; height: 160px; right: -63px; top: -61px; border: 32px solid rgba(199, 255, 82, .12); border-radius: 50%; }
.hero-topline { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
.eyebrow, .card-kicker { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #b8c4bd; }
.eyebrow.dark, .card-kicker { color: var(--green); }
.status-dot { color: #b7c2bc; font-size: 11px; display: flex; align-items: center; gap: 6px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--acid); box-shadow: 0 0 0 4px rgba(199,255,82,.10); }
.hero-value { font-family: "DM Sans", sans-serif; font-weight: 600; letter-spacing: -.06em; font-size: clamp(52px, 12vw, 86px); line-height: .95; margin-top: 34px; }
.hero-label { color: #b7c2bc; font-size: 13px; margin-top: 9px; }
.hero-meta { margin-top: 24px; color: #dce4df; font-size: 13px; }
.hero-rule { height: 1px; background: #2b3932; margin: 18px 0; }
.hero-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hero-mini .mini-label { display: block; font-size: 10px; color: #86958d; margin-bottom: 4px; }
.hero-mini strong { font-family: "DM Sans", sans-serif; font-size: 17px; font-weight: 600; }

.section-heading, .orders-heading { display: flex; justify-content: space-between; align-items: end; margin: 0 4px 14px; }
.section-heading h1, .orders-heading h1 { font-size: 25px; letter-spacing: -.04em; margin-top: 3px; }
.text-button { border: 0; background: none; color: var(--green); font-size: 12px; font-weight: 700; padding: 8px 0; cursor: pointer; }

.assumption-panel { background: #e4eadf; border: 1px solid #ced8c8; border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.assumption-panel label { display: grid; grid-template-columns: 1fr 82px auto; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; margin-bottom: 12px; }
.assumption-panel label span { grid-row: 2; font-size: 10px; font-weight: 400; color: var(--muted); }
.assumption-panel input { grid-row: 1 / 3; grid-column: 2; width: 82px; padding: 8px; border: 1px solid #bac7b4; background: var(--surface); border-radius: 9px; text-align: right; }
.assumption-panel label b { grid-row: 1 / 3; grid-column: 3; font-size: 11px; color: var(--ink-2); }
.assumption-panel p { font-size: 10px; color: var(--muted); margin-top: 9px; }

.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.metric-card { min-height: 118px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 15px; box-shadow: 0 6px 22px rgba(12,23,18,.025); }
.metric-card.emphasis { background: var(--acid); border-color: #b3ea3e; }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 600; }
.metric-value { font-family: "DM Sans", sans-serif; font-weight: 600; letter-spacing: -.045em; font-size: 29px; margin: 10px 0 7px; }
.metric-sub { color: var(--ink-2); font-size: 10px; line-height: 1.45; }
.loading { position: relative; overflow: hidden; background: var(--surface-2); border: 0; }
.loading::after { content: ""; position: absolute; left: 14px; top: 20px; width: 60%; height: 12px; background: rgba(255,255,255,.55); border-radius: 9px; box-shadow: 0 30px 0 7px rgba(255,255,255,.55); }

.insight-stack { display: grid; gap: 8px; margin-bottom: 14px; }
.insight { display: grid; grid-template-columns: 8px 1fr; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 13px; }
.insight::before { content: ""; border-radius: 9px; background: var(--blue); }
.insight.risk::before { background: var(--orange); }
.insight.watch::before { background: #d9ad16; }
.insight h3 { font-size: 13px; margin-bottom: 3px; }
.insight p { color: var(--ink-2); font-size: 11px; line-height: 1.55; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card h2 { font-size: 17px; letter-spacing: -.025em; margin-top: 3px; }
.card-heading { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 17px; }
.card-heading > strong { font-family: "DM Sans", sans-serif; color: var(--orange); font-size: 26px; }
.action-card { border: 0; background: #dfe7ff; box-shadow: none; padding-right: 50px; position: relative; }
.action-card::after { content: "↗"; position: absolute; top: 18px; right: 18px; font-size: 22px; color: var(--blue); }
.action-card .headline { margin-top: 8px; font-size: 15px; font-weight: 600; line-height: 1.55; }
.action-card .meta { font-size: 11px; color: var(--ink-2); margin-top: 6px; }

.daily-performance { display: grid; gap: 13px; }
.day-line { display: grid; grid-template-columns: 44px 1fr 70px; gap: 9px; align-items: center; }
.day-label { font-family: "DM Sans", sans-serif; color: var(--muted); font-size: 11px; }
.day-track { height: 12px; background: var(--surface-2); border-radius: 8px; overflow: hidden; display: flex; }
.day-track i { display: block; height: 100%; }
.day-track .base-fill { background: var(--blue); }
.day-track .bonus-fill { background: var(--orange); }
.day-value { font-family: "DM Sans", sans-serif; font-size: 12px; text-align: right; font-weight: 700; }
.day-extra { grid-column: 2 / 4; margin-top: -7px; color: var(--muted); font-size: 9px; display: flex; justify-content: space-between; }
.cumulative-total { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.cumulative-total strong { color: var(--ink); font-family: "DM Sans", sans-serif; font-size: 18px; }

.stackbar { display: flex; gap: 3px; height: 15px; overflow: hidden; border-radius: 8px; background: var(--surface-2); }
.stackbar > div { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 13px; margin-top: 10px; color: var(--ink-2); font-size: 10px; }
.legend.compact { margin: 0; align-self: center; }
.legend .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot.base { background: var(--blue); }.dot.bonus { background: var(--orange); }
.card-note { margin-top: 13px; color: var(--muted); font-size: 10px; line-height: 1.55; }

.analysis-intro { padding: 22px 5px 30px; }
.analysis-intro h1 { font-size: clamp(38px, 9vw, 64px); line-height: 1.03; letter-spacing: -.055em; margin: 8px 0 12px; }
.analysis-intro p { max-width: 560px; color: var(--ink-2); font-size: 13px; line-height: 1.7; }
.compact-intro { padding-top: 10px; }

.hour-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.hour-cell { aspect-ratio: .82; border: 1px solid var(--line); background: var(--surface-2); border-radius: 11px; padding: 7px 4px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; text-align: left; color: var(--ink); }
.hour-cell.active { background: color-mix(in srgb, var(--blue) var(--intensity), var(--surface)); border-color: transparent; color: white; }
.hour-cell.selected { outline: 3px solid var(--acid); outline-offset: 1px; }
.hour-cell span { font-family: "DM Sans", sans-serif; font-size: 10px; opacity: .82; }
.hour-cell strong { font-family: "DM Sans", sans-serif; font-size: 13px; }
.chart-detail { min-height: 44px; margin-top: 13px; border-top: 1px solid var(--line); padding-top: 12px; color: var(--ink-2); font-size: 11px; line-height: 1.55; }
.business-callout { margin-top: 8px; padding: 12px; background: #e4eadf; border-radius: 12px; color: #344139; font-size: 11px; line-height: 1.6; }

#map { height: 285px; border-radius: 14px; margin-bottom: 15px; background: var(--surface-2); }
.leaflet-control-attribution { font-size: 8px !important; }
.district-table { display: grid; gap: 2px; }
.district-row { display: grid; grid-template-columns: 54px 1fr 62px; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.district-row:last-child { border-bottom: 0; }
.district-name { font-size: 12px; font-weight: 600; }
.district-bars { display: grid; gap: 4px; }
.district-bar { height: 6px; border-radius: 5px; overflow: hidden; background: var(--surface-2); }
.district-bar i { display: block; height: 100%; background: var(--blue); border-radius: 5px; }
.district-meta { font-size: 9px; color: var(--muted); }
.district-score { text-align: right; }
.district-score strong { display: block; font-family: "DM Sans", sans-serif; font-size: 13px; }
.district-score span { font-size: 8px; color: var(--muted); }

.ranklist .row { display: grid; grid-template-columns: 42px 1fr 82px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.ranklist .track { height: 8px; overflow: hidden; border-radius: 6px; background: var(--surface-2); }
.ranklist .fill { height: 100%; border-radius: inherit; background: var(--orange); }
.ranklist .val { color: var(--ink-2); text-align: right; }
.split-cards { display: grid; grid-template-columns: 1fr; gap: 0; }
.split-cards h2 { margin-bottom: 11px; }
.weak-item { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.weak-item:last-child { border-bottom: 0; }
.weak-item .main { flex: 1; font-weight: 600; }
.weak-item .sub { color: var(--muted); font-size: 9px; font-weight: 400; margin-top: 3px; }
.weak-item .side { flex: none; color: var(--red); font-family: "DM Sans", sans-serif; font-weight: 700; }

.field-label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
textarea { width: 100%; min-height: 210px; resize: vertical; border: 1px solid var(--line); border-radius: 13px; background: var(--page); padding: 13px; color: var(--ink); font-size: 12px; line-height: 1.6; }
textarea:focus, input:focus, select:focus { outline: 3px solid rgba(63,110,242,.15); border-color: var(--blue); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 0; border-radius: 11px; padding: 10px 17px; background: var(--dark); color: white; font-weight: 700; font-size: 12px; cursor: pointer; margin-top: 10px; }
.btn:hover { filter: brightness(1.12); }.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--dark); border: 1px solid var(--dark); }
.btn.danger { background: var(--red); }.btn.small { min-height: 34px; padding: 7px 12px; margin-top: 0; }
.maintenance-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; box-shadow: none; }
.maintenance-card p { font-size: 10px; color: var(--muted); margin-top: 3px; }
.maintenance-card > div:last-child { grid-column: 1 / -1; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 10px; margin-top: 12px; }
.preview-table th, .preview-table td { padding: 7px 4px; text-align: left; border-bottom: 1px solid var(--line); }
.preview-table th { color: var(--muted); font-weight: 600; }.preview-table .num { text-align: right; }.preview-table tr.dup { opacity: .4; }
.import-summary { font-size: 11px; color: var(--ink-2); margin-top: 12px; line-height: 1.7; }
.notice { font-size: 11px; padding: 11px; border-radius: 11px; margin-top: 10px; }.notice.ok { background: #e3f3e9; color: #126240; }.notice.err { background: #f8e5e0; color: #a3362b; }

.orders-heading { margin-top: 13px; margin-bottom: 19px; }
.day-group { margin-bottom: 18px; }
.day-head { display: flex; justify-content: space-between; padding: 4px 3px 8px; color: var(--ink-2); font-size: 11px; font-weight: 700; }
.order-row { display: grid; grid-template-columns: 42px 1fr auto auto; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px; margin-bottom: 6px; font-size: 11px; cursor: pointer; }
.order-row .time { color: var(--muted); font-family: "DM Sans", sans-serif; }.order-row .store { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.order-row .tag { padding: 2px 6px; background: var(--surface-2); border-radius: 6px; color: var(--ink-2); font-size: 9px; }.order-row .amt { font-family: "DM Sans", sans-serif; font-weight: 700; }.order-row.bonus .amt { color: var(--orange); }
.edit-form { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 13px; margin: 7px 0; }
.edit-form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }.edit-form label { color: var(--muted); font-size: 9px; display: block; margin-bottom: 3px; }.edit-form input, .edit-form select { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--page); padding: 8px; color: var(--ink); font-size: 11px; }.edit-form .actions { display: flex; justify-content: flex-end; gap: 7px; }
.empty { text-align: center; color: var(--muted); font-size: 11px; padding: 28px 0; }

nav { position: fixed; z-index: 1000; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); height: 65px; display: flex; background: rgba(12,23,18,.96); border: 1px solid #25342d; border-radius: 19px; padding: 5px; box-shadow: 0 14px 40px rgba(12,23,18,.25); backdrop-filter: blur(16px); }
nav button { flex: 1; border: 0; background: transparent; color: #829188; border-radius: 14px; font-size: 9px; font-weight: 600; cursor: pointer; }
.nav-icon { display: block; font-family: "DM Sans", sans-serif; font-size: 19px; line-height: 21px; margin-bottom: 1px; }
nav button.active { background: #1c2b24; color: var(--acid); }

@media (min-width: 760px) {
  body { padding-bottom: 114px; }
  main { width: min(1080px, calc(100% - 48px)); }
  #tab-overview { grid-template-columns: 1.12fr .88fr; gap: 16px; align-items: start; }
  #tab-overview.active { display: grid; }
  #tab-overview > .hero-card { grid-column: 1 / -1; }
  #tab-overview > .section-heading, #tab-overview > .assumption-panel, #tab-overview > .metric-grid, #tab-overview > .insight-stack { grid-column: 1; }
  #tab-overview > .action-card { grid-column: 1; }
  #tab-overview > .card:not(.action-card) { grid-column: 2; }
  #tab-overview > .card:nth-last-child(1) { align-self: start; }
  .hero-card { padding: 30px 34px; }
  .hero-mini { width: 55%; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .metric-card { min-height: 135px; }
  .metric-value { font-size: 25px; }
  .analysis-intro { padding: 46px 8px 40px; }
  .hour-grid { grid-template-columns: repeat(12, 1fr); }
  .split-cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  nav { width: 430px; left: 50%; right: auto; transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
