/* ============================================================
   장부셈 / BizKit
   Ledger paper: warm stock, green ink, vermilion stamp.
   ============================================================ */

:root {
  --paper: #f3f1e8;
  --paper-2: #faf8f0;
  --card: #fffef9;
  --ink: #14231d;
  --ink-2: #2b3a33;
  --muted: #5d6a63;
  --faint: #8b958e;
  --line: #ded9c9;
  --line-2: #c8c1ad;
  --green: #0f6b4f;
  --green-2: #17835f;
  --green-soft: #e7f2ec;
  --green-line: #c2dccd;
  --red: #b23a2a;
  --red-soft: #fbeae6;
  --amber: #96630a;
  --amber-soft: #fbf0d6;
  --slate-soft: #eceee9;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(20, 35, 29, .05), 0 18px 40px -30px rgba(20, 35, 29, .4);
  --shadow-sm: 0 1px 2px rgba(20, 35, 29, .05);
  --sans: "Inter", "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", Georgia, "Noto Serif KR", serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 92px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.62;
  letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  word-break: keep-all;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(700px 460px at 94% -10%, rgba(15, 107, 79, .1), transparent 64%),
    radial-gradient(560px 380px at -8% 8%, rgba(178, 58, 42, .05), transparent 70%),
    var(--paper);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(20, 35, 29, .03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(20, 35, 29, .03) 1px, transparent 1px);
  background-size: 88px 88px;
  -webkit-mask-image: radial-gradient(1100px 760px at 50% 0%, #000 6%, transparent 74%);
  mask-image: radial-gradient(1100px 760px at 50% 0%, #000 6%, transparent 74%);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--green); }
img, canvas, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -.035em; line-height: 1.18; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--green); color: #fff; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--ink); color: #fff; font-weight: 700;
  padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 16px; }

/* ---------------- header ---------------- */

.hdr {
  position: sticky; top: 0; z-index: 40;
  background: rgba(243, 241, 232, .88);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.hdr-in { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--ink); color: #fff;
  display: grid; place-items: center; flex: none;
  box-shadow: 0 6px 14px -8px rgba(20, 35, 29, .8);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 3px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 5px;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-word { display: flex; align-items: baseline; gap: 8px; font-weight: 900; font-size: 18.5px; letter-spacing: -.045em; }
.brand-word em {
  font-style: normal; font-family: var(--mono);
  font-size: 10px; letter-spacing: .16em; color: var(--muted);
  text-transform: uppercase; font-weight: 600;
}
.hdr nav { display: flex; align-items: center; gap: 22px; font-size: 14.5px; color: var(--ink-2); font-weight: 600; }
.hdr nav a { padding: 6px 0; }
.hdr nav a:hover { color: var(--green); }
.lang {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-2); background: rgba(255, 254, 249, .7);
  padding: 7px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-2);
  white-space: nowrap;
}
.lang:hover { border-color: var(--ink); color: var(--ink); }

.strip {
  border-bottom: 1px dashed var(--line-2);
  background: rgba(255, 254, 249, .55);
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.strip .wrap { min-height: 34px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 5px; padding-bottom: 5px; }
.strip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: none; box-shadow: 0 0 0 3px rgba(15, 107, 79, .14); }
.strip strong { color: var(--ink-2); font-weight: 700; }
.strip .sep { color: var(--line-2); }
.strip .right { margin-left: auto; }

/* ---------------- hero ---------------- */

.hero { padding: 44px 0 24px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--green);
  background: var(--green-soft); border: 1px solid var(--green-line);
  padding: 5px 10px; border-radius: 6px; font-weight: 700; margin-bottom: 16px;
}
.hero h1 { font-size: clamp(30px, 4.6vw, 52px); letter-spacing: -.045em; line-height: 1.12; max-width: 17em; }
.hero h1 .hl {
  background: linear-gradient(180deg, transparent 60%, rgba(178, 58, 42, .18) 60%);
  padding: 0 2px;
}
.hero p.lede { margin-top: 16px; color: var(--muted); font-size: 16.5px; max-width: 42em; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}
.chip svg { width: 14px; height: 14px; color: var(--green); flex: none; }
.chip .mono { font-size: 11.5px; color: var(--muted); }

/* ---------------- ad slots ---------------- */

