/* ภ.ง.ด.50 planning page — standalone, no Divi. Light theme. */
:root {
  --blue: #2ea3f2;
  --blue-ink: #0b6fb3; /* AA on white for text/links */
  --blue-soft: #e8f5fe;
  --navy: #091744;
  --red: #ff1e1e;
  --red-ink: #c40000;
  --red-soft: #fff0f0;
  --green: #0c9900;
  --green-ink: #0a7a00;
  --green-soft: #ecf8ea;
  --yellow: #ffc254;
  --yellow-ink: #8a5a00;
  --yellow-soft: #fff7e6;
  --bg: #ffffff;
  --bg-alt: #f5f5f5;
  --ink: #1d2433;
  --muted: #5d6676;
  --line: #e3e6ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(9, 23, 68, 0.04), 0 6px 24px rgba(9, 23, 68, 0.06);
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-alt);
  color: var(--ink);
  font-family: 'Kanit', system-ui, sans-serif;
  font-weight: 300;
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}
h1, h2, h3 { font-weight: 500; color: var(--navy); line-height: 1.3; }
b, strong { font-weight: 500; }
small { font-size: 0.82em; color: var(--muted); font-weight: 300; }
a { color: var(--blue-ink); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--navy); color: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.muted { color: var(--muted); margin: 0 0 14px; font-size: 0.95rem; }
.num, .tnum { font-variant-numeric: tabular-nums; }

/* header / footer */
.pc-header { background: #fff; border-bottom: 1px solid var(--line); }
.pc-header__in { display: flex; align-items: center; gap: 14px; min-height: 64px; }
.brand img { display: block; height: 40px; width: auto; }
.pc-header__tag { color: var(--muted); font-size: 0.95rem; border-left: 1px solid var(--line); padding-left: 14px; }
.pc-footer { padding: 28px 0 40px; color: var(--muted); font-size: 0.9rem; }
.pc-footer p { margin: 4px 0; }

/* hero */
.hero { padding: 20px 0 4px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px; }
.hero__text { min-width: 0; flex: 1 1 520px; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); margin: 0 0 2px; }
.lead { margin: 0; color: var(--muted); max-width: 760px; }
.kbd { display: inline-block; font-size: 0.85em; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--navy); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

