/* ==========================================================================
   Afriq Brain invoice platform — application styles
   Palette carried over from the original register: navy sidebar, copper accent.
   ========================================================================== */
:root {
  --navy-900: #0f2240;
  --navy-800: #152d52;
  --navy-700: #1c416c;
  --ink: #16233a;
  --ink-2: #3a4a61;
  --muted: #66758a;
  --line: #dde5ef;
  --line-2: #e9eef5;
  --bg: #eef3f9;
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --copper: #c27135;
  --copper-600: #a95e27;
  --copper-soft: #f7e6d8;
  --green: #2f7a61;
  --green-soft: #dcefe6;
  --blue: #3a6ea5;
  --blue-soft: #e3edf8;
  --amber: #a86a12;
  --amber-soft: #fbefd5;
  --teal: #237a86;
  --teal-soft: #dcf0f2;
  --red: #c24545;
  --red-soft: #f9e1df;
  --grey: #5f6b7a;
  --grey-soft: #eceff3;
  --slate: #3d4654;
  --slate-soft: #dde1e7;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 34, 64, 0.06);
  --shadow: 0 6px 18px rgba(15, 34, 64, 0.08);
  --shadow-lg: 0 22px 50px rgba(15, 34, 64, 0.18);
  --mono: 'Manrope', system-ui, sans-serif;
  --sidebar-w: 248px;
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-variant-numeric: tabular-nums lining-nums; background: var(--bg); font-size: 14px; line-height: 1.45; color: var(--ink); }
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: none; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- Boot and states ---------- */
.boot-screen { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--copper); border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.state-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 60px 20px; color: var(--muted); }
.state-empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.state-empty .icon, .state-empty-icon .icon { width: 34px; height: 34px; color: var(--copper); }
.state-empty h3 { margin: 10px 0 6px; color: var(--ink); font-size: 16px; }
.state-empty p { margin: 0 0 16px; }
.state-error { display: flex; gap: 12px; align-items: flex-start; padding: 16px; margin: 20px 0; border: 1px solid #f0c9c5; border-radius: var(--radius); background: var(--red-soft); color: var(--red); }
.state-error p { margin: 4px 0 0; color: var(--ink-2); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 15px; border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 700; font-size: 13px; text-decoration: none; white-space: nowrap; transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s; }
.btn .icon { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }
.btn-accent { background: var(--copper); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--copper-600); }
.btn-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { border-color: #c5d2e1; background: var(--surface-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a83838; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--grey-soft); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 12px; }
.btn-block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
.btn-secondary.is-busy::after { border-color: var(--line); border-top-color: var(--copper); }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); text-decoration: none; }
.icon-btn:hover { background: var(--grey-soft); color: var(--ink); }
.link-btn { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 700; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Badges and avatars ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-draft { background: var(--grey-soft); color: var(--grey); }
.badge-sent { background: var(--blue-soft); color: var(--blue); }
.badge-pending { background: var(--amber-soft); color: var(--amber); }
.badge-partially_paid { background: var(--teal-soft); color: var(--teal); }
.badge-paid { background: var(--green-soft); color: var(--green); }
.badge-overdue { background: var(--red-soft); color: var(--red); }
.badge-cancelled { background: var(--slate-soft); color: var(--slate); text-decoration: line-through; }
.badge-active { background: var(--green-soft); color: var(--green); }
.badge-pending-approval { background: var(--amber-soft); color: var(--amber); }
.badge-suspended { background: var(--red-soft); color: var(--red); }
.badge-deactivated { background: var(--slate-soft); color: var(--slate); }
.badge-role { background: var(--copper-soft); color: var(--copper-600); }
.badge-role::before { display: none; }
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; background: #d8e4f1; color: #24466e; font-weight: 800; object-fit: cover; }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 44px; height: 44px; font-size: 15px; }
.avatar-lg { width: 72px; height: 72px; font-size: 24px; }
.avatar-xl { width: 96px; height: 96px; font-size: 30px; }
.count-badge { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-size: 10px; font-weight: 800; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar-w); display: flex; flex-direction: column; padding: 18px 12px; background: var(--navy-900); color: #c9d6e8; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; color: #fff; }
.sidebar-brand strong { display: block; font-size: 14px; line-height: 1.2; }
.sidebar-brand small { color: #8fa4c2; font-size: 11px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--copper); color: #fff; font-family: var(--mono); font-weight: 500; font-size: 13px; }
.brand-logo { width: 34px; height: 34px; flex: none; border-radius: 9px; object-fit: contain; background: #fff; }
.sidebar-nav { display: grid; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px; border: 0; border-radius: 8px; background: none; color: #b3c3d9; font-size: 13px; font-weight: 600; text-align: left; text-decoration: none; transition: background 0.15s, color 0.15s; }
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-link.active { background: #fff; color: var(--navy-900); box-shadow: var(--shadow-sm); }
.nav-link.active .icon { color: var(--copper); }
.nav-badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--copper); color: #fff; font-size: 11px; font-weight: 800; text-align: center; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.08); display: grid; gap: 4px; }
/* Language switch in the side menu: shown on phones, where the top bar has no room for it. */
.sidebar-lang { display: none; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 8px 10px; color: #8fa4c2; font-size: 12px; font-weight: 700; }
.sidebar-lang .lang-toggle { margin-right: 0; background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.12); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: #fff; text-decoration: none; }
.sidebar-user:hover { background: rgba(255, 255, 255, 0.07); }
.sidebar-user strong, .sidebar-user small { display: block; }
.sidebar-user strong { font-size: 13px; }
.sidebar-user small { color: #8fa4c2; font-size: 11px; }
.sidebar-scrim { display: none; }
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 28px; background: rgba(238, 243, 249, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.menu-toggle { display: none; }
.topbar-title { min-width: 0; }
.topbar-title .crumb { display: block; color: var(--muted); font-size: 11px; }
.topbar-title strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.topbar-new { margin-right: 6px; }
.profile-btn { border: 0; background: none; padding: 2px; border-radius: 50%; }
.content { padding: 26px 28px 60px; outline: none; max-width: 1480px; width: 100%; }

/* ---------- Page layout ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-header h1 { font-size: 26px; letter-spacing: -0.03em; }
.page-header p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px; border-bottom: 1px solid var(--line-2); }
.card-header h2, .card-header h3 { font-size: 15px; }
.card-header .muted { font-size: 12px; }
.card-body { padding: 18px; }
.section { margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stack { display: grid; gap: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stat { position: relative; display: block; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; box-shadow: var(--shadow-sm); transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s; }
a.stat:hover, button.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #c9d6e6; }
button.stat { width: 100%; text-align: left; font: inherit; cursor: pointer; }
.stat-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-label .icon { width: 16px; height: 16px; }
.stat-value { margin-top: 10px; font-family: var(--mono); font-size: 21px; font-weight: 500; letter-spacing: -0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-note { margin-top: 4px; color: var(--muted); font-size: 12px; }
.stat::after { content: ''; position: absolute; left: 16px; right: 16px; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent, transparent); }
.stat.tone-paid { --accent: var(--green); }
.stat.tone-pending { --accent: var(--amber); }
.stat.tone-overdue { --accent: var(--red); }
.stat.tone-draft { --accent: var(--grey); }
.stat.tone-sent { --accent: var(--blue); }
.stat.tone-accent { --accent: var(--copper); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; color: var(--ink-2); font-size: 12.5px; font-weight: 700; }
.field input, .field select, .field textarea, .input { width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid #cfdae7; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 500; transition: border-color 0.15s, box-shadow 0.15s; }
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--copper); box-shadow: 0 0 0 3px var(--copper-soft); }
.field input:disabled, .field select:disabled { background: var(--surface-2); color: var(--muted); }
.field .hint { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.field-full { grid-column: 1 / -1; }
.field-inline { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink-2); font-size: 13px; }
.form-alert { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.form-alert.error { background: var(--red-soft); color: var(--red); }
.form-alert.success { background: var(--green-soft); color: var(--green); }
.form-alert.info { background: var(--blue-soft); color: var(--blue); }
.form-section { padding: 18px; border-bottom: 1px solid var(--line-2); }
.form-section:last-child { border-bottom: 0; }
.form-section > h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 14px; }
.form-section > h3 .step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--navy-800); color: #fff; font-size: 11px; font-family: var(--mono); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---------- Toolbar, filters and tables ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--line-2); }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-left: 34px; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); }
.filters .field { font-size: 11.5px; }
.chip-tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 18px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: 12.5px; font-weight: 700; }
.chip:hover { border-color: #c5d2e1; }
.chip.active { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.chip .chip-count { font-family: var(--mono); font-size: 11px; opacity: 0.75; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { position: sticky; top: 0; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.05em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th .sort-arrow { margin-left: 4px; color: var(--copper); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; white-space: nowrap; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: #f8fbfe; }
.table tbody tr.clickable { cursor: pointer; }
.table .num { font-family: var(--mono); text-align: right; }
.table .ref { font-family: var(--mono); font-weight: 500; color: var(--navy-800); }
.table .strong { font-weight: 700; color: var(--ink); }
.table tfoot td { background: var(--surface-2); font-weight: 700; }
.person { display: inline-flex; align-items: center; gap: 8px; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px; color: var(--muted); font-size: 12.5px; }
.pager { display: flex; align-items: center; gap: 6px; }
.pager select { min-height: 32px; padding: 4px 8px; }

/* ---------- Menus ---------- */
.menu { position: absolute; z-index: 90; min-width: 200px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: menu-in 0.12s ease; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--ink); font-size: 13px; font-weight: 600; text-align: left; }
.menu-item:hover, .menu-item:focus { background: var(--surface-2); outline: none; }
.menu-item .icon { width: 16px; height: 16px; color: var(--muted); }
.menu-item.danger, .menu-item.danger .icon { color: var(--red); }
.menu-divider { height: 1px; margin: 5px 4px; background: var(--line-2); }

/* ---------- Dialogs and drawers ---------- */
.layer { position: fixed; inset: 0; z-index: 60; display: grid; background: rgba(12, 24, 44, 0); transition: background 0.2s; }
.layer.open { background: rgba(12, 24, 44, 0.45); }
.layer-modal { place-items: center; padding: 20px; overflow-y: auto; }
.layer-drawer { justify-items: end; }
.modal, .drawer { display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-lg); max-height: calc(100vh - 40px); }
.modal { width: 100%; border-radius: 14px; opacity: 0; transform: translateY(10px) scale(0.98); transition: opacity 0.2s, transform 0.2s; }
.layer.open .modal { opacity: 1; transform: none; }
.modal-sm { max-width: 440px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 860px; }
.drawer { width: min(640px, 100vw); height: 100vh; max-height: 100vh; transform: translateX(100%); transition: transform 0.25s ease; }
.drawer-lg { width: min(780px, 100vw); }
.layer.open .drawer { transform: none; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-2); }
.dialog-header h2 { font-size: 18px; }
.dialog-body { padding: 18px 20px; overflow-y: auto; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line-2); }
.confirm-message { margin: 0 0 14px; color: var(--ink-2); }

/* ---------- Toasts ---------- */
#toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
.toast { padding: 11px 15px; border-radius: var(--radius-sm); background: var(--navy-900); color: #fff; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(10px); transition: opacity 0.25s, transform 0.25s; border-left: 4px solid var(--green); }
.toast.show { opacity: 1; transform: none; }
.toast-error { border-left-color: var(--red); }
.toast-info { border-left-color: var(--blue); }

/* ---------- Tabs ---------- */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; border-radius: 9px; background: var(--grey-soft); }
.segmented button { padding: 8px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 700; font-size: 13px; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-weight: 700; font-size: 13px; white-space: nowrap; }
.tab.active { color: var(--ink); border-bottom-color: var(--copper); }
.view-toggle { display: inline-flex; padding: 3px; border-radius: 8px; background: var(--grey-soft); }
.view-toggle button { display: grid; place-items: center; width: 32px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.view-toggle button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Auth screen ---------- */
.auth-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 560px); background: var(--surface); }
.auth-aside { position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: 56px; background: radial-gradient(circle at 20% 15%, #264c7d 0, transparent 45%), linear-gradient(160deg, var(--navy-800), var(--navy-900)); color: #fff; }
.auth-aside::after { content: ''; position: absolute; right: -120px; top: -120px; width: 380px; height: 380px; border-radius: 50%; border: 60px solid rgba(194, 113, 53, 0.22); }
.auth-aside-inner { position: relative; max-width: 460px; }
.auth-aside .eyebrow { color: #e3a877; }
.auth-aside h2 { font-size: 32px; line-height: 1.15; letter-spacing: -0.03em; }
.auth-aside ul { margin: 22px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; color: #c9d6e8; }
.auth-aside li::before { content: '✓'; margin-right: 10px; color: #e3a877; font-weight: 800; }
.auth-picture { position: fixed; inset: 0; z-index: 0; }
.auth-picture img { width: 100%; height: 100%; object-fit: cover; }
.auth-picture::after { content: ''; position: absolute; inset: 0; background: rgba(12, 24, 44, 0.18); }
.auth-panel { display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 48px clamp(20px, 5vw, 60px); overflow-y: auto; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.auth-form { display: grid; gap: 14px; }
.auth-form h1 { font-size: 26px; }
.auth-form > .muted { margin: -8px 0 4px; }

/* ---------- Charts ---------- */
.chart-card { display: flex; flex-direction: column; min-width: 0; }
.chart-card .card-body { flex: 1; }
.chart-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--swatch); }
.bar-list { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 150px) minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 4px 6px; margin: 0 -6px; border: 0; border-radius: 6px; background: none; text-align: left; font-size: 12.5px; color: var(--ink-2); width: calc(100% + 12px); }
button.bar-row:hover { background: var(--surface-2); }
.bar-row .bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bar-track { height: 10px; border-radius: 99px; background: var(--grey-soft); overflow: hidden; }
.bar-track, .bar-fill { display: block; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--swatch, var(--copper)); transform-origin: left; animation: grow 0.6s ease; }
@keyframes grow { from { transform: scaleX(0); } }
.bar-value { font-family: var(--mono); font-size: 12px; color: var(--ink); white-space: nowrap; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { width: 180px; height: 180px; flex: none; }
.donut circle.segment { transition: opacity 0.15s; cursor: pointer; }
.donut circle.segment:hover { opacity: 0.8; }
.donut-legend { display: grid; gap: 8px; flex: 1; min-width: 180px; }
.donut-legend button { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; padding: 4px 6px; border: 0; border-radius: 6px; background: none; text-align: left; font-size: 12.5px; color: var(--ink-2); }
.donut-legend button:hover { background: var(--surface-2); }
.donut-legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--swatch); }
.donut-legend .mono { color: var(--ink); }
.line-chart { width: 100%; height: auto; overflow: visible; }
.line-chart .grid-line { stroke: var(--line-2); }
.line-chart .axis-label { fill: var(--muted); font-size: 10px; font-family: var(--mono); }
.line-chart .dot { transition: r 0.1s; }
.line-chart .hover-zone:hover + .dot, .line-chart .dot:hover { r: 5; }
.chart-tooltip { position: fixed; z-index: 95; pointer-events: none; padding: 8px 10px; border-radius: 7px; background: var(--navy-900); color: #fff; font-size: 12px; box-shadow: var(--shadow-lg); }
.chart-tooltip strong { display: block; margin-bottom: 3px; }
.chart-tooltip .mono { font-size: 11.5px; }
.aging-bars { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; align-items: end; height: 190px; padding-top: 10px; }
.aging-col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; border: 0; background: none; padding: 0; font: inherit; }
.aging-col .aging-bar { width: 100%; max-width: 64px; border-radius: 7px 7px 3px 3px; background: var(--swatch); min-height: 4px; transition: filter 0.15s, transform 0.15s; box-shadow: inset -8px 0 0 rgba(0, 0, 0, 0.08); transform-origin: bottom; animation: rise 0.6s ease; }
@keyframes rise { from { transform: scaleY(0); } }
.aging-col:hover .aging-bar { filter: brightness(1.08); transform: translateY(-2px); }
.aging-col .mono { font-size: 11px; color: var(--ink); text-align: center; }
.aging-col small { color: var(--muted); font-size: 11px; text-align: center; }
.rank-list { display: grid; gap: 2px; }
.rank-item { display: grid; grid-template-columns: 22px auto 1fr auto; align-items: center; gap: 10px; padding: 8px 6px; border: 0; border-radius: 7px; background: none; text-align: left; color: inherit; text-decoration: none; }
.rank-item:hover { background: var(--surface-2); }
.rank-item .rank { font-family: var(--mono); color: var(--muted); font-size: 12px; }
.rank-item strong { display: block; font-size: 13px; }
.rank-item small { color: var(--muted); font-size: 11.5px; }
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.period-bar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.period-bar .field { min-width: 150px; font-size: 11.5px; }
.period-bar .chip-tabs { padding: 0; flex: 1 1 100%; }

/* ---------- Staff directory ---------- */
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; padding: 18px; }
.staff-card { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s; outline: none; }
.staff-card:hover, .staff-card:focus-visible { z-index: 5; transform: translateY(-4px) scale(1.02); box-shadow: var(--shadow-lg); border-color: #c5d2e1; }
.staff-card-top { display: flex; align-items: center; gap: 12px; }
.staff-card-top h3 { font-size: 14.5px; }
.staff-card-top p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.staff-card-menu { margin-left: auto; align-self: flex-start; }
.staff-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.staff-meta span { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.staff-meta .icon { width: 14px; height: 14px; }
.staff-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.staff-counts div { text-align: center; }
.staff-counts strong { display: block; font-family: var(--mono); font-size: 15px; }
.staff-counts small { color: var(--muted); font-size: 10.5px; }
.staff-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); }
.staff-total strong { font-family: var(--mono); color: var(--ink); font-size: 14px; }
.hover-panel { position: absolute; left: 50%; bottom: calc(100% + 10px); z-index: 10; width: 270px; padding: 14px; border-radius: 12px; background: var(--navy-900); color: #dbe5f2; font-size: 12px; box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translate(-50%, 6px); transition: opacity 0.18s, transform 0.18s, visibility 0.18s; pointer-events: none; }
.hover-panel::after { content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 7px solid transparent; border-top-color: var(--navy-900); }
.staff-card:hover .hover-panel, .staff-card:focus-visible .hover-panel { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.hover-panel strong { color: #fff; }
.hover-panel dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 0; }
.hover-panel dt { color: #8fa4c2; }
.hover-panel dd { margin: 0; text-align: right; font-family: var(--mono); color: #fff; }
.staff-grid.top-row-safe { padding-top: 18px; }
.profile-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-hero h3 { font-size: 20px; }
.profile-hero p { margin: 2px 0 6px; color: var(--muted); }
.info-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin: 0; }
.info-list div { min-width: 0; }
.info-list dt { color: var(--muted); font-size: 11.5px; font-weight: 700; }
.info-list dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mini-stat { padding: 10px 12px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line-2); }
.mini-stat small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.mini-stat strong { display: block; margin-top: 3px; font-family: var(--mono); font-size: 14px; font-weight: 500; }
.mini-stat.tone-paid { border-left: 3px solid var(--green); }
.mini-stat.tone-pending { border-left: 3px solid var(--amber); }
.mini-stat.tone-overdue { border-left: 3px solid var(--red); }
.mini-stat.tone-draft { border-left: 3px solid var(--grey); }
.mini-stat.tone-cancelled { border-left: 3px solid var(--slate); }
.drawer-section { margin-top: 22px; }
.drawer-section > h4 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 13.5px; }
.admin-box { padding: 14px; border: 1px dashed #e3b58e; border-radius: 10px; background: #fffaf5; }
.perm-list { display: grid; gap: 6px; max-height: 280px; overflow-y: auto; padding-right: 4px; }
.perm-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 7px; background: var(--surface); border: 1px solid var(--line-2); font-size: 12.5px; }
.perm-row small { display: block; color: var(--muted); font-family: var(--mono); font-size: 10.5px; }
.perm-row select { min-height: 30px; padding: 3px 6px; font-size: 12px; }
.timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 7px 0; font-size: 12.5px; }
.timeline li::before { content: ''; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--dot, var(--blue)); }
.timeline small { display: block; color: var(--muted); font-size: 11.5px; }
.timeline .t-login_failed, .timeline .t-login_blocked { --dot: var(--red); }
.timeline .t-login { --dot: var(--green); }
.timeline .t-logout { --dot: var(--grey); }

/* ---------- Invoice form ---------- */
.invoice-form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.summary-panel { position: sticky; top: 80px; }
.summary-rows { display: grid; gap: 0; }
.summary-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: 13px; color: var(--ink-2); border-bottom: 1px dashed var(--line-2); }
.summary-row .mono { color: var(--ink); }
.summary-row.minus .mono { color: var(--red); }
.summary-row.subtotal { font-weight: 700; color: var(--ink); border-bottom-style: solid; }
.summary-net { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 12px; padding: 14px; border-radius: 10px; background: var(--navy-900); color: #fff; }
.summary-net span { font-size: 12.5px; font-weight: 700; color: #b9c9de; }
.summary-net strong { font-family: var(--mono); font-size: 20px; font-weight: 500; }
.summary-formula { margin: 12px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.items-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.items-table th.qty { width: 80px; }
.items-table th.rate { width: 130px; }
.items-table th.amt { width: 150px; }
.items-table th:last-child { width: 44px; }
.items-table th { padding: 6px 6px; color: var(--muted); font-family: var(--mono); font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; text-align: left; }
.items-table td { padding: 5px 6px; vertical-align: top; }
.items-table input, .items-table textarea { width: 100%; min-height: 36px; padding: 7px 9px; border: 1px solid #cfdae7; border-radius: 6px; background: var(--surface); font-size: 13px; }
.items-table textarea { resize: vertical; min-height: 36px; height: 36px; }
.items-table input:focus, .items-table textarea:focus { outline: none; border-color: var(--copper); box-shadow: 0 0 0 3px var(--copper-soft); }
.items-table .qty { width: 80px; }
.items-table .rate, .items-table .amt { width: 140px; }
.items-table .amt input { font-family: var(--mono); text-align: right; }
.items-table .line-total { display: block; padding: 8px 0; font-family: var(--mono); text-align: right; }
.reference-field input { font-family: var(--mono); font-size: 15px; font-weight: 500; letter-spacing: 0.02em; }
.reference-field .ref-row { display: flex; gap: 8px; }
.reference-field .ref-row input { flex: 1; }
.client-picker { position: relative; }
.suggestions { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 15; max-height: 240px; overflow-y: auto; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.suggestions button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 5px; background: none; text-align: left; font-size: 13px; }
.suggestions button:hover, .suggestions button.active { background: var(--surface-2); }
.suggestions small { display: block; color: var(--muted); font-size: 11.5px; }
.selected-client { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.selected-client small { display: block; color: var(--muted); }
.collapsible > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 700; font-size: 13px; }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary::before { content: '▸'; color: var(--muted); transition: transform 0.15s; }
.collapsible[open] > summary::before { transform: rotate(90deg); }
.collapsible > .grid-2, .collapsible > .grid-3 { margin-top: 12px; }

/* ---------- Invoice detail page ---------- */
.invoice-detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.preview-stage { padding: 24px; background: #dfe6ef; border-radius: var(--radius); overflow-x: auto; }
.side-card + .side-card { margin-top: 14px; }
.kv { display: grid; gap: 8px; margin: 0; font-size: 13px; }
.kv div { display: flex; justify-content: space-between; gap: 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- Messages ---------- */
.messages-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); min-height: calc(100vh - 190px); }
.message-list { border-right: 1px solid var(--line); overflow-y: auto; max-height: calc(100vh - 190px); }
.message-item { display: grid; grid-template-columns: auto 1fr; gap: 10px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line-2); background: none; text-align: left; color: inherit; text-decoration: none; }
.message-item:hover { background: var(--surface-2); }
.message-item.active { background: var(--blue-soft); }
.message-item.unread .msg-subject { font-weight: 800; }
.message-item.unread .msg-from::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: var(--copper); vertical-align: middle; }
.msg-top { display: flex; justify-content: space-between; gap: 8px; }
.msg-from { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.msg-subject { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-preview { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread { display: flex; flex-direction: column; min-width: 0; }
.thread-header { padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.thread-header h2 { font-size: 17px; }
.thread-body { flex: 1; display: grid; gap: 14px; align-content: start; padding: 20px; overflow-y: auto; max-height: calc(100vh - 380px); }
.bubble { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.bubble-content { padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface-2); }
.bubble.mine .bubble-content { background: #eef4fb; border-color: #d5e3f3; }
.bubble-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.bubble-meta strong { color: var(--ink); font-size: 13px; }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.reply-box { display: grid; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); }
.recipient-picker { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; min-height: 42px; border: 1px solid #cfdae7; border-radius: var(--radius-sm); background: var(--surface); }
.recipient-picker input { flex: 1; min-width: 140px; border: 0; outline: none; padding: 4px; font-size: 13px; }
.token { display: inline-flex; align-items: center; gap: 5px; padding: 3px 4px 3px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--navy-800); font-size: 12px; font-weight: 700; }
.token button { display: grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 50%; background: transparent; color: inherit; }
.token button:hover { background: rgba(0, 0, 0, 0.08); }
.token .icon { width: 12px; height: 12px; }
.group-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Notifications & audit ---------- */
.notice-list { display: grid; }
.notice { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: flex-start; padding: 14px 18px; border-bottom: 1px solid var(--line-2); color: inherit; text-decoration: none; }
.notice:hover { background: var(--surface-2); }
.notice.unread { background: #fbfdff; }
.notice.unread .notice-title::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 7px; border-radius: 50%; background: var(--copper); vertical-align: middle; }
.notice-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--blue-soft); color: var(--blue); }
.notice-icon.t-paid { background: var(--green-soft); color: var(--green); }
.notice-icon.t-overdue { background: var(--red-soft); color: var(--red); }
.notice-icon.t-user { background: var(--copper-soft); color: var(--copper-600); }
.notice-title { font-weight: 700; font-size: 13.5px; }
.notice p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.notice time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.diff { display: grid; gap: 4px; font-family: var(--mono); font-size: 11.5px; }
.diff .old { color: var(--red); }
.diff .new { color: var(--green); }
.audit-action { font-family: var(--mono); font-size: 12px; font-weight: 500; }

/* ---------- Settings ---------- */
.image-slot { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface-2); }
.image-slot .preview { display: grid; place-items: center; width: 140px; height: 70px; flex: none; border-radius: 7px; background: var(--surface); border: 1px solid var(--line-2); overflow: hidden; color: var(--muted); font-size: 11px; }
.image-slot .preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-slot .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.image-slot strong { display: block; font-size: 13px; }
.image-slot small { display: block; color: var(--muted); font-size: 11.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .invoice-form-layout, .invoice-detail-layout { grid-template-columns: minmax(0, 1fr); }
  .summary-panel { position: static; }
  .span-4, .span-5, .span-7 { grid-column: span 6; }
  .span-8 { grid-column: span 12; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(12, 24, 44, 0.45); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
  .messages-layout { grid-template-columns: 1fr; }
  .messages-layout.has-thread .message-list { display: none; }
  .messages-layout:not(.has-thread) .thread { display: none; }
  .message-list { border-right: 0; max-height: none; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .auth-screen { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}
@media (max-width: 760px) {
  .content { padding: 18px 14px 50px; }
  .topbar { padding: 0 10px; gap: 6px; height: 58px; }
  .topbar-new span { display: none; }
  .topbar-new { padding: 5px 9px; margin-right: 2px; }
  .topbar-title { flex: 1 1 auto; }
  .topbar-title .crumb { display: none; } /* phone: page title only, so it is not cut off */
  .topbar-actions { gap: 2px; }
  .topbar .lang-toggle { display: none; }
  .sidebar-lang { display: flex; }
  .segmented button { padding: 8px 4px; font-size: 12px; }
  .grid-2, .grid-3, .info-list { grid-template-columns: minmax(0, 1fr); }
  .dash-grid > * { grid-column: span 12 !important; }
  .page-header h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 16px; }
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .aging-bars { gap: 5px; }
  .preview-stage { padding: 8px; }
  .items-table thead { display: none; }
  .items-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
  .items-table td { padding: 0; width: auto !important; }
  .items-table td:first-child { grid-column: 1 / -1; }
  .hover-panel { display: none; }
  .bar-row { grid-template-columns: minmax(70px, 100px) minmax(0, 1fr) auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.admin-box > h4 { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
.admin-box > h4 .muted { margin-left: auto; }

/* Sign-in page with an uploaded picture: the picture fills the whole screen behind a mostly solid card,
   so the form stays easy to read whatever the photo looks like. */
.auth-screen.has-picture { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 32px 16px; background: var(--navy-900); }
.auth-screen.has-picture .auth-panel {
  position: relative;
  z-index: 1;
  width: min(500px, 100%);
  padding: 36px clamp(22px, 5vw, 40px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: 0 24px 60px rgba(8, 20, 40, 0.35);
  overflow: visible;
}
.auth-screen.has-picture .segmented { background: rgba(226, 232, 240, 0.9); }
.auth-form .grid-2 { align-items: start; }

/* Company logo: shown at its real proportions (logos are often wide banners). */
.auth-logo { display: flex; justify-content: center; padding: 4px 0 6px; }
.auth-logo img { display: block; max-width: min(300px, 100%); max-height: 96px; width: auto; height: auto; object-fit: contain; }
.brand-logo { width: auto; max-width: 150px; height: 38px; padding: 3px 6px; object-fit: contain; }

/* Numbers use Manrope with evenly spaced digits (plain zero, no slash). */
.stat-value { font-weight: 700; letter-spacing: -0.02em; }
.table .ref { font-weight: 700; letter-spacing: 0.01em; }
.summary-net strong, .mini-stat strong, .staff-counts strong, .staff-total strong, .staff-metrics strong { font-weight: 700; }
.form-section .grid-2, .form-section .grid-3 { align-items: start; }
.dash-grid .span-4 .table td:first-child { white-space: normal; min-width: 120px; }

/* Dashboard banner: new sign-ups waiting for approval */
.approval-banner { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; padding: 14px 18px; border-radius: var(--radius); border: 1px solid rgba(240, 163, 107, 0.55); background: linear-gradient(135deg, rgba(240, 163, 107, 0.18), rgba(96, 165, 250, 0.1)); color: var(--ink); text-decoration: none; box-shadow: 0 0 0 0 rgba(240, 163, 107, 0.5); animation: approval-pulse 2.4s ease-out 3; }
.approval-banner > .icon { width: 26px; height: 26px; color: var(--copper-600); flex: none; }
.approval-banner strong { display: block; font-size: 14.5px; }
.approval-banner small { display: block; color: var(--muted); font-size: 12.5px; }
.approval-banner .btn { margin-left: auto; }
.approval-banner:hover { border-color: var(--copper-600); }
@keyframes approval-pulse { 0% { box-shadow: 0 0 0 0 rgba(240, 163, 107, 0.45); } 100% { box-shadow: 0 0 0 14px rgba(240, 163, 107, 0); } }

/* EN | FR language switch */
.lang-toggle { display: inline-flex; padding: 3px; margin-right: 4px; border-radius: 999px; background: var(--grey-soft); border: 1px solid var(--line); }
.lang-toggle button { min-width: 34px; padding: 4px 9px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 800; letter-spacing: 0.04em; }
.lang-toggle button.active { background: linear-gradient(135deg, #f0a36b, #c27135); color: #fff; box-shadow: 0 3px 10px rgba(240, 163, 107, 0.35); }
.lang-toggle button:not(.active):hover { color: var(--ink); }
.auth-panel .lang-toggle, .auth-lang { align-self: flex-end; }

/* Invoice register on phones: each invoice becomes a compact card instead of a wide table row. */
@media (max-width: 760px) {
  .register-table { min-width: 0; }
  .register-table thead { display: none; }
  .register-table, .register-table tbody { display: block; width: 100%; }
  .register-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: 'ref status menu' 'client net menu' 'due net menu';
    align-items: center;
    gap: 3px 10px;
    padding: 12px 6px 12px 12px;
    border-bottom: 1px solid var(--line);
  }
  .register-table td { display: block; padding: 0 !important; border: 0 !important; white-space: normal; }
  .register-table td.c-extra { display: none; }
  .register-table .c-ref { grid-area: ref; }
  .register-table .c-status { grid-area: status; justify-self: end; }
  .register-table .c-menu { grid-area: menu; align-self: center; }
  .register-table .c-client { grid-area: client; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .register-table .c-net { grid-area: net; align-self: end; text-align: right; font-size: 15px; white-space: nowrap; }
  .register-table .c-due { grid-area: due; color: var(--muted); font-size: 12px; }
  .register-table .c-due::before { content: attr(data-label) ' '; }
}

/* Buttons that only make sense with a mouse, e.g. printing straight from the browser. */
@media (pointer: coarse) {
  .desktop-only { display: none !important; }
}

/* Shared invoices: people working on an invoice, and the "Shared" tag in the register */
.people-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.people-list li { display: flex; align-items: center; gap: 10px; }
.people-list li > span:not(.avatar) { display: grid; flex: 1; min-width: 0; }
.people-list strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-list small { color: var(--muted); font-size: 11.5px; }
.people-list .icon-btn { width: 30px; height: 30px; }
.shared-tag { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: rgba(59, 130, 246, 0.14); color: #60a5fa; font-size: 10.5px; font-weight: 800; vertical-align: 1px; white-space: nowrap; }
.shared-tag .icon { width: 12px; height: 12px; }
.attest-tag { display: inline-flex; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-size: 10.5px; font-weight: 800; vertical-align: 1px; white-space: nowrap; }
.attest-file { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; }
.attest-file .icon { width: 16px; height: 16px; color: var(--muted); }
.attest-file a { flex: 1; min-width: 0; font-weight: 700; }
.attest-file .link-btn { font-size: 12px; }

/* "Send through Outlook" — Outlook's blue, so it is recognisable at a glance */
.btn-outlook { background: #0f6cbd; border-color: #0f6cbd; color: #fff; }
.btn-outlook:hover { background: #115ea3; border-color: #115ea3; color: #fff; }

/* Suggestions board */
.suggest-list { display: grid; }
.suggest { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; padding: 16px 18px; border-top: 1px solid var(--line); }
.suggest .vote { display: grid; justify-items: center; align-content: start; gap: 2px; min-width: 52px; padding: 8px 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.suggest .vote .icon { width: 18px; height: 18px; }
.suggest .vote strong { font-size: 14px; color: var(--ink); }
.suggest .vote:hover { border-color: var(--copper); color: var(--copper); }
.suggest .vote.voted { border-color: var(--copper); background: rgba(240, 163, 107, 0.14); color: var(--copper); }
.suggest-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.suggest-cat { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.suggest-cat .icon { width: 14px; height: 14px; }
.suggest h3 { margin: 6px 0 4px; font-size: 15.5px; }
.suggest-body { margin: 0 0 8px; white-space: pre-line; color: var(--ink-2); font-size: 13.5px; }
.suggest-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.suggest-reply { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--copper); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: rgba(240, 163, 107, 0.08); font-size: 13px; }
.suggest-reply p { margin: 4px 0 0; white-space: pre-line; }
.suggest-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 10px; }
.card-header h2 .icon { width: 18px; height: 18px; vertical-align: -3px; color: var(--copper); }
.badge-declined { background: var(--slate-soft); color: var(--slate); }
.suggest .vote { align-self: start; }
#suggest-sort { width: auto; }
.card .toolbar .field-inline { white-space: nowrap; }