.ad {
  margin: 22px 0;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  background: rgba(255, 254, 249, .55);
  min-height: 76px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--faint); font-size: 11.5px;
  text-align: center; padding: 12px 16px;
}
.ad .ad-tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em;
  border: 1px solid var(--line-2); border-radius: 4px; padding: 2px 5px;
}
.ad--foot { min-height: 90px; }

/* ---------------- tabs ---------------- */

.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; margin: 8px 0 0;
  border-bottom: 1px solid var(--line-2);
  position: sticky; top: 64px; z-index: 30;
  background: linear-gradient(180deg, var(--paper) 70%, rgba(243, 241, 232, .92));
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding-top: 6px;
}
.tab {
  appearance: none; border: 0; background: transparent;
  padding: 13px 10px 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  font-weight: 700; font-size: 14.5px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  text-align: center; line-height: 1.25;
}
.tab .tab-no {
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .06em;
  color: var(--faint); border: 1px solid var(--line-2); border-radius: 4px;
  padding: 2px 4px; flex: none;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab[aria-selected="true"] .tab-no { background: var(--ink); color: #fff; border-color: var(--ink); }

.panel { padding: 26px 0 8px; }
.panel[hidden] { display: none; }

/* ---------------- cards ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 18px; align-items: start; }
.grid-2 + .grid-2, .card + .card, .grid-2 + .card, .card + .grid-2, .card + .grid-2 { margin-top: 18px; }
.stack > * + * { margin-top: 18px; }

.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.kicker {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--green); font-weight: 700;
}
.card-head h2 { font-size: 20px; letter-spacing: -.03em; }
.card-head .hint { margin-left: auto; font-size: 12px; color: var(--faint); }

/* ---------------- generic form ---------------- */

.field label, .fld label { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.inp, .field input, .field select {
  width: 100%; height: 42px;
  border: 1px solid var(--line-2); border-radius: 9px;
  background: #fff; color: var(--ink);
  padding: 0 11px; font: inherit; font-size: 14px; font-weight: 600;
  transition: border-color .15s, box-shadow .15s;
}
.inp:focus, .field input:focus, .field select:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 107, 79, .12);
}
textarea.inp { height: auto; min-height: 76px; padding: 10px 11px; line-height: 1.55; font-weight: 500; resize: vertical; }
.inp::placeholder { color: #b3b8b0; font-weight: 500; }

/* ---------------- tab 1: segmented modes ---------------- */

.seg {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px;
  background: var(--paper-2); border: 1px solid var(--line);
  padding: 4px; border-radius: 12px; margin-bottom: 20px;
}
.seg-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  border-radius: 9px; padding: 9px 6px; text-align: center;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg-btn b { display: block; font-size: 13.5px; font-weight: 700; letter-spacing: -.02em; color: var(--ink-2); }
.seg-btn span { display: block; font-size: 10.5px; color: var(--faint); margin-top: 1px; }
.seg-btn:hover b { color: var(--green); }
.seg-btn[aria-pressed="true"] { background: var(--ink); box-shadow: 0 8px 16px -12px rgba(20, 35, 29, .9); }
.seg-btn[aria-pressed="true"] b { color: #fff; }
.seg-btn[aria-pressed="true"] span { color: rgba(255, 255, 255, .55); }

.big-field { display: block; margin-top: 4px; }
.big-field .bf-label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.big-money {
  display: flex; align-items: center; gap: 6px;
  border-bottom: 2px solid var(--ink); padding: 4px 0 6px;
}
.big-money input {
  flex: 1; width: 100%; min-width: 0; border: 0; background: transparent;
  font-family: var(--mono); font-size: clamp(28px, 4.4vw, 38px); font-weight: 700;
  letter-spacing: -.04em; text-align: right; color: var(--ink);
  padding: 0; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.big-money input::-webkit-outer-spin-button, .big-money input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.big-money input:focus { outline: none; }
.big-money .unit { font-size: 15px; font-weight: 700; color: var(--muted); padding-bottom: 4px; }
.big-field .bf-hint { display: block; margin-top: 8px; font-size: 11.5px; color: var(--faint); }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 16px; }
.quick-label { font-size: 11px; color: var(--faint); font-weight: 600; margin-right: 2px; }
.chip-btn {
  appearance: none; cursor: pointer; border: 1px solid var(--line-2);
  background: var(--paper-2); border-radius: 999px; padding: 6px 11px;
  font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink-2);
}
.chip-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-soft); }

.checkline { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; cursor: pointer; }
.checkline input { accent-color: var(--green); width: 16px; height: 16px; }

