/* Haptags Hub — tokens follow haptags.com (navy + #007af5, Outfit / Plus Jakarta Sans). */
:root {
  --navy: #02213d;
  --navy-2: #0a2c4d;
  --navy-3: #13395f;
  --blue: #007af5;
  --blue-600: #0066d6;
  --blue-700: #0052ad;
  --blue-50: #ecf4ff;
  --blue-100: #d6e8ff;

  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0b1324;
  --text-2: #445169;
  --text-3: #64748b;

  --green: #15803d; --green-bg: #e8f7ee;
  --amber: #b45309; --amber-bg: #fdf3e2;
  --red: #c81e3a; --red-bg: #fdecef;
  --violet: #6d28d9; --violet-bg: #f1ebfe;
  --cyan: #0e7490; --cyan-bg: #e5f6fa;
  --grey: #475569; --grey-bg: #eef2f6;

  --font-head: 'Outfit', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(11, 19, 36, 0.06);
  --shadow: 0 1px 2px rgba(11, 19, 36, 0.04), 0 8px 24px rgba(11, 19, 36, 0.06);
  --focus: 0 0 0 3px rgba(0, 122, 245, 0.35);
  --sidebar: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.55 var(--font-body); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15.5px; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code, .mono { font-family: var(--font-mono); }
code { font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.ico { flex: none; vertical-align: -3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--navy); color: #c7d4e5;
  display: flex; flex-direction: column; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 30px; }
.brand b { font: 800 17px/1 var(--font-head); letter-spacing: .08em; }
.brand small { display: block; font: 500 11px/1.2 var(--font-body); color: #8fb3da; letter-spacing: .04em; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #7d97b6; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: #c7d4e5; font-weight: 500;
}
.nav a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--blue); color: #fff; }
.nav .count { margin-left: auto; background: rgba(255,255,255,.14); color: #fff; font-size: 11.5px; font-weight: 700; border-radius: 99px; padding: 1px 8px; }
.nav a.active .count { background: rgba(255,255,255,.25); }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--navy-3); display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font: 700 13px var(--font-head); flex: none; }
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who b { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who a { color: #8fb3da; font-size: 12px; }
.icon-btn { background: none; border: 0; color: inherit; cursor: pointer; padding: 6px; border-radius: 8px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--navy-2); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: rgba(246, 248, 252, .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar .menu-btn { display: none; color: var(--text); }
.topbar .menu-btn:hover { background: var(--grey-bg); color: var(--text); }
.search { flex: 1; max-width: 420px; position: relative; }
.search input[type=search] { padding-left: 36px; background: var(--surface); }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px 48px; width: 100%; max-width: 1360px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-3); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.crumbs a { color: var(--text-3); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 10px;
  font: 600 14px/1.2 var(--font-body); border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  background: var(--blue); color: #fff; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--blue-600); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-danger { background: var(--surface); color: var(--red); border-color: #f3c2cb; }
.btn-danger:hover { background: var(--red-bg); }
.btn-success { background: var(--green); }
.btn-success:hover { background: #116a32; }
.btn-wa { background: #25d366; color: #052e16; }
.btn-wa:hover { background: #1fbe5b; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 13px 22px; font-size: 15.5px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--blue-600); padding: 0; font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; background: none; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.inline { display: inline; }

/* ---------- Cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .muted { font-size: 13px; }
.card-body { padding: 20px; }
.card + .card, .stack > * + * { margin-top: 16px; }
.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)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mt-0 { margin-top: 0 !important; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.empty { text-align: center; padding: 34px 20px; color: var(--text-3); }
.empty b { display: block; color: var(--text); font-family: var(--font-head); font-size: 16px; margin-bottom: 4px; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .label { color: var(--text-3); font-size: 13px; font-weight: 500; }
.stat .value { font: 650 24px/1.2 var(--font-body); margin-top: 6px; color: var(--text); }
.stat .delta { font-size: 12.5px; margin-top: 6px; color: var(--text-3); }
.stat .delta b { font-weight: 650; }
.up { color: var(--green); } .down { color: var(--red); }
.stat a.value { display: block; }
.stat a.value:hover { text-decoration: none; color: var(--blue-600); }
.hero-stat { background: var(--navy); border-color: var(--navy); color: #fff; }
.hero-stat .label { color: #a9c3e0; }
.hero-stat .value { color: #fff; font-size: 34px; }
.hero-stat .delta { color: #a9c3e0; }
.hero-stat .up { color: #6ee7a0; } .hero-stat .down { color: #fda4b4; }

/* ---------- Chart ---------- */
.chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: #edf1f6; stroke-width: 1; }
.chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart .tick { fill: var(--text-3); font: 500 11px var(--font-body); font-variant-numeric: tabular-nums; }
.chart .val { fill: var(--text); font: 650 11.5px var(--font-body); }
.chart .bar { fill: var(--blue); }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit:hover, .chart .hit:focus { fill: rgba(0, 122, 245, .06); }
.tooltip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--text); color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; box-shadow: var(--shadow); transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap;
}
details.table-view summary { cursor: pointer; color: var(--text-3); font-size: 13px; margin-top: 10px; }

/* Horizontal meters (pipeline) */
.meter-list { display: flex; flex-direction: column; gap: 14px; }
.meter-row .row-between { font-size: 13.5px; margin-bottom: 6px; }
.meter { height: 8px; background: var(--blue-50); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--blue); border-radius: 0 4px 4px 0; min-width: 2px; }
.progress { height: 8px; background: var(--blue-50); border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.progress.done > span { background: var(--green); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafcff; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td a.strong, .strong { font-weight: 600; color: var(--text); }
.table td a.strong:hover { color: var(--blue-600); }
.table .sub { display: block; color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.card > .table-wrap:first-child table th:first-child { border-top-left-radius: var(--radius-lg); }
.pager { display: flex; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ---------- Badges & tabs ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tone-blue { background: var(--blue-50); color: var(--blue-700); }
.tone-green { background: var(--green-bg); color: var(--green); }
.tone-amber { background: var(--amber-bg); color: var(--amber); }
.tone-red { background: var(--red-bg); color: var(--red); }
.tone-violet { background: var(--violet-bg); color: var(--violet); }
.tone-cyan { background: var(--cyan-bg); color: var(--cyan); }
.tone-grey { background: var(--grey-bg); color: var(--grey); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 7px 13px; border-radius: 99px; color: var(--text-2); font-weight: 600; font-size: 13.5px; border: 1px solid transparent; }
.tabs a:hover { background: var(--surface); border-color: var(--border); text-decoration: none; }
.tabs a.active { background: var(--navy); color: #fff; }
.tabs a .n { opacity: .7; font-weight: 500; margin-left: 4px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; color: var(--text); }
.field { margin-bottom: 16px; }
.field .hint { font-size: 12.5px; color: var(--text-3); margin-top: 5px; font-weight: 400; }
.field .error { font-size: 12.5px; color: var(--red); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  font: 400 14.5px/1.4 var(--font-body); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
[aria-invalid=true] { border-color: var(--red) !important; }
.check { display: flex; align-items: flex-start; gap: 9px; font-weight: 500; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--blue); flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* Line-item editor */
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); text-align: left; padding: 0 6px 8px; font-weight: 600; }
.items td { padding: 4px 6px; vertical-align: top; }
.items td.amt { text-align: right; padding-top: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.items .c-desc { width: 46%; } .items .c-sac { width: 12%; } .items .c-qty { width: 10%; } .items .c-rate { width: 16%; }
.totals { margin-left: auto; width: 100%; max-width: 340px; font-size: 14px; }
.totals .row-between { padding: 6px 0; flex-wrap: nowrap; }
.totals .grand { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font: 700 18px var(--font-head); }

/* ---------- Flash ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.flash-success { background: var(--green-bg); color: #14532d; border-color: #bfe8cf; }
.flash-error { background: var(--red-bg); color: #881337; border-color: #f6c7d0; }
.flash-info { background: var(--blue-50); color: #0b3d75; border-color: var(--blue-100); }

/* ---------- Lists, timeline ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .meta { font-size: 12.5px; color: var(--text-3); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 22px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.timeline li::after { content: ''; position: absolute; left: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li.k-call::before, .timeline li.k-meeting::before, .timeline li.k-whatsapp::before { background: var(--green); }
.timeline li.k-email::before { background: var(--blue); }
.timeline li.k-status::before { background: var(--violet); }
.timeline .meta { font-size: 12px; color: var(--text-3); }
.timeline .body { white-space: pre-wrap; word-break: break-word; }
.dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 12px; font-size: 14px; margin: 0; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; word-break: break-word; }
.kv-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-2); }

/* Ticket thread */
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; background: var(--surface); max-width: 760px; }
.msg.mine { background: var(--blue-50); border-color: var(--blue-100); margin-left: auto; }
.msg.internal { background: #fffbeb; border-color: #fde68a; }
.msg .meta { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.msg .body { white-space: pre-wrap; word-break: break-word; }

/* Milestones */
.ms { display: flex; align-items: center; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.ms:last-child { border-bottom: 0; }
.ms .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; display: grid; place-items: center; color: #fff; }
.ms.doing .dot { border-color: var(--blue); background: var(--blue-50); }
.ms.done .dot { border-color: var(--green); background: var(--green); }
.ms.done .t { color: var(--text-3); text-decoration: line-through; }
.ms .t { flex: 1; min-width: 0; }

/* ---------- Public / auth ---------- */
.public { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(1200px 600px at 10% -10%, #dcebff 0, transparent 60%), var(--bg); }
.public-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; max-width: 1120px; width: 100%; margin: 0 auto; }
.public-head .brand { color: var(--navy); padding: 0; }
.public-head .brand small { color: var(--text-3); }
.public-main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 16px 24px 56px; }
.public-foot { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 20px 16px 28px; }
.auth-card { max-width: 420px; margin: 32px auto 0; }
.auth-card h1 { font-size: 24px; }
.hero { text-align: center; padding: 48px 0 24px; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); font-weight: 800; color: var(--navy); }
.hero p { font-size: 17px; color: var(--text-2); max-width: 560px; margin: 12px auto 26px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 36px; }
.feature { padding: 20px; }
.feature .ico { color: var(--blue); }
.feature h3 { margin: 10px 0 6px; }
.feature p { color: var(--text-2); margin: 0; font-size: 14px; }

/* ---------- Document (invoice / quote) ---------- */
.doc-page { background: var(--bg); min-height: 100vh; padding: 24px 16px 60px; }
.doc-actions { max-width: 860px; margin: 0 auto 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.doc { max-width: 860px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 40px 44px; box-shadow: var(--shadow); }
.doc-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 22px; border-bottom: 2px solid var(--navy); }
.doc-head .org { display: flex; gap: 12px; }
.doc-head .org img { width: 38px; height: 41px; }
.doc-head .org .org-name { font: 800 20px var(--font-head); color: var(--navy); letter-spacing: .04em; }
.doc-head .org div { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
.doc-title { text-align: right; }
.doc-title h1 { font-size: 24px; letter-spacing: .06em; text-transform: uppercase; color: var(--navy); margin: 0 0 6px; }
.doc-title .dl { grid-template-columns: auto auto; justify-content: end; font-size: 13px; gap: 3px 14px; }
.doc-title .dl dd { text-align: right; font-weight: 600; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 22px 0; font-size: 13.5px; }
.doc-parties h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin-bottom: 6px; font-family: var(--font-body); }
.doc-parties b { font-size: 15px; }
.doc table.lines { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.doc table.lines th { background: var(--navy); color: #fff; text-align: left; font-weight: 600; padding: 9px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.doc table.lines th:first-child { border-top-left-radius: 8px; } .doc table.lines th:last-child { border-top-right-radius: 8px; }
.doc table.lines td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc table.lines .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-foot { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; margin-top: 18px; font-size: 13px; }
.doc-foot .totals { max-width: none; font-size: 13.5px; }
.doc-foot .words { font-style: italic; color: var(--text-2); margin-top: 10px; }
.doc-section { margin-top: 22px; font-size: 13px; color: var(--text-2); }
.doc-section h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin-bottom: 6px; font-family: var(--font-body); }
.doc-sign { margin-top: 36px; display: flex; justify-content: flex-end; text-align: center; font-size: 12.5px; color: var(--text-2); }
.doc-sign div { border-top: 1px solid var(--border-strong); padding-top: 6px; min-width: 200px; }
.stamp { display: inline-block; border: 2px solid currentColor; padding: 4px 12px; border-radius: 8px; font: 800 15px var(--font-head); letter-spacing: .12em; text-transform: uppercase; transform: rotate(-4deg); }
.stamp.paid { color: var(--green); } .stamp.void, .stamp.overdue { color: var(--red); } .stamp.draft { color: var(--grey); }
.pay-box { max-width: 860px; margin: 16px auto 0; }
.pay-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.pay-opt { border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: var(--surface); }
.pay-opt h3 { display: flex; align-items: center; gap: 8px; }
.qr { width: 180px; height: 180px; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 10px; padding: 6px; background: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(2, 33, 61, .4); z-index: 40; }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-grid; }
  .content { padding: 18px 16px 40px; }
  .grid-2, .grid-3, .form-grid, .feature-grid, .doc-parties, .doc-foot { grid-template-columns: minmax(0, 1fr); }
  .doc { padding: 24px 18px; }
  .doc-title { text-align: left; }
  .doc-title .dl { justify-content: start; }
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .items td { padding: 0; }
  .items td.c-desc-td { grid-column: 1 / -1; }
  .items td.amt { padding-top: 10px; }
  h1 { font-size: 22px; }
  .hero-stat .value { font-size: 28px; }
  .dl { grid-template-columns: 110px minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .hide-sm { display: none !important; }
  .topbar { gap: 8px; }
  .topbar strong { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .spacer { display: none; }
  .doc table.lines { font-size: 12.5px; }
  .doc table.lines th, .doc table.lines td { padding: 8px 6px; }
  .page-head .actions { width: 100%; }
  .chart { min-width: 600px; }
}

/* ---------- Print: invoices & quotes print cleanly to PDF ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body, .doc-page { background: #fff !important; padding: 0 !important; }
  .no-print, .doc-actions, .pay-box, .flash { display: none !important; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .doc table.lines th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; }
}
