/* Noème portal — styled after noemeparis.com: white and cream surfaces,
   dark brown ink, the logo's gold as a fine accent, Instrument Sans. Light only. */
:root {
  --ink: #321E1E;
  --ink-2: #6B5A58;
  --ink-3: #9A8D8B;
  --paper: #FFFFFF;
  --cream: #FAF4F0;
  --cream-2: #F3EAE3;
  --line: #EBE9E9;
  --line-strong: #D9D3CF;
  --gold: #D4B44A;
  --gold-deep: #9C7C1F;
  --gold-soft: rgba(212, 180, 74, 0.14);
  --red: #B3261E;
  --red-soft: #FBEAE8;
  --green: #2E6B4A;
  --green-soft: #E7F2EC;
  --amber: #8A5A00;
  --amber-soft: #FBF1DC;
  --blue: #2B4C7E;
  --blue-soft: #E8EEF7;
  --font: 'Instrument Sans', 'Helvetica Neue', Arial, sans-serif;
  --radius: 3px;
  --shadow: 0 12px 40px -18px rgba(50, 30, 30, 0.35);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 500; }
.muted { color: var(--ink-3); }
.neg { color: var(--red); }
.pos { color: var(--green); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---- shell ---------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--cream); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { padding: 26px 20px 18px; text-align: center; border-bottom: 1px solid var(--line); }
.side .brand img { width: 84px; height: auto; display: block; margin: 0 auto; }
.side .brand .tag { margin-top: 10px; font-size: 10px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--gold-deep); }
.nav { padding: 14px 0; flex: 1; }
.nav .group { padding: 16px 24px 6px; font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-3); }
.nav a { display: block; padding: 9px 24px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; text-decoration: none; color: var(--ink-2); border-left: 2px solid transparent; transition: background 160ms var(--ease), color 160ms var(--ease); }
.nav a:hover { background: var(--cream-2); color: var(--ink); }
.nav a.active { color: var(--ink); border-left-color: var(--gold); background: var(--paper); font-weight: 600; }
.side .foot { padding: 14px 20px 18px; border-top: 1px solid var(--line); font-size: 12px; }
.side .foot .who { font-weight: 600; }
.side .foot .role { color: var(--ink-3); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.side .foot .links { margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.side .foot .links button { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; font-size: 12px; }

.main { min-width: 0; }
.scrim { display: none; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 32px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.topbar .mini-logo { display: none; height: 34px; }
.page { padding: 28px 32px 64px; max-width: 1500px; }

.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--line); position: relative; }
.page-head::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 56px; height: 2px; background: var(--gold); }
.page-head h1 { font-size: 22px; letter-spacing: 0.04em; font-weight: 500; }
.page-head .sub { color: var(--ink-3); font-size: 13px; width: 100%; order: 3; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-2); margin: 30px 0 12px; font-weight: 600; }

