:root {
  /* SM Web Development brand (smwebdev.com) */
  --brand: #C2410C;      /* burnt orange accent */
  --brand-soft: #FB923C;
  --ink: #0C1826;        /* navy */
  --ink-raised: #12202F;
  --bg: #F7F8FA;         /* bone */
  --surface: #ffffff;
  --surface-2: #F7F8FA;
  --text: #33475B;       /* slate */
  --heading: #0C1826;
  --muted: #64748B;      /* steel */
  --border: #E3E8EE;
  --font-head: "Archivo", "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --success: #138a52;
  --success-bg: #e7f6ee;
  --warn: #9a6300;
  --warn-bg: #fff4dc;
  --danger: #c42b2b;
  --danger-bg: #fdeaea;
  --info-bg: #eaf0ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.55 var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-family: var(--font-head); color: var(--heading); letter-spacing: -0.01em; }
h1 { font-weight: 800; } h2, h3 { font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; }
small, .muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── Layout ────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #c3cbd6; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.sidebar .brand { text-decoration: none; color: #fff; font-family: var(--font-head); font-weight: 700; padding: 4px 8px 22px; display: block; }
.sidebar .brand img { display: block; width: 100%; max-width: 170px; height: auto; }
.sidebar .brand small { display: block; color: #8b97a8; font-family: var(--font-body); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 8px; }
.sidebar nav a { display: block; color: inherit; text-decoration: none; padding: 8px 10px; border-radius: 8px; margin-bottom: 2px; }
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.active { background: rgba(255, 255, 255, 0.08); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.sidebar .spacer { flex: 1; }
.sidebar form button { background: none; border: 0; color: inherit; padding: 8px 10px; cursor: pointer; font: inherit; }
.main { padding: 28px 36px 60px; max-width: 1200px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; }
  .sidebar nav { display: flex; }
  .sidebar .brand { padding: 0 10px; }
  .main { padding: 20px 16px 48px; }
  .grid-2, .grid-3, .grid-4, .split { grid-template-columns: 1fr; }
}

/* ── Cards & tables ────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { display: flex; justify-content: space-between; align-items: center; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-family: var(--font-head); font-size: 1.6rem; font-weight: 800; color: var(--heading); margin-top: 4px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
.table-card { padding: 0; overflow: hidden; }
.table-card table td:first-child, .table-card table th:first-child { padding-left: 20px; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

/* ── Badges ────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 0.78rem; font-weight: 600; background: #eef0f4; color: #4a5263; white-space: nowrap; }
.badge.draft { background: #eef0f4; color: #4a5263; }
.badge.sent { background: var(--info-bg); color: #2647b5; }
.badge.viewed { background: #f1e9ff; color: #6a35c9; }
.badge.accepted, .badge.success { background: var(--success-bg); color: var(--success); }
.badge.declined, .badge.failed { background: var(--danger-bg); color: var(--danger); }
.badge.expired, .badge.skipped { background: var(--warn-bg); color: var(--warn); }
.badge.pending, .badge.running { background: var(--info-bg); color: #2647b5; }
.dot-ok, .dot-off { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-ok { background: var(--success); }
.dot-off { background: #c3c8d2; }

/* ── Forms & buttons ───────────────────────────────── */
label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 5px; }
label .hint, .hint { font-weight: 400; color: var(--muted); font-size: 0.83rem; }
.field { margin-bottom: 14px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="url"], input[type="search"], select, textarea {
  width: 100%; font: inherit; color: inherit; padding: 9px 11px; border: 1px solid #cfd4dd; border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.88rem; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin-bottom: 10px; }
.check input { margin-top: 4px; }
.btn {
  font-family: var(--font-body);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 0.9rem;
  padding: 9px 16px; border-radius: 8px; border: 1px solid #cfd4dd; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(0.95); }
.btn.danger { color: var(--danger); border-color: #f0c4c4; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { padding: 5px 10px; font-size: 0.82rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.inline { display: inline; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a.active { color: var(--text); border-color: var(--brand); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; border: 1px solid transparent; }
.alert.success { background: var(--success-bg); color: #0d5c37; border-color: #bfe5d0; }
.alert.error { background: var(--danger-bg); color: #8f1d1d; border-color: #f3c3c3; }
.alert.info { background: var(--info-bg); color: #233f9c; border-color: #cbd8ff; }
.alert .secret { display: block; margin-top: 8px; padding: 8px 10px; background: #fff; border-radius: 6px; font-family: ui-monospace, Menlo, monospace; word-break: break-all; color: var(--text); }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; background: var(--surface-2); }

/* ── Timeline ──────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--border); position: relative; font-size: 0.9rem; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline time { display: block; color: var(--muted); font-size: 0.8rem; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.steps li:last-child { border-bottom: 0; }
.steps .err { color: var(--danger); font-size: 0.83rem; margin-top: 4px; word-break: break-word; }

/* ── Editor ────────────────────────────────────────── */
.editor-section { border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 12px; background: var(--surface-2); }
.editor-section .head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.editor-section .head input { font-weight: 600; }
.editor-section textarea { min-height: 140px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.88rem; }
.items-table td { padding: 6px; vertical-align: middle; }
.items-table input[type="text"], .items-table input[type="number"] { padding: 6px 8px; }
.items-table .desc { margin-top: 4px; font-size: 0.85rem; }
.items-table .qty { width: 70px; }
.items-table .price { width: 120px; }
.items-table .flag { width: 70px; text-align: center; }
.totals { margin-left: auto; max-width: 340px; }
.totals div { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; }
.totals .grand { font-weight: 700; font-size: 1.1rem; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }
.totals .deposit { color: var(--brand); font-weight: 600; }
.sticky-bar { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(4px); padding: 12px 0; margin-top: 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; align-items: center; }

/* ── Login ─────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; border-top: 4px solid var(--brand); }
.auth-card .logo { display: block; max-width: 220px; height: auto; margin: 4px 0 18px; }

/* ── Public proposal ───────────────────────────────── */
.pub { background: var(--bg); }
.pub-top { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.pub-top .inner { max-width: 880px; margin: 0 auto; padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pub-top img { max-height: 34px; display: block; }
.pub-top .co { font-weight: 700; }
.doc { max-width: 880px; margin: 28px auto 80px; padding: 0 16px; }
.doc .paper { background: #fff; border-radius: 12px; box-shadow: 0 4px 24px rgba(16, 24, 40, 0.07); overflow: hidden; }
.cover { padding: 56px 56px 40px; background: linear-gradient(135deg, var(--ink-raised), var(--ink)); color: #fff; border-bottom: 4px solid var(--brand); }
.cover .logo { display: block; height: 44px; width: auto; margin-bottom: 28px; }
.cover .eyebrow { color: var(--brand-soft); font-weight: 600; font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; }
.cover h1 { font-size: 2.3rem; margin: 10px 0 18px; color: #fff; }
.cover .meta { display: flex; gap: 32px; flex-wrap: wrap; opacity: 0.92; font-size: 0.92rem; }
.cover .meta strong { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.75; font-weight: 600; }
.doc section { padding: 36px 56px; border-top: 1px solid var(--border); }
.doc section h2 { font-size: 1.35rem; margin-bottom: 14px; }
.prose { line-height: 1.7; }
.prose table { margin: 12px 0; border: 1px solid var(--border); }
.prose img { max-width: 100%; }
.prose blockquote { margin: 0; padding-left: 14px; border-left: 3px solid var(--border); color: var(--muted); }
.pricing td, .pricing th { padding: 12px 10px; }
.pricing .item-name { font-weight: 600; }
.pricing .item-desc { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.pricing tr.excluded td { color: #a0a6b3; }
.pricing tr.excluded .item-name { text-decoration: line-through; }
.opt-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 600; color: var(--brand); cursor: pointer; margin-top: 6px; }
.accept-box { background: var(--surface-2); }
.sig-pad { border: 1px dashed #b9bfca; border-radius: 8px; background: #fff; width: 100%; height: 160px; touch-action: none; display: block; }
.sig-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.sig-tabs button { font: inherit; font-size: 0.85rem; border: 1px solid var(--border); background: #fff; padding: 5px 12px; border-radius: 99px; cursor: pointer; }
.sig-tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.typed-sig { font-family: "Brush Script MT", "Segoe Script", "Snell Roundhand", cursive; font-size: 2.2rem; padding: 18px; border: 1px dashed #b9bfca; border-radius: 8px; background: #fff; min-height: 80px; }
.signed { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.signed img { max-width: 280px; max-height: 110px; display: block; border-bottom: 1px solid var(--text); }
.banner { padding: 14px 18px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.banner.ok { background: var(--success-bg); color: #0d5c37; }
.banner.warn { background: var(--warn-bg); color: #6b4500; }
.banner.bad { background: var(--danger-bg); color: #8f1d1d; }
.banner.preview { background: var(--ink); color: #fff; }
.mobile-cta { display: none; }
@media (max-width: 700px) {
  .cover, .doc section { padding: 28px 22px; }
  .cover h1 { font-size: 1.6rem; }
  .signed { grid-template-columns: 1fr; }
  .mobile-cta { display: block; position: fixed; bottom: 0; left: 0; right: 0; padding: 12px 16px; background: #fff; border-top: 1px solid var(--border); z-index: 6; }
  .mobile-cta .btn { width: 100%; }
}
dialog { border: 0; border-radius: 12px; padding: 24px; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(16, 24, 40, 0.45); }

@media print {
  .pub-top, .no-print, .mobile-cta, .opt-toggle { display: none !important; }
  .doc { margin: 0; max-width: none; padding: 0; }
  .doc .paper { box-shadow: none; border-radius: 0; }
  .cover { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  section { break-inside: avoid-page; }
}
