:root {
  --bg: #F5F8FC;
  --bg-glow-1: #DCE8FF;
  --bg-glow-2: #DDF2FD;
  --card: #FFFFFF;
  --card-glass: rgba(255, 255, 255, .9);
  --field: #FFFFFF;
  --line: #E2E8F0;
  --line-2: #D3DBE6;
  --soft: #EEF3F9;
  --hover: #F4F7FB;
  --ink: #1E293B;
  --ink-2: #334155;
  --sub: #52627A;
  --muted: #64748B;
  --faint: #CBD5E1;
  --ac: #2563EB;
  --ac-2: #0EA5E9;
  --ac-hover: #1D4ED8;
  --ac-soft: #E8F0FF;
  --ac-ink: #1D4ED8;
  --ring: rgba(37, 99, 235, .16);
  --stage: linear-gradient(180deg, #E7EDF5, #D9E2EE);
  --ok: #047857;
  --ok-soft: #E7F8F1;
  --warn: #B45309;
  --danger: #DC2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --overlay: rgba(15, 23, 42, .45);
  --r: 12px;
  --r-lg: 16px;
  --font: 'Inter', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --tabbar-h: 64px;
  color-scheme: light;
}

/* Dark theme: deep blue surfaces, never pure black. The quote paper itself stays white. */
html.dark {
  --bg: #0F1E35;
  --bg-glow-1: #17386A;
  --bg-glow-2: #113C5C;
  --card: #172B47;
  --card-glass: rgba(23, 43, 71, .9);
  --field: #12243D;
  --line: #28426A;
  --line-2: #33507A;
  --soft: #1D355A;
  --hover: #1E3858;
  --ink: #E8EEF7;
  --ink-2: #C9D5E6;
  --sub: #A7B6CC;
  --muted: #8DA0BA;
  --faint: #3D5A82;
  --ac: #5B9BFF;
  --ac-2: #38BDF8;
  --ac-hover: #78ADFF;
  --ac-soft: rgba(91, 155, 255, .16);
  --ac-ink: #93BBFF;
  --ring: rgba(91, 155, 255, .28);
  --stage: linear-gradient(180deg, #0D1B30, #0B182B);
  --ok: #34D399;
  --ok-soft: rgba(52, 211, 153, .14);
  --warn: #FBBF24;
  --danger: #FB7185;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 10px 28px -14px rgba(0, 0, 0, .5);
  --overlay: rgba(6, 14, 28, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: radial-gradient(1100px 480px at 8% -12%, var(--bg-glow-1), transparent 60%), radial-gradient(900px 480px at 100% -8%, var(--bg-glow-2), transparent 55%), var(--bg); background-attachment: fixed; color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
a { color: var(--ac); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.boot { min-height: 100vh; }
.noscript { max-width: 760px; margin: 40px auto; padding: 16px 20px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); color: var(--ink-2); }

:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 500; font-size: 14px;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover); border-color: var(--line-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: linear-gradient(135deg, var(--ac), var(--ac-2)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px -8px rgba(37, 99, 235, .6); }
.btn.primary:hover { background: linear-gradient(135deg, var(--ac-hover), var(--ac)); border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.lg { height: 50px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.danger-text { color: var(--danger) !important; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 10px; border: none; background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: var(--soft); }
.icon-btn.sm { width: 34px; height: 34px; color: var(--muted); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.link-btn { border: none; background: none; color: var(--ac-ink); font: inherit; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 6px 0; }
.link-btn svg { width: 18px; height: 18px; }

input, select, textarea {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--field);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px; height: 42px; width: 100%; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
textarea { padding: 10px 12px; height: auto; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ac); box-shadow: 0 0 0 4px var(--ring); }
input[type="color"] { padding: 4px; width: 56px; cursor: pointer; }
input[type="checkbox"] { width: auto; height: auto; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--sub); }
.field > span { display: flex; align-items: center; gap: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span2 { grid-column: span 2; }
.form-error { color: var(--danger); font-size: 14px; min-height: 1em; }
.form-error:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 38px; padding: 0 16px; border-radius: 99px; border: 1px solid var(--line); background: var(--card);
  color: var(--sub); font: inherit; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--line-2); }
.chip.active { background: var(--ac); border-color: var(--ac); color: #fff; }
.chip.active .pro { background: rgba(255,255,255,.18); color: #fff; }

.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.b-draft { background: #FEF3C7; color: #92400E; }
.b-sent { background: #DBEAFE; color: #1D4ED8; }
.b-won { background: #D1FAE5; color: #065F46; }
.b-lost { background: #F1F5F9; color: #475569; }
.pro { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: #FEF3C7; color: #92400E; letter-spacing: .3px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card.narrow { width: 100%; max-width: 420px; padding: 28px; gap: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-tools { display: flex; gap: 8px; align-items: center; }
.card-tools select { height: 36px; font-size: 14px; max-width: 220px; }

.search { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); flex: 1; }
.search input { border: none; height: 100%; padding: 0; box-shadow: none !important; background: transparent; }
.search.sm { height: 38px; flex: 0 1 260px; }

.switch { position: relative; width: 52px; height: 30px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--faint); border-radius: 99px; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--ac); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 2px solid var(--ac); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; width: 248px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; padding: 22px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 0 8px 22px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--ac), var(--ac-2)); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.brand-name em { font-style: normal; color: var(--ac); }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: var(--sub); text-decoration: none; font-size: 15px; }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { background: var(--ac-soft); color: var(--ac-ink); font-weight: 600; }
.side-foot { margin-top: auto; }
.plan-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.plan-user { display: flex; gap: 10px; align-items: center; min-width: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ac-soft); color: var(--ac-ink); display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.plan-who { display: flex; flex-direction: column; min-width: 0; }
.plan-who strong, .plan-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.plan-who span { font-size: 12px; color: var(--muted); }
.plan-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--sub); gap: 8px; }
.meter { height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.meter div { height: 100%; background: var(--ac); border-radius: 99px; }

.main { flex: 1; min-width: 0; padding: 32px 36px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1280px; }
.main.main-editor { max-width: none; }
.tabbar { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- quotes list ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.stat span { font-size: 13px; color: var(--sub); }
.stat strong { font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.stat small { font-size: 12px; color: var(--muted); }
.stat small.ok { color: var(--ok); }
.stat.accent { background: linear-gradient(150deg, #2563EB, #0EA5E9); border-color: transparent; color: #fff; }
.stat.accent span, .stat.accent small { color: rgba(255,255,255,.88); }
.toolbar { display: flex; gap: 10px; }

.qlist { display: flex; flex-direction: column; gap: 10px; }
.qrow { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.qrow:hover { border-color: var(--line-2); box-shadow: 0 4px 14px rgba(15,23,42,.05); }
.qrow-mark { width: 46px; height: 46px; border-radius: 12px; background: var(--soft); color: var(--ink-2); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 17px; flex-shrink: 0; }
.qrow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.qrow-main .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qrow-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qrow-title strong { font-size: 15px; }
.qrow-amt { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.qrow-amt strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.qrow-amt .muted { font-size: 12px; }
.qrow-go { color: var(--faint); display: flex; }

.empty { background: var(--card); border: 1px dashed var(--line-2); border-radius: 18px; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }

/* ---------- tables ---------- */
.table-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
.dtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.dtable th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dtable td { padding: 14px 16px; border-top: 1px solid var(--soft); vertical-align: middle; }
.dtable tbody tr:first-child td { border-top: none; }
.dtable thead + tbody tr:first-child td { border-top: none; }
.cell-main { display: flex; flex-direction: column; gap: 2px; }
.cell-main .muted { font-size: 13px; }
.row-tools { text-align: right; white-space: nowrap; width: 1%; }
.row-tools > * + * { margin-left: 4px; }
.dtable.users td { min-width: 120px; }
.dtable.users td:first-child { min-width: 240px; }
.dtable.users input[type="date"] { height: 36px; font-size: 14px; width: 160px; }
.dtable.users select { height: 36px; font-size: 14px; width: 96px; }

/* ---------- editor ---------- */
.ed-top { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; position: sticky; top: 12px; z-index: 5; }
.ed-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ed-title > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ed-title strong { font-size: 17px; }
.ed-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.seg { display: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg-btn { flex: 1; height: 40px; border: none; border-radius: 9px; background: transparent; font: inherit; font-weight: 500; color: var(--sub); cursor: pointer; }
.seg-btn.active { background: var(--ac); color: #fff; }
.editor { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(0, 1.05fr); gap: 24px; align-items: start; }
.ed-form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ed-preview { position: sticky; top: 92px; background: var(--stage); border-radius: 20px; padding: 20px; min-width: 0; }
.stage { position: relative; overflow: hidden; }
.stage-inner { width: 794px; transform-origin: top left; margin: 0 auto; }
.stage-inner .paper { box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 14px 36px rgba(15,23,42,.12); border-radius: 4px; }

.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; padding: 14px 0; border-top: 1px solid var(--soft); }
.item:first-child { border-top: none; padding-top: 0; }
.item-main { display: flex; flex-direction: column; gap: 6px; grid-column: 1; }
.item-name { font-weight: 500; }
.item-desc { height: 36px; font-size: 14px; color: var(--sub); }
.item-tools { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; }
.item-nums { grid-column: 1 / -1; display: grid; grid-template-columns: 90px 80px minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
.item-nums label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.item-nums input { height: 38px; font-variant-numeric: tabular-nums; }
.item-total { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); text-align: right; }
.item-total strong { font-size: 16px; color: var(--ink); height: 38px; line-height: 38px; font-variant-numeric: tabular-nums; }
.item-tools { flex-direction: row; }
.add-row { height: 46px; border-radius: 12px; border: 1.5px dashed var(--line-2); background: transparent; color: var(--ac-ink); font: inherit; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.add-row:hover { background: var(--ac-soft); border-color: var(--ac); }
.sum { display: flex; flex-direction: column; gap: 6px; background: var(--soft); border: 1px solid var(--soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--sub); }
.sum > div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.sum-total { color: var(--ink); font-weight: 700; font-size: 18px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.swatch.active { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ac); }
.swatch-custom { display: inline-flex; align-items: center; gap: 6px; }
.swatch-custom input { width: 44px; height: 34px; border-radius: 10px; }
.mbar { display: none; }

/* ---------- modal ---------- */
.modal-wrap { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; animation: fade .15s ease; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 40px); background: var(--card); border-radius: 20px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px rgba(15,23,42,.25); }
.modal-form { display: flex; flex-direction: column; min-height: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 22px; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 8px 22px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--soft); flex-wrap: wrap; }
.modal-foot .form-error { margin-right: auto; }
.picker { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.pick { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; cursor: pointer; text-align: left; }
.pick:hover { border-color: var(--ac); background: var(--ac-soft); }
.pick > span:first-child { display: flex; flex-direction: column; }
.share-row { display: flex; gap: 8px; }
.share-row input { font-size: 14px; color: var(--sub); }
.share-more { display: flex; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0 } }

#toasts { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #1E3A5F; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: 0 10px 30px rgba(15,23,42,.25); transition: opacity .3s, transform .3s; animation: rise .2s ease; text-align: center; }
.toast-error { background: var(--danger); }
.toast-warn { background: #92400E; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes rise { from { opacity: 0; transform: translateY(8px) } }

/* ---------- settings / admin ---------- */
.settings { display: flex; flex-direction: column; gap: 16px; }
.uploads { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.upload { display: flex; gap: 14px; align-items: center; border: 1px solid var(--soft); border-radius: 14px; padding: 14px; }
.upload > div:last-child { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.upload-img { width: 84px; height: 84px; border-radius: 12px; background: var(--soft); display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; font-size: 12px; }
.upload-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.form-bar { display: flex; justify-content: flex-end; }
.account { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.billing { flex-direction: row; align-items: center; justify-content: space-between; gap: 20px; }
.billing p { margin-top: 4px; }
.feat-list { display: flex; flex-direction: column; }
.feat { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--soft); flex-wrap: wrap; }
.feat:first-child { border-top: none; padding-top: 0; }
.feat-info { display: flex; flex-direction: column; gap: 2px; min-width: 200px; flex: 1; }
.feat-ctrl { display: flex; gap: 10px; align-items: center; }
.feat-ctrl select { width: 140px; height: 38px; font-size: 14px; }
.inline-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--sub); white-space: nowrap; }
.inline-field input { width: 84px; height: 38px; }

/* ---------- auth / landing ---------- */
.center-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px 16px; }
.center-page .brand { padding: 0; }
.auth .muted.center a { margin-left: 4px; font-weight: 500; }

.landing { min-height: 100vh; }
.land-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 32px; max-width: 1240px; margin: 0 auto; }
.land-top .brand { padding: 0; }
.land-actions { display: flex; gap: 8px; }
.hero { max-width: 1240px; margin: 0 auto; padding: 48px 32px 80px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.hero-copy { display: flex; flex-direction: column; gap: 20px; }
.eyebrow { align-self: flex-start; background: var(--ac-soft); color: var(--ac-ink); font-weight: 600; font-size: 13px; padding: 6px 14px; border-radius: 99px; }
.hero h1 { font-size: 52px; line-height: 1.15; letter-spacing: -.5px; }
.hero p { font-size: 18px; color: var(--sub); max-width: 520px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-points { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; color: var(--ink-2); }
.hero-points li { display: flex; gap: 10px; align-items: center; }
.hero-points svg { color: var(--ok); }
.hero-paper { background: var(--stage); border-radius: 28px; padding: 28px; overflow: hidden; height: 560px; }
.hero-paper-inner { width: 794px; transform: scale(.62); transform-origin: top left; }
.hero-paper-inner .paper { box-shadow: 0 20px 50px rgba(15,23,42,.18); border-radius: 4px; }

/* ---------- share page ---------- */
.share-page { min-height: 100vh; }
.share-top { position: sticky; top: 0; z-index: 5; background: var(--card-glass); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px; }
.share-co { display: flex; align-items: center; gap: 12px; min-width: 0; }
.share-co img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; }
.share-co > div { display: flex; flex-direction: column; min-width: 0; }
.share-actions { display: flex; gap: 8px; }
.share-body { max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 20px; }
.banner { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 12px 16px; font-weight: 500; }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.accept { gap: 14px; }
.sig-wrap { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.sig { width: 100%; height: 160px; border: 1.5px dashed var(--line-2); border-radius: 12px; background: #FFFFFF; touch-action: none; cursor: crosshair; }
.powered { text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- export ---------- */
.export-host { position: fixed; left: -10000px; top: 0; width: 794px; pointer-events: none; }

/* ======================================================
   Quote paper (A4 at 96dpi = 794 × 1123)
   ====================================================== */
.paper {
  width: 794px; min-height: 1123px; background: #fff; color: #0F172A; padding: 56px 60px 48px;
  display: flex; flex-direction: column; font: 13px/1.6 var(--font); position: relative; text-align: left;
}
.paper .p-muted { color: #6B7280; font-size: 12px; }
.paper .p-label { color: #6B7280; font-size: 12px; margin-bottom: 2px; }
.p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.p-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.p-logo { width: 52px; height: 52px; object-fit: contain; border-radius: 10px; flex-shrink: 0; }
.p-logo-text { background: var(--ac); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; }
.p-co { font-size: 17px; font-weight: 700; }
.p-title { text-align: right; flex-shrink: 0; }
.p-title > div { font-size: 30px; font-weight: 700; letter-spacing: 4px; line-height: 1.2; }
.p-title span { color: #6B7280; letter-spacing: 2px; font-size: 11px; }
.p-bar { height: 4px; width: 100%; background: linear-gradient(90deg, var(--ac), var(--ac-mid)); margin: 26px 0 22px; border-radius: 2px; }
.tpl-modern .p-title > div { color: var(--ac); }
.p-info { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; }
.p-client { font-size: 16px; font-weight: 700; }
.p-meta { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; color: #374151; }
.p-meta span { color: #6B7280; margin-right: 12px; }
.p-subject { margin-top: 18px; padding: 10px 14px; background: var(--ac-soft); border-radius: 8px; font-weight: 500; }
.p-subject span { color: #6B7280; margin-right: 12px; font-weight: 400; }
.p-items { width: 100%; border-collapse: collapse; margin-top: 22px; }
.p-items th { background: #F4F5F9; color: #374151; font-weight: 600; font-size: 12px; padding: 9px 10px; text-align: left; }
.p-items th:first-child { border-radius: 6px 0 0 6px; }
.p-items th:last-child { border-radius: 0 6px 6px 0; }
.p-items td { padding: 11px 10px; border-bottom: 1px solid #EEF0F5; vertical-align: top; }
.p-items .num { text-align: right; white-space: nowrap; }
.p-items .c-no { width: 28px; color: #9AA1AE; }
.p-items .c-unit { width: 48px; text-align: center; }
.p-name { font-weight: 500; }
.p-desc { color: #6B7280; font-size: 12px; }
.p-empty { text-align: center; color: #9AA1AE; padding: 28px !important; }
.p-totals { margin: 16px 0 0 auto; width: 280px; display: flex; flex-direction: column; gap: 6px; color: #374151; }
.p-totals > div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.p-totals .p-grand { border-top: 2px solid #0F172A; padding-top: 10px; margin-top: 4px; color: #0F172A; font-weight: 700; align-items: baseline; }
.p-grand span:last-child { font-size: 22px; color: var(--ac); }
.p-foot { margin-top: auto; padding-top: 32px; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.p-notes { color: #374151; font-size: 12px; max-width: 400px; display: flex; flex-direction: column; gap: 2px; }
.p-notes .p-label { font-weight: 600; color: #374151; margin-top: 8px; }
.p-notes .p-label:first-child { margin-top: 0; }
.p-signs { display: flex; gap: 16px; flex-shrink: 0; }
.p-sign { display: flex; flex-direction: column; align-items: center; gap: 6px; color: #6B7280; font-size: 12px; }
.p-sign-box { width: 150px; height: 80px; border: 1px dashed #C7CCD8; border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.p-sign-box img { max-height: 100%; }
.p-stamp { width: 96px; height: 96px; object-fit: contain; opacity: .92; }
.p-watermark { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; font-size: 10px; color: #A3A9B6; letter-spacing: 1px; }

/* classic */
.tpl-classic { padding-top: 48px; }
.c-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.c-logo { height: 44px; object-fit: contain; margin-bottom: 6px; }
.c-co { font-size: 18px; font-weight: 700; }
.c-title { font-size: 28px; font-weight: 700; letter-spacing: 16px; margin: 14px 0 16px; padding-left: 16px; }
.tpl-classic table { border: 1.5px solid #0F172A; }
.c-info { width: 100%; border-collapse: collapse; }
.c-info th, .c-info td { border: 1px solid #0F172A; padding: 7px 10px; text-align: left; }
.c-info th { width: 90px; background: #F4F5F9; font-weight: 600; white-space: nowrap; }
.tpl-classic .p-items { margin-top: 14px; }
.tpl-classic .p-items th, .tpl-classic .p-items td { border: 1px solid #0F172A; border-radius: 0 !important; }
.tpl-classic .p-items th { background: #F4F5F9; text-align: center; }
.tpl-classic .p-totals { width: 100%; margin-top: 0; border: 1.5px solid #0F172A; border-top: none; padding: 8px 10px; }
.tpl-classic .p-totals > div { justify-content: flex-end; gap: 28px; }
.tpl-classic .p-totals .p-grand { border-top: 1px solid #0F172A; }
.tpl-classic .p-grand span:last-child { color: #0F172A; }
.tpl-classic .p-sign-box { border-style: solid; border-color: #0F172A; border-radius: 0; }

/* brand */
.tpl-brand { padding: 0 0 48px; }
.b-head { background: var(--ac); color: #fff; padding: 40px 60px 34px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.b-head .p-title span, .b-sub { color: rgba(255,255,255,.82); font-size: 12px; }
.b-logo { background: #fff; padding: 4px; }
.b-logo.p-logo-text { background: rgba(255,255,255,.2); color: #fff; }
.b-body { padding: 30px 60px 0; display: flex; flex-direction: column; flex: 1; }
.tpl-brand .p-items th { background: var(--ac-mid); color: #0F172A; }
.tpl-brand .p-totals .p-grand { background: var(--ac); color: #fff; border: none; padding: 10px 14px; border-radius: 8px; }
.tpl-brand .p-grand span:last-child { color: #fff; }

/* ---------- dark-theme tweaks ---------- */
html.dark .btn.primary { background: linear-gradient(135deg, #3B82F6, #0EA5E9); }
html.dark .chip.active, html.dark .seg-btn.active { background: #3B82F6; border-color: #3B82F6; }
html.dark .b-draft { background: rgba(251, 191, 36, .16); color: #FCD34D; }
html.dark .b-sent { background: rgba(91, 155, 255, .18); color: #A9C8FF; }
html.dark .b-won { background: rgba(52, 211, 153, .16); color: #6EE7B7; }
html.dark .b-lost { background: rgba(148, 163, 184, .16); color: #CBD5E1; }
html.dark .pro { background: rgba(251, 191, 36, .16); color: #FCD34D; }
html.dark .toast { background: #24456F; }

/* ---------- theme toggle ---------- */
.theme-toggle { display: inline-flex; background: var(--soft); border: 1px solid var(--line); border-radius: 99px; padding: 3px; gap: 2px; flex-shrink: 0; }
.theme-toggle button { width: 34px; height: 30px; border: none; border-radius: 99px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.theme-toggle button.on { background: var(--card); color: var(--ac); box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }
.side-foot { display: flex; flex-direction: column; gap: 10px; }
.side-foot .theme-toggle { align-self: flex-start; margin-left: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); text-decoration: none; margin: -6px 0 -4px -4px; }
.back-link:hover { color: var(--ac); }

/* ---------- free editor (home page) ---------- */
.fe { min-height: 100vh; padding-bottom: 32px; }
.fe-top { display: flex; align-items: center; gap: 14px; padding: 14px 28px; max-width: 1560px; margin: 0 auto; }
.fe-brand { padding: 0 !important; }
.fe-brand .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
.fe-brand .brand-name { font-size: 18px; }
.fe-nav { display: flex; gap: 4px; margin-left: 18px; }
.fe-nav-item { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px; border: none; background: transparent; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.fe-nav-item:hover { color: var(--ink); }
.fe-nav-item.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .08); cursor: default; }
.fe-nav-item .count { font-size: 12px; background: var(--ac-soft); color: var(--ac-ink); padding: 1px 8px; border-radius: 99px; }
.fe-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.fe-right .btn { height: 38px; font-size: 14px; }
.save-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ok); background: var(--ok-soft); padding: 6px 12px; border-radius: 99px; transition: opacity .2s; white-space: nowrap; }
.save-chip svg { width: 16px; height: 16px; }
.save-chip.busy { opacity: .55; }
.save-chip.bad { color: var(--danger); background: rgba(220, 38, 38, .1); }

.fe-switch, .fe-steps, .fe-mbar { display: none; }
.fe-wrap { display: grid; grid-template-columns: minmax(520px, 620px) minmax(0, 1fr); gap: 22px; padding: 4px 28px 0; max-width: 1560px; margin: 0 auto; align-items: start; }
.fe-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.fe-card { background: var(--card-glass); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; scroll-margin-top: 120px; }
.fe-h { display: flex; align-items: center; gap: 10px; }
.fe-h h2 { font-size: 16px; font-weight: 700; }
.fe-num { width: 26px; height: 26px; border-radius: 8px; background: var(--ac-soft); color: var(--ac-ink); font-weight: 800; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; }
.fe-opt { margin-left: auto; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.fe-grid { display: grid; gap: 12px; }
.fe-grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fe-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fe-grid .span-all { grid-column: 1 / -1; }
.fe .field > span { font-weight: 600; color: var(--ink-2); }
.req { color: var(--danger); }
.suffix-wrap { position: relative; display: block; }
.suffix-wrap em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12px; color: var(--muted); pointer-events: none; }
.suffix-wrap input { padding-right: 92px; }
.fe-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.fe-party { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fe-party h3 { font-size: 12px; letter-spacing: 1px; color: var(--muted); font-weight: 700; }
.fe-more { display: flex; flex-direction: column; gap: 12px; }
.fe-link { align-self: flex-start; border: none; background: none; color: var(--ac-ink); font: inherit; font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 2px 0; }
.fe-link svg { width: 16px; height: 16px; transition: transform .2s; }
.fe-link.open svg { transform: rotate(45deg); }
.fe-uploads { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.fe-upload { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; }
.fe-up-img { width: 52px; height: 52px; border-radius: 10px; background: var(--soft); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; font-size: 11px; color: var(--muted); text-align: center; }
.fe-up-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fe-up-btns { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; min-width: 0; }
.fe-up-btns .btn { height: 32px; font-size: 13px; padding: 0 10px; }
.btn.disabled { opacity: .6; cursor: not-allowed; }

/* items */
.fe-items { border: 1px solid var(--line); border-radius: 12px; background: var(--field); overflow: hidden; }
.fe-ir { display: grid; grid-template-columns: 18px minmax(0, 1fr) 96px 64px 56px 86px 22px; gap: 8px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--field); }
.fe-ir:nth-child(2) { border-top: none; }
.fe-ir-h { background: var(--soft); font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px 10px; border-top: none; }
.fe-ir.dragging { box-shadow: 0 10px 30px rgba(15, 23, 42, .18); position: relative; z-index: 2; border-radius: 10px; outline: 2px solid var(--ac); }
.fe-ir:focus-within { background: var(--hover); box-shadow: inset 3px 0 0 var(--ac); }
.fe-grip { color: var(--faint); cursor: grab; touch-action: none; display: grid; place-items: center; height: 100%; }
.fe-grip:active { cursor: grabbing; }
.fe-nm { display: flex; flex-direction: column; min-width: 0; }
.fe-in { height: 34px; border: 1px solid transparent; background: transparent; padding: 0 8px; border-radius: 8px; font-size: 14px; }
.fe-in:hover { border-color: var(--line); }
.fe-in:focus { background: var(--field); }
.fe-in.strong { font-weight: 600; }
.fe-in.sub { height: 28px; font-size: 12.5px; color: var(--muted); }
.fe-in.num { text-align: right; font-variant-numeric: tabular-nums; }
.fe-cell { display: block; min-width: 0; }
.fe-stepper { display: flex; align-items: center; }
.fe-stepper input { min-width: 0; }
.fe-amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.fe-x { width: 22px; height: 22px; border: none; background: none; color: var(--faint); cursor: pointer; display: grid; place-items: center; padding: 0; border-radius: 6px; }
.fe-x:hover { color: var(--danger); background: var(--soft); }
.fe-x svg { width: 16px; height: 16px; }
.only-m { display: none !important; }
.fe-addrow { display: flex; gap: 8px; }
.btn.dashed { flex: 1; border-style: dashed; color: var(--ink-2); }
.btn.dashed:hover { border-color: var(--ac); color: var(--ac-ink); background: var(--ac-soft); }

/* money */
.fe-money { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: start; }
.fe-money > div:first-child { display: flex; flex-direction: column; gap: 12px; }
.fe-seg { display: flex; background: var(--soft); border-radius: 10px; padding: 3px; gap: 2px; }
.fe-seg button { flex: 1; height: 34px; border: none; border-radius: 8px; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; padding: 0 8px; }
.fe-seg button.on { background: var(--card); color: var(--ac-ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.fe-seg.sm { flex: 0 0 auto; }
.fe-discount { display: flex; gap: 8px; }
.fe-total { border-radius: 16px; background: linear-gradient(150deg, #2563EB, #0EA5E9); color: #EFF6FF; padding: 16px 18px; box-shadow: 0 14px 28px -16px rgba(37, 99, 235, .7); display: flex; flex-direction: column; }
.fe-total .l { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; color: #DBEAFE; font-variant-numeric: tabular-nums; }
.fe-total .l.big { border-top: 1px dashed rgba(255, 255, 255, .4); margin-top: 8px; padding-top: 12px; color: #fff; font-size: 15px; font-weight: 700; align-items: baseline; }
.fe-total .l.big b { font-size: 28px; letter-spacing: -.5px; }
.fe-check { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-2); font-weight: 600; cursor: pointer; }

/* preview */
.fe-pv { position: sticky; top: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fe-pvbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--card-glass); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 10px 12px; }
.fe-pv-group { display: flex; align-items: center; gap: 8px; }
.fe-lab { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.fe-tpls { display: flex; gap: 6px; }
.fe-tpl { width: 46px; height: 36px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; padding: 6px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.fe-tpl i { display: block; height: 4px; border-radius: 2px; background: #E2E8F0; }
.fe-tpl.t-modern i:first-child { background: #2563EB; width: 60%; }
.fe-tpl.t-classic i { background: #64748B; }
.fe-tpl.t-classic i:first-child { width: 100%; height: 5px; }
.fe-tpl.t-brand { background: #2563EB; border-color: #2563EB; }
.fe-tpl.t-brand i { background: rgba(255, 255, 255, .45); }
.fe-tpl.t-brand i:first-child { background: #fff; width: 50%; }
.fe-tpl.on { outline: 2px solid var(--ac); outline-offset: 2px; }
.fe-swatches { display: flex; gap: 6px; align-items: center; }
.fe-sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; padding: 0; flex-shrink: 0; position: relative; display: grid; place-items: center; }
.fe-sw.on { box-shadow: 0 0 0 2px var(--ac); }
.fe-sw-custom { background: conic-gradient(#2563EB, #0EA5E9, #059669, #EAB308, #EA580C, #E11D48, #2563EB); color: #fff; }
.fe-sw-custom svg { width: 12px; height: 12px; }
.fe-sw-custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; padding: 0; border: none; }
.fe-pv-actions { display: flex; gap: 8px; margin-left: auto; }
.fe-pv-actions .btn { height: 38px; padding: 0 12px; font-size: 14px; }
.btn.icon-only { width: 38px; padding: 0; }
.fe-stage { position: relative; border-radius: 20px; background: var(--stage); border: 1px solid var(--line); padding: 16px; overflow: hidden; min-height: 360px; }
.fe-stage .stage-inner { width: 794px; transform-origin: top left; margin: 0; }
.fe-stage .paper { box-shadow: 0 24px 50px -22px rgba(15, 23, 42, .45); border-radius: 4px; }
.fe-stage-note { position: absolute; left: 14px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ok); background: var(--card); border-radius: 10px; padding: 6px 10px; box-shadow: var(--shadow); }
.fe-stage-note svg { width: 14px; height: 14px; }

/* sheet + records */
.fe-sheet { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.fe-opt-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; border: none; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; padding: 4px 0; }
.fe-opt-btn i { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--soft); color: var(--ink-2); }
.fe-opt-btn.primary i { background: linear-gradient(135deg, var(--ac), var(--ac-2)); color: #fff; }
.fe-opt-btn:disabled { opacity: .6; }
.fe-hint { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 12px; background: var(--ac-soft); color: var(--ink-2); font-size: 13.5px; text-decoration: none; }
.fe-hint b { color: var(--ac-ink); }
.fe-hint svg { color: var(--ac); flex-shrink: 0; }
.fe-records { display: flex; flex-direction: column; gap: 8px; max-height: 55vh; overflow-y: auto; }
.fe-rec { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 6px 6px 6px 4px; }
.fe-rec.current { border-color: var(--ac); background: var(--ac-soft); }
.fe-rec-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; border: none; background: none; font: inherit; color: var(--ink); cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.fe-rec-main .muted { font-size: 12.5px; }
.fe-rec-main strong, .fe-rec-main .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fe-rec-amt { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.fe-rec-tools { display: flex; }
.fe-rec-note a { margin: 0 2px; }
.fe-rec-empty { text-align: center; color: var(--muted); padding: 20px 8px; font-size: 14px; }

/* ---------- quiet footer under the editor (plain HTML in index.html) ---------- */
.seo { max-width: 1560px; margin: 72px auto 0; padding: 0 28px; color: var(--muted); font-size: 13px; line-height: 1.75; }
.seo-in { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .8fr); gap: 40px; border-top: 1px solid var(--line); padding: 28px 0 20px; }
.seo h1 { font-size: 14px; font-weight: 700; color: var(--sub); margin-bottom: 6px; letter-spacing: 0; }
.seo h2 { font-size: 12px; font-weight: 700; color: var(--sub); margin-bottom: 8px; letter-spacing: .5px; }
.seo-about p { max-width: 520px; }
.seo details { padding: 2px 0; }
.seo summary { cursor: pointer; list-style: none; color: var(--muted); }
.seo summary::-webkit-details-marker { display: none; }
.seo summary::before { content: '+'; display: inline-block; width: 14px; color: var(--faint); font-weight: 700; }
.seo details[open] summary::before { content: '−'; }
.seo summary:hover { color: var(--ink-2); }
.seo details p { padding: 2px 0 6px 14px; }
.seo ul { list-style: none; margin: 0; padding: 0; }
.seo li { padding: 2px 0; }
.seo a { color: var(--muted); text-decoration: none; }
.seo a:hover { color: var(--ac); text-decoration: underline; }
.seo-bottom { display: flex; gap: 18px; flex-wrap: wrap; padding: 14px 0 28px; border-top: 1px solid var(--line); font-size: 12px; }

/* Mid-width screens (small laptops, zoomed browsers): keep form and live preview side by side,
   and fold each item row into two lines so the name still has room. */
@media (max-width: 1279px) {
  .fe-wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 4px 16px 0; }
  .fe-top { padding: 12px 16px; }
  .fe-card { padding: 16px; }
  .fe-money { grid-template-columns: minmax(0, 1fr); }
  .fe-grid.g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fe-grid.g3 > :first-child { grid-column: 1 / -1; }
  .fe-parties { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .fe-ir-h { display: none; }
  .fe-ir { grid-template-columns: 18px minmax(0, 1fr) 64px 56px minmax(0, 1fr) 22px; grid-template-areas: "grip nm nm nm nm x" "grip price qty unit amt x"; row-gap: 4px; padding: 10px; }
  .fe-ir:nth-child(2) { border-top: none; }
  .fe-grip { grid-area: grip; }
  .fe-nm { grid-area: nm; }
  .fe-ir > .fe-cell:nth-of-type(1) { grid-area: price; }
  .fe-ir .fe-qty { grid-area: qty; }
  .fe-ir > .fe-cell:nth-of-type(3) { grid-area: unit; }
  .fe-amt { grid-area: amt; align-self: end; padding-bottom: 6px; }
  .fe-x { grid-area: x; }
  .fe-cell > .only-m { display: block !important; font-size: 11.5px; color: var(--muted); padding-left: 8px; }
  .fe-in { border-color: var(--line); }
  .fe-pv-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
  .hide-t { display: none !important; }
}

@media (max-width: 1023px) {
  .fe-switch { display: flex; max-width: 760px; margin: 4px auto 10px; padding: 0 16px; gap: 4px; }
  .fe-switch button { flex: 1; height: 42px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; font: inherit; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
  .fe-switch button.on { background: var(--ac-soft); color: var(--ac-ink); border-color: var(--ac); }
  .fe-wrap { grid-template-columns: minmax(0, 1fr); max-width: 760px; padding: 0 16px; }
  .fe-wrap.pane-edit .fe-pv { display: none; }
  .fe-wrap.pane-preview .fe-form { display: none; }
  .fe-pv { position: static; }
  .hide-t { display: none !important; }
}

@media (max-width: 767px) {
  .fe { padding-bottom: 24px; }
  .fe-top { padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  .fe-brand .brand-mark { width: 30px; height: 30px; }
  .fe-brand .brand-name { font-size: 16px; }
  .fe-nav { order: 3; width: 100%; margin: 0; }
  .fe-nav-item { flex: 1; justify-content: center; }
  .save-chip span { display: none; }
  .save-chip { padding: 6px 8px; }
  .fe-switch { padding: 0 14px; margin-bottom: 8px; }
  .fe-steps { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 6px 14px 10px; position: sticky; top: 0; z-index: 6; background: linear-gradient(var(--bg) 75%, transparent); }
  .fe.previewing .fe-steps { display: none; }
  .fe-steps button { flex-shrink: 0; height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
  .fe-steps button.done { color: var(--ok); }
  .fe-wrap { padding: 0 12px; }
  .fe-card { padding: 14px; border-radius: 16px; scroll-margin-top: 56px; }
  .fe-opt { display: none; }
  .fe-grid.g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fe-grid.g3 > :first-child { grid-column: 1 / -1; }
  .fe-parties, .fe-uploads { grid-template-columns: minmax(0, 1fr); }
  .fe-money { grid-template-columns: minmax(0, 1fr); }
  .fe-addrow { flex-direction: column; }
  .fe-addrow .btn { height: 46px; }

  .fe-items { border: none; background: transparent; display: flex; flex-direction: column; gap: 10px; overflow: visible; }
  .fe-ir-h { display: none; }
  .fe-ir { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 30px; grid-template-areas: "nm nm grip" "price qty qty" "unit amt x"; gap: 8px 10px; border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--card); }
  .fe-ir:nth-child(2) { border-top: 1px solid var(--line); }
  .fe-ir:focus-within { box-shadow: 0 0 0 2px var(--ac); background: var(--card); }
  .fe-ir .fe-grip { grid-area: grip; align-self: start; height: 34px; }
  .fe-nm { grid-area: nm; }
  .fe-ir > .fe-cell:nth-of-type(1) { grid-area: price; }
  .fe-ir .fe-qty { grid-area: qty; }
  .fe-ir > .fe-cell:nth-of-type(3) { grid-area: unit; }
  .fe-amt { grid-area: amt; display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-end; font-size: 16px; }
  .fe-amt .only-m { display: block !important; font-size: 12px; font-weight: 500; color: var(--muted); }
  .fe-ir .fe-x { grid-area: x; align-self: end; width: 30px; height: 30px; }
  .fe-cell > .only-m { display: block !important; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
  .fe-in { border-color: var(--line); background: var(--field); height: 42px; font-size: 15px; }
  .fe-in.strong { font-size: 16px; }
  .fe-in.sub { border: none; background: transparent; height: 30px; padding-left: 8px; }
  .fe-stepper { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--field); }
  .fe-stepper button.only-m { display: grid !important; place-items: center; width: 42px; height: 42px; border: none; background: transparent; color: var(--ac); cursor: pointer; flex-shrink: 0; }
  .fe-stepper input { border: none; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; text-align: center; }

  .fe-pvbar { gap: 10px; }
  .fe-pv-actions { display: none; }
  .fe-stage { padding: 10px; border-radius: 14px; min-height: 0; }
  .fe-stage-note { display: none; }

  .fe-mbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--card-glass); backdrop-filter: blur(10px); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(15, 23, 42, .08); }
  .fe-mbar > div { display: flex; flex-direction: column; min-width: 0; }
  .fe-mbar span { font-size: 12px; color: var(--muted); }
  .fe-mbar strong { font-size: 21px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
  .fe-mbar .btn { height: 48px; padding: 0 20px; border-radius: 14px; }
  body:has(.fe-mbar) .seo { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .seo { padding: 0 16px; margin-top: 48px; }
  .seo-in { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}

/* ======================================================
   Responsive
   ====================================================== */
@media (max-width: 1023px) {
  .seg { display: flex; }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor.pane-edit .ed-preview { display: none; }
  .editor.pane-preview .ed-form { display: none; }
  .ed-preview { position: static; padding: 16px; }
}

@media (max-width: 1099px) {
  .side { width: 88px; padding: 20px 8px; align-items: center; }
  .side .brand { padding: 0 0 18px; }
  .side .brand-name, .side-foot { display: none; }
  .side .nav-item { flex-direction: column; gap: 4px; font-size: 12px; padding: 10px 4px; width: 72px; text-align: center; }
  .main { padding: 28px 28px 40px; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-paper { height: 480px; }
  .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  body { font-size: 15px; }
  h1 { font-size: 22px; }
  .side { display: none; }
  .main { padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); gap: 16px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); background: var(--card-glass); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  }
  .tabbar .nav-item { flex: 1; flex-direction: column; gap: 2px; font-size: 11px; padding: 8px 2px; border-radius: 0; justify-content: center; }
  .tabbar .nav-item.active { background: transparent; color: var(--ac); }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .stats, .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; border-radius: 14px; }
  .stat strong { font-size: 20px; }
  .stat.accent { grid-column: span 2; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .chip { flex-shrink: 0; }
  .qrow { padding: 12px 14px; gap: 12px; }
  .qrow-mark { width: 40px; height: 40px; }
  .qrow-go { display: none; }
  .grid2, .uploads, .account { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .card { padding: 16px; border-radius: 14px; }
  .hide-m { display: none !important; }
  .table-wrap { margin: 0 -16px -16px; }

  .shell:has(.main-editor) .tabbar { display: none; }
  .main.main-editor { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .ed-top { position: static; padding: 8px 10px; gap: 8px 6px; flex-wrap: wrap; }
  .ed-title > .muted.small { display: none; }
  .ed-title strong { font-size: 16px; }
  .ed-actions { order: 3; width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
  .icon-only-m { width: auto; padding: 0; }
  .icon-only-m span { display: none; }
  .ed-preview { padding: 10px; border-radius: 14px; }
  .item-nums { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .item-total { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
  .item-total strong { height: auto; line-height: 1.4; }
  .mbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--card-glass); backdrop-filter: blur(10px); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(15,23,42,.06);
  }
  .mbar > div { display: flex; flex-direction: column; }
  .mbar .muted { font-size: 12px; }
  .mbar strong { font-size: 20px; }
  .mbar .btn { height: 48px; padding: 0 22px; }

  .modal-wrap { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 22px 22px 0 0; max-height: 92vh; }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .modal-foot .form-error { width: 100%; }

  .billing { flex-direction: row; }
  .feat-ctrl { width: 100%; }
  .feat-ctrl select { flex: 1; width: auto; }

  .land-top { padding: 14px 16px; }
  .land-actions .ghost { display: none; }
  .hero { padding: 20px 16px 48px; gap: 28px; }
  .hero h1 { font-size: 36px; }
  .hero p { font-size: 16px; }
  .hero-cta .btn { flex: 1; }
  .hero-paper { height: 340px; padding: 16px; border-radius: 20px; }
  .hero-paper-inner { transform: scale(.4); }

  .share-top { padding: 10px 12px; }
  .share-actions .btn span { display: none; }
  .share-actions .btn { width: 44px; padding: 0; }
  .share-body { padding: 12px 10px 40px; }
  #toasts { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
