/* =====================================================================
 * Kidult Chess Academy — prototype stylesheet
 * 視覺依客戶手機截圖：# RENEWAL DETAILS / # FEE OVERVIEW 兩欄卡片
 * ===================================================================== */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e7eaef;
  --line-strong: #d7dce4;
  --ink: #14181f;
  --ink-2: #3c4450;
  --muted: #8b929e;
  --muted-2: #aab1bc;
  --blue: #1d4ed8;
  --blue-soft: #eff4ff;
  --orange: #c2410c;
  --orange-soft: #fff5f0;
  --green: #0f7b4f;
  --red: #c0392b;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 28px rgba(16, 24, 40, .05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC",
               "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 20px 72px; }

/* ---------- 頂部工具列 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: #2b2430; color: #fff; display: grid; place-items: center;
  font-size: 16px;
}
.brand .name { font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.brand .sub { font-size: 12.5px; color: var(--muted); }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  display: inline-flex; align-items: center; height: 34px; padding: 0 13px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: #fff;
  color: var(--ink-2); font-size: 13.5px; font-weight: 600; text-decoration: none;
}
.nav a:hover { background: #f7f8fa; }
.nav a.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- 版面 ---------- */
.grid {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 20px; align-items: start;
}
.grid.wide { grid-template-columns: minmax(0, 1fr); }
.sticky { position: sticky; top: 20px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }

.eyebrow {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}
.h1 { font-size: 27px; font-weight: 800; letter-spacing: .01em; margin: 6px 0 20px; }
.h2 { font-size: 17px; font-weight: 700; margin: 0 0 12px; }
.h3 { font-size: 14px; font-weight: 700; margin: 18px 0 8px; color: var(--ink-2); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); font-weight: 500; }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
hr.dash { border: none; border-top: 1px dashed var(--line-strong); margin: 16px 0; }

