/* Ahmedonics Hub. Dense, fast, keyboard-friendly. Shares tokens with the site.
   Mobile-first: the sidebar is an off-canvas drawer below 900px, list tables
   stack into cards below 700px (table.stack + data-label on cells). */
:root {
  --navy: #0c274a; --navy-700: #123a6b; --blue: #1d5fa5; --blue-600: #17508c; --orange: #e8901c; --orange-600: #c9780f;
  --ink: #1b2432; --ink-2: #4a5568; --ink-3: #718096; --line: #e2e8f0; --bg: #ffffff; --bg-2: #f5f7fa; --bg-3: #eaf0f7;
  --ok: #1f8a4c; --warn: #b7791f; --err: #c0392b; --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 232px; --topbar: 52px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: .95rem; line-height: 1.5; color: var(--ink); background: var(--bg-2); }
body.nav-open { overflow: hidden; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 1px; }
h1, h2, h3 { color: var(--navy); line-height: 1.25; margin: 0 0 .6rem; overflow-wrap: anywhere; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; margin-top: 1.4rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--bg-3); padding: .05rem .3rem; border-radius: 4px; overflow-wrap: anywhere; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .9em; overflow-wrap: anywhere; } /* a 64-character hash or key has no break in it: wrap rather than widen the page */
@media (min-width: 900px) { h1 { font-size: 1.45rem; } }