/* ---- controls ------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); border-radius: var(--radius); font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease); }
.btn:hover { background: var(--ink); color: #fff; }
.btn.btn-primary { background: var(--ink); color: #fff; }
.btn.btn-primary:hover { background: #1F1212; border-color: #1F1212; }
.btn.btn-quiet { border-color: var(--line-strong); color: var(--ink-2); font-weight: 500; }
.btn.btn-quiet:hover { background: var(--cream); color: var(--ink); border-color: var(--ink-3); }
.btn.btn-danger { border-color: var(--red); color: var(--red); }
.btn.btn-danger:hover { background: var(--red); color: #fff; }
.btn.btn-small { padding: 5px 10px; font-size: 10.5px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .chip:focus-visible, .nav a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.select-plain { border: 1px solid var(--line-strong); background: var(--paper); border-radius: var(--radius); padding: 7px 10px; font-size: 12.5px; cursor: pointer; }
.lang-toggle { min-width: 46px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 6px 13px; border: 1px solid var(--line-strong); background: var(--paper); border-radius: 999px; font-size: 12px; cursor: pointer; color: var(--ink-2); transition: all 160ms var(--ease); }
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.chip-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .count { opacity: 0.65; margin-left: 5px; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { margin: 0; min-width: 150px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; background: var(--cream-2); color: var(--ink-2); white-space: nowrap; }
.badge.badge-green { background: var(--green-soft); color: var(--green); }
.badge.badge-red { background: var(--red-soft); color: var(--red); }
.badge.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge.badge-gold { background: var(--gold-soft); color: var(--gold-deep); }

/* ---- cards and KPIs ------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { border: 1px solid var(--line); border-top: 2px solid var(--gold); background: var(--paper); padding: 16px 18px; border-radius: var(--radius); }
.kpi .label { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); }
.kpi .value { font-size: 24px; font-weight: 500; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi .sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.kpi.kpi-click { cursor: pointer; transition: box-shadow 160ms var(--ease), transform 160ms var(--ease); }
.kpi.kpi-click:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; }

.notice { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border: 1px solid var(--line-strong); border-left: 3px solid var(--gold); background: var(--cream); border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; }
.notice.notice-red { border-left-color: var(--red); background: var(--red-soft); }
.notice .grow { flex: 1; min-width: 200px; }

/* ---- tables --------------------------------------------------------------- */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--paper); }
.table-tools { display: flex; justify-content: flex-end; margin-bottom: 6px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; padding: 10px 12px; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 600; color: var(--ink-2); background: var(--cream); border-bottom: 1px solid var(--line-strong); white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 0; }
.tbl th.num { text-align: right; }
.tbl th[data-no-sort] { cursor: default; }
.tbl th .arrow { display: inline-block; width: 10px; margin-left: 4px; color: var(--gold-deep); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.row-click { cursor: pointer; }
.tbl tbody tr.row-click:hover td { background: var(--cream); }
.tbl tr.totals-row td { background: var(--cream); border-top: 1px solid var(--line-strong); border-bottom: 0; font-weight: 600; }
.tbl td.cell-click { cursor: pointer; }
.tbl td.cell-click:hover { background: var(--gold-soft); }
.tbl td.zero { color: var(--line-strong); }
.tbl .empty { text-align: center; padding: 34px 12px; color: var(--ink-3); }
.tbl td.low { box-shadow: inset 3px 0 0 var(--red); }

/* ---- forms and modals ----------------------------------------------------- */
.overlay { position: fixed; inset: 0; background: rgba(50, 30, 30, 0.42); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fade 160ms var(--ease); }
.modal { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 560px; border-top: 3px solid var(--gold); animation: rise 220ms var(--ease); }
.modal.modal-wide { max-width: 880px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 12px; }
.modal-head h2 { font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; flex: 1; }
.modal-close { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-3); padding: 2px 6px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 6px 22px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; grid-column: span 2; }
.field.field-half { grid-column: span 1; }
.field > label { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.field input, .field select, .field textarea { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 9px 10px; background: var(--paper); width: 100%; font-size: 14px; }
.field textarea { min-height: 70px; resize: vertical; }
.field input[type=checkbox] { width: auto; margin-right: 8px; }
.field .check { display: flex; align-items: center; font-size: 13.5px; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.field.field-error input, .field.field-error select, .field.field-error textarea { border-color: var(--red); }
.form-error { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }
.lines { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--cream); display: flex; flex-direction: column; gap: 8px; }
.lines .line { display: grid; grid-template-columns: minmax(0, 1fr) 110px 32px; gap: 8px; }
.lines .line button { border: 1px solid var(--line-strong); background: var(--paper); border-radius: var(--radius); cursor: pointer; color: var(--ink-3); }
.lines .line button:hover { color: var(--red); border-color: var(--red); }

.detail { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13.5px; margin-bottom: 14px; }
.detail dt { color: var(--ink-3); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; padding-top: 3px; }
.detail dd { margin: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

/* ---- sign-in -------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--cream); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--paper); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 34px 30px 28px; box-shadow: var(--shadow); text-align: center; }
.login-card img { width: 120px; height: auto; }
.login-card h1 { font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold-deep); margin: 14px 0 22px; font-weight: 600; }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-card .btn { width: 100%; padding: 12px; margin-top: 6px; }
.login-card .lang { margin-top: 16px; }

/* ---- document viewer ------------------------------------------------------ */
.viewer { position: fixed; inset: 0; z-index: 200; background: rgba(31, 18, 18, 0.9); display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--ink); color: #fff; }
.viewer-bar .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.viewer-bar .btn { border-color: rgba(255, 255, 255, 0.5); background: transparent; color: #fff; }
.viewer-bar .btn:hover { background: #fff; color: var(--ink); }
.viewer-body { flex: 1; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-body img, .viewer-body canvas { max-width: 100%; height: auto; background: #fff; margin-top: 10px; }

/* ---- toasts --------------------------------------------------------------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--radius); font-size: 13px; box-shadow: var(--shadow); border-left: 3px solid var(--gold); max-width: 360px; animation: rise 220ms var(--ease); }
.toast.toast-error { border-left-color: #FF8A80; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- phone ---------------------------------------------------------------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; left: 0; top: 0; width: 264px; transform: translateX(-100%); transition: transform 240ms var(--ease); box-shadow: var(--shadow); }
  .shell.nav-open .side { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(50, 30, 30, 0.4); z-index: 50; }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .mini-logo { display: block; }
  .page { padding: 18px 16px 56px; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .field.field-half { grid-column: span 2; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .value { font-size: 19px; }
  .grid-2 { grid-template-columns: 1fr; }
  .overlay { padding: 0; align-items: flex-end; }
  .modal, .modal.modal-wide { max-width: none; border-radius: 10px 10px 0 0; max-height: 94vh; overflow-y: auto; }
}
@media print {
  .side, .topbar, .page-head .actions, .table-tools, #toasts { display: none !important; }
  .shell { display: block; }
}

/* ---- phone refinements ---------------------------------------------------- */
@media (max-width: 900px) {
  /* Wide tables scroll sideways; the first column stays put so rows stay readable. */
  .tbl th:first-child, .tbl td:first-child { position: sticky; left: 0; z-index: 1; background: var(--paper); box-shadow: 1px 0 0 var(--line); }
  .tbl th:first-child, .tbl tr.totals-row td:first-child { background: var(--cream); }
  .tbl th, .tbl td { padding: 9px 10px; }
  .btn { padding: 11px 14px; }
  .btn.btn-small { padding: 7px 10px; }
  .field input, .field select, .field textarea, .select-plain { font-size: 16px; } /* stops iOS zooming on focus */
  .notice { gap: 8px; }
  .detail { grid-template-columns: 1fr; gap: 2px 0; }
  .detail dd { margin-bottom: 8px; }
  .toolbar .field { min-width: 0; flex: 1 1 140px; }
  #toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .toast { max-width: none; }
}
/* On iPhone, position: sticky can silently fail, so the top bar is fixed there. */
@media (hover: none) and (pointer: coarse) {
  .topbar { position: fixed; top: 0; left: 0; right: 0; padding-top: calc(env(safe-area-inset-top, 0px) + 10px); }
  .page { padding-top: calc(env(safe-area-inset-top, 0px) + 76px); }
  .side { padding-top: env(safe-area-inset-top, 0px); }
}
.notice .btn-row { margin: 0; align-items: center; }

/* ---- side drawers --------------------------------------------------------- */
.drawer-wrap { position: fixed; inset: 0; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(50, 30, 30, 0.28); animation: fade 160ms var(--ease); }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(600px, 100vw); background: var(--paper); border-left: 3px solid var(--gold); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide-in 260ms var(--ease); }
.drawer.drawer-wide { width: min(820px, 100vw); }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px 14px; border-bottom: 1px solid var(--line); background: var(--cream); }
.drawer-titles { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 18px; font-weight: 500; letter-spacing: 0.02em; }
.drawer-sub { margin-top: 4px; font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 24px 28px; -webkit-overflow-scrolling: touch; }
.drawer-body .section-title:first-child { margin-top: 4px; }
.drawer-body .kpis { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 8px; }
.drawer-body .kpi { padding: 12px 14px; }
.drawer-body .kpi .value { font-size: 18px; }
.drawer .modal-foot { padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px)); }
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink); text-align: left; text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link:hover { color: var(--gold-deep); }
.link:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 900px) {
  /* On a phone the drawer becomes a sheet that rises from the bottom. */
  .drawer, .drawer.drawer-wide { top: auto; left: 0; width: 100%; max-height: 92vh; border-left: 0; border-top: 3px solid var(--gold); border-radius: 12px 12px 0 0; animation-name: slide-up; }
  .drawer-head { padding: 16px 16px 12px; border-radius: 12px 12px 0 0; }
  .drawer-body { padding: 14px 16px 24px; }
}