/* ---------- 表單 ---------- */
.field { margin-bottom: 16px; }
.label { font-size: 15px; font-weight: 600; margin-bottom: 8px; color: var(--ink); }
.sub-label { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.row { display: flex; gap: 10px; align-items: flex-start; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }

.input, .select {
  width: 100%; height: 46px; padding: 0 12px; font-size: 15px; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-family: inherit; outline: none;
}
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, .select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 78, 216, .13); }
.input:disabled, .select:disabled { background: #f6f7f9; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.check { display: inline-flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 14px; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }

/* 金額輸入：$ 前綴在框內 */
.money-wrap { position: relative; max-width: 220px; }
.money-wrap .pfx {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14.5px; font-weight: 600; pointer-events: none;
}
.money-wrap .input { padding-left: 28px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 46px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  font-family: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: #f7f8fa; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2a3240; }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.blue:hover { background: #1a45c0; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.tall { height: auto; min-height: 46px; line-height: 1.25; padding: 6px 14px; text-align: center; }
.btn.icon { width: 34px; height: 34px; padding: 0; font-size: 15px; color: var(--muted); }
.btn.icon:hover { color: var(--red); border-color: var(--red); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- 班別區塊 ---------- */
.course {
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 16px 8px;
  background: #fcfcfd; margin-bottom: 16px;
}
.course.is-addon { background: #fffdf8; border-color: #f0e3cd; }
.course-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px;
}
.tag {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue); font-size: 12.5px; font-weight: 700;
}
.tag.addon { background: #fdf3e3; color: #9a6212; }
.tag.gray { background: #f1f3f6; color: var(--ink-2); }

/* ---------- 日期 chips ---------- */
.dates-block { margin: 4px 0 16px; }
.dates-title {
  display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700;
  color: var(--ink-2); margin-bottom: 9px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; height: 28px; padding: 0 10px;
  border-radius: 8px; background: #f1f3f6; color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.chip.hol {
  background: var(--orange-soft); color: var(--orange); text-decoration: line-through;
  text-decoration-thickness: 1.5px; font-weight: 600;
}
.chip.kept { background: #eef7f1; color: var(--green); }
.chip.first { background: var(--ink); color: #fff; }
.chip.first::after { content: "首堂"; font-size: 10px; margin-left: 6px; opacity: .85; }
.empty { font-size: 13px; color: var(--muted); }

/* ---------- 提示 / 警告 ---------- */
.notes { margin: 0 0 14px; }
.note {
  display: flex; gap: 8px; font-size: 13px; line-height: 1.45; padding: 9px 11px;
  border-radius: 9px; margin-bottom: 8px; border: 1px solid transparent;
}
.note.info { background: #f5f7fa; color: var(--ink-2); border-color: var(--line); }
.note.warn { background: var(--orange-soft); color: var(--orange); border-color: #f6ddcd; }
.note.good { background: #f0f8f3; color: var(--green); border-color: #d6ebdf; }
.note b { font-weight: 700; }

/* ---------- 假期清單 ---------- */
.hol-list { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.hol-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; font-size: 13px;
  border-bottom: 1px solid var(--line); background: #fff;
}
.hol-row:last-child { border-bottom: none; }
.hol-row .d { font-family: var(--mono); font-size: 12.5px; color: var(--ink); min-width: 74px; font-weight: 600; }
.hol-row .n { flex: 1 1 auto; color: var(--ink-2); min-width: 0; }
.hol-row .act { font-size: 12px; font-weight: 700; white-space: nowrap; }
.hol-row .act.off { color: var(--orange); }
.hol-row .act.on { color: var(--green); }
.hol-row.na { background: #fafbfc; color: var(--muted); }

/* ---------- 費用摘要 ---------- */
.srow {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 9px 0; font-size: 15px;
}
.srow .k { color: var(--ink-2); }
.srow .v { font-weight: 600; }
.srow.card-line .k { color: var(--ink); font-weight: 700; }
.srow.dim .v { color: var(--muted); font-weight: 500; }
.srow .v.neg { color: var(--ink-2); }
.total {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding-top: 14px; border-top: 1px dashed var(--line-strong);
}
.total .k { font-size: 17px; font-weight: 800; }
.total .amt { font-size: 27px; font-weight: 800; color: var(--blue); letter-spacing: -.01em; }
.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; background: #f1f3f6; color: var(--ink-2);
}
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.green { background: #eef7f1; color: var(--green); }

.dates-card {
  margin-top: 18px; background: #fafbfc; border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
}
.dates-card .head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.cal {
  width: 22px; height: 22px; border-radius: 5px; flex: none; background: #fff;
  border: 1px solid #e3b7b7; color: #b4483f; font-size: 9.5px; font-weight: 800;
  display: grid; place-items: center; line-height: 1; position: relative;
}
.cal::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: #b4483f; border-radius: 4px 4px 0 0;
}
.cal span { margin-top: 4px; }
.dates-card .title { font-size: 14.5px; font-weight: 700; }
.dates-card .grp { margin-bottom: 10px; }
.dates-card .grp:last-child { margin-bottom: 0; }
.dates-card .grp .gl { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.dates-card .ph { margin-top: 9px; font-size: 13px; color: var(--orange); font-weight: 600; }
.dates-card .ph.kept { color: var(--green); }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th {
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; background: #fbfcfd; white-space: nowrap;
}
.table tbody tr:hover { background: #fcfcfd; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.total-row td { font-weight: 800; border-top: 1px solid var(--line-strong); background: #fbfcfd; }
.table .wd { font-weight: 700; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- 其他 ---------- */
.preset-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.pill-note { font-size: 12.5px; color: var(--muted); }
ul.clean { margin: 8px 0 0; padding-left: 20px; }
ul.clean li { margin-bottom: 6px; font-size: 14px; color: var(--ink-2); }
code.kbd {
  font-family: var(--mono); font-size: 12.5px; background: #f1f3f6; padding: 1.5px 6px;
  border-radius: 6px; color: var(--ink);
}
details.rules { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fcfcfd; }
details.rules summary { cursor: pointer; font-weight: 700; font-size: 14px; }
details.rules > *:not(summary) { margin-top: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.section-title { font-size: 20px; font-weight: 800; margin: 30px 0 14px; }
.footer { margin-top: 34px; font-size: 12.5px; color: var(--muted-2); text-align: center; }

/* =====================================================================
 * Invoice（收費單）— 畫面預覽 + 列印
 * ===================================================================== */
.inv-wrap { display: none; }
.inv-wrap.show {
  display: block; position: fixed; inset: 0; z-index: 90;
  background: rgba(17, 22, 30, .55); overflow: auto; padding: 26px 16px 64px;
}
.inv-toolbar {
  max-width: 1000px; margin: 0 auto 14px; display: flex; gap: 10px; align-items: center;
}
.inv-toolbar .spacer { margin-right: auto; color: #fff; font-size: 13px; opacity: .9; white-space: nowrap; }

.inv-sheet {
  max-width: 840px; margin: 0 auto; background: #fff; color: #16181d;
  border-radius: 12px; padding: 36px 40px 30px; font-size: 13.5px; line-height: 1.55;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
}
.inv-tiny { font-size: 11.5px; color: #6b7280; }
.inv-blank { color: #b9bec7; letter-spacing: .04em; }

.inv-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 24px;
  border-bottom: 2px solid #16181d; padding-bottom: 15px;
}
.inv-brand { display: flex; gap: 13px; align-items: flex-start; }
.inv-logo {
  width: 42px; height: 42px; border-radius: 50%; flex: none; background: #2b2430;
  color: #fff; display: grid; place-items: center; font-size: 20px;
}
.inv-name { font-size: 16.5px; font-weight: 800; letter-spacing: .01em; }
.inv-sub { font-size: 12px; color: #5b6270; }
.inv-meta { text-align: right; font-size: 12.5px; color: #33383f; white-space: nowrap; }
.inv-title { font-size: 21px; font-weight: 800; letter-spacing: .14em; margin-bottom: 5px; }

.inv-billto {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px 26px;
  padding: 15px 0; border-bottom: 1px dashed #c3c8d0;
}
.inv-billto .k { display: inline-block; min-width: 84px; color: #6b7280; }
.inv-billto .v { font-weight: 600; }

.inv-table { width: 100%; border-collapse: collapse; margin: 18px 0 4px; font-size: 13px; }
.inv-table th {
  background: #f3f4f7; border-bottom: 1px solid #c9ced6; padding: 9px;
  text-align: left; font-size: 11.5px; font-weight: 700; color: #33383f; white-space: nowrap;
}
.inv-table td { padding: 10px 9px; border-bottom: 1px solid #e6e8ec; vertical-align: top; }
.inv-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.inv-dateblock { margin-top: 12px; font-size: 12.5px; }
.inv-dateblock .dl { margin-bottom: 8px; color: #33383f; }

.inv-totals { margin: 18px 0 0 auto; width: 330px; }
.inv-totals .r { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; }
.inv-totals .r span:last-child { font-variant-numeric: tabular-nums; }
.inv-totals .r.grand {
  border-top: 2px solid #16181d; margin-top: 7px; padding-top: 11px;
  font-size: 17px; font-weight: 800;
}

.inv-notes { margin-top: 24px; border-top: 1px dashed #c3c8d0; padding-top: 13px; font-size: 12px; color: #454b54; }
.inv-notes ul { margin: 7px 0 0; padding-left: 19px; }
.inv-notes li { margin-bottom: 4px; }

.inv-sign { margin-top: 30px; display: flex; gap: 46px; font-size: 12px; color: #5b6270; }
.inv-sign div { flex: 1; border-top: 1px solid #9aa1ab; padding-top: 7px; }
.inv-foot { margin-top: 20px; font-size: 10.5px; color: #9aa1ab; text-align: center; }

/* ---------- 列印：只印 Invoice ---------- */
@media print {
  .wrap.app { display: none !important; }
  .inv-wrap, .inv-wrap.show {
    display: block !important; position: static !important; inset: auto !important;
    background: none !important; padding: 0 !important; overflow: visible !important;
  }
  .inv-toolbar { display: none !important; }
  .inv-sheet {
    max-width: none; margin: 0; box-shadow: none; border-radius: 0; padding: 0; font-size: 12px;
  }
  .inv-table tr, .inv-totals, .inv-notes, .inv-sign, .inv-dateblock { break-inside: avoid; }
  @page { size: A4; margin: 14mm; }
}

/* ---------- 響應式 ---------- */
@media (max-width: 980px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
  .wrap { padding: 16px 14px 60px; }
  .h1 { font-size: 23px; }
}
@media (max-width: 560px) {
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 14px; }
  .total .amt { font-size: 23px; }
}

/* ---------- 列印 ---------- */
@media print {
  body { background: #fff; }
  .nav, .preset-bar, .no-print, .toast { display: none !important; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .sticky { position: static; }
  .grid { grid-template-columns: 1fr; }
}