.fine { font-size: 11.5px; color: var(--faint); margin-top: 14px; line-height: 1.5; }

/* ---------------- receipt result ---------------- */

.receipt {
  background: #fffdf6;
  border: 1px solid var(--line);
  border-top: 3px solid var(--ink);
  border-radius: 4px 4px var(--radius) var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 16px;
  position: relative;
}
.receipt::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -7px; height: 7px;
  background: linear-gradient(-45deg, transparent 5px, var(--card) 0), linear-gradient(45deg, transparent 5px, var(--card) 0);
  background-size: 10px 10px;
  background-position: left bottom;
  background-repeat: repeat-x;
}
.receipt-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 9px; letter-spacing: .16em;
  color: var(--faint); text-transform: uppercase;
  border-bottom: 1px dashed var(--line-2); padding-bottom: 10px;
}
.receipt-big { padding: 18px 0 12px; }
.receipt-big .rk { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.receipt-big .rv {
  display: block; font-family: var(--mono); font-weight: 700;
  font-size: clamp(32px, 4.8vw, 44px); letter-spacing: -.045em; line-height: 1.12;
  margin-top: 2px; word-break: break-all;
}
.receipt-big .rv em { font-style: normal; font-size: .45em; color: var(--muted); margin-left: 4px; letter-spacing: 0; font-weight: 600; }
.receipt-rows { border-top: 1px dashed var(--line-2); }
.rrow { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-bottom: 1px dashed rgba(222, 217, 201, .8); font-size: 13px; color: var(--muted); }
.rrow b { font-family: var(--mono); font-size: 13.5px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.rrow.strong { border-bottom: 1px solid var(--ink); color: var(--ink); font-weight: 700; }
.rrow.strong b { font-size: 16px; }
.rrow.subrow { padding-left: 12px; font-size: 11.5px; border-bottom-style: dotted; }
.rrow.subrow b { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.receipt-formula {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-2);
  background: var(--paper-2); border-radius: 7px; padding: 8px 10px; margin-top: 12px;
  word-break: break-all;
}
.receipt-yearly { font-size: 11.5px; color: var(--green); margin-top: 8px; font-weight: 600; }
.receipt-note { font-size: 11.5px; color: var(--faint); margin-top: 10px; line-height: 1.55; }
.receipt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 14px; }
.receipt-grid > div { background: #fffdf6; padding: 9px 11px; }
.receipt-grid span { display: block; font-size: 10px; color: var(--faint); font-weight: 600; }
.receipt-grid b { font-family: var(--mono); font-size: 14px; font-weight: 700; }
.receipt-rule { height: 1px; background: transparent; }
.receipt-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; font-size: 10.5px; color: var(--faint); }
.link-btn {
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer;
  font-size: 11.5px; font-weight: 700; color: var(--green); text-decoration: underline;
  text-underline-offset: 2px;
}
.mini-links { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 16px; font-size: 12.5px; font-weight: 600; }
.mini-links a { color: var(--green); }

/* ---------------- buttons ---------------- */

.btn {
  appearance: none; cursor: pointer; border: 0; border-radius: 9px;
  padding: 11px 15px; font-size: 13.5px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: #fff;
  transition: transform .12s, background .15s, box-shadow .15s;
  box-shadow: 0 10px 20px -14px rgba(20, 35, 29, .9);
}
.btn:hover { background: #1d312a; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn svg { width: 15px; height: 15px; }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line-2); box-shadow: none; }
.btn.ghost:hover { background: var(--paper-2); color: var(--ink); border-color: var(--ink-2); }
.btn.blue { background: var(--green); }
.btn.blue:hover { background: #0c5a42; }
.btn.sm { padding: 8px 11px; font-size: 12.5px; border-radius: 8px; }

/* ---------------- tab 2: invoice ---------------- */

.inv-toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.inv-toolbar h2 { font-size: 22px; margin-top: 2px; }
.inv-toolbar .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.inv-form { display: grid; gap: 14px; }
.inv-doc-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.1fr; gap: 12px; }
.inv-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inv-two .card, .inv-form .card { padding: 20px; }
.inv-group h3 { font-size: 13px; letter-spacing: .02em; color: var(--muted); text-transform: uppercase; font-family: var(--mono); font-weight: 700; margin-bottom: 14px; }
.inv-group .fld + .fld { margin-top: 10px; }
.fld-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fld-2 + .fld { margin-top: 10px; }

.items { margin-top: 2px; }
.item-head, .item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 118px 108px 26px;
  gap: 8px; align-items: center;
}
.item-head {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); font-weight: 700; padding: 0 2px 6px;
}
.item-head .ta-r { text-align: right; }
.item-row { padding: 5px 0; border-top: 1px solid rgba(222, 217, 201, .7); }
.item-row input {
  width: 100%; height: 36px; border: 1px solid transparent; border-radius: 7px;
  background: var(--paper-2); padding: 0 9px; font: inherit; font-size: 13px; color: var(--ink);
  min-width: 0;
}
.item-row .it-qty, .item-row .it-price { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.item-row input:hover { border-color: var(--line-2); }
.item-row input:focus { outline: none; border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(15, 107, 79, .1); }
.it-amt { font-family: var(--mono); font-size: 12.5px; font-weight: 700; text-align: right; color: var(--ink-2); white-space: nowrap; }
.it-del {
  appearance: none; background: none; border: 0; cursor: pointer;
  width: 26px; height: 26px; border-radius: 6px; color: var(--faint);
  font-size: 16px; line-height: 1; display: grid; place-items: center;
}
.it-del:hover { color: var(--red); background: var(--red-soft); }
.items-empty { padding: 18px 4px; font-size: 13px; color: var(--faint); }
.items-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.items-foot .spacer { margin-left: auto; }

.inv-sum { display: flex; gap: 22px; justify-content: flex-end; align-items: baseline; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--ink); flex-wrap: wrap; }
.inv-sum > div { display: flex; align-items: baseline; gap: 8px; }
.inv-sum span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.inv-sum b { font-family: var(--mono); font-size: 14.5px; font-weight: 700; }
.inv-sum .strong b { font-size: 19px; }
.inv-sum .strong span { color: var(--ink); font-weight: 700; }