/* ---- attachments ---------------------------------------------------------- */
.drop-zone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 16px; text-align: center; background: var(--cream); cursor: pointer; font-size: 13px; transition: border-color 160ms var(--ease), background 160ms var(--ease); }
.drop-zone:hover, .drop-zone.drop-over { border-color: var(--gold); background: var(--gold-soft); }
.drop-zone:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.drop-zone.drop-busy { opacity: 0.55; pointer-events: none; }
.drop-list, .attach-list { display: flex; flex-direction: column; margin-top: 8px; }
.drop-file, .attach-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.drop-file:last-child, .attach-row:last-child { border-bottom: 0; }
.drop-file .name, .attach-row .link { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-row .muted { font-size: 11.5px; white-space: nowrap; }
.lines .line.line-priced { grid-template-columns: minmax(0, 1fr) 84px 104px 32px; }

/* ---- charts --------------------------------------------------------------- */
.bars { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr max-content; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row.bar-click { cursor: pointer; }
.bar-row.bar-click:hover .bar-label { color: var(--gold-deep); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--cream-2); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--ink); border-radius: 2px; }
.bar-fill.bar-neg { background: var(--red); }
.bar-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cols-wrap { overflow-x: auto; margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px 8px; background: var(--paper); }
.cols { display: flex; gap: 6px; align-items: flex-start; min-width: max-content; }
.col { flex: 1 0 46px; display: flex; flex-direction: column; align-items: center; min-width: 46px; }
.col-plot { position: relative; width: 100%; }
.col-bar { position: absolute; left: 18%; right: 18%; background: var(--ink); border-radius: 2px 2px 0 0; }
.col-bar.col-neg { background: var(--red); border-radius: 0 0 2px 2px; }
.col-zero { position: absolute; left: 0; right: 0; height: 1px; background: var(--line-strong); }
.col-value { font-size: 10.5px; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }

