/* FAZELY CRM — FAZELY brand (orange #EB5E28, carbon #252422 and their lighter tones), light and dark themes. */
@font-face { font-family: "Rethink Sans"; src: url("../fonts/RethinkSans-Regular.26ff2d0c11e7.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Rethink Sans"; src: url("../fonts/RethinkSans-Bold.edb9a4910728.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Rethink Sans"; src: url("../fonts/RethinkSans-Italic.e663abbb6c68.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Plus Jakarta Sans"; src: url("../fonts/PlusJakartaSans-Bold.5a3a96a9ba07.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Space Mono"; src: url("../fonts/SpaceMono-Bold.d6a2ed5cbe1c.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Space Mono"; src: url("../fonts/SpaceMono-Regular.b0ea4c1a4ffd.ttf") format("truetype"); font-weight: 400; font-display: swap; }

:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #F7F5F0; --surface: #FFFFFF; --surface-2: #FBF9F5; --sunken: #F2EEE6; --line: #E8E2D7; --line-strong: #D9D1C3;
  --text: #252422; --text-2: #4A463F; --muted: #7A7368;
  --brand: #EB5E28; --brand-strong: #C9481A; --brand-soft: #FDEDE4; --brand-ink: #A33C12; --on-brand: #1E1D1B;
  --carbon: #252422; --on-carbon: #FFFCF2; --carbon-muted: #CCC5B9;
  --ok: #23784A; --ok-soft: #E1F2E7; --warn: #8F5B00; --warn-soft: #FFF1D9; --danger: #B3261E; --danger-soft: #FBE7E5; --info: #2F5FB3; --info-soft: #E5EDFB;
  --chart-1: #252422; --chart-2: #EB5E28;
  --shadow: 0 1px 0 rgba(37,36,34,.04), 0 10px 30px -18px rgba(37,36,34,.28);
  --shadow-pop: 0 24px 60px -24px rgba(37,36,34,.45), 0 2px 8px rgba(37,36,34,.06);
  --ring: rgba(235,94,40,.22);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121110; --surface: #1C1B19; --surface-2: #211F1D; --sunken: #282624; --line: #312E2A; --line-strong: #44403A;
  --text: #F3EFE7; --text-2: #D6D0C5; --muted: #9D968B;
  --brand: #F07A47; --brand-strong: #FF915F; --brand-soft: rgba(240,122,71,.14); --brand-ink: #FFAE88; --on-brand: #171614;
  --carbon: #2B2926; --on-carbon: #FFFCF2; --carbon-muted: #B5AEA2;
  --ok: #6FD39A; --ok-soft: rgba(111,211,154,.12); --warn: #F2C26B; --warn-soft: rgba(242,194,107,.12); --danger: #FF8A80; --danger-soft: rgba(255,138,128,.12); --info: #8DB4FF; --info-soft: rgba(141,180,255,.12);
  --chart-1: #E9E3D8; --chart-2: #F07A47;
  --shadow: 0 1px 0 rgba(0,0,0,.4), 0 12px 30px -18px rgba(0,0,0,.7);
  --shadow-pop: 0 24px 60px -20px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.04);
  --ring: rgba(240,122,71,.3);
}
:root {
  --radius: 18px; --radius-sm: 12px;
  --font: "Rethink Sans", system-ui, sans-serif; --heading: "Plus Jakarta Sans", var(--font); --mono: "Space Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; transition: background .2s, color .2s; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--heading); font-weight: 700; line-height: 1.2; margin: 0 0 .6rem; color: var(--text); letter-spacing: -0.015em; }
h1 { font-size: 1.75rem; letter-spacing: -0.025em; }
h2 { font-size: 1.08rem; } h3 { font-size: .98rem; }
small, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .84em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
.i { width: 1.05em; height: 1.05em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.15em; }
[hidden] { display: none !important; }

/* Layout ------------------------------------------------------------------------------------------ */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .55rem; padding: 4px 8px 18px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.brand:hover { text-decoration: none; }
.brand img { width: 118px; height: auto; display: block; }
.brand span { font-family: var(--mono); font-weight: 700; font-size: .66rem; letter-spacing: .12em; color: var(--on-brand); background: var(--brand); padding: 3px 8px; border-radius: 999px; }
.logo-dark { display: none !important; }
[data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .logo-dark { display: block !important; }
.nav a { position: relative; display: flex; align-items: center; gap: .65rem; color: var(--text-2); padding: .52rem .7rem; border-radius: 10px; font-size: .93rem; margin: 1px 0; }
.nav a .i { width: 17px; height: 17px; color: var(--muted); }
.nav a:hover { background: var(--sunken); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; }
.nav a.active .i { color: var(--brand); }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav .group { color: var(--muted); font-size: .68rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: .1em; margin: 1.1rem .7rem .35rem; }
.main { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 2rem; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar form.search { position: relative; }
.topbar form.search .i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar form.search input { width: 360px; border-radius: 999px; padding-left: 2.3rem; }
.topbar .user { display: flex; gap: .6rem; align-items: center; font-size: .9rem; }
.topbar .who { display: inline-flex; gap: .4rem; align-items: center; font-weight: 700; color: var(--text); }
.theme-toggle { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); cursor: pointer; transition: background .15s, color .15s; }
.theme-toggle:hover { color: var(--brand); border-color: var(--brand); }
.theme-toggle .show-dark { display: none; }
[data-theme="dark"] .theme-toggle .show-dark { display: block; }
[data-theme="dark"] .theme-toggle .show-light { display: none; }
.content { padding: 1.8rem 2rem 3rem; max-width: 1320px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: -.3rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: 1rem; }

/* Cards ------------------------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.3rem; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: .9rem; }
.card h2 .i, .card-head h2 .i { color: var(--brand); margin-right: .35rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; gap: .5rem; }
.card-head h2, .card-head h3 { margin: 0; }
.kpi { padding: 1.05rem 1.2rem; background: var(--surface); }
.kpi .label { color: var(--muted); font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; }
.kpi .value { font-weight: 700; font-size: 1.55rem; margin-top: .25rem; white-space: nowrap; color: var(--text); letter-spacing: -0.02em; }
.kpi .hint { font-size: .82rem; color: var(--muted); }
.kpi.accent { background: var(--carbon); border-color: var(--carbon); color: var(--on-carbon); box-shadow: 0 16px 34px -20px rgba(37,36,34,.8); }
.kpi.accent .label { color: var(--brand); } .kpi.accent .hint { color: var(--carbon-muted); }
.kpi.accent .value { color: var(--on-carbon); }
[data-theme="dark"] .kpi.accent { border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }

/* Tables ------------------------------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.table th { text-align: left; font-family: var(--mono); font-weight: 400; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: var(--sunken); padding: .6rem .75rem; white-space: nowrap; border-bottom: 1px solid var(--line); }
.table th:first-child { border-top-left-radius: 10px; } .table th:last-child { border-top-right-radius: 10px; }
.table td { padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; border-bottom: none; }
.table tfoot tr.grand td { background: var(--carbon); color: var(--on-carbon); }
.table tfoot tr.grand td:first-child { border-bottom-left-radius: 10px; } .table tfoot tr.grand td:last-child { border-bottom-right-radius: 10px; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.kind { display: inline-flex; align-items: center; gap: .35rem; color: var(--text-2); }
.kind .i { color: var(--brand); }

/* Badges ------------------------------------------------------------------------------------------ */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .14rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; background: var(--brand-soft); color: var(--brand-ink); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.role { background: var(--sunken); color: var(--text-2); }
.badge.draft { background: var(--sunken); color: var(--muted); }
.badge.issued, .badge.recorded, .badge.open { background: var(--info-soft); color: var(--info); }
.badge.sent, .badge.partially_paid { background: var(--warn-soft); color: var(--warn); }
.badge.accepted, .badge.paid, .badge.delivered, .badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.rejected, .badge.void, .badge.cancelled, .badge.overdue { background: var(--danger-soft); color: var(--danger); }
.badge.expired, .badge.superseded { background: var(--sunken); color: var(--muted); }
.badge.channel { background: var(--brand-soft); color: var(--brand-ink); }

/* Forms ------------------------------------------------------------------------------------------- */
label { font-weight: 700; font-size: .84rem; display: block; margin-bottom: .3rem; color: var(--text-2); }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=date], input[type=datetime-local], input[type=search], input[type=url], input[type=tel], select, textarea {
  width: 100%; font: inherit; color: var(--text); padding: .55rem .75rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
input[disabled], select[disabled], textarea[disabled] { background: var(--sunken); color: var(--muted); }
input[type=date]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
[data-theme="dark"] input[type=date]::-webkit-calendar-picker-indicator, [data-theme="dark"] input[type=datetime-local]::-webkit-calendar-picker-indicator { filter: invert(1); }
textarea { resize: vertical; }
.field { margin-bottom: 1rem; }
.field .help { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.field .errors, .errorlist { color: var(--danger); font-size: .84rem; margin: .25rem 0 0; padding: 0; list-style: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.1rem; }
.form-grid .full { grid-column: 1 / -1; }
.radio-inline ul, ul.radio-inline { display: flex; gap: 1rem; list-style: none; padding: 0; margin: 0; }
.radio-inline label, .check label { font-weight: 400; display: inline-flex; gap: .45rem; align-items: center; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 1rem; height: 1rem; }
.with-icon { position: relative; }
.with-icon > .i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.with-icon > input { padding-left: 2.2rem; }

/* Segmented choice (radio) with icons */
.seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--sunken); border: 1px solid var(--line); border-radius: 14px; flex-wrap: wrap; }
.seg label { margin: 0; display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .95rem; border-radius: 10px; font-weight: 700; font-size: .9rem; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.seg label .i { color: var(--muted); }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--line); }
.seg label:has(input:checked) .i { color: var(--brand); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Custom select (progressive enhancement of <select>, see app.js) */
.cs { position: relative; width: 100%; }
.cs > select.cs-native { position: absolute; inset: 0; opacity: 0; pointer-events: none; width: 100%; height: 100%; }
.cs-btn { width: 100%; display: flex; align-items: center; gap: .5rem; font: inherit; color: var(--text); text-align: left; padding: .55rem .75rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s; min-height: 2.45rem; }
.cs-btn:hover { border-color: color-mix(in srgb, var(--brand) 55%, var(--line-strong)); }
.cs-btn[aria-expanded="true"], .cs-btn:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--ring); }
.cs-btn:disabled { background: var(--sunken); color: var(--muted); cursor: not-allowed; }
.cs-val { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-val.placeholder { color: var(--muted); }
.cs-btn > .i { color: var(--muted); transition: transform .15s; }
.cs-btn[aria-expanded="true"] > .i { transform: rotate(180deg); color: var(--brand); }
.cs-pop { position: fixed; z-index: 1000; width: max-content; max-width: min(520px, 92vw); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-pop); padding: 6px; animation: cs-in .12s ease-out; }
@keyframes cs-in { from { opacity: 0; transform: translateY(-4px); } }
.cs-search { margin: 2px 2px 6px; width: calc(100% - 4px) !important; padding: .45rem .7rem !important; font-size: .9rem; }
.cs-list { list-style: none; margin: 0; padding: 0; max-height: 290px; overflow-y: auto; }
.cs-opt { display: flex; align-items: center; gap: .55rem; padding: .5rem .65rem; border-radius: 9px; cursor: pointer; font-size: .93rem; color: var(--text); }
.cs-opt .tick { width: 15px; height: 15px; color: var(--brand); visibility: hidden; }
.cs-opt[aria-selected="true"] { font-weight: 700; }
.cs-opt[aria-selected="true"] .tick { visibility: visible; }
.cs-opt.active, .cs-opt:hover { background: var(--brand-soft); color: var(--text); }
.cs-opt.placeholder { color: var(--muted); }
.cs-opt[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.cs-opt .meta { margin-left: auto; padding-left: 1rem; color: var(--muted); font-size: .8rem; }
.cs-create { color: var(--brand-ink); font-weight: 700; border-bottom: 1px solid var(--line); border-radius: 9px 9px 0 0; margin-bottom: 4px; }
.cs-create .i { color: var(--brand); }
.cs-empty { padding: .6rem .7rem; color: var(--muted); font-size: .88rem; }
.cs-group { padding: .45rem .65rem .2rem; font-family: var(--mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* Buttons ----------------------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font-family: var(--mono); font-weight: 700; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  padding: .6rem 1rem; border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, border-color .15s, transform .15s; }
.btn .i { width: 15px; height: 15px; }
.btn:hover { border-color: var(--text); text-decoration: none; color: var(--text); transform: translateY(-1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }
.btn.dark { background: var(--carbon); border-color: var(--carbon); color: var(--on-carbon); }
.btn.dark:hover { background: #000; border-color: #000; color: #fff; }
[data-theme="dark"] .btn.dark { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .32rem .7rem; font-size: .64rem; }
.btn.small .i { width: 13px; height: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunken); border-color: transparent; }
.btn.icon-only { padding: .38rem; border-radius: 50%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
details.action { position: relative; }
details.action > summary { list-style: none; }
details.action > summary::-webkit-details-marker { display: none; }
details.action .pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 1.05rem; }
details > summary.btn { list-style: none; } details > summary.btn::-webkit-details-marker { display: none; }

/* Dialog ------------------------------------------------------------------------------------------ */
dialog.modal { border: 1px solid var(--line); border-radius: 22px; padding: 0; width: min(600px, 94vw); background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); }
dialog.modal::backdrop { background: rgba(18,17,16,.55); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; display: flex; gap: .5rem; align-items: center; }
.modal-head h2 .i { color: var(--brand); }
.modal-body { padding: 1.2rem 1.3rem .4rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.3rem 1.2rem; }
.modal-error { margin: 0 0 1rem; padding: .7rem .9rem; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: .9rem; }
.sub-block { border: 1px dashed var(--line-strong); border-radius: 14px; padding: .9rem 1rem .1rem; margin-top: .4rem; }
.sub-block > .sub-title { display: flex; align-items: center; gap: .45rem; font-weight: 700; font-size: .86rem; margin-bottom: .7rem; color: var(--text-2); }
.sub-block > .sub-title .i { color: var(--brand); }

/* Recipient picker on documents */
.recipient { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: .9rem 1rem .2rem; }
.recipient .seg { margin-bottom: .8rem; }

/* Messages ---------------------------------------------------------------------------------------- */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .75rem 1rem; border-radius: 12px; margin-bottom: .5rem; border: 1px solid transparent; }
.messages .success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.messages .error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.messages .info, .messages .warning { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.callout { border-left: 3px solid var(--brand); background: var(--brand-soft); padding: .8rem 1rem; border-radius: 0 12px 12px 0; }
.callout.info { border-color: var(--info); background: var(--info-soft); }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.secret { font-family: var(--mono); background: var(--carbon); color: var(--on-carbon); padding: .75rem .95rem; border-radius: 12px; word-break: break-all; user-select: all; }

/* Tabs & timeline --------------------------------------------------------------------------------- */
.tabs { display: inline-flex; gap: .25rem; padding: .25rem; background: var(--sunken); border: 1px solid var(--line); border-radius: 999px; margin-bottom: 1.2rem; flex-wrap: wrap; }
.tabs a { padding: .4rem .9rem; color: var(--text-2); border-radius: 999px; font-size: .9rem; }
.tabs a:hover { text-decoration: none; background: var(--surface); }
.tabs a.active { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.25rem; border-left: 2px solid var(--line); margin-left: .35rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.timeline .when { font-size: .76rem; color: var(--muted); font-family: var(--mono); }

/* Line editor ------------------------------------------------------------------------------------- */
.lines-editor td { vertical-align: top; padding: .45rem .35rem; }
.lines-editor input, .lines-editor select, .lines-editor textarea, .lines-editor .cs-btn { padding: .42rem .5rem; font-size: .9rem; min-height: 0; }
.lines-editor textarea { margin-top: .35rem; }
.lines-editor .w-qty { width: 84px; } .lines-editor .w-unit { width: 92px; } .lines-editor .w-price { width: 118px; } .lines-editor .w-pct { width: 78px; } .lines-editor .w-tax, .lines-editor .cs:has(.w-tax) { width: 100px; }
.lines-editor .handle { color: var(--muted); font-family: var(--mono); font-weight: 700; text-align: center; padding-top: .75rem; }
.totals-box { min-width: 320px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: .4rem; }
.totals-box table { width: 100%; border-collapse: separate; border-spacing: 0; }
.totals-box td { padding: .45rem .6rem; }
.totals-box tr.grand td { background: var(--carbon); color: var(--on-carbon); font-weight: 700; }
.totals-box tr.grand td:first-child { border-radius: 10px 0 0 10px; } .totals-box tr.grand td:last-child { border-radius: 0 10px 10px 0; color: var(--brand); }

/* Chart ------------------------------------------------------------------------------------------- */
.bars { display: flex; align-items: flex-end; gap: .55rem; height: 170px; padding: .5rem 0 0; }
.bars .m { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem; min-width: 26px; }
.bars .pair { display: flex; align-items: flex-end; gap: 3px; height: 140px; width: 100%; justify-content: center; }
.bars .b { width: 42%; max-width: 18px; border-radius: 6px 6px 2px 2px; min-height: 3px; }
.bars .b.inv { background: var(--chart-1); } .bars .b.col { background: var(--chart-2); }
.bars .lbl { font-size: .7rem; color: var(--muted); font-family: var(--mono); }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .3rem; vertical-align: middle; }
.legend i.inv { background: var(--chart-1); } .legend i.col { background: var(--chart-2); }

/* Login & public pages ---------------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1fr) 1.05fr; background: var(--bg); }
.login-side { position: relative; overflow: hidden; background: #1E1D1B; color: #FFFCF2; display: flex; flex-direction: column; justify-content: space-between; gap: 2.2rem; padding: 48px 52px; }
.login-side::before { content: ""; position: absolute; width: 620px; height: 620px; right: -200px; bottom: -260px; border-radius: 50%; background: radial-gradient(circle, rgba(235,94,40,.55), rgba(235,94,40,0) 65%); }
.login-side::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,252,242,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,252,242,.045) 1px, transparent 1px); background-size: 44px 44px; -webkit-mask-image: linear-gradient(to bottom, #000, transparent 85%); mask-image: linear-gradient(to bottom, #000, transparent 85%); }
.login-side > * { position: relative; z-index: 1; }
.login-side .tag { align-self: flex-start; font-family: var(--mono); font-weight: 700; font-size: .7rem; letter-spacing: .12em; background: #EB5E28; color: #1E1D1B; padding: .3rem .7rem; border-radius: 999px; }
.login-side h2 { color: #FFFCF2; font-family: var(--heading); font-size: clamp(2.2rem, 3.6vw, 3.4rem); line-height: 1.02; letter-spacing: -0.04em; margin: 0 0 1rem; max-width: 13ch; }
.login-side h2 em { font-style: normal; color: #EB5E28; }
.login-side p { font-size: 1.1rem; line-height: 1.45; color: #CCC5B9; max-width: 34ch; margin: 0; }
.login-side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; color: #E7E1D6; }
.login-side li { display: flex; gap: .6rem; align-items: center; }
.login-side li .i { color: #EB5E28; }
.login-main { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 88px); }
.login-main .logo { width: 150px; margin-bottom: 2.6rem; }
.login-card { width: 100%; max-width: 460px; }
.login-card h1 { font-size: 2.3rem; letter-spacing: -0.035em; margin-bottom: .5rem; }
.login-card .intro { font-size: 1.05rem; color: var(--muted); margin: 0 0 1.8rem; }
.cells { border: 1px solid var(--line-strong); border-radius: 16px; overflow: hidden; background: var(--surface); margin-bottom: 1.2rem; }
.cells .cell { border-bottom: 1px solid var(--line); padding: .55rem 1rem .6rem; display: grid; grid-template-columns: auto 1fr; column-gap: .75rem; align-items: center; }
.cells .cell > .i { grid-row: span 2; color: var(--muted); width: 18px; height: 18px; }
.cells .cell:last-child { border-bottom: 0; }
.cells label { font-family: var(--mono); font-weight: 400; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 .1rem; }
.cells input { border: 0; padding: .2rem 0 .25rem; font-size: 1.05rem; border-radius: 0; box-shadow: none !important; background: transparent; }
.cells .cell:focus-within { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--brand); }
.cells .cell:focus-within > .i { color: var(--brand); }
.btn.block { width: 100%; padding: .95rem 1.2rem; font-size: .8rem; }
.login-foot { margin-top: 1.6rem; font-size: .84rem; color: var(--muted); line-height: 1.6; }
.login-foot a { white-space: nowrap; }
.login-theme { position: absolute; top: 18px; right: 18px; }
.rule { display: none; }

.pagination { display: flex; gap: .4rem; align-items: center; justify-content: flex-end; margin-top: .9rem; font-size: .88rem; }

.public-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem 4rem; background: var(--bg); }
.public-card { width: 100%; max-width: 760px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 2.4rem clamp(1.4rem, 4vw, 2.8rem); }
.public-card .logo { width: 140px; margin-bottom: 1.6rem; }
.public-card h1 { font-size: 2rem; }
.public-card h2 { margin-top: 1.4rem; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { display: flex; flex-wrap: wrap; gap: .2rem; } .nav .group { display: none; } .nav a.active::before { display: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .topbar { padding: .8rem 1rem; } .topbar form.search { flex: 1; } .topbar form.search input { width: 100%; }
  .topbar .who span, .topbar .role { display: none; }
  .content { padding: 1rem; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { min-height: 280px; order: -1; padding: 28px; }
}
@media print { .sidebar, .topbar, .actions { display: none !important; } .shell { display: block; } body { background: #fff; color: #000; } }
