:root {
  --bg: #f4f5f7;
  --card: #fff;
  --soft: #f7f8f9;
  --ink: #172b4d;
  --ink-2: #44546f;
  --muted: #626f86;
  --line: #e4e6ea;
  --field: #d0d4db;
  --accent: #0c66e4;
  --accent-ink: #0055cc;
  --accent-soft: #e9f2ff;
  --accent-line: #cce0ff;
  --ok: #1d6fe0;
  --ok-soft: #e9f2ff;
  --ok-line: #cce0ff;
  --warn: #8f5b00;
  --warn-soft: #fff5dc;
  --warn-line: #f2dfaa;
  --bad: #b8394d;
  --bad-soft: #fdedf0;
  --bad-line: #f5c8d0;
  --radius: 12px;
  --shadow: 0 1px 2px #172b4d0a, 0 8px 24px #172b4d0a;

  /* 類別色 */
  --c-live: #ae4787;
  --c-platform: #0c66e4;
  --c-promotions: #e56910;
  --c-marketing: #22a06b;
  --c-games: #6e5dc6;
  --c-support: #8590a2;
  --c-unassigned: #d9a12f;
}
[data-cat="live"] { --cat: var(--c-live); }
[data-cat="platform"] { --cat: var(--c-platform); }
[data-cat="promotions"] { --cat: var(--c-promotions); }
[data-cat="marketing"] { --cat: var(--c-marketing); }
[data-cat="games"] { --cat: var(--c-games); }
[data-cat="support"] { --cat: var(--c-support); }
[data-cat="unassigned"] { --cat: var(--c-unassigned); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cat, var(--muted)); display: inline-block; flex: none; }