.preview-wrap { margin-top: 26px; }
.preview-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.preview-head h3 { font-size: 15px; }
.preview-head span { font-size: 11.5px; color: var(--faint); }
.preview-head #inv-zoom { display: none; margin-left: auto; }
.zoom-hint { font-size: 11.5px; color: var(--faint); margin: -4px 0 10px; }
.paper {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px -44px rgba(20, 35, 29, .55), 0 2px 4px rgba(20, 35, 29, .06);
  border-radius: 3px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- the A4 sheet ---- */
.inv-sheet {
  width: 794px; min-height: 1123px;
  margin: 0 auto; padding: 46px 44px 30px;
  background: #fff; color: #1a231d;
  font-size: 11.5px; line-height: 1.5;
  display: flex; flex-direction: column;
  letter-spacing: -.005em;
}
.sh-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 26px; }
.sh-from { max-width: 52%; padding-top: 2px; }
.sh-name { font-size: 1.75em; font-weight: 800; letter-spacing: -.03em; line-height: 1.2; }
.sh-line { font-size: .92em; color: #6b736d; margin-top: .28em; line-height: 1.45; }
.sh-line.sm { font-size: .86em; }
.sh-title { text-align: right; }
.sh-en { font-family: var(--mono); font-size: .74em; letter-spacing: .28em; color: #97a09a; font-weight: 600; }
.sh-ko { font-size: 2.35em; font-weight: 800; letter-spacing: .06em; line-height: 1.2; margin-top: .1em; }
.sh-meta { margin-top: .9em; display: grid; gap: .22em; }
.sh-meta > div { display: flex; justify-content: flex-end; gap: 1em; font-size: .84em; }
.sh-meta span { color: #97a09a; }
.sh-meta b { font-family: var(--mono); font-weight: 600; color: #303b34; min-width: 8.5em; text-align: right; }

.sh-to {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 20px; margin-top: 2.4em; padding: 1.1em 1.2em;
  background: #f8f7f1; border-left: 3px solid #14231d;
}
.sh-lbl { display: block; font-family: var(--mono); font-size: .72em; letter-spacing: .14em; text-transform: uppercase; color: #97a09a; font-weight: 700; }
.sh-client { margin-top: .35em; font-size: 1.28em; font-weight: 700; letter-spacing: -.01em; }
.sh-client span { font-weight: 500; color: #5d6a63; font-size: .82em; margin-left: .3em; }
.sh-to .sh-line { margin-top: .3em; }
.sh-total-mini { font-family: var(--mono); font-size: 1.5em; font-weight: 700; margin-top: .25em; }

.sh-table { width: 100%; border-collapse: collapse; margin-top: 2em; font-size: .95em; }
.sh-table th {
  background: #14231d; color: #fff; font-size: .82em; font-weight: 600;
  letter-spacing: .06em; text-align: left; padding: .62em .6em;
}
.sh-table td { padding: .66em .6em; border-bottom: 1px solid #ecebe3; vertical-align: top; }
.sh-table .c-no { width: 3.2em; text-align: center; color: #97a09a; font-family: var(--mono); font-size: .88em; }
.sh-table th.c-no { color: rgba(255, 255, 255, .7); }
.sh-table .c-desc { word-break: break-word; }
.sh-table .c-num { width: 6.4em; text-align: right; white-space: nowrap; }
.sh-table .c-amt { width: 7.6em; text-align: right; white-space: nowrap; font-family: var(--mono); font-weight: 600; }
.sh-table td.c-num { font-family: var(--mono); }
.sh-table .sh-empty { text-align: center; color: #97a09a; padding: 2.2em 0; }

.sh-bottom { display: flex; justify-content: space-between; gap: 26px; margin-top: 1.8em; align-items: flex-start; }
.sh-notes { flex: 1; min-width: 0; display: grid; gap: 1em; }
.sh-note p { margin-top: .35em; font-size: .92em; color: #4b554f; line-height: 1.55; white-space: normal; }
.sh-totals { width: 15.5em; flex: none; }
.sh-totals > div { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; padding: .42em 0; font-size: .92em; color: #5d6a63; }
.sh-totals b { font-family: var(--mono); font-size: 1.02em; color: #1a231d; font-weight: 600; }
.sh-totals .grand { border-top: 1px solid #14231d; margin-top: .3em; padding-top: .55em; color: #14231d; font-weight: 700; }
.sh-totals .grand b { font-size: 1.45em; font-weight: 700; }

.sh-foot { margin-top: auto; padding-top: 2.4em; }
.sh-foot p { font-size: .86em; color: #97a09a; }
.sh-sign { display: flex; align-items: flex-end; gap: .6em; justify-content: flex-end; margin-top: 1.4em; font-size: .86em; color: #5d6a63; }
.sh-sign i { display: block; width: 9em; border-bottom: 1px solid #c8c1ad; height: 1.3em; }
.sh-maker { margin-top: 1.1em; padding-top: .8em; border-top: 1px solid #ecebe3; font-size: .7em; color: #b3b7b2; font-family: var(--mono); letter-spacing: .02em; }

/* ---------------- tab 3: BEP ---------------- */

.bep-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.preset {
  appearance: none; cursor: pointer; border: 1px solid var(--line-2);
  background: var(--paper-2); border-radius: 999px; padding: 7px 13px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.preset:hover { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.bep-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bep-fields .span2 { grid-column: 1 / -1; }
.bep-fields > div { min-width: 0; }
.bep-fields label { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.bep-fields label[data-unit]::after { content: " (" attr(data-unit) ")"; font-weight: 600; color: var(--faint); }
.bep-fields input { width: 100%; height: 42px; border: 1px solid var(--line-2); border-radius: 9px; background: #fff; padding: 0 11px; font-family: var(--mono); font-size: 14px; font-weight: 600; text-align: right; }
.bep-fields input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(15, 107, 79, .12); }

.bep-big { border-bottom: 2px solid var(--ink); padding-bottom: 12px; }
.bep-big .k { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.bep-big .v { display: block; font-family: var(--mono); font-size: clamp(34px, 5vw, 46px); font-weight: 700; letter-spacing: -.04em; line-height: 1.15; }
.bep-big .v em { font-style: normal; font-size: .38em; color: var(--muted); margin-left: 4px; font-weight: 600; }
.bep-big .s { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.bep-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 16px; }
.bep-grid > div { background: var(--card); padding: 10px 12px; }
.bep-grid span { display: block; font-size: 10px; color: var(--faint); font-weight: 600; }
.bep-grid b { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.bep-grid b.neg { color: var(--red); }
.bep-grid b.pos { color: var(--green); }
.bep-note { font-size: 11px; color: var(--faint); margin-top: 12px; line-height: 1.5; }
.bep-invalid { background: var(--red-soft); border: 1px solid #f0cbc5; color: var(--red); border-radius: 10px; padding: 14px; font-size: 13px; font-weight: 600; }
.bep-fig { margin-top: 18px; }
.bep-legend { display: flex; gap: 16px; margin: 0 0 4px 4px; font-size: 11px; color: var(--muted); font-weight: 600; }
.bep-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bep-legend span::before { content: ""; width: 18px; border-top: 2px solid var(--green); display: inline-block; }
.bep-legend .lg-cost::before { border-top: 2px dashed var(--red); }
.bep-fig svg { width: 100%; height: auto; display: block; overflow: visible; }
.bep-fig .grid { stroke: #e9e6da; stroke-width: 1; }
.bep-fig .axis { stroke: #bdb7a6; stroke-width: 1; }
.bep-fig .ax { font-family: var(--mono); font-size: 11px; fill: var(--faint); }
.bep-fig .ln-rev { stroke: var(--green); stroke-width: 2.2; fill: none; }
.bep-fig .ln-cost { stroke: var(--red); stroke-width: 2.2; fill: none; stroke-dasharray: 6 4; }
.bep-fig .ln-drop { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; opacity: .35; }
.bep-fig .dot { fill: var(--ink); stroke: #fff; stroke-width: 2; }
.bep-fig .bep-lab { font-family: var(--mono); font-size: 11px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: #fffef9; stroke-width: 4px; stroke-linejoin: round; }

/* ---------------- sections ---------------- */

.section { padding: 40px 0 10px; }
.section-head { max-width: 46em; margin-bottom: 20px; }
.section-head .kicker { display: block; margin-bottom: 8px; }
.section-head h2 { font-size: clamp(22px, 3vw, 30px); }
.section-head p { color: var(--muted); margin-top: 8px; font-size: 14.5px; }

.aff-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.aff {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow-sm); position: relative;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.aff:hover { transform: translateY(-2px); border-color: var(--line-2); box-shadow: var(--shadow); color: inherit; }
.aff .aff-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 14px; font-weight: 800; letter-spacing: -.03em; }
.aff h3 { font-size: 14.5px; letter-spacing: -.02em; }
.aff p { font-size: 12px; color: var(--muted); line-height: 1.5; }
.aff .go { font-size: 11.5px; font-weight: 700; color: var(--green); margin-top: auto; }
.aff .tag { position: absolute; top: 12px; right: 12px; font-family: var(--mono); font-size: 8.5px; letter-spacing: .1em; color: var(--faint); border: 1px solid var(--line); padding: 1px 4px; border-radius: 3px; }
.aff-note { font-size: 11px; color: var(--faint); margin-top: 10px; line-height: 1.5; }

.guide-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gcard {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 6px;
  transition: transform .15s, box-shadow .15s;
}
.gcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: inherit; }
.gcard .gk { font-family: var(--mono); font-size: 9px; letter-spacing: .14em; color: var(--green); font-weight: 700; }
.gcard h3 { font-size: 14px; line-height: 1.4; letter-spacing: -.02em; }
.gcard p { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.gcard .gm { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-top: auto; padding-top: 6px; }

.xlinks { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.xlink {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
  transition: border-color .15s, transform .15s;
}
.xlink:hover { border-color: var(--green); transform: translateY(-1px); color: inherit; }
.xlink b { font-size: 13px; letter-spacing: -.02em; }
.xlink span { font-size: 11px; color: var(--muted); }

/* ---------------- FAQ ---------------- */

.faq { max-width: 820px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  cursor: pointer; list-style: none; padding: 16px 28px 16px 0; position: relative;
  font-weight: 700; font-size: 15px; letter-spacing: -.02em;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 4px; top: 14px; font-size: 18px; color: var(--faint); font-weight: 400; }
.faq details[open] summary::after { content: "−"; }
.faq details p { padding: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.7; }

/* ---------------- footer ---------------- */

.ftr { margin-top: 48px; background: var(--ink); color: rgba(255, 255, 255, .72); padding: 34px 0 26px; }
.ftr a { color: rgba(255, 255, 255, .86); }
.ftr a:hover { color: #fff; }
.ftr-top { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; align-items: flex-start; }
.ftr .brand-mark { background: #fff; color: var(--ink); box-shadow: none; }
.ftr .brand-mark::after { border-color: rgba(20, 35, 29, .25); }
.ftr .brand-word { color: #fff; }
.ftr .brand-word em { color: rgba(255, 255, 255, .45); }
.ftr p { font-size: 12px; line-height: 1.65; max-width: 30em; color: rgba(255, 255, 255, .52); margin-top: 10px; }
.ftr-links { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12.5px; font-weight: 600; max-width: 520px; }
.ftr-links a { padding: 2px 0; }
.ftr-bottom {
  margin-top: 24px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .12);
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between;
  font-size: 11px; color: rgba(255, 255, 255, .4); font-family: var(--mono);
}

/* ---------------- prose / docs ---------------- */

.narrow { max-width: 880px; margin: 0 auto; padding: 0 24px; }
.doc-hero { padding: 44px 0 8px; max-width: 800px; }
.doc-hero h1 { font-size: clamp(27px, 4vw, 40px); }
.doc-hero .dek { margin-top: 12px; color: var(--muted); font-size: 16px; }
.doc-meta { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--faint); font-family: var(--mono); }
.guide-hero { padding: 42px 0 4px; }
.guide-hero .gk { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; color: var(--green); font-weight: 700; }
.guide-hero h1 { margin-top: 10px; font-size: clamp(26px, 3.8vw, 38px); }
.guide-hero .dek { margin-top: 12px; color: var(--muted); font-size: 16px; }
.guide-hero .meta { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.prose { max-width: 760px; padding: 26px 0 20px; font-size: 16px; line-height: 1.8; color: var(--ink-2); }
.prose > * + * { margin-top: 18px; }
.prose h2 { font-size: 22px; margin-top: 38px; letter-spacing: -.03em; color: var(--ink); }
.prose h3 { font-size: 17px; margin-top: 26px; color: var(--ink); }
.prose p { color: var(--ink-2); }
.prose ul, .prose ol { margin: 0; padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--green); }
.prose strong { color: var(--ink); }
.prose a { color: var(--green); text-decoration: underline; text-underline-offset: 2px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 14px 0 6px; }
.prose th, .prose td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.prose th { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--paper-2); }
.prose td.num { font-family: var(--mono); text-align: right; white-space: nowrap; }
.prose .callout { background: var(--paper-2); border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 10px; padding: 14px 16px; font-size: 14px; color: var(--ink-2); }
.prose .callout b { color: var(--ink); }
.prose .lead { font-size: 17.5px; line-height: 1.7; color: var(--ink-2); }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cta-box { background: var(--ink); color: #fff; border-radius: 16px; padding: 22px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 30px 0 10px; }
.cta-box .ct { flex: 1; min-width: 220px; }
.cta-box b { display: block; font-size: 17px; letter-spacing: -.02em; }
.cta-box span { font-size: 13px; color: rgba(255, 255, 255, .62); }
.cta-box .btn { background: #fff; color: var(--ink); }
.doc-foot-nav { display: flex; flex-wrap: wrap; gap: 10px; margin: 38px 0 10px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.doc-foot-nav a { color: var(--green); }

.guide-list { display: grid; gap: 12px; max-width: 860px; }
.guide-row {
  display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 16px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .15s;
}
.guide-row:hover { border-color: var(--green); transform: translateY(-1px); color: inherit; }
.guide-row .gnum { font-family: var(--mono); font-size: 15px; color: var(--faint); font-weight: 700; }
.guide-row h3 { font-size: 15.5px; letter-spacing: -.02em; }
.guide-row p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.guide-row .garrow { color: var(--faint); font-size: 18px; }

/* ---------------- toast ---------------- */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(14px);
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 600;
  padding: 11px 16px; border-radius: 9px; z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .6); max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 404 ---------------- */

.nf { min-height: 62vh; display: grid; place-content: center; text-align: center; padding: 40px 0; }
.nf .code { font-family: var(--mono); font-size: 64px; font-weight: 700; color: var(--green); letter-spacing: -.06em; line-height: 1; }
.nf h1 { font-size: 24px; margin-top: 12px; }
.nf p { color: var(--muted); margin-top: 8px; }
.nf .actions { justify-content: center; margin-top: 22px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- responsive ---------------- */

@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .aff-grid, .guide-grid { grid-template-columns: repeat(2, 1fr); }
  .xlinks { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
  .wrap { padding: 0 16px; }
  .hdr-in { height: 56px; gap: 12px; }
  .hdr nav { display: none; }
  .brand-word { font-size: 17px; }
  .brand-word em { display: none; }
  .strip { font-size: 10px; }
  .strip .right { display: none; }
  .hero { padding: 26px 0 14px; }
  .hero h1 { font-size: clamp(26px, 8vw, 34px); }
  .hero p.lede { font-size: 14px; margin-top: 10px; line-height: 1.58; }
  .hero-meta { margin-top: 14px; gap: 6px; }
  .chip { padding: 5px 9px; font-size: 11.5px; }
  .eyebrow { margin-bottom: 10px; font-size: 9.5px; padding: 4px 8px; }
  .ad { margin: 14px 0; min-height: 60px; }
  .tabs { top: 56px; }
  .tab { padding: 11px 4px; font-size: 12.5px; gap: 6px; flex-direction: column; }
  .tab .tab-no { font-size: 9px; padding: 1px 3px; }
  .preview-head #inv-zoom { display: inline-flex; }
  .card { padding: 18px 16px; border-radius: 14px; }
  .seg { gap: 3px; }
  .seg-btn { padding: 8px 4px; }
  .seg-btn b { font-size: 12px; }
  .seg-btn span { font-size: 9.5px; }
  .receipt { padding: 16px 16px 14px; }
  .receipt-big .rv { font-size: clamp(28px, 9vw, 38px); }
  .receipt-grid { grid-template-columns: 1fr 1fr; }
  .inv-toolbar h2 { font-size: 19px; }
  .inv-toolbar .actions { margin-left: 0; width: 100%; }
  .inv-toolbar .actions .btn { flex: 1; justify-content: center; }
  .inv-doc-row { grid-template-columns: 1fr 1fr; }
  .inv-two { grid-template-columns: 1fr; }
  .inv-form .card { padding: 16px; }
  .item-head, .item-row { grid-template-columns: minmax(0, 1fr) 46px 82px 24px; gap: 6px; }
  .item-head span:nth-child(4), .item-row .it-amt { display: none; }
  .item-row input { height: 34px; font-size: 12px; padding: 0 7px; }
  .inv-sum { gap: 12px 18px; }
  .inv-sum b { font-size: 13px; }
  .inv-sum .strong b { font-size: 17px; }
  .paper { overflow-x: auto; }
  .inv-sheet { width: 100%; min-height: 0; padding: 22px 18px 18px; font-size: 8.4px; }
  .paper.zoomed .inv-sheet { width: 794px; min-height: 1123px; padding: 40px 36px 28px; font-size: 11px; }
  .sh-top { gap: 12px; }
  .sh-from { max-width: 50%; }
  .sh-ko { font-size: 2.2em; }
  .sh-meta b { min-width: 7em; }
  .sh-table th, .sh-table td { padding: .55em .35em; }
  .sh-table .c-no { width: 2.4em; }
  .sh-table .c-num { width: 4.2em; }
  .sh-table .c-amt { width: 5.4em; }
  .sh-bottom { gap: 12px; }
  .sh-totals { width: 12.5em; }
  .bep-fields { grid-template-columns: 1fr 1fr; }
  .bep-big .v { font-size: 38px; }
  .bep-grid b { font-size: 13.5px; }
  .aff-grid, .guide-grid { grid-template-columns: 1fr; }
  .xlinks { grid-template-columns: repeat(2, 1fr); }
  .guide-row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; padding: 14px; }
  .ftr-top { flex-direction: column; }
  .narrow { padding: 0 16px; }
  .guide-hero { padding: 28px 0 2px; }
  .prose { font-size: 15.5px; }
  .prose h2 { font-size: 20px; margin-top: 30px; }
}

/* ---------------- print: only the invoice sheet ---------------- */

@page { size: A4; margin: 0; }

@media print {
  html, body { background: #fff !important; }
  body::before, body::after { display: none !important; }
  .hdr, .strip, .hero, .tabs, .ad, .ftr, .section, .skip, .toast,
  .inv-toolbar, .inv-form, .preview-head, .zoom-hint, .mini-links,
  .panel:not(#tab-invoice) { display: none !important; }
  .panel { padding: 0; }
  .wrap { max-width: none; padding: 0; margin: 0; }
  .preview-wrap { margin: 0; }
  .paper { border: 0 !important; box-shadow: none !important; overflow: visible !important; background: #fff; }
  #inv-sheet {
    position: static;
    width: 210mm; min-height: 296mm;
    margin: 0; padding: 14mm 13mm 12mm;
    font-size: 9.4pt; line-height: 1.45;
    border: 0; box-shadow: none;
    display: flex; flex-direction: column;
  }
}