/* ---- acting-as banner ----------------------------------------------------- */
.acting { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 32px; background: var(--ink); color: #fff; font-size: 13px; border-bottom: 2px solid var(--gold); }
.acting .btn { border-color: rgba(255, 255, 255, 0.6); background: transparent; color: #fff; }
.acting .btn:hover { background: #fff; color: var(--ink); }
@media (max-width: 900px) {
  .acting { padding: 8px 16px; }
  .lines .line.line-priced { grid-template-columns: minmax(0, 1fr) 64px 84px 32px; }
  .bar-row { grid-template-columns: minmax(80px, 38%) 1fr max-content; }
}

.lines .line.line-lot { grid-template-columns: minmax(0, 1fr) 84px 110px 32px; }
.lines .line.line-priced.line-lot { grid-template-columns: minmax(0, 1fr) 72px 92px 104px 32px; }
@media (max-width: 900px) {
  .lines .line.line-priced.line-lot { grid-template-columns: 1fr 1fr 1fr 32px; }
  .lines .line.line-priced.line-lot select { grid-column: 1 / -1; }
}
.col { max-width: 96px; }
.cols { justify-content: center; }

/* ---- a livelier palette ---------------------------------------------------
   Same brand (the logo's gold, deep brown, cream) with more saturation and
   contrast: a dark sidebar that lets the gold logo glow, gold calls to action,
   and clearer status colours. Everything is driven by the tokens below. */
:root {
  --ink: #2A1414;
  --ink-2: #5A4442;
  --ink-3: #8C7673;
  --cream: #FBF3E6;
  --cream-2: #F5E6CF;
  --line: #ECE2D6;
  --line-strong: #D8C7B4;
  --gold: #E2B01E;
  --gold-deep: #A87400;
  --gold-soft: rgba(226, 176, 30, 0.18);
  --wine: #7A1F3D;
  --red: #D22B2B;
  --red-soft: #FDE4E1;
  --green: #12824E;
  --green-soft: #DDF3E6;
  --amber: #B86A00;
  --amber-soft: #FFEBC7;
  --blue: #1D56B8;
  --blue-soft: #DFEAFB;
  --shadow: 0 14px 40px -18px rgba(42, 20, 20, 0.45);
}
body { background: #FFFDF9; }

/* Sidebar: dark, with the gold logo and gold active marker. */
.side { background: linear-gradient(180deg, #2A1414 0%, #3A1A22 100%); border-right: 0; color: #F3E7D3; }
.side .brand { border-bottom-color: rgba(226, 176, 30, 0.28); }
.side .brand .tag { color: var(--gold); }
.nav .group { color: rgba(243, 231, 211, 0.5); }
.nav a { color: rgba(243, 231, 211, 0.82); border-left-width: 3px; }
.nav a:hover { background: rgba(226, 176, 30, 0.12); color: #fff; }
.nav a.active { background: rgba(226, 176, 30, 0.2); color: var(--gold); border-left-color: var(--gold); }
.side .foot { border-top-color: rgba(226, 176, 30, 0.28); }
.side .foot .who { color: #fff; }
.side .foot .role { color: var(--gold); }
.side .foot .links button { color: rgba(243, 231, 211, 0.82); }
.side .foot .links button:hover { color: var(--gold); }
.side::-webkit-scrollbar { width: 8px; }
.side::-webkit-scrollbar-thumb { background: rgba(226, 176, 30, 0.35); border-radius: 4px; }

/* Calls to action in gold; everything else stays quiet so they stand out. */
.btn.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--ink); box-shadow: 0 6px 16px -8px rgba(168, 116, 0, 0.8); }
.btn.btn-primary:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }
.btn:hover { background: var(--ink); color: #fff; }
.chip.chip-active { background: var(--wine); border-color: var(--wine); }
.chip:hover { border-color: var(--gold); }
.login { background: linear-gradient(160deg, #2A1414 0%, #4A1D2C 100%); }
.login-card { border-top-width: 4px; }
.login-card .btn { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.login-card .btn:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }

/* Headings and cards. */
.page-head::after { width: 72px; height: 3px; }
.page-head h1 { font-weight: 600; }
.section-title { color: var(--wine); }
.kpi { border-top-width: 3px; background: linear-gradient(180deg, #FFF9EC 0%, #FFFFFF 58%); box-shadow: 0 8px 22px -18px rgba(42, 20, 20, 0.55); }
.kpi .label { color: var(--gold-deep); font-weight: 600; }
.kpi .value { font-weight: 600; }
.kpis .kpi:nth-child(4n + 2) { border-top-color: var(--wine); }
.kpis .kpi:nth-child(4n + 3) { border-top-color: var(--green); }
.kpis .kpi:nth-child(4n + 4) { border-top-color: var(--blue); }
.notice { border-left-width: 4px; background: #FFF6DC; }
.notice.notice-red { background: var(--red-soft); }

/* Tables. */
.tbl th { background: var(--ink); color: #F6E9CF; border-bottom: 2px solid var(--gold); }
.tbl th .arrow { color: var(--gold); }
.tbl tbody tr:nth-child(even) td { background: #FFFBF3; }
.tbl tbody tr.row-click:hover td { background: #FFF1CC; }
.tbl tr.totals-row td { background: var(--cream-2); border-top: 2px solid var(--gold); }
.tbl td.cell-click:hover { background: #FFE9A8; }
.link { text-decoration-color: var(--gold); text-decoration-thickness: 2px; }
@media (max-width: 900px) {
  .tbl th:first-child { background: var(--ink); }
  .tbl tr.totals-row td:first-child { background: var(--cream-2); }
  .tbl tbody tr:nth-child(even) td:first-child { background: #FFFBF3; }
}

/* Badges, charts, drawers. */
.badge { background: #EFE3D3; color: var(--ink-2); }
.badge.badge-gold { background: #FFE49A; color: #6B4A00; }
.bar-track, .col-zero { background: var(--cream-2); }
.bar-fill { background: linear-gradient(90deg, var(--gold-deep) 0%, var(--gold) 100%); }
.col-bar { background: linear-gradient(180deg, var(--gold) 0%, var(--gold-deep) 100%); }
.bar-fill.bar-neg, .col-bar.col-neg { background: var(--red); }
.drawer { border-left-width: 4px; }
.drawer-head { background: linear-gradient(135deg, #2A1414 0%, #4A1D2C 100%); color: #fff; }
.drawer-head .drawer-sub { color: rgba(255, 255, 255, 0.75); }
.drawer-head .modal-close { color: rgba(255, 255, 255, 0.75); }
.drawer-head .modal-close:hover { color: var(--gold); }
.drawer-head .link { color: #fff; }
.modal { border-top-width: 4px; }
.drop-zone { border-color: var(--gold); background: #FFF9EC; }
.toast { background: var(--wine); }
.acting { background: var(--wine); }
.topbar { box-shadow: 0 6px 18px -16px rgba(42, 20, 20, 0.6); }
@media (max-width: 900px) { .drawer, .drawer.drawer-wide { border-top-width: 4px; } }

/* ---- compact menu ---------------------------------------------------------
   A small logo beside the name instead of a tall one above it, tighter rows,
   and groups that fold away so the whole menu fits without scrolling. */
.side .brand { display: flex; align-items: center; gap: 12px; padding: 14px 18px; text-align: left; text-decoration: none; }
.side .brand img { width: 40px; height: 40px; margin: 0; flex: none; object-fit: contain; }
.side .brand .brand-name { color: var(--gold); font-size: 15px; letter-spacing: 0.26em; font-weight: 600; line-height: 1.1; }
.side .brand .tag { margin-top: 2px; font-size: 9.5px; letter-spacing: 0.3em; color: rgba(243, 231, 211, 0.6); }
.nav { padding: 8px 0; }
.nav a { padding: 7px 18px; font-size: 11.5px; letter-spacing: 0.1em; }
.nav > a { padding-left: 18px; }
.nav .nav-items a { padding-left: 30px; }
.nav button.group { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0; border-left: 3px solid transparent; cursor: pointer; padding: 9px 18px; margin-top: 2px; font: inherit; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; font-weight: 600; color: rgba(243, 231, 211, 0.7); text-align: left; }
.nav button.group:hover { color: #fff; background: rgba(226, 176, 30, 0.08); }
.nav button.group:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.nav .caret { font-size: 15px; line-height: 1; transition: transform 200ms var(--ease); color: var(--gold); }
.nav .nav-section.open .caret { transform: rotate(90deg); }
.nav .nav-items { display: none; padding-bottom: 4px; }
.nav .nav-section.open .nav-items { display: block; }
.nav .nav-section.open > button.group { color: var(--gold); }
/* A closed group still shows which one holds the current screen. */
.nav .nav-section:not(.open):has(a.active) > button.group { border-left-color: var(--gold); color: var(--gold); }
.side .foot { padding: 10px 18px 12px; }
.side .foot .links { margin-top: 5px; }

/* Rows of filter chips scroll sideways on a phone instead of stacking into many lines. */
@media (max-width: 900px) {
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}

/* ---- drawer motion --------------------------------------------------------
   Opens by sliding in from the right edge and closes by sliding back out to
   the right. On a phone, where it is a bottom sheet, it rises and drops instead. */
.drawer { animation: drawer-in 280ms var(--ease) both; }
.drawer-wrap.drawer-closing { pointer-events: none; }
.drawer-wrap.drawer-closing .drawer { animation: drawer-out 240ms cubic-bezier(0.4, 0, 1, 1) both; }
.drawer-wrap.drawer-closing .drawer-scrim { animation: fade-out 240ms linear both; }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes drawer-out { from { transform: translateX(0); } to { transform: translateX(100%); } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@media (max-width: 900px) {
  .drawer, .drawer.drawer-wide { animation-name: sheet-in; }
  .drawer-wrap.drawer-closing .drawer { animation-name: sheet-out; }
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheet-out { from { transform: translateY(0); } to { transform: translateY(100%); } }

/* ---- type-to-search drop-downs -------------------------------------------- */
.combo { position: relative; min-width: 0; width: 100%; }
.combo-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.combo .combo-input { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 9px 30px 9px 10px; background: var(--paper); font-size: 14px; text-overflow: ellipsis; }
.combo .combo-input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.combo .combo-input:disabled { background: var(--cream); color: var(--ink-3); }
.combo-caret { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-3); font-size: 12px; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; max-height: 280px; overflow-y: auto; background: var(--paper); border: 1px solid var(--line-strong); border-top: 2px solid var(--gold); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 240px; -webkit-overflow-scrolling: touch; }
.combo-group { padding: 8px 10px 4px; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 600; color: var(--wine); background: var(--cream); position: sticky; top: 0; }
.combo-option { padding: 8px 12px; font-size: 13.5px; cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink); }
.combo-option.combo-active { background: #FFE9A8; }
.combo-option.combo-selected { font-weight: 600; box-shadow: inset 3px 0 0 var(--gold); }
.combo-empty { padding: 12px; font-size: 13px; color: var(--ink-3); }
.field.field-error .combo-input { border-color: var(--red); }
.toolbar .combo { min-width: 180px; }
@media (max-width: 900px) {
  .combo .combo-input { font-size: 16px; }
  .combo-list { max-height: 46vh; }
}

/* ---- installed app (home-screen) ------------------------------------------
   With the translucent iPhone status bar the page draws under the clock, so the
   top bar and the menu keep clear of it. */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(env(safe-area-inset-top, 0px) + 10px); }
  .side { padding-top: env(safe-area-inset-top, 0px); }
  .login { padding-top: calc(env(safe-area-inset-top, 0px) + 20px); }
  body { overscroll-behavior-y: none; }
}