/* ---------- Header ---------- */
.app-header {
  background: #fff; color: var(--ink); border-bottom: 1px solid var(--line);
  padding: 14px 0; padding-top: max(14px, env(safe-area-inset-top));
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff;
  background: linear-gradient(140deg, #388bff, #0c66e4 60%, #0055cc); box-shadow: 0 2px 6px #0c66e440;
}
h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; color: var(--ink); }
.brand p { margin: 1px 0 0; color: var(--muted); font-size: 13px; }
.header-side { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.month-nav { display: flex; align-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.month-nav input {
  width: auto; background: transparent; border: 0; color: var(--ink); font-weight: 650; font-size: 15px;
  padding: 6px 4px; text-align: center;
}
.month-nav input:focus-visible { outline: 2px solid #85b8ff; border-radius: 8px; box-shadow: none; }
.mn-btn { border: 0; background: none; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; font-size: 20px; cursor: pointer; line-height: 1; }
.mn-btn:hover { background: #fff; color: var(--accent); }
.save-state { display: flex; align-items: center; gap: 6px; }
.chip { font-size: 12px; font-weight: 600; padding: 4px 10px 4px 8px; border-radius: 6px; background: var(--soft); color: var(--ink-2); border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #8590a2; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.chip.ok::before { background: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.chip.warn::before { background: #e2a03f; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.chip.bad::before { background: var(--bad); }
.save-state .link-btn { font-size: 12.5px; }

/* ---------- Step nav ---------- */
.stepnav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.stepnav-inner { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding-top: 10px; padding-bottom: 10px; }
.stepn {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
  padding: 7px 12px; border-radius: 12px; min-width: 0; position: relative; transition: background .15s;
}
.stepn:hover { background: #ffffffb0; }
.stepn-num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 12.5px; font-weight: 750; background: #fff; color: var(--muted); border: 1.5px solid var(--field);
}
.stepn-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.stepn-text b { font-size: 13.5px; }
.stepn-text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepn.done .stepn-num { background: var(--ok); border-color: var(--ok); color: #fff; font-size: 0; }
.stepn.done .stepn-num::before { content: "✓"; font-size: 13px; }
.stepn.done small { color: var(--ok); }
.stepn.warn .stepn-num { border-color: #e7b14a; color: var(--warn); background: var(--warn-soft); }
.stepn.warn small { color: var(--warn); }
.stepn.bad .stepn-num { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.stepn.bad small { color: var(--bad); }
.stepn:not(:last-child)::after {
  content: ""; position: absolute; right: -8px; top: 50%; width: 8px; height: 1.5px; background: var(--field);
}

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(340px, 1fr); gap: 20px; align-items: start; margin-top: 20px; margin-bottom: 32px; }
.col-full { grid-column: 1 / -1; }
.col-side { display: grid; gap: 20px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 6px; flex-wrap: wrap; }
h2 { font-size: 17px; margin: 0 0 4px; display: flex; align-items: center; gap: 9px; letter-spacing: -.01em; }
h3 { font-size: 14px; margin: 0 0 4px; display: flex; align-items: center; gap: 7px; }
.step {
  width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center;
  font-size: 12px; font-weight: 750; color: #fff; background: var(--accent);
}
.sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

/* ---------- Forms ---------- */
label { font-size: 12.5px; color: var(--ink-2); display: block; margin: 0 0 5px; font-weight: 600; }
input, textarea, select {
  font: inherit; color: var(--ink); border: 1px solid var(--field); background: #fff;
  border-radius: 10px; padding: 8px 11px; width: 100%; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236e6a84' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center;
}
textarea { resize: vertical; }
input:hover, textarea:hover, select:hover { border-color: #b3b9c4; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #0c66e426; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid #579dff; outline-offset: 2px; }
input[aria-invalid="true"] { border-color: var(--bad); background: var(--bad-soft); }
input[readonly] { background: var(--soft); color: var(--muted); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.field { margin-bottom: 12px; }
.field.inline { margin: 0; }
.notes { margin: 18px 0 0; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 10px 0 0; font-size: 13px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; background: var(--accent); color: #fff;
  padding: 8px 15px; font: inherit; font-size: 14px; font-weight: 650; cursor: pointer; min-height: 40px;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s; white-space: nowrap;
}
.btn:not(.ghost):not(.secondary):not(.danger):not(.danger-text) { box-shadow: 0 1px 2px #091e4226; }
.btn:not(:disabled):hover { background: var(--accent-ink); }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn.secondary { background: var(--accent-soft); color: var(--accent-ink); }
.btn.secondary:not(:disabled):hover { background: #cce0ff; }
.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--field); }
.btn.ghost:not(:disabled):hover { background: var(--soft); border-color: #b3b9c4; color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.btn.danger:not(:disabled):hover { background: #fbdfe4; }
.btn.danger-text { background: none; color: var(--bad); }
.btn.danger-text:not(:disabled):hover { background: var(--bad-soft); }
.btn.sm { padding: 5px 11px; font-size: 13px; min-height: 34px; border-radius: 6px; }
.btn.icon-only { padding: 0; width: 40px; font-size: 18px; letter-spacing: 1px; }
.btn.primary-lg { min-height: 46px; font-size: 15px; }
.btn:disabled { opacity: .42; cursor: not-allowed; box-shadow: none !important; }
.link-btn { border: 0; background: none; padding: 4px 6px; color: var(--accent-ink); font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; border-radius: 6px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #0c66e455; }
.link-btn:hover:not(:disabled) { text-decoration-color: currentColor; }
.link-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn { border: 0; background: none; color: #8590a2; font-size: 20px; line-height: 1; width: 34px; height: 34px; border-radius: 9px; cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--bad-soft); color: var(--bad); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.actions .btn { flex: 1 1 auto; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 4px; align-items: center; }

/* More menu */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--soft); }
.menu-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 15; min-width: 210px;
  background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 6px;
  box-shadow: 0 12px 36px #172b4d26;
}
.menu-pop button {
  display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; font-size: 14px;
  padding: 9px 11px; border-radius: 8px; cursor: pointer; color: var(--ink);
}
.menu-pop button:hover:not(:disabled) { background: var(--soft); }
.menu-pop button:disabled { opacity: .4; cursor: not-allowed; }
.menu-pop .danger-text { color: var(--bad); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

/* ---------- Overview ---------- */
.overview { background: var(--soft); border: 1px solid var(--line); border-radius: 15px; padding: 16px 18px; }
.ov-main { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px 18px; flex-wrap: wrap; margin-bottom: 12px; }
.ov-big { display: flex; align-items: baseline; gap: 8px; }
.ov-big > b { font-size: 34px; line-height: 1; font-weight: 780; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ov-big > span { color: var(--muted); font-size: 14px; }
.ov-big > span span { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.ov-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.ov-stats span { font-size: 12.5px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; }
.ov-stats b { color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 2px; }

.stackbar {
  display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 2px;
  background: repeating-linear-gradient(135deg, #e4e6ea 0 6px, #f1f2f4 6px 12px);
}
.stackbar.thin { height: 8px; }
.stackbar > span { background: var(--cat); min-width: 3px; transition: flex-grow .35s ease; }
.stackbar > span.over { background: repeating-linear-gradient(135deg, var(--bad) 0 5px, #e2483d 5px 10px); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend:empty { display: none; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { font-variant-numeric: tabular-nums; }

/* ---------- Weeks ---------- */
.weeks { margin-top: 6px; }
.week { border: 1px solid var(--line); border-radius: 16px; margin-top: 14px; background: #fff; overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.week:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px #0c66e40f; }
.week-top { padding: 12px 14px 12px; background: var(--soft); border-bottom: 1px solid var(--line); }
.week-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.week-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wk-no { font-size: 11.5px; font-weight: 750; color: var(--accent-ink); background: var(--accent-soft); border-radius: 7px; padding: 3px 7px; flex: none; }
.week-dates { display: flex; align-items: center; gap: 2px; }
.week-dates input {
  width: auto; padding: 4px 6px; font-weight: 650; border-color: transparent; background: transparent; font-size: 14.5px;
}
.week-dates input:hover { border-color: var(--field); background: #fff; }
.week-dates span { color: var(--muted); }
.week-status { font-size: 12.5px; font-weight: 650; padding: 3px 10px; border-radius: 99px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.week-status.ok { background: var(--ok-soft); color: var(--ok); }
.week-status.warn { background: var(--warn-soft); color: var(--warn); }
.week-status.idle { background: #f1f2f4; color: var(--muted); }
.week-days { display: flex; gap: 8px 12px; margin: 10px 0 10px; align-items: center; flex-wrap: wrap; }
.dfield { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dfield label { font-size: 12.5px; margin: 0; color: var(--muted); font-weight: 600; white-space: nowrap; }
.dfield-row { display: flex; gap: 4px; align-items: center; min-width: 0; }
.num-in { width: 56px; flex: none; text-align: center; font-variant-numeric: tabular-nums; font-weight: 650; padding: 6px 4px; }
.note-in { width: 108px; font-size: 13px; padding: 6px 9px; }
.week-head-r { display: flex; align-items: center; gap: 10px; }
.net { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.net b { font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 2px; }
.week .stackbar { height: 7px; }

.tasks { padding: 4px 14px 2px; }
.task {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center;
  padding: 10px 0 10px 12px; border-bottom: 1px solid var(--line); position: relative;
}
.task::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3.5px; border-radius: 4px; background: var(--cat, var(--field)); }
.task:last-child { border-bottom: 0; }
.task-title {
  border-color: transparent; background: transparent; padding: 5px 8px; margin-left: -8px; font-weight: 600; font-size: 14.5px;
  resize: none; overflow: hidden; line-height: 1.45; field-sizing: content; min-height: 0;
}
.task-title:hover { border-color: var(--field); background: #fff; }
.task-title:focus-visible { background: #fff; }
.task.is-suggested { background: linear-gradient(90deg, #eef5ff, transparent 70%); }
.task-ctl { display: flex; align-items: center; gap: 6px; }
.cat-select { width: 150px; font-size: 13px; padding: 6px 28px 6px 26px; border-radius: 99px; font-weight: 600; position: relative; }
.cat-wrap { position: relative; }
.cat-wrap::before { content: ""; position: absolute; left: 11px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--cat, var(--muted)); pointer-events: none; z-index: 1; }
.dstep { display: flex; align-items: center; border: 1px solid var(--field); border-radius: 10px; background: #fff; overflow: hidden; }
.dstep:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px #0c66e426; }
.dstep input { border: 0; width: 46px; border-radius: 0; padding: 6px 0; box-shadow: none !important; }
.dstep input[aria-invalid="true"] { background: var(--bad-soft); }
.dstep input:placeholder-shown { background: var(--warn-soft); }
.dstep button { border: 0; background: none; width: 28px; height: 32px; font-size: 16px; color: var(--accent-ink); cursor: pointer; }
.dstep button:hover { background: var(--accent-soft); }
.dstep .unit { font-size: 12px; color: var(--muted); padding-right: 2px; }
.task-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task-meta:empty { display: none; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: #f1f2f4; color: #44546f; border: 0; font-family: inherit; line-height: 1.6; }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-info { background: #e8f1ff; color: #2c5ca6; }
button.tag-suggest { background: var(--accent); color: #fff; cursor: pointer; font-weight: 650; padding: 3px 10px; }
button.tag-suggest:hover { background: var(--accent-ink); }
.detail { font-size: 12px; color: var(--muted); min-width: 0; }
.no-tasks { color: var(--muted); font-size: 13px; padding: 12px 0; margin: 0; }
.week-foot { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 10px; border-top: 1px solid var(--line); background: #fafbfc; }
.week-foot .danger-text { margin-left: auto; }
.week-foot .btn.ghost { border-color: transparent; background: transparent; color: var(--accent-ink); }
.week-foot .btn.ghost:hover { background: var(--accent-soft); }
.empty-state { text-align: center; padding: 30px 12px; color: var(--muted); border: 1.5px dashed var(--field); border-radius: 16px; margin-top: 14px; }

/* ---------- Allocation ---------- */
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); }
thead th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tbody th { font-weight: 550; }
.cat-name { display: inline-flex; align-items: center; gap: 8px; }
tfoot th, tfoot td { border-bottom: 0; font-weight: 700; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-col, .bar-cell { width: 30%; }
.bar-track { display: block; height: 7px; border-radius: 99px; background: #f1f2f4; overflow: hidden; }
.bar { display: block; height: 100%; border-radius: 99px; background: var(--cat, var(--accent)); transition: width .35s ease; }
tr.zero th, tr.zero td { color: #a5adba; }
.warn-row th, .warn-row td { color: var(--warn); }
.callout { font-size: 13px; border-radius: 11px; padding: 10px 12px; margin-top: 12px; border: 1px solid transparent; }
.callout:empty { display: none; }
.callout.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.callout.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.verify { list-style: none; padding: 0; margin: 10px 0 0; font-size: 13px; }
.verify li { padding: 4px 0 4px 24px; position: relative; color: var(--ink-2); }
.verify li::before {
  content: "!"; position: absolute; left: 0; top: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 800; display: grid; place-items: center;
}
.verify li.ok { color: var(--ok); font-weight: 600; }
.verify li.ok::before { content: "✓"; background: var(--ok); color: #fff; }

/* Confirm all (step 1) */
.confirm-all { margin-top: 16px; padding: 14px; border-radius: 15px; background: linear-gradient(90deg, #eef5ff, #f5f9ff); border: 1px solid var(--accent-line); }
.confirm-all p { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-2); }
.confirm-all .btn { width: 100%; }

/* Checklist (step 2) */
.auto-pill { font-size: 11px; font-weight: 700; color: var(--muted); background: #f1f2f4; padding: 2px 8px; border-radius: 99px; letter-spacing: 0; }
.checklist { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist li.todo { background: #fffcf3; }
.ck { width: 20px; height: 20px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.ok .ck { background: #579dff; color: #fff; }
.ok .ck::before { content: "✓"; }
.todo .ck { border: 2px solid #e7b14a; }
.ck-text { flex: 1; min-width: 0; }
.ok .ck-text { color: var(--muted); }
.todo .ck-text { color: var(--ink); font-weight: 600; }
.ck-text small { display: block; font-weight: 400; color: var(--warn); font-size: 12px; }
.checklist .link-btn { flex: none; }
.check.ack { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: 11px; padding: 9px 11px; margin-top: 10px; color: var(--warn); }
.table-title { margin: 18px 0 2px; font-size: 13px; color: var(--ink-2); }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px #e5691066; background-color: #fff8ea; } }

.to-points { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.to-points .btn { width: 100%; }
.to-points .btn.is-applied { opacity: 1; box-shadow: none !important; background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); cursor: default; }
.to-points p { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }

/* How-to (step 3) */
.howto { list-style: none; padding: 0; margin: 0 0 6px; display: grid; gap: 2px; }
.howto li { display: flex; gap: 10px; padding: 8px 0; }
.how-n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 750; display: grid; place-items: center; flex: none; margin-top: 1px; }
.howto li.done .how-n { background: var(--ok); color: #fff; font-size: 0; }
.howto li.done .how-n::before { content: "✓"; font-size: 12px; }
.how-body { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.how-body b { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.how-body > span { font-size: 12.5px; color: var(--muted); }
.how-body .btn { margin-top: 6px; }
.inline-select { width: auto; padding: 3px 26px 3px 10px; font-size: 13.5px; font-weight: 700; color: var(--accent-ink); border-radius: 8px; background-position: right 9px center; }

/* ---------- Points ---------- */
.points-tools { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 4px; }
.points-tools .field { flex: 1 1 160px; }
.pt-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pt-name { font-weight: 650; margin: 0; color: var(--ink); font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pt-ref { grid-column: 1; font-size: 12px; color: var(--muted); padding-left: 17px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pt-row .stepper { grid-row: 1 / span 2; grid-column: 2; }
.sugg { border: 1px dashed var(--accent-line); background: none; color: var(--accent-ink); font: inherit; font-size: 11.5px; font-weight: 650; padding: 1px 7px; border-radius: 99px; cursor: pointer; }
.sugg:hover { background: var(--accent-soft); border-style: solid; }
.sugg.same { border-color: transparent; color: var(--muted); cursor: default; font-weight: 500; }
.sugg.same:hover { background: none; }
.bal-tag { font-size: 10.5px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); padding: 1px 7px; border-radius: 99px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--field); border-radius: 12px; background: #fff; overflow: hidden; }
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px #0c66e426; }
.stepper input { width: 64px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; border: 0; border-radius: 0; padding: 8px 0; box-shadow: none !important; }
.stepper button { width: 36px; height: 38px; border: 0; background: none; font-size: 18px; color: var(--accent-ink); cursor: pointer; }
.stepper button:hover:not(:disabled) { background: var(--accent-soft); }
.stepper button:disabled { opacity: .3; cursor: not-allowed; }
.is-balance .stepper { background: var(--soft); border-style: dashed; }
.is-balance .stepper input { background: transparent; color: var(--accent-ink); }
.pt-err { grid-column: 1 / -1; font-size: 12px; color: var(--bad); }
.pt-err:empty { display: none; }
.sumbox { border-radius: 15px; padding: 14px 16px; margin-top: 16px; border: 1px solid; transition: background .2s, border-color .2s; }
.sum-row-inner { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.sumbox.ok { background: var(--ok-soft); border-color: var(--ok-line); }
.sumbox.bad { background: var(--bad-soft); border-color: var(--bad-line); }
.sumbox .stackbar { background: #ffffffa0; }
.sum-label { font-size: 11.5px; color: var(--muted); font-weight: 750; letter-spacing: .06em; }
.sum-state { font-size: 13px; font-weight: 550; }
.sumbox.ok .sum-state, .sumbox.ok .sum-value { color: var(--ok); }
.sumbox.bad .sum-state, .sumbox.bad .sum-value { color: var(--bad); }
.sum-value { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; }

/* ---------- Report ---------- */
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.report-head h2 { margin: 0; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.report-sheet { border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.report-table { font-size: 14.5px; }
.report-table th, .report-table td { padding: 10px 14px; }
.report-table thead th { background: var(--soft); color: var(--ink-2); font-size: 12px; }
.report-table tbody tr:hover { background: #f7faff; }
.report-table td.num { font-weight: 650; }
.report-table tr.sum-row th, .report-table tr.sum-row td { font-weight: 800; border-bottom: 0; background: var(--soft); font-size: 15px; }
.export-row { display: flex; align-items: center; gap: 2px; margin-top: 8px; font-size: 13px; color: var(--muted); justify-content: center; }
.export-row span { margin-right: 4px; }

/* ---------- History ---------- */
.history { margin-top: 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.hist-item { border: 1px solid var(--line); border-radius: 15px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.hist-item:hover { border-color: var(--accent-line); box-shadow: 0 6px 18px #172b4d0d; }
.hist-item.current { border-color: var(--accent); box-shadow: 0 0 0 3px #0c66e41a; }
.hist-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.hist-title strong { font-size: 17px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.hist-meta { font-size: 12.5px; color: var(--muted); }
.hist-pts { display: flex; flex-wrap: wrap; gap: 3px 10px; font-size: 12px; color: var(--ink-2); }
.hist-pts span { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.hist-actions { display: flex; gap: 6px; margin-top: auto; }
.hist-actions .btn { flex: 1; }
.empty { color: var(--muted); font-size: 13px; padding: 18px; text-align: center; border: 1.5px dashed var(--field); border-radius: 14px; grid-column: 1 / -1; margin: 0; }

/* ---------- Settings ---------- */
.settings summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary::before { content: "›"; color: var(--muted); font-size: 18px; transition: transform .15s; display: inline-block; }
.settings[open] summary::before { transform: rotate(90deg); }
.settings summary h2, .settings summary .sub { margin: 0; }
.settings[open] summary { margin-bottom: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 12px; }
.rules { display: grid; gap: 10px; }
.rule-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 10px; align-items: center; }
.rule-row label { margin: 0; display: flex; align-items: center; gap: 8px; }

/* ---------- Import dialog ---------- */
.dialog {
  border: 0; padding: 0; border-radius: 20px; width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  box-shadow: 0 24px 80px #091e4266; color: var(--ink); background: #fff; overflow: hidden;
}
.dialog[open] { display: flex; flex-direction: column; animation: pop .18s ease-out; }
.dialog::backdrop { background: #091e4280; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; }
.dialog-head .icon-btn:hover { background: var(--soft); color: var(--ink); }
.dialog-body { padding: 20px; overflow-y: auto; }
.import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.import-card { border: 1px solid var(--line); border-radius: 15px; padding: 16px; background: var(--soft); display: flex; flex-direction: column; }
.import-card textarea { flex: 1; font-size: 13px; font-family: ui-monospace, "SF Mono", Menlo, monospace; background: #fff; }
.ic { width: 24px; height: 24px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-size: 13px; }
.pill { font-size: 11px; font-weight: 700; color: var(--ok); background: var(--ok-soft); padding: 1px 8px; border-radius: 99px; }
.upload {
  border: 1.5px dashed #85b8ff; background: #fff; border-radius: 13px; padding: 18px; text-align: center; cursor: pointer;
  font-weight: 500; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: background .15s, border-color .15s;
}
.upload:hover { background: #f5f9ff; border-color: var(--accent); }
.upload-ic { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 20px; display: grid; place-items: center; margin-bottom: 4px; }
.upload strong { color: var(--ink); }
.upload small { color: var(--muted); font-size: 12px; }
.upload input { display: none; }
.upload-drop { display: none; }
.dialog.is-dragging .upload { background: var(--accent-soft); border-color: var(--accent); border-style: solid; box-shadow: 0 0 0 4px #0c66e41f; transform: scale(1.01); }
.dialog.is-dragging .upload-idle { display: none; }
.dialog.is-dragging .upload-drop { display: block; color: var(--accent-ink); }
.dialog.is-dragging .upload-ic { background: var(--accent); color: #fff; }
.upload { transition: background .15s, border-color .15s, box-shadow .15s, transform .15s; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs:empty { display: none; }
.thumb { position: relative; }
.thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.thumb button { position: absolute; top: -7px; right: -7px; border: 2px solid #fff; border-radius: 50%; background: #172b4d; color: #fff; width: 24px; height: 24px; cursor: pointer; font-size: 13px; line-height: 1; }
.status { font-size: 13px; color: var(--muted); margin: 8px 0 0; white-space: pre-wrap; }
.status:empty { display: none; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }
.notice { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.preview { margin-top: 18px; border: 1px solid var(--accent-line); background: #f5f9ff; border-radius: 15px; padding: 16px; }
.preview-week { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.preview-week:last-of-type { border-bottom: 0; }
.preview-week ul { margin: 6px 0 0; padding: 0; list-style: none; }
.preview-week li { margin: 3px 0; display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.preview-week li .dot { position: relative; top: -1px; }

/* Confirm dialog */
.dialog.ask { width: min(440px, calc(100vw - 32px)); }
.ask form { padding: 22px 22px 18px; }
.ask-msg { margin: 0 0 20px; font-size: 15px; line-height: 1.6; white-space: pre-line; color: var(--ink); }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn.danger-solid { background: var(--bad); }
.btn.danger-solid:not(:disabled):hover { background: #ae2e24; }
.toast-btn { margin-left: 12px; border: 0; background: #ffffff26; color: #fff; font: inherit; font-weight: 700; padding: 3px 10px; border-radius: 6px; cursor: pointer; }
.toast-btn:hover { background: #ffffff40; }

/* ---------- Footer / Toast ---------- */
.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 0 16px 30px; padding-bottom: max(30px, env(safe-area-inset-bottom)); }
.toast {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #172b4d; color: #fff; padding: 11px 16px; border-radius: 13px; font-size: 14px; font-weight: 500;
  box-shadow: 0 12px 34px #0004; max-width: calc(100vw - 32px); z-index: 50; animation: toast .2s ease-out;
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast.ok { background: #0055cc; }
.toast.warn { background: #7a5310; }
.toast.bad { background: #8f2639; }

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

/* ---------- Tablet ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  html { scroll-padding-top: 64px; }
  .wrap { padding: 0 12px; }
  .app-header { padding: 14px 0 16px; padding-top: max(14px, env(safe-area-inset-top)); }
  .brand p { display: none; }
  .logo { width: 36px; height: 36px; border-radius: 11px; }
  h1 { font-size: 17px; }
  .header-side { width: 100%; justify-content: space-between; }
  .month-nav input { font-size: 16px; }
  .stepnav-inner { gap: 4px; padding-top: 8px; padding-bottom: 8px; }
  .stepn { flex-direction: column; gap: 3px; padding: 4px 2px; text-align: center; }
  .stepn-text { align-items: center; }
  .stepn-text b { font-size: 12px; }
  .stepn-text small { font-size: 11px; max-width: 100%; }
  .stepn:not(:last-child)::after { right: -4px; top: 17px; width: 4px; }
  .layout { margin-top: 12px; gap: 12px; }
  .col-side { gap: 12px; }
  .panel { padding: 16px; border-radius: 16px; }
  input, textarea, select { font-size: 16px; } /* 避免 iOS 聚焦時自動放大 */
  .overview { padding: 14px; }
  .ov-big > b { font-size: 30px; }
  .toolbar .btn:not(.icon-only) { flex: 1; }
  .menu-pop { left: auto; right: 0; }
  .week-top { padding: 10px 12px; }
  .week-head { gap: 6px; }
  .week-dates input { font-size: 15px; padding: 4px 2px; }
  .week-days { gap: 8px; }
  .dfield { flex: 1 1 100%; }
  .dfield label { width: 56px; }
  .dfield-row { flex: 1; }
  .note-in { flex: 1; width: auto; font-size: 15px; }
  .num-in { width: 52px; }
  .tasks { padding: 2px 12px; }
  .task { grid-template-columns: minmax(0, 1fr); }
  .task-title { font-size: 15px; }
  .task-ctl { gap: 8px; }
  .cat-wrap { flex: 1; min-width: 0; }
  .cat-select { width: 100%; font-size: 15px; }
  .dstep, .icon-btn { flex: none; }
  .dstep button { width: 34px; height: 40px; }
  .dstep input { font-size: 16px; width: 42px; }
  .dstep .unit { display: none; }
  .cat-select { padding-left: 24px; padding-right: 24px; background-position: right 9px center; }
  .cat-wrap::before { left: 10px; }
  .icon-btn { width: 40px; height: 40px; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 40px; }
  .stepper button { width: 44px; height: 44px; }
  .stepper input { width: 60px; }
  .import-grid { grid-template-columns: 1fr; }
  .dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .dialog-body { padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .rule-row { grid-template-columns: 1fr; gap: 4px; }
  .history { grid-template-columns: 1fr; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
}