/* buttons */
.btn {
  border: 1px solid transparent; border-radius: 999px; padding: 7px 16px; cursor: pointer;
  font-weight: 400; background: #fff; line-height: 1.4;
}
.btn--soft { background: var(--blue-soft); color: var(--blue-ink); border-color: #cbe8fc; }
.btn--soft:hover { background: #d7eefd; }
.btn--ghost { border-color: var(--line); color: var(--navy); }
.btn--ghost:hover { border-color: var(--blue); }
.btn--add { border: 1px dashed #9ccfef; color: var(--blue-ink); background: #fff; border-radius: 10px; width: 100%; padding: 8px; margin-top: 4px; }
.btn--add:hover { background: var(--blue-soft); }
.btn--small { padding: 3px 12px; font-size: 0.88rem; }
.btn--fill { background: var(--blue); color: #fff; }
.btn--fill:hover { background: var(--blue-ink); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  cursor: pointer; color: var(--muted); flex: 0 0 auto; display: inline-grid; place-items: center;
}
.icon-btn:hover { color: var(--red-ink); border-color: #f3b3b3; }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; padding: 12px 0 24px; }
.inputs { display: grid; gap: 16px; min-width: 0; }
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 22px 20px; min-width: 0; }
.card h2 { font-size: 1.2rem; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card h2 small { font-size: 0.8rem; }
.step {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: 0.9rem; font-weight: 500; flex: 0 0 auto;
}
h3.sub { font-size: 1rem; margin: 22px 0 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field label { display: block; font-weight: 400; margin-bottom: 4px; color: var(--navy); }

/* money input */
.money { position: relative; display: flex; align-items: center; min-width: 0; }
.money input {
  width: 100%; min-width: 0; height: 44px; padding: 0 30px 0 12px; border: 1px solid #cfd5df; border-radius: 10px;
  background: #fff; text-align: right; font-variant-numeric: tabular-nums; font-weight: 400; font-size: 1.05rem;
}
.money input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(46, 163, 242, 0.25); }
.money input[readonly] { background: var(--bg-alt); color: var(--muted); }
.money .unit { position: absolute; right: 11px; color: var(--muted); pointer-events: none; font-size: 0.9rem; }
.money input.is-invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 30, 30, 0.15); }

/* SME wizard */
.q { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.q legend { font-weight: 400; color: var(--navy); margin-bottom: 8px; padding: 0; }
.qn { display: inline-block; font-size: 0.8rem; background: var(--blue-soft); color: var(--blue-ink); border-radius: 6px; padding: 0 8px; margin-right: 6px; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice {
  display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; min-width: 0;
}
.choice:hover { border-color: var(--blue); }
.choice input { margin: 5px 0 0; accent-color: var(--blue); flex: 0 0 auto; width: 16px; height: 16px; }
.choice:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.choice span { min-width: 0; }
.choice small { display: block; }
.hint { margin-top: 8px; font-size: 0.92rem; }
.hint summary { cursor: pointer; color: var(--blue-ink); width: fit-content; }
.hint p { margin: 6px 0; color: var(--muted); }
.check { margin: 10px 0 0; font-size: 0.92rem; }
.check .ok { color: var(--green-ink); }
.check .no { color: var(--red-ink); }
.sme-result { margin: 4px 0 10px; font-weight: 400; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 10px; font-size: 0.85rem;
  font-weight: 500; border: 1px solid transparent; white-space: nowrap; line-height: 1.6;
}
.badge--sme { background: var(--green-soft); color: var(--green-ink); border-color: #bfe5b8; }
.badge--gen { background: #eef0f4; color: var(--navy); border-color: #d9dde5; }
button.badge { cursor: pointer; }
button.badge:hover { border-color: var(--blue); }

/* banners */
.banners { display: grid; gap: 10px; }
.banner { border-radius: 12px; padding: 12px 14px; border: 1px solid; border-left-width: 5px; }
.banner p { margin: 0; }
.banner .title { font-weight: 500; }
.banner--danger { background: var(--red-soft); border-color: #ffc2c2; border-left-color: var(--red); color: #5c0000; }
.banner--warn, .banner--caution { background: var(--yellow-soft); border-color: #ffe0a3; border-left-color: var(--yellow); color: #4d3200; }
.banner--info { background: var(--blue-soft); border-color: #cbe8fc; border-left-color: var(--blue); color: #08365a; }
.banner details { margin-top: 6px; font-size: 0.92rem; }
.banner summary { cursor: pointer; font-weight: 400; text-decoration: underline; width: fit-content; }
.banner details p { margin-top: 6px; }

/* option toggle */
.option { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; background: #fcfcfd; }
.switch { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.switch input { width: 18px; height: 18px; margin: 4px 0 0; accent-color: var(--blue); flex: 0 0 auto; }
.pill { display: inline-block; background: var(--yellow-soft); color: var(--yellow-ink); border: 1px solid #ffd98a; border-radius: 999px; padding: 0 8px; font-size: 0.78rem; font-weight: 400; margin-left: 4px; vertical-align: 1px; }
.option .desc { margin: 2px 0 0 28px; }

/* donation rows */
.don-rows { display: grid; gap: 10px; margin-bottom: 8px; }
.don-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; }
.don-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.don-main select {
  width: 100%; min-width: 0; height: 44px; border: 1px solid #cfd5df; border-radius: 10px; padding: 0 10px; background: #fff;
  text-overflow: ellipsis;
}
.don-main select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(46, 163, 242, 0.25); }
.don-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-top: 6px; font-size: 0.88rem; }
.don-desc { color: var(--muted); }
.edon { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; color: var(--navy); }
.edon input { accent-color: var(--blue); width: 16px; height: 16px; margin: 0; }
.note { margin: 6px 0 0; font-size: 0.92rem; font-weight: 400; }
.note--ok { color: var(--green-ink); }
.note--warn { color: var(--yellow-ink); }
.note--bad { color: var(--red-ink); }
.note--muted { color: var(--muted); font-weight: 300; }

/* cap bars */
.caps { display: grid; gap: 14px; }
.cap-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.cap-name { font-weight: 400; color: var(--navy); }
.cap-name small { margin-left: 4px; }
.cap-nums { font-variant-numeric: tabular-nums; font-size: 0.92rem; color: var(--muted); }
.bar { height: 10px; background: #edf0f4; border-radius: 999px; overflow: hidden; margin: 6px 0; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--green); transition: width 0.25s ease; }
.cap--yellow .bar > span { background: var(--yellow); }
.cap--red .bar > span { background: var(--red); }
.cap-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.9rem; }
.cap--red .cap-foot .msg { color: var(--red-ink); font-weight: 400; }
.cap-foot .msg { min-width: 0; }

/* cost + suggestion */
.cost { margin-top: 18px; background: var(--bg-alt); border-radius: 12px; padding: 14px 16px; }
.cost h3 { margin: 0 0 8px; font-size: 1rem; }
.cost dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; margin: 0; }
.cost dt { color: var(--muted); }
.cost dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 400; }
.cost .strong { color: var(--navy); font-weight: 500; }
.cost .per100 { margin: 10px 0 0; font-size: 1.05rem; color: var(--navy); }
.cost .per100 b { font-size: 1.3rem; color: var(--green-ink); }
.suggestion { margin-top: 12px; border: 1px solid #cbe8fc; background: var(--blue-soft); color: #08365a; border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.suggestion p { margin: 0; min-width: 0; flex: 1 1 260px; }

/* adjustment lines */
.adj-lines { display: grid; gap: 10px; margin-bottom: 10px; }
.adj-line { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.adj-head { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(130px, 200px); gap: 10px; align-items: center; }
.adj-title label, .adj-title .lbl { font-weight: 400; color: var(--navy); display: block; }
.adj-title .desc, .desc { margin: 0; color: var(--muted); font-size: 0.86rem; }
.sign { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-weight: 500; }
.sign--plus { background: var(--red-soft); color: var(--red-ink); }
.sign--minus { background: var(--green-soft); color: var(--green-ink); }
.expand { background: none; border: 0; padding: 4px 0; color: var(--blue-ink); cursor: pointer; font-size: 0.9rem; margin-top: 4px; }
.expand[aria-expanded='true'] .caret { display: inline-block; transform: rotate(90deg); }
.caret { display: inline-block; transition: transform 0.15s; }
.items { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { border: 1px solid #cbe8fc; background: #fff; color: var(--blue-ink); border-radius: 999px; padding: 3px 12px; cursor: pointer; font-size: 0.88rem; text-align: left; }
.chip:hover { background: var(--blue-soft); }
.chip:disabled { color: #9aa3b2; border-color: var(--line); cursor: not-allowed; background: #fafafa; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; padding: 8px 0; border-bottom: 1px solid #f0f2f5; }
.item:last-child { border-bottom: 0; }
.item-body { min-width: 0; }
.item-label { font-weight: 400; color: var(--navy); }
.item-label input { width: 100%; height: 38px; border: 1px solid #cfd5df; border-radius: 8px; padding: 0 10px; }
.item-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 6px; }
.item-inputs .money input { height: 40px; font-size: 1rem; }
.item-inputs .lbl { font-size: 0.82rem; color: var(--muted); display: block; margin-bottom: 2px; }
.item-out { margin: 4px 0 0; font-size: 0.9rem; font-weight: 400; color: var(--navy); }
.item-out.bad { color: var(--red-ink); }
.from-don { margin-top: 8px; font-size: 0.9rem; display: flex; justify-content: space-between; gap: 8px; color: var(--navy); background: var(--bg-alt); border-radius: 8px; padding: 6px 10px; }
.from-don span:last-child { font-variant-numeric: tabular-nums; font-weight: 400; }

/* summary */
.summary { position: sticky; top: 16px; display: grid; gap: 14px; min-width: 0; max-height: calc(100vh - 32px); overflow: auto; overscroll-behavior: contain; }
.summary__card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; border-top: 4px solid var(--blue); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-head h2 { font-size: 1.15rem; margin: 0 0 8px; }
.sheet-close { display: none; }
.lines { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; font-size: 0.93rem; }
.lines dt, .lines dd { padding: 4px 0; border-bottom: 1px solid #f1f3f6; margin: 0; }
.lines dd { text-align: right; font-variant-numeric: tabular-nums; font-weight: 400; padding-left: 10px; white-space: nowrap; }
.lines .op { display: inline-block; width: 1.3em; color: var(--muted); font-weight: 400; }
.lines .zero { color: #a3aab6; font-weight: 300; }
.lines .total { font-weight: 500; color: var(--navy); border-bottom: 2px solid var(--line); }
.lines .subl { font-size: 0.84rem; color: var(--muted); padding: 1px 0 3px 1.6em; border-bottom: 0; font-weight: 300; }
.lines dd.subl { padding-left: 10px; }
.lines .taxrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.lines details { grid-column: 1 / -1; font-size: 0.85rem; color: var(--muted); padding: 2px 0 6px 1.6em; }
.lines details summary { cursor: pointer; color: var(--blue-ink); width: fit-content; }
.brk { width: 100%; border-collapse: collapse; margin-top: 4px; }
.brk td { padding: 2px 0; }
.brk td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.lossnote { grid-column: 1 / -1; font-size: 0.85rem; color: var(--muted); padding: 2px 0 6px 1.6em; }
.final { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--navy); color: #fff; position: sticky; bottom: 0; box-shadow: 0 -10px 16px -6px #fff; }
.final__label { font-size: 0.95rem; opacity: 0.9; }
.final__value { font-size: clamp(1.9rem, 4.5vw, 2.4rem); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; letter-spacing: 0.3px; }
.final__note { font-size: 0.85rem; opacity: 0.85; margin-top: 2px; }
.final.is-refund { background: var(--green-ink); }
.sum-alert { display: block; width: 100%; text-align: left; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; font-size: 0.88rem; cursor: pointer; border: 1px solid; }
.sum-alert--danger { background: var(--red-soft); border-color: #ffc2c2; color: #5c0000; }
.sum-alert--caution, .sum-alert--warn { background: var(--yellow-soft); border-color: #ffe0a3; color: #4d3200; }

.disclaimer { background: var(--yellow-soft); border: 1px solid #ffd98a; border-radius: 12px; padding: 12px 14px; font-size: 0.9rem; color: #4d3200; }
.disclaimer p { margin: 0; }
.disclaimer .ref { margin-top: 6px; color: var(--yellow-ink); }
.mobile-only { display: none; }

/* mobile bar + sheet */
.mobile-bar { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(9, 23, 68, 0.45); z-index: 45; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff;
  padding: 8px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: 0.2s; z-index: 70; font-size: 0.92rem;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; }
}

@media (max-width: 768px) {
  body { padding-bottom: 76px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 18px 14px 16px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .choices { grid-template-columns: minmax(0, 1fr); }
  .adj-head { grid-template-columns: auto minmax(0, 1fr); }
  .adj-head .money { grid-column: 1 / -1; }
  .don-main { grid-template-columns: minmax(0, 1fr) auto; }
  .don-main select { grid-column: 1 / -1; }
  .mobile-only { display: block; }
  .pc-header__tag { display: none; }

  .summary {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 50; max-height: 88vh; overflow: auto;
    background: var(--bg-alt); border-radius: 18px 18px 0 0; padding: 12px 12px 20px;
    transform: translateY(105%); visibility: hidden; transition: transform 0.25s ease, visibility 0s linear 0.25s;
    box-shadow: 0 -8px 30px rgba(9, 23, 68, 0.2);
  }
  body.sheet-open { overflow: hidden; }
  body.sheet-open .summary { transform: none; visibility: visible; transition: transform 0.25s ease; }
  .summary .disclaimer { display: none; }
  .summary__card { box-shadow: none; }
  .sheet-close {
    display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
    background: #fff; cursor: pointer; font-size: 1rem; flex: 0 0 auto;
  }

  .mobile-bar {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(9, 23, 68, 0.08);
  }
  .mobile-bar button {
    width: 100%; display: flex; align-items: center; gap: 8px; justify-content: space-between; border: 0; cursor: pointer;
    background: var(--navy); color: #fff; border-radius: 12px; padding: 10px 14px; text-align: left;
  }
  .mobile-bar button.is-refund { background: var(--green-ink); }
  .mobile-bar strong { font-size: 1.2rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-left: auto; white-space: nowrap; }
  .toast { bottom: auto; top: 12px; transform: translateX(-50%) translateY(-20px); }
  .toast.show { transform: translateX(-50%) translateY(0); }
}

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