:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --text: #1c1c1a;
  --muted: #62625d;
  --border: #dddcd6;
  --brand: #c2410c;
  --brand-ink: #ffffff;
  --brand-soft: #fdeee6;
  --accent: #f5b301;
  --danger: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141513;
    --surface: #1d1e1c;
    --surface-2: #262724;
    --text: #ecebe6;
    --muted: #a3a29b;
    --border: #353632;
    --brand: #fb923c;
    --brand-ink: #1f0d03;
    --brand-soft: #3a2014;
    --danger: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--brand); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 5vw, 2.9rem); margin: 0 0 .5em; }
h2 { font-size: clamp(1.35rem, 3.4vw, 1.8rem); margin: 0 0 .6em; }
h3 { font-size: 1.1rem; margin: 0 0 .4em; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }

/* Header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.logo { font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: .9rem; }
.nav { display: flex; align-items: center; gap: 16px; }
.nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
.nav a.btn { color: var(--brand-ink); }
@media (max-width: 560px) { .nav .hide-sm { display: none; } }
.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 32px 0 48px; color: var(--muted); font-size: .9rem; }
.site-footer .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; }
.site-footer a { color: var(--muted); text-decoration: none; display: block; padding: 2px 0; }
.site-footer a:hover { color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 8px; border: 1px solid transparent;
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 650;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; }
.btn-sm { padding: 7px 12px; font-size: .9rem; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-accent { background: var(--accent); color: #1c1c1a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

/* Landing */
.hero { padding: 56px 0 40px; }
.eyebrow { color: var(--brand); font-weight: 700; font-size: .9rem; letter-spacing: .02em; margin: 0 0 12px; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 620px; }
.hero .ctas { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.small-note { color: var(--muted); font-size: .9rem; margin-top: 10px; }
section.block { padding: 40px 0; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-trades { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card p { margin: 0; color: var(--muted); }
.trade-card { text-decoration: none; color: var(--text); font-weight: 600; padding: 14px 16px; }
.trade-card span { display: block; color: var(--muted); font-weight: 400; font-size: .85rem; margin-top: 2px; }
.trade-card:hover { border-color: var(--brand); }

.pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.price { font-size: 2.2rem; font-weight: 800; margin: 8px 0; }
.price small { font-size: 1rem; color: var(--muted); font-weight: 500; }
.plan-pro { border: 2px solid var(--brand); }
.checks { list-style: none; padding: 0; margin: 16px 0 20px; }
.checks li { padding: 5px 0 5px 26px; position: relative; }
.checks li::before { content: "✓"; position: absolute; left: 0; color: var(--brand); font-weight: 800; }
.checks li.no::before { content: "–"; color: var(--muted); }

details.faq { border-bottom: 1px solid var(--border); padding: 14px 0; }
details.faq summary { font-weight: 650; cursor: pointer; }
details.faq p { color: var(--muted); margin: 8px 0 0; }

/* Template pages */
.breadcrumb { font-size: .88rem; color: var(--muted); padding-top: 20px; }
.breadcrumb a { color: var(--muted); }
.doc-preview { background: #fff; color: #222; border-radius: 6px; padding: 28px; box-shadow: var(--shadow); border: 1px solid var(--border); font-size: .9rem; overflow-x: auto; }
.doc-preview .dp-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.doc-preview .dp-title { color: #c2410c; font-size: 1.5rem; font-weight: 800; letter-spacing: .04em; }
.doc-preview table { width: 100%; border-collapse: collapse; min-width: 420px; }
.doc-preview th { background: #c2410c; color: #fff; text-align: left; padding: 8px; font-size: .8rem; }
.doc-preview td { border-bottom: 1px solid #e6e6e6; padding: 8px; }
.doc-preview .num { text-align: right; white-space: nowrap; }
.doc-preview .dp-total { text-align: right; margin-top: 14px; font-size: 1.05rem; }
.two-col { display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.prose ul { padding-left: 1.2em; }
.prose li { margin: 4px 0; }
.related { display: flex; flex-wrap: wrap; gap: 8px; }
.related a { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; text-decoration: none; color: var(--text); font-size: .9rem; }

/* App */
.app-main { padding: 20px 0 120px; }
.app-grid { display: grid; gap: 16px; max-width: 820px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.panel h2 { font-size: 1.05rem; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel h2 .hint { font-size: .8rem; font-weight: 500; color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .82rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 11px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
textarea { resize: vertical; min-height: 70px; }
input[type="color"] { padding: 3px; height: 44px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 7px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.items { display: grid; gap: 10px; }
.item-row { display: grid; grid-template-columns: 1fr 80px 110px 100px 36px; gap: 8px; align-items: center; }
.item-row .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.item-head { font-size: .78rem; font-weight: 600; color: var(--muted); }
.mini { display: block; min-width: 0; }
.mini span { display: none; font-size: .75rem; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.item-head .amt { font-weight: 600; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 8px; height: 40px; width: 36px; cursor: pointer; font-size: 1.1rem; }
.icon-btn:hover { color: var(--danger); border-color: var(--danger); }
@media (max-width: 620px) {
  .item-head { display: none; }
  .item-row { grid-template-columns: 1fr 1fr 36px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
  .item-row .desc { grid-column: 1 / -1; }
  .mini span { display: block; }
  .item-row .amt { grid-column: 1 / 3; text-align: left; }
  .item-row .icon-btn { grid-column: 3; grid-row: 3; }
}
.totals { margin-top: 14px; display: grid; gap: 4px; justify-content: end; text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 1.25rem; font-weight: 800; }

.pro-tag { font-size: .7rem; font-weight: 800; letter-spacing: .05em; background: var(--accent); color: #1c1c1a; border-radius: 5px; padding: 2px 6px; vertical-align: middle; }
.locked { position: relative; }
.locked input, .locked select, .locked button.lockable { pointer-events: none; opacity: .55; }
.locked::after { content: ""; position: absolute; inset: 0; cursor: pointer; }
.logo-preview { max-height: 48px; max-width: 160px; border-radius: 4px; background: #fff; }

.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.action-bar .inner { max-width: 820px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.action-bar .total-sm { font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.action-bar .usage { font-size: .8rem; color: var(--muted); }
.action-bar .btns { display: flex; gap: 8px; }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-back.open { display: flex; }
.modal { background: var(--surface); border-radius: 14px; max-width: 440px; width: 100%; padding: 24px; box-shadow: 0 10px 40px rgba(0,0,0,.25); max-height: 90vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: .92rem; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }
