@font-face { font-family: Fraunces; src: url(/fonts/Fraunces-normal-latin.woff2) format('woff2'); font-weight: 300 800; font-display: swap; }
@font-face { font-family: Fraunces; src: url(/fonts/Fraunces-italic-latin.woff2) format('woff2'); font-weight: 300 600; font-style: italic; font-display: swap; }
@font-face { font-family: Manrope; src: url(/fonts/Manrope-normal-latin.woff2) format('woff2'); font-weight: 300 800; font-display: swap; }

:root {
  --g950: #051d15; --g900: #072a1e; --g800: #0b3d2c; --g700: #145740; --g500: #1e7155; --g300: #7fae96; --g200: #a9c7b8; --g100: #dde8e2; --g50: #eef4f1;
  --paper: #f6f6f3; --card: #ffffff; --ink: #1c2420; --body: #374151; --muted: #4b5563; --line: #e3e5e2; --line2: #eef0ed;
  --warn: #9a3412; --warn-bg: #fdecd8; --bad: #b42318; --bad-bg: #fde8e7; --badge: #b45309;
  --serif: Fraunces, Georgia, serif; --sans: Manrope, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--g700); outline-offset: 2px; }
a { color: var(--g800); }

.word { letter-spacing: -.02em; line-height: 1; white-space: nowrap; }
.word b { font-weight: 800; } .word span { font-weight: 400; opacity: .85; }
.eyebrow { display: block; font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--g200); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .word { font-size: 18px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--g200); background: var(--card); color: var(--g800); font-size: 14px; font-weight: 700; text-decoration: none; }
.btn.primary { background: var(--g800); border-color: var(--g800); color: #fff; }
.btn.primary:hover { background: var(--g900); }
.btn.danger-armed { background: var(--badge); border-color: var(--badge); color: #fff; }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 999px; }
.btn.icon { width: 44px; padding: 0; color: var(--muted); border-color: var(--line); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--g200); font-size: 12px; font-weight: 700; text-decoration: underline; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--g800); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; padding: 32px 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 6px 0 10px; font-size: 22px; display: flex; align-items: baseline; gap: 10px; }
.login-card .eyebrow { color: var(--g700); display: inline; }
.login-card label, .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
input, textarea { padding: 11px 12px; border: 1px solid var(--g200); border-radius: 10px; background: #fff; font-size: 15px; font-weight: 500; color: var(--ink); }
textarea { line-height: 1.5; resize: vertical; min-height: 140px; }
.error { margin: 0; min-height: 18px; color: var(--bad); font-size: 13px; font-weight: 700; }

/* ---------- shell (phone first) ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.side { display: none; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 12px 18px;
  padding-top: max(12px, env(safe-area-inset-top)); background: var(--g800); color: #fff; }
.top-status { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--g100); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #7fd1a4; flex-shrink: 0; }
.dot.bad { background: #f59e8b; }
.main { flex: 1; padding: 20px 18px 110px; outline: none; max-width: 1180px; width: 100%; }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px 4px max(10px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.tab { min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; background: none;
  color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; position: relative; }
.tab .bar { width: 22px; height: 3px; border-radius: 999px; background: transparent; }
.tab[aria-current="page"] { color: var(--g800); font-weight: 800; }
.tab[aria-current="page"] .bar { background: var(--g800); }
.badge { font-size: 11px; font-weight: 800; color: #fff; background: var(--badge); border-radius: 999px; padding: 1px 7px; }
.tab .badge { position: absolute; top: 4px; right: calc(50% - 32px); }

/* ---------- content ---------- */
.date { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.h1 { margin: 4px 0 0; font-family: var(--serif); font-weight: 400; font-size: 32px; letter-spacing: -.02em; line-height: 1.1; }
.sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 20px; }
.section { display: flex; flex-direction: column; gap: 10px; }
.h2 { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--g700); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.pad { padding: 16px; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { padding: 14px; }
.kpi .label { margin: 0; font-size: 12px; font-weight: 700; color: var(--muted); }
.kpi .num { margin: 6px 0 2px; font-family: var(--serif); font-size: 34px; line-height: 1; }
.kpi .num small { font-size: 18px; color: var(--muted); }
.kpi .note { margin: 0; font-size: 12px; color: var(--muted); }
.kpi .note.warn { color: var(--warn); font-weight: 700; }
.action { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 14px 16px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--card); color: var(--ink); text-align: left; text-decoration: none; width: 100%; }
.action.dark { background: var(--g800); border-color: var(--g800); color: #fff; }
.action .t { display: block; font-size: 15px; font-weight: 700; }
.action .s { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.action.dark .s { color: var(--g100); }
.rows { padding: 2px 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line2); }
.row:last-child { border-bottom: 0; }
.row .t { font-size: 14px; font-weight: 700; }
.row .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row .when { width: 64px; flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--muted); }
.row .grow { flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 700; }
.tag { flex-shrink: 0; font-size: 11px; font-weight: 800; padding: 5px 9px; border-radius: 999px; background: var(--line2); color: #374151; }
.tag.green { background: var(--g100); color: var(--g800); }
.tag.orange { background: var(--warn-bg); color: #7c2d12; }
.tag.red { background: var(--bad-bg); color: var(--bad); }
.kind { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--g700); background: var(--g50); padding: 5px 9px; border-radius: 999px; }
.draft { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.draft .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.draft .to { font-size: 12px; font-weight: 700; color: var(--muted); }
.draft .subject { font-size: 16px; font-weight: 700; line-height: 1.3; }
.draft .body { margin: 0; font-size: 14px; line-height: 1.55; color: var(--body); white-space: pre-line; max-height: 9.3em; overflow: hidden; }
.draft .body.open { max-height: none; }
.btns { display: flex; gap: 8px; }
.btns .grow { flex: 1; }
.agent { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.agent .top-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.agent .name { font-size: 16px; font-weight: 800; }
.agent .role { font-size: 13px; line-height: 1.45; color: var(--muted); margin-top: 3px; }
.agent .foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line2); }
.agent .status { font-size: 12px; font-weight: 600; color: var(--g700); }
.agent .status.off { color: var(--warn); }
.switch { flex-shrink: 0; width: 52px; height: 30px; border: 0; border-radius: 999px; padding: 3px; background: #c9cec9; display: flex; }
.switch span { width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--g700); }
.switch[aria-checked="true"] span { transform: translateX(22px); }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row .lbl { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.bar-row .track { height: 8px; border-radius: 999px; background: var(--line2); overflow: hidden; }
.bar-row .fill { height: 8px; border-radius: 999px; background: var(--g700); }
.move { background: var(--g800); color: #fff; border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.move .eyebrow { color: var(--g200); letter-spacing: .14em; font-weight: 800; }
.move p { margin: 0; font-family: var(--serif); font-size: 22px; line-height: 1.25; }
.move .btn { align-self: flex-start; background: #fff; color: var(--g800); border-color: #fff; font-weight: 800; }
.empty { padding: 40px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty p { margin: 0; } .empty .big { font-family: var(--serif); font-size: 24px; }
.skeleton { height: 120px; border-radius: var(--r); background: linear-gradient(90deg, #eceee9, #f4f5f2, #eceee9); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px);
  background: var(--g900); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); }
.cols { display: grid; gap: 16px; }

/* ---------- Phase 2: forms, services, money, content ---------- */
select { padding: 11px 12px; border: 1px solid var(--g200); border-radius: 10px; background: #fff; font-size: 15px; font-weight: 500; color: var(--ink); width: 100%; }
.field input, .field textarea, .field select { width: 100%; }
.hint { display: block; margin: 0; font-size: 12px; font-weight: 500; color: var(--muted); line-height: 1.45; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack-s { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.line-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(64px, 1fr) minmax(90px, 1.3fr) auto; gap: 8px; align-items: end; }
@media (max-width: 560px) { .line-row { grid-template-columns: 1fr 1fr auto; } .line-row .field:first-child { grid-column: 1 / -1; } }
.total-row { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; border-top: 1px solid var(--line2); font-size: 15px; font-weight: 700; }
.total-row b { font-family: var(--serif); font-size: 24px; font-weight: 500; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checkline { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; font-weight: 600; color: var(--ink); }
.checkline input, .row.check input { width: 20px; height: 20px; accent-color: var(--g700); padding: 0; flex-shrink: 0; }
.rows.flush { padding: 0; }
.row.check { cursor: pointer; justify-content: flex-start; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > .stack-s { flex-basis: 100%; }
.row.link { color: inherit; text-decoration: none; }
.row.link:hover .t { text-decoration: underline; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.btns.wrap { flex-wrap: wrap; }
.chip b { font-family: var(--serif); font-size: 16px; font-weight: 500; }
.chip.small { padding: 4px 10px; font-size: 12px; }
.kpi .num.small { font-size: 22px; line-height: 1.2; }
.notice { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: var(--r); background: var(--g50); border: 1px solid var(--g100); color: var(--g800); font-size: 14px; text-decoration: none; }
.notice p { margin: 0; }
.notice.warn { background: var(--warn-bg); border-color: #f7d2ad; color: #7c2d12; }
details.card > summary { cursor: pointer; list-style: none; min-height: 28px; display: flex; align-items: center; }
details.card > summary::-webkit-details-marker { display: none; }
.day { margin: 6px 0 0; font-size: 14px; font-weight: 800; color: var(--ink); }

/* invoice document */
.inv-wrap { overflow-x: auto; }
.invoice-doc { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 28px; display: flex; flex-direction: column; gap: 22px; min-width: 300px; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.inv-head > div:first-child { display: flex; gap: 14px; align-items: flex-start; }
.inv-co, .inv-title, .inv-to { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--body); }
.inv-co b { font-size: 16px; color: var(--ink); }
.inv-title { text-align: right; }
.inv-title b { font-family: var(--serif); font-size: 24px; font-weight: 500; color: var(--ink); }
.inv-word { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--g700); }
.inv-to b { font-size: 16px; color: var(--ink); }
.label { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--g700); }
.inv-lines { width: 100%; border-collapse: collapse; font-size: 14px; }
.inv-lines th { text-align: left; font-size: 12px; font-weight: 800; color: var(--muted); padding: 8px 6px; border-bottom: 2px solid var(--g800); }
.inv-lines td { padding: 10px 6px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.inv-lines th:not(:first-child), .inv-lines td:not(:first-child) { text-align: right; white-space: nowrap; }
.inv-sum { align-self: flex-end; min-width: 260px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.inv-sum > div { display: flex; justify-content: space-between; gap: 20px; }
.inv-sum .due { padding-top: 8px; border-top: 2px solid var(--g800); font-size: 16px; }
.inv-sum .due b { font-family: var(--serif); font-size: 22px; font-weight: 500; }
.inv-note { margin: 0; font-size: 13px; color: var(--body); }
.inv-pay { padding: 14px 16px; background: var(--g50); border-radius: 10px; }
.inv-pay p { margin: 6px 0 0; font-size: 14px; white-space: pre-line; }
.inv-foot { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.stamp { position: absolute; top: 120px; right: 40px; transform: rotate(-12deg); border: 3px solid var(--g700); color: var(--g700); padding: 6px 16px; border-radius: 8px;
  font-size: 22px; font-weight: 800; letter-spacing: .2em; opacity: .75; }
.stamp.void { border-color: var(--bad); color: var(--bad); }
@media print {
  body { background: #fff; }
  .side, .top, .bottom-nav, .toast, .no-print, #login { display: none !important; }
  .app { display: block; } .main { padding: 0; max-width: none; }
  .invoice-doc { border: 0; padding: 0; }
  @page { size: A4; margin: 16mm; }
}

/* ---------- desktop ---------- */
@media (min-width: 1024px) {
  .app { flex-direction: row; }
  .top, .bottom-nav { display: none; }
  .side { display: flex; flex-direction: column; width: 248px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; background: var(--g800); color: #fff; padding: 26px 18px; }
  .side .brand { padding: 0 8px 28px; }
  .side-nav { display: flex; flex-direction: column; gap: 4px; }
  .side-nav .tab { flex-direction: row; justify-content: space-between; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--g100); font-size: 14px; }
  .side-nav .tab .bar { display: none; }
  .side-nav .tab[aria-current="page"] { background: var(--g700); color: #fff; }
  .side-nav .tab .badge { position: static; }
  .side-label { margin: 26px 12px 8px; font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--g300); }
  .side-soon { list-style: none; margin: 0; padding: 0; }
  .side-soon li { min-height: 40px; display: flex; align-items: center; padding: 0 12px; color: var(--g200); font-size: 14px; font-weight: 600; }
  .side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 8px 0; border-top: 1px solid var(--g700); }
  .side-user b { display: block; font-size: 14px; }
  .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--g100); color: var(--g800); display: grid; place-items: center; font-size: 13px; font-weight: 800; }
  .main { padding: 34px 40px 48px; }
  .h1 { font-size: 44px; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .kpi { padding: 20px; } .kpi .num { font-size: 44px; }
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .toast { bottom: 32px; }
}
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .switch span { transition: none; } }