/* Shell */
.hub { min-height: 100vh; }
.hub__top { background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 0 .75rem 0 .5rem; height: var(--topbar); position: sticky; top: 0; z-index: 30; }
.hub__top .left { display: flex; align-items: center; gap: .35rem; min-width: 0; }
.hub__top .brand { color: #fff; font-weight: 700; letter-spacing: .02em; white-space: nowrap; display: flex; align-items: center; gap: .35rem; }
.hub__top .brand span { color: var(--orange); }
.hub__top .who { display: flex; align-items: center; gap: .25rem; font-size: .88rem; color: rgba(255,255,255,.85); min-width: 0; }
.hub__top .who form { margin: 0; }
.hub__top button.link, .hub__top a.link { display: inline-flex; align-items: center; gap: .45rem; background: none; border: 0; color: #fff; font: inherit; cursor: pointer; padding: .35rem .5rem; border-radius: 6px; min-height: 40px; white-space: nowrap; }
.hub__top button.link:hover, .hub__top a.link:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.hub__top .who .name { display: none; }
.hub__top .bell { position: relative; padding: .35rem .45rem; }
.hub__top .bell svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hub__top .bell .count { position: absolute; top: 0; right: 0; background: var(--orange); color: #fff; border-radius: 999px; font-size: .66rem; font-weight: 700; line-height: 1; padding: .18rem .35rem; min-width: 1.1rem; text-align: center; }
.side-search { margin: 0 0 .75rem; }
.side-search input { width: 100%; padding: .5rem .65rem; min-height: 38px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: .92rem; background: #fff; color: var(--ink); }
.side-search input:focus { border-color: var(--blue); outline: 3px solid rgba(29,95,165,.18); outline-offset: 0; }
ul.notifications li.is-unread a { font-weight: 600; }
.hub__top .signout { display: none; }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--orange); color: #fff; font-weight: 700; font-size: .78rem; letter-spacing: .02em; flex: none; }
.hub__menu { display: inline-grid; place-items: center; width: 44px; height: 44px; background: none; border: 0; color: #fff; border-radius: 8px; cursor: pointer; padding: 0; }
.hub__menu:hover { background: rgba(255,255,255,.12); }
.hub__menu svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; }
.hub__menu .icon-close, .nav-open .hub__menu .icon-open { display: none; }
.nav-open .hub__menu .icon-close { display: block; }
.hub__body { display: grid; grid-template-columns: 1fr; }
.hub__side { background: var(--bg); border-right: 1px solid var(--line); padding: .75rem .75rem calc(1rem + env(safe-area-inset-bottom)); position: fixed; top: var(--topbar); left: 0; bottom: 0; width: min(300px, 86vw); overflow-y: auto; z-index: 40; transform: translateX(-102%); transition: transform .18s ease-out; visibility: hidden; }
.hub__side.is-open { transform: none; visibility: visible; }
.hub__backdrop { position: fixed; inset: var(--topbar) 0 0 0; background: rgba(12,39,74,.45); z-index: 35; display: none; }
.nav-open .hub__backdrop { display: block; }
.hub__side ul { list-style: none; margin: 0; padding: 0; }
.hub__side .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: .9rem .7rem .3rem; }
.hub__side a { display: flex; align-items: center; gap: .6rem; padding: .65rem .7rem; border-radius: 6px; color: var(--ink); font-weight: 500; min-height: 44px; }
.hub__side a:hover { background: var(--bg-2); text-decoration: none; }
.hub__side a[aria-current="page"] { background: var(--bg-3); color: var(--navy); }
.hub__side svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; opacity: .8; flex: none; }
.hub__side .count { margin-left: auto; background: var(--orange); color: #fff; font-size: .72rem; font-weight: 700; padding: .05rem .45rem; border-radius: 999px; }
.hub__side .side-user { border-top: 1px solid var(--line); margin-top: .75rem; padding-top: .5rem; }
.hub__side .side-user form { margin: 0; }
.hub__side .side-user button { display: flex; align-items: center; gap: .6rem; width: 100%; background: none; border: 0; font: inherit; font-weight: 500; color: var(--err); padding: .65rem .7rem; border-radius: 6px; cursor: pointer; text-align: left; min-height: 44px; }
.hub__side .side-user button:hover { background: #fdecea; }
.hub__main { padding: 1rem .9rem calc(3rem + env(safe-area-inset-bottom)); min-width: 0; max-width: 100%; }
@media (min-width: 900px) {
  .hub__top { padding: 0 1.25rem; }
  .hub__top .who .name { display: inline; }
  .hub__top .signout { display: block; }
  .hub__body { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .hub__side { position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); width: auto; transform: none; visibility: visible; transition: none; padding: 1rem .75rem; }
  .hub__side .side-user { display: none; }
  .hub__menu, .hub__backdrop { display: none !important; }
  .hub__main { padding: 1.5rem 2rem 3rem; }
}

/* Page header */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem .75rem; margin-bottom: 1rem; }
.page-head > div { min-width: 0; }
.page-head h1 { margin: 0; }
.page-head .sub { margin: .1rem 0 0; color: var(--ink-3); font-size: .9rem; overflow-wrap: anywhere; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 599px) { .page-head .actions { width: 100%; } .page-head .actions .btn { flex: 1 1 auto; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .9rem; min-height: 40px; border-radius: 6px; font: inherit; font-weight: 600; line-height: 1.2; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: var(--blue-600); }
.btn--accent { background: var(--orange); color: #fff; }
.btn--accent:hover { background: var(--orange-600); }
.btn--ghost { background: #fff; color: var(--navy); border-color: #cbd5e0; }
.btn--ghost:hover { background: var(--bg-2); }
.btn--danger { background: #fff; color: var(--err); border-color: #f5c6c2; }
.btn--danger:hover { background: #fdecea; }
.btn--ok { background: var(--ok); color: #fff; }
.btn--ok:hover { background: #17703d; }
.btn--sm { padding: .3rem .6rem; font-size: .85rem; min-height: 32px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* Cards & stats */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1rem; min-width: 0; }
@media (min-width: 640px) { .card { padding: 1rem 1.1rem; } }
.card h2 { margin-top: 0; }
.card__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; margin-bottom: .5rem; }
.card__head h2 { margin: 0; }
.card--warn { border-color: #f1d9a6; background: #fffaf0; }
.stats { display: grid; gap: .6rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
@media (min-width: 700px) { .stats { gap: .75rem; grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .85rem; min-width: 0; }
.stat .label { font-size: .74rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 1.45rem; font-weight: 700; color: var(--navy); line-height: 1.1; margin-top: .2rem; overflow-wrap: anywhere; }
.stat .value.is-attention { color: var(--orange-600); }
.stat .value.is-money { font-size: 1.15rem; }
.stat a { color: inherit; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.grid-2 > * { min-width: 0; }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.grid-3 { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.grid-3 > * { min-width: 0; }
@media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Quick actions (reception sales desk) */
.quick { display: grid; gap: .5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
@media (min-width: 700px) { .quick { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.quick a { display: flex; align-items: center; justify-content: center; gap: .4rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .5rem; min-height: 48px; font-weight: 600; color: var(--navy); text-align: center; }
.quick a:hover { background: var(--bg-3); text-decoration: none; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); max-width: 100%; }
.card .table-wrap { border: 0; border-radius: 0; margin: 0 -1rem; background: transparent; }
.card .table-wrap table { min-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-2); color: var(--ink-2); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.date, th.date { white-space: nowrap; }
td .sub { display: block; color: var(--ink-3); font-size: .82rem; }
td.actions { white-space: nowrap; text-align: right; }
.empty { padding: 1.5rem; text-align: center; color: var(--ink-3); }
tfoot td { font-weight: 600; background: var(--bg-2); }
/* Stacked mode: each row becomes a card with "label  value" lines. Cells
   with data-label show it; cells without span the full width. */
@media (max-width: 699px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tfoot, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: .5rem .9rem; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack tfoot tr { background: var(--bg-2); border-top: 1px solid var(--line); }
  table.stack tbody tr:hover td { background: transparent; }
  table.stack td { border: 0; padding: .2rem 0; text-align: left; white-space: normal; }
  table.stack td[data-label] { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: .5rem; align-items: baseline; }
  table.stack td[data-label]::before { content: attr(data-label); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; }
  table.stack td[data-label] > * { justify-self: start; }
  table.stack td[data-label] > .fill { justify-self: stretch; min-width: 0; } /* a cell holding a form: as wide as its column, never wider */
  table.stack td.primary { font-size: 1.02rem; font-weight: 600; padding-top: .3rem; }
  table.stack td.num, table.stack td.date { text-align: left; }
  table.stack td.actions { text-align: left; padding-top: .45rem; }
  table.stack td:empty { display: none; }
  table.stack td.empty { display: block; padding: 1.5rem; text-align: center; }
  .card .table-wrap { margin: 0 -1rem; }
}

/* Badges */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; letter-spacing: .03em; background: var(--bg-3); color: var(--navy); white-space: nowrap; vertical-align: middle; }
.badge--new, .badge--draft, .badge--pending, .badge--submitted, .badge--open { background: #fff4e0; color: #7a4a00; }
.badge--contacted, .badge--qualified, .badge--sent, .badge--partially_paid, .badge--approved, .badge--in_review { background: #e3edf9; color: #17508c; }
.badge--quotation, .badge--negotiation, .badge--purchased { background: #efe7fb; color: #5b3a9a; }
.badge--won, .badge--active, .badge--ok, .badge--paid, .badge--accepted, .badge--converted, .badge--closed, .badge--completed { background: #e6f5ec; color: #155d33; }
.badge--lost, .badge--disabled, .badge--fail, .badge--rejected, .badge--cancelled, .badge--overdue, .badge--expired, .badge--left { background: #fdecea; color: #7a1f16; }
.badge--muted { background: var(--bg-2); color: var(--ink-3); }

/* Forms */
.form { display: grid; gap: .9rem; max-width: 760px; }
.form--wide { max-width: none; }
.form .row { display: grid; gap: .9rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .form .row { grid-template-columns: 1fr 1fr; } .form .row--3 { grid-template-columns: 1fr 1fr 1fr; } .form .row--4 { grid-template-columns: repeat(4, 1fr); } }
.field { min-width: 0; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; color: var(--navy); font-size: .9rem; }
.field input, .field select, .field textarea { width: 100%; padding: .55rem .65rem; min-height: 42px; border: 1px solid #cbd5e0; border-radius: 6px; font: inherit; background: #fff; color: var(--ink); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); outline: 3px solid rgba(29,95,165,.18); outline-offset: 0; }
.field input[type=radio], .field input[type=checkbox] { width: 1.15rem; height: 1.15rem; min-height: 0; padding: 0; margin: 0; flex: none; accent-color: var(--blue); }
.field textarea { min-height: 110px; resize: vertical; }
.field .hint { color: var(--ink-3); font-size: .82rem; margin-top: .2rem; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--err); }
.field .error { color: var(--err); font-size: .85rem; margin-top: .25rem; }
.field input[readonly] { background: var(--bg-2); color: var(--ink-2); }
/* Prevent iOS zooming into inputs: 16px is the threshold. */
@media (max-width: 899px) { .field input, .field select, .field textarea { font-size: 16px; } }
.checks { display: grid; gap: .35rem; }
.checks label { display: flex; gap: .5rem; align-items: center; font-weight: 500; min-height: 32px; }
.inline-form { display: inline; }
.inline-form.row { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.inline-form.compact { display: inline-flex; gap: .3rem; align-items: center; }
.inline-form.compact .w-qty { width: 4.5rem; text-align: right; }
.inline-form.compact input[type=date], .inline-form.compact .w-qty { padding: .3rem .4rem; min-height: 32px; border: 1px solid #cbd5e0; border-radius: 6px; font: inherit; font-size: .85rem; background: #fff; color: var(--ink); }
.inline-form .field { flex: 1 1 160px; }
.inline-form.row select { max-width: 100%; min-width: 0; } /* a long option list never pushes the form past its cell */
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
@media (max-width: 599px) { .form-actions .btn { flex: 1 1 auto; } }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0; min-width: 0; }
legend { font-weight: 600; color: var(--navy); padding: 0 .35rem; }

/* Line items (quotations, sales, invoices) */
.items { width: 100%; }
.items th, .items td { padding: .4rem .4rem; vertical-align: middle; }
.items input, .items select { width: 100%; padding: .4rem .5rem; min-height: 38px; border: 1px solid #cbd5e0; border-radius: 6px; font: inherit; }
.items td.num input { text-align: right; }
.items .remove { background: none; border: 0; color: var(--err); font-size: 1.1rem; cursor: pointer; padding: .2rem .4rem; line-height: 1; }
.items-wrap { overflow-x: auto; }
.items-wrap table { min-width: 620px; }
.totals { display: grid; grid-template-columns: max-content minmax(6rem, max-content); gap: .3rem 1rem; justify-content: end; margin-top: .75rem; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--ink-3); }
.totals dd { margin: 0; text-align: right; }
.totals .grand { font-weight: 700; font-size: 1.05rem; color: var(--navy); }
.totals .grand + dd { font-weight: 700; font-size: 1.05rem; color: var(--navy); }

/* Flash */
.flash { border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; display: flex; justify-content: space-between; gap: 1rem; }
.flash--success { background: #e6f5ec; border-color: #b9e2c8; color: #155d33; }
.flash--error { background: #fdecea; border-color: #f5c6c2; color: #7a1f16; }
.flash--info { background: #e3edf9; border-color: #bcd3ee; color: #17508c; }
.flash button { background: none; border: 0; font: inherit; cursor: pointer; color: inherit; font-size: 1.2rem; line-height: 1; }

/* Filters */
.filters { display: grid; gap: .5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; margin-bottom: 1rem; }
.filters .field { min-width: 0; }
.filters .field label { font-size: .74rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.filters .btn { min-height: 42px; }
@media (max-width: 599px) { .filters > .field:first-child { grid-column: 1 / -1; } }
@media (min-width: 600px) { .filters { display: flex; flex-wrap: wrap; } .filters .field { min-width: 140px; flex: 0 1 auto; } .filters .field--grow { flex: 1 1 220px; } }

/* Tabs (record detail sections) */
.tabs { display: flex; gap: .25rem; overflow-x: auto; -webkit-overflow-scrolling: touch; border-bottom: 1px solid var(--line); margin-bottom: 1rem; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: .6rem .8rem; white-space: nowrap; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--navy); }
.tabs a[aria-current="page"] { color: var(--navy); border-bottom-color: var(--orange); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .75rem; color: var(--ink-3); font-size: .88rem; }
.pagination .links { display: flex; gap: .35rem; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--bg-3); border: 2px solid var(--blue); margin-top: .35rem; }
.timeline .when { color: var(--ink-3); font-size: .8rem; }
.timeline .note { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Detail lists */
.dl { display: grid; grid-template-columns: minmax(6rem, max-content) minmax(0, 1fr); gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--ink-3); font-size: .85rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.dl--tight { gap: .2rem .75rem; }

/* Status stepper (leads, quotations, expenses) */
.steps { display: flex; flex-wrap: wrap; gap: .3rem; list-style: none; margin: 0 0 1rem; padding: 0; font-size: .78rem; }
.steps li { padding: .2rem .6rem; border-radius: 999px; background: var(--bg-3); color: var(--ink-3); }
.steps li.is-done { background: #e6f5ec; color: #155d33; }
.steps li.is-current { background: var(--navy); color: #fff; }

/* Notices */
.notice { border-left: 4px solid var(--orange); background: #fff8ec; padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; }
.notice--info { border-color: var(--blue); background: #eef4fb; }

/* Auth pages */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem 1rem; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-700) 60%, var(--blue) 100%); }
.auth__card { width: 100%; max-width: 420px; background: #fff; border-radius: 12px; padding: 1.5rem; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
@media (min-width: 480px) { .auth__card { padding: 2rem; } }
.auth__card .logo { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto 1.5rem; }
.auth__card h1 { text-align: center; font-size: 1.3rem; }
.auth__card .form { max-width: none; }
.auth__card .links { text-align: center; font-size: .9rem; margin-top: 1rem; }
.auth { grid-template-rows: 1fr auto; align-content: center; }
.auth__foot { text-align: center; font-size: .85rem; color: rgba(255,255,255,.75); padding-top: 1rem; }
.auth__foot a { color: rgba(255,255,255,.9); }

/* Printable documents (quotation, invoice, payslip, receipt) */
.doc { background: #fff; color: #111; max-width: 800px; margin: 0 auto; padding: 1.25rem; font-size: .95rem; }
.doc__head { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-start; border-bottom: 2px solid var(--navy); padding-bottom: 1rem; margin-bottom: 1rem; }
.doc__head img { width: 240px; height: auto; margin-bottom: .6rem; }
.doc__head .from { font-size: .85rem; color: #333; line-height: 1.45; }
.doc__title { text-align: right; }
.doc__title h1 { margin: 0; font-size: 1.6rem; letter-spacing: .04em; text-transform: uppercase; }
.doc__title .ref { font-family: var(--mono); font-size: 1rem; color: #333; }
.doc__meta { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; font-size: .9rem; }
.doc__meta h3 { margin: 0 0 .25rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: #555; }
.doc table { font-size: .92rem; }
.doc th { background: var(--bg-3); color: var(--navy); }
.doc .totals { margin-top: 1rem; }
.doc__notes { margin-top: 1.25rem; font-size: .88rem; color: #333; white-space: pre-wrap; }
.doc__status { display: inline-block; border: 2px solid; border-radius: 6px; padding: .2rem .6rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-top: .5rem; }
.doc-bar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; padding: .75rem; background: var(--bg-2); border-bottom: 1px solid var(--line); }
@media (max-width: 599px) { .doc__head { flex-direction: column; } .doc__title { text-align: left; } .doc__meta { grid-template-columns: 1fr; } }
@media print {
  body { background: #fff; }
  .doc-bar, .hub__top, .hub__side, .hub__backdrop, .flash { display: none !important; }
  .doc { max-width: none; padding: 0; }
  .doc__head { flex-direction: row; }
  .doc__title { text-align: right; }
  .doc__meta { grid-template-columns: 1fr 1fr; }
  a { color: inherit; }
  @page { margin: 14mm; }
}

/* Utilities. Inline style attributes are blocked by the CSP (style-src 'self'), so templates use these. */
.mt-1 { margin-top: .75rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .75rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.pre { white-space: pre-wrap; }
/* Ticket threads and simple record lists. */
.message { padding: .7rem 0; border-top: 1px solid var(--line); }
.message:first-of-type { border-top: 0; padding-top: 0; }
.message header { margin-bottom: .3rem; }
.message--client { background: var(--bg-2); padding: .7rem .85rem; border-radius: var(--radius); border-top: 0; margin-top: .5rem; }
.message--internal { background: #fff7e6; padding: .7rem .85rem; border-radius: var(--radius); border-top: 0; margin-top: .5rem; }
ul.list { list-style: none; margin: 0; padding: 0; }
ul.list li { padding: .45rem 0; border-top: 1px solid var(--line); }
ul.list li:first-child { border-top: 0; padding-top: 0; }
.small { font-size: .78rem; }
.strong { font-weight: 600; }
.center { justify-content: center; }
.tl { text-align: left; }
.ta-sm { min-height: 70px !important; } .ta-md { min-height: 80px !important; }
.f-xs { flex: 0 1 90px !important; } .f-sm { flex: 0 1 110px !important; } .f-md { flex: 0 1 170px !important; } .f-none { flex: 0 0 auto !important; }
.rule-b { padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.doc-body { background: #e9edf2; }
.ta-lg { min-height: 260px !important; }
.items .w-desc { width: 44%; } .items input.w-qty { width: 5.5rem; } .items input.w-unit { width: 5rem; } .items input.w-price { width: 8rem; }
/* Line-item editor on phones: each row becomes a small card. */
@media (max-width: 699px) {
  .items-wrap table { min-width: 0; }
  .items thead { display: none; }
  .items, .items tbody { display: block; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr 1.4fr auto; gap: .4rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
  .items td { display: block; padding: 0; border: 0; }
  .items td:first-child { grid-column: 1 / -1; }
  .items td:nth-child(5) { order: 6; grid-column: 1 / -1; text-align: right; font-weight: 600; padding-top: .2rem; }
  .items td:nth-child(5)::before { content: "Line total "; font-weight: 400; color: var(--ink-3); font-size: .8rem; }
  .items input.w-qty, .items input.w-unit, .items input.w-price { width: 100%; }
  .items .remove { min-height: 38px; }
}

/* Guest share pages (/s/{token}): one column, branded, nothing else. */
.share-body { background: var(--bg); }
.share { max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem calc(2rem + env(safe-area-inset-bottom)); }
.share__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1rem; }
.share__head .logo { display: block; width: 220px; max-width: 100%; height: auto; }
.share__foot { margin-top: 1.5rem; text-align: center; }
.share .card h1 { font-size: 1.25rem; margin: 0 0 .5rem; }
/* File lists and share-link boxes. */
.files .badge { margin-left: .3rem; }
/* Images among an entity's files (project photos, captures, mockups): newest first, the file page on click. */
.gallery { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin: 0 0 .75rem; }
.gallery figure { margin: 0; min-width: 0; }
.gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); }
.gallery figcaption { font-size: .8rem; margin-top: .25rem; overflow-wrap: anywhere; }
.gallery figcaption .sub { display: block; color: var(--ink-3); font-size: .75rem; }
.upload h3 { font-size: 1rem; margin: 0 0 .4rem; }
.thumb-sm img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; vertical-align: middle; margin-right: .4rem; border: 1px solid var(--line); background: var(--bg-2); }
input[data-select-on-focus] { width: 100%; font-size: .9rem; }
td.is-attention { color: var(--err); font-weight: 600; }
select.btn--sm { min-height: 32px; padding: .2rem .4rem; font-size: .85rem; width: auto; }

/* Phase 7 statuses: engineering records, revisions, releases, test results, packages, product stages. */
.badge--proposed, .badge--planned, .badge--review, .badge--in_progress, .badge--running, .badge--not_run { background: #fff4e0; color: #7a4a00; }
.badge--candidate, .badge--implemented, .badge--built, .badge--stage-design, .badge--stage-prototype, .badge--stage-requirements, .badge--stage-discovery, .badge--stage-feasibility { background: #e3edf9; color: #17508c; }
.badge--released, .badge--deployed, .badge--verified, .badge--done, .badge--pass, .badge--delivered, .badge--stage-released, .badge--stage-production_ready, .badge--stage-validation, .badge--stage-pilot { background: #e6f5ec; color: #155d33; }
.badge--rolled_back, .badge--withdrawn, .badge--abandoned, .badge--obsolete, .badge--stage-retired { background: #fdecea; color: #7a1f16; }
.badge--superseded, .badge--archived, .badge--stage-idea, .badge--stage-maintenance { background: var(--bg-2); color: var(--ink-3); }
.badge--blocked { background: #efe7fb; color: #5b3a9a; }
.results select { min-width: 7rem; }
fieldset.field { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; }
fieldset.field legend { font-weight: 600; font-size: .85rem; padding: 0 .3rem; }
fieldset[disabled] { opacity: .6; }

/* Product registry and releases (ADR 018): lifecycle and rollout badges. */
.badge--life-concept, .badge--life-development { background: var(--bg-2); color: var(--ink-3); }
.badge--life-internal, .badge--life-alpha, .badge--life-beta { background: #e3edf9; color: #17508c; }
.badge--life-active, .badge--life-mature { background: #e6f5ec; color: #155d33; }
.badge--life-maintenance, .badge--life-end_of_sale { background: #fff4e0; color: #7a4a00; }
.badge--life-end_of_support, .badge--life-discontinued { background: #fdecea; color: #7a1f16; }
.badge--lic-active { background: #e6f5ec; color: #155d33; }
.badge--lic-suspended, .badge--lic-refund_pending { background: #fff4e0; color: #7a4a00; }
.badge--lic-refunded, .badge--lic-revoked { background: #fdecea; color: #7a1f16; }
.badge--rollout-none { background: var(--bg-2); color: var(--ink-3); }
.badge--rollout-internal, .badge--rollout-beta, .badge--rollout-selected { background: #e3edf9; color: #17508c; }
.badge--rollout-percentage { background: #efe7fb; color: #5b3a9a; }
.badge--rollout-full { background: #e6f5ec; color: #155d33; }
.badge--rollout-paused { background: #fff4e0; color: #7a4a00; }
.badge--planned, .badge--in_progress { background: #fff4e0; color: #7a4a00; }
.catalogue { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin: 1rem 0 2rem; }
.items select.w-product { display: block; margin-top: .25rem; font-size: .82rem; min-height: 30px; padding: .15rem .35rem; max-width: 100%; }

/* Digital paperwork (ADR 020) */
.ta-xl { min-height: 420px !important; }
.doc-text { font-size: 1rem; line-height: 1.6; max-width: 72ch; }
/* One block per party on the document form: who they are, then the identity line under their signature. */
.party { margin-bottom: .75rem; background: var(--paper, #fafbfc); }
.form .party .row { gap: .6rem .8rem; }
@media (min-width: 640px) { .form .party .row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } .form .party .row > .field--grow { grid-column: span 2; } .form .party .row > .party__remove { grid-column: auto; } }
.party__details { margin-top: .5rem; padding-top: .5rem; border-top: 1px dashed var(--line); }
.party__remove { align-self: end; }
.party__buttons { display: flex; gap: .4rem; flex-wrap: wrap; }
.list { padding-left: 1.1rem; margin: 0; }
.list li { margin: .25rem 0; }
.badge--doc-draft { background: var(--bg-2); color: var(--ink-3); }
.badge--doc-sent, .badge--doc-viewed, .badge--doc-partially_signed { background: #e3edf9; color: #17508c; }
.badge--doc-signed { background: #e6f5ec; color: #155d33; }
.badge--doc-declined, .badge--doc-voided { background: #fdecea; color: #7a1f16; }
.badge--doc-expired { background: #fff4e0; color: #7a4a00; }
