/* Finance Portal design system — Navico-style design language.
   Flat & angular (no rounded corners), ink #031b20 + teal #61eddc,
   Teko condensed uppercase headings, Montserrat UI, Lato body.
   All fonts self-hosted (strict CSP, no CDNs). */

/* ---- Fonts ---------------------------------------------------------------- */
@font-face {
    font-family: 'Teko';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/assets/fonts/teko-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 100 900;             /* variable font */
    font-display: swap;
    src: url('/assets/fonts/montserrat.woff2') format('woff2');
}
@font-face {
    font-family: 'Lato';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/lato-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Lato';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/assets/fonts/lato-700.woff2') format('woff2');
}

:root {
    --ink: #031b20;                  /* primary text / dark surfaces */
    --ink-offset: #38494d;           /* raised elements on dark */
    --teal: #61eddc;                 /* highlight / hover / accents */
    --teal-dim: #4a6867;             /* link hover, secondary accents */
    --bg: #ffffff;
    --panel: #f2f2f2;                /* flat gray panels */
    --border: #6a7679;
    --border-soft: #d7dcdd;
    --muted: #5c6a6d;
    --danger: #eb1212;
    --danger-soft: #fdecec;
    --success: #0a7d43;
    --success-soft: #e9f7ef;
    --warning-soft: #fff8e5;
    --font-heading: 'Teko', 'Arial Narrow', 'Segoe UI', sans-serif;
    --font-ui: 'Montserrat', 'Segoe UI', sans-serif;
    --font-body: 'Lato', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
}

h1, h2, h3 {
    font-family: var(--font-heading);
    font-weight: 500;
    text-transform: uppercase;
    line-height: .95;
    letter-spacing: .01em;
    margin: 0 0 .5rem;
}
p { margin: 0 0 1rem; }
a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--teal-dim); }
code { font-size: .85em; background: var(--panel); padding: .1em .4em; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); font-style: italic; }

/* ---- App shell --------------------------------------------------------- */
body.app { display: flex; min-height: 100vh; }

.sidebar {
    display: flex;
    flex-direction: column;
    width: 264px;
    flex-shrink: 0;
    background: var(--ink);
    color: #fff;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    /* Above in-page sticky bars (brand navigator z 50), below modals (100):
     * the flyout submenus live inside the sidebar's stacking context. */
    z-index: 60;
}

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 22px; }
.sidebar-menu { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.brand-mark {
    width: 28px; height: 28px; flex-shrink: 0;
    background: var(--teal);
    clip-path: polygon(0 0, 100% 0, 100% 70%, 70% 100%, 0 100%); /* angular cut corner */
}
.brand-mark-lg { width: 44px; height: 44px; }
.brand-name {
    font-family: var(--font-heading);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 1.5rem;
    line-height: 1;
    color: #fff;
    letter-spacing: .03em;
}

/* Hamburger — hidden on desktop, shown on mobile. */
.nav-toggle {
    display: none;
    margin-left: auto;
    background: none;
    border: 0;
    padding: 6px;
    color: #fff;
    cursor: pointer;
}
.nav-toggle:hover { background: var(--ink-offset); }
.nav-toggle svg { width: 24px; height: 24px; display: block; }
.nav-toggle .nav-toggle-close { display: none; }
.sidebar.is-open .nav-toggle .nav-toggle-open { display: none; }
.sidebar.is-open .nav-toggle .nav-toggle-close { display: block; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.nav-section {
    margin: 20px 10px 8px;
    font-family: var(--font-ui);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--border);
}
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px;
    font-family: var(--font-ui);
    font-size: .82rem;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #dbe4e4;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.nav-link svg { width: 18px; height: 18px; opacity: .85; }
.nav-link:hover { background: var(--ink-offset); color: #fff; }
.nav-link.is-active { background: var(--ink-offset); color: var(--teal); border-left-color: var(--teal); }

.sidebar-footer { border-top: 1px solid var(--ink-offset); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.avatar {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    background: var(--teal);
    color: var(--ink);
    font-family: var(--font-ui);
    font-weight: 600; font-size: .9rem; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: #fff; font-family: var(--font-ui); font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { color: var(--border); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; padding: 34px 42px 56px; }
.topbar { margin-bottom: 22px; border-bottom: 3px solid var(--ink); padding-bottom: 10px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.page-title { font-size: 2.4rem; margin: 0; }
.content { display: flex; flex-direction: column; gap: 22px; }

/* ---- Cards, grids ------------------------------------------------------- */
.card {
    background: var(--panel);
    padding: 26px 28px;
    margin-bottom: 22px;
}
.content > .card { margin-bottom: 0; }
.card-title { font-size: 1.6rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head .card-title { margin: 0; }
.card-narrow { max-width: 480px; }
.card-accent { border-left: 4px solid var(--teal); }
.stat { display: flex; flex-direction: column; gap: 0; margin-bottom: 0; }
.stat-label {
    font-family: var(--font-ui);
    font-size: .72rem; font-weight: 600;
    letter-spacing: .12em; text-transform: uppercase;
    color: var(--muted);
}
.stat-value { font-family: var(--font-heading); font-weight: 500; font-size: 3.2rem; line-height: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---- Forms -------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
    font-family: var(--font-ui);
    font-weight: 600; font-size: .78rem;
    letter-spacing: .08em; text-transform: uppercase;
}
.field-label small { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="search"], select {
    font: inherit;
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--ink);
    width: 100%;
    height: 46px;                    /* identical for inputs and selects */
    border-radius: 0;
}
textarea {
    font: inherit;
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--ink);
    width: 100%;
    border-radius: 0;
    resize: vertical;
}
textarea.code-input { font-family: Consolas, 'Courier New', monospace; font-size: .88rem; line-height: 1.5; }
input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 1.5px var(--teal);
}
fieldset.field { border: 0; padding: 0; margin: 0; }
.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.form-error { color: var(--danger); font-size: .88rem; margin: 0; }
.notice { background: var(--warning-soft); border-left: 4px solid #e5b800; padding: 10px 14px; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
    font-family: var(--font-ui);
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.2;                /* identical height for <a> and <button> */
    padding: 12px 22px;
    border-radius: 0;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.btn-icon { width: 18px; height: 18px; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: .72rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; display: inline-flex; }

.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: var(--teal); border-color: var(--teal); color: var(--ink); }
.btn-outline { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn-outline:hover { background: var(--teal); border-color: var(--teal); color: var(--ink); }
.btn-ghost { background: transparent; color: inherit; border-color: transparent; }
.btn-ghost:hover { background: var(--panel); color: var(--ink); }
.sidebar .btn-ghost { color: #dbe4e4; border-color: var(--ink-offset); }
.sidebar .btn-ghost:hover { background: var(--teal); border-color: var(--teal); color: var(--ink); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ---- Tables, lists, badges ---------------------------------------------- */
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table-scroll { overflow-x: auto; }
.table-scroll .table td, .table-scroll .table th { white-space: nowrap; }
.link-form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-top: 14px; }
.link-form-row .field { flex: 1 1 170px; min-width: 0; }
.link-form-row .btn { flex: 0 0 auto; }

/* ---- Customer outlook page ---------------------------------------------- */
.is-hidden { display: none; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.eyebrow {
    font-family: var(--font-ui);
    font-size: .68rem; font-weight: 600;
    letter-spacing: .14em; text-transform: uppercase;
    color: var(--teal-dim);
}
.fc-customer-name { font-size: 1.9rem; line-height: 1; }
.search-field { min-width: 240px; }
.search-form { display: flex; gap: 10px; align-items: flex-end; }
.fc-table td.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

.kv-panel { background: var(--panel); padding: 12px 16px; margin: 12px 0; max-width: 560px; }
.kv-panel.kv-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 0 40px; max-width: 960px; align-items: start;
}
.kv-grid .kv-row .kv-label { flex-basis: 200px; }
@media (max-width: 1000px) { .kv-panel.kv-grid { grid-template-columns: 1fr; } }
input.kv-input {
    flex: 1; padding: 6px 10px;
    border: 1px solid var(--border-soft); border-radius: 0;
    font: inherit; font-size: .9rem; background: #fff;
}
.kv-actions { align-items: center; gap: 10px; }
select.chip-select {
    width: auto; padding: 6px 10px;
    border: 0; border-left: 3px solid var(--teal); border-radius: 0;
    background: #fff; font: inherit; font-weight: 700; font-size: .9rem;
}
.chip-form { background: var(--panel); }
.kv-row { display: flex; gap: 14px; padding: 4px 0; }
.kv-label {
    flex: 0 0 220px;
    font-family: var(--font-ui);
    font-size: .72rem; font-weight: 600;
    letter-spacing: .1em; text-transform: uppercase;
    color: var(--teal-dim);
    align-self: center;
}

.chip-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.chip { display: inline-flex; align-items: stretch; min-height: 48px; border: 1.5px solid var(--border-soft); }
.chip-label {
    font-family: var(--font-ui);
    font-size: .68rem; font-weight: 600;
    letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted);
    padding: 6px 10px;
    align-self: center;
}
.chip-value {
    display: inline-flex; align-items: center;   /* centered next to the taller select chips */
    background: var(--panel);
    border-left: 3px solid var(--teal);
    padding: 6px 12px;
    font-weight: 700; font-size: .9rem;
}

.fc-block { padding-top: 0; }
.fc-table td.num, .fc-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.fc-table th.fc-brand {
    font-family: var(--font-heading);
    font-size: 1.25rem; letter-spacing: .02em;
    text-transform: uppercase;
}
/* table.fc-* selectors outrank the generic .table rules regardless of order. */
table.fc-table {
    table-layout: fixed;            /* every month column the same width */
    width: 100%;
    min-width: 1430px;              /* room for 7-digit amounts; below this the card scrolls */
}
table.fc-table th:first-child { width: 230px; }
table.fc-table th.fc-year-col { width: 110px; }
table.fc-table td { padding: 6px 10px; }
table.fc-table th { padding: 10px; }
.fc-table .fc-row-label { font-weight: 700; white-space: nowrap; }
.fc-table .fc-year-col { background: var(--panel); }
.fc-table th.fc-year-col { background: var(--ink-offset); }
.fc-table .neg { color: var(--danger); font-style: italic; }
.fc-note { margin: 10px 0 0; }
.fc-baseline td { background: #d9f9f3; }               /* light teal — the baseline row */
.fc-baserow td { background: #eef4f4; }                /* pale — the budget base outlook row */
.fc-table .fc-baserow td:first-child { background: #eef4f4; }
.fc-baseline td.fc-year-col { background: #c4f2ea; }
.fc-current td { background: var(--teal); font-weight: 700; }
.fc-current td.fc-year-col { background: #4cd9c7; }
.fc-var td { font-style: italic; color: var(--muted); }
.fc-adjust td { background: var(--warning-soft); }
.fc-adjust td.fc-year-col { background: #f6ecc8; }
.fc-adjust td.fc-locked { background: #e8ebeb; }   /* closed months: no longer editable */
/* Flat click-to-edit cells: inputs look like plain (yellow) cells until you
 * interact with them. input.* selectors outrank the global width:100% rule. */
input.fc-input {
    width: 100%; min-width: 56px; height: auto; padding: 4px 5px;
    border: 1px solid transparent; border-radius: 0;
    font: inherit; font-size: .95rem; line-height: 1.35;   /* after font: inherit — the shorthand resets it */
    text-align: right;
    background: transparent;
}
input.fc-input:hover { border-color: var(--border-soft); background: #fff; }
input.fc-input:focus-visible { outline: none; background: #fff; border-color: var(--ink); box-shadow: 0 0 0 1.5px var(--teal); }
input.fc-input.fc-saved, input.fc-label-input.fc-saved { border-color: var(--success); box-shadow: 0 0 0 1.5px var(--success); }
input.fc-input.fc-save-error, input.fc-label-input.fc-save-error { border-color: var(--danger); box-shadow: 0 0 0 1.5px var(--danger); }

input.fc-label-input {
    flex: 1; min-width: 120px; height: auto; padding: 0 4px;
    border: 1px solid transparent; border-radius: 0;
    font: inherit; font-size: .95rem; line-height: 1.35; font-style: italic;
    background: transparent;
}
input.fc-label-input:hover { border-color: var(--border-soft); background: #fff; }
input.fc-label-input:focus-visible { outline: none; background: #fff; border-color: var(--ink); box-shadow: 0 0 0 1.5px var(--teal); }
.fc-line-flex { display: flex; align-items: center; gap: 4px; }

.fc-line-label { min-width: 200px; }
.fc-line-actions { margin-left: 6px; white-space: nowrap; }
.btn-xs { padding: 3px 8px; font-size: .68rem; }
.fc-add-row td { background: #fff; padding: 8px 10px; }
.fc-add-group {
    display: inline-flex; align-items: center;
    border: 1px dashed var(--border);
    background: #fff;
}
input.fc-add-input {
    width: 240px; height: auto; padding: 6px 10px;
    border: 0; border-radius: 0;
    font: inherit; font-size: .85rem; font-style: italic;
    background: transparent;
}
input.fc-add-input:focus-visible { outline: none; box-shadow: inset 0 -2px 0 var(--teal); }
.fc-add-btn {
    border: 0; border-left: 1px dashed var(--border);
    background: none; padding: 6px 12px;
    font-family: var(--font-ui); font-size: .72rem; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase;
    cursor: pointer; color: var(--muted);
}
.fc-add-btn:hover { background: var(--teal); color: var(--ink); }
.fc-add-pill { border: 1px dashed var(--border); background: #fff; }
/* A line without a name yet: the required field shows it needs completing. */
input.fc-label-input:invalid { border-color: var(--danger); background: #fff; }

/* Toasts — bottom right, same flat language as the flashes. */
.toast-stack {
    position: fixed; right: 22px; bottom: 22px; z-index: 200;
    display: flex; flex-direction: column; gap: 10px;
    max-width: 380px;
}
.toast {
    display: flex; align-items: flex-start; gap: 12px;
    background: var(--ink); color: #fff;
    border-left: 4px solid var(--teal);
    padding: 14px 16px;
    font-size: .92rem;
    box-shadow: none;
    transition: opacity .4s, transform .4s;
}
.toast .flash-close { background: none; border: 0; color: #fff; cursor: pointer; font-size: 1rem; line-height: 1; }
.toast-error { border-left-color: var(--danger); }
.toast-out { opacity: 0; transform: translateY(8px); }

/* Customer list: filters + clickable rows. */
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filter-bar .field { flex: 1 1 170px; min-width: 0; }
.filter-bar .btn { flex: 0 0 auto; }
.row-links tbody tr { cursor: pointer; }
.row-links tbody tr:hover td { background: var(--warning-soft); }
.fc-customer-name .badge { vertical-align: middle; margin-left: 8px; }
.auth-alt { text-align: center; margin-top: 16px; font-size: .9rem; }

/* Keep the row labels and Year column visible while scrolling horizontally. */
.fc-table th:first-child, .fc-table td:first-child { position: sticky; left: 0; z-index: 2; background: #fff; }
.fc-table th:last-child, .fc-table td:last-child { position: sticky; right: 0; z-index: 2; }
.fc-table thead th:first-child { background: var(--ink); }   /* brand header must stay dark */
.fc-table .fc-baseline td:first-child { background: #d9f9f3; }
.fc-table .fc-current td:first-child { background: var(--teal); }
.fc-table .fc-adjust td:first-child { background: var(--warning-soft); }
.fc-table .fc-var td:first-child, .fc-table .fc-add-row td:first-child { background: #fff; }

/* Currency shown small under the month name, inside the same header cell. */
.fc-th-cur {
    display: block;
    font-weight: 400; font-size: .58rem;
    letter-spacing: .1em;
    color: #8fa3a3;
    margin-top: 1px;
}
.fc-collapse {
    background: none; border: 0; padding: 0 8px 0 0;
    color: var(--teal); cursor: pointer;
    font-size: .8rem; line-height: 1;
    vertical-align: middle;
}
.fc-block.is-collapsed tbody { display: none; }
.fc-brand-logo {
    height: 22px; max-width: 130px; object-fit: contain;
    vertical-align: middle;   /* transparent PNGs sit directly on the dark header */
}
/* Preview on the ink background — matching the brand header where logos
 * actually appear, so white/transparent logo artwork is visible here too. */
.brand-logo-preview { height: 32px; max-width: 160px; object-fit: contain; background: var(--ink); padding: 4px 10px; }
.logo-form { display: flex; gap: 8px; align-items: center; }
.npi-scroll { max-height: 480px; overflow-y: auto; margin-top: 14px; }
.npi-scroll thead th { position: sticky; top: 0; z-index: 3; }
.logo-form input[type="file"] { font-size: .8rem; max-width: 240px; }

/* Amount inputs fill their cell — no dead space around the numbers. */
.fc-table td.fc-cell-input { padding: 3px 4px; }
.am-form .kv-row { align-items: center; }
.am-form select { flex: 1; max-width: 320px; width: auto; padding: 7px 10px; }
.am-form input.kv-input { flex: 1; max-width: 320px; min-width: 200px; }
.am-form .kv-actions { gap: 10px; }

.option-title {
    font-family: var(--font-ui);
    font-size: .78rem; font-weight: 600;
    letter-spacing: .1em; text-transform: uppercase;
    margin: 18px 0 8px;
}
.steps { margin: 0 0 12px; padding-left: 20px; }
.steps li { margin: 4px 0; }
.token-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; max-width: 760px; }
.token-form .field { flex: 1; }
.token-form .btn { flex: 0 0 auto; }
/* Sync progress modal (flat, angular — no radius, like everything else). */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(3, 27, 32, .55);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
/* Must beat .modal-backdrop's display:flex regardless of rule order. */
.modal-backdrop.is-hidden { display: none; }
.modal { background: #fff; padding: 22px 24px; width: 100%; max-width: 560px; border-top: 4px solid var(--teal); }
.modal .table { margin: 10px 0; }
.sync-status { text-align: right; white-space: nowrap; }
.sync-status.sync-err { white-space: normal; }
.sync-ok { color: var(--success); font-weight: 700; }
.sync-err { color: var(--danger); font-size: .85rem; }
.spinner {
    display: inline-block; width: 12px; height: 12px;
    background: var(--teal);
    animation: spin .9s steps(8) infinite;
    vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Outlook versions admin */
.add-year-form { display: flex; gap: 10px; align-items: center; }
.add-year-form input { width: 110px; }
.year-tabs { margin-bottom: 14px; }
.form-actions { margin-top: 14px; }
.row-current td { background: var(--success-soft); }
.table input[type="date"] { max-width: 190px; padding: 7px 10px; }

.device-login { background: var(--panel); border-left: 4px solid var(--teal); padding: 14px 18px; margin-top: 14px; }
.device-code {
    font-family: var(--font-heading);
    font-size: 2.6rem; line-height: 1;
    letter-spacing: .18em;
    margin: 6px 0;
    user-select: all;
}
.table th {
    text-align: left;
    font-family: var(--font-ui);
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #fff;
    background: var(--ink);
    padding: 10px 12px;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; font-size: .95rem; }
.table tr:last-child td { border-bottom: 0; }
.row-muted td { opacity: .55; }

.list { list-style: none; margin: 0 0 16px; padding: 0; }
.list-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-soft);
}
.list-item:last-child { border-bottom: 0; }
.list-item > div { display: flex; flex-direction: column; }

.badge {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 3px 10px;
    background: var(--ink);
    color: #fff;
    margin-right: 4px;
}
.badge-admin { background: var(--teal); color: var(--ink); }
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-off { background: #e3e7e8; color: var(--muted); }
.badge-err { background: var(--danger-soft); color: var(--danger); }

.inline-form { display: inline-block; }
.row-error-detail td { background: var(--danger-soft); }

/* ---- Flash messages ------------------------------------------------------ */
.flash {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    padding: 12px 15px;
    margin-bottom: 16px;
    border-left: 4px solid;
    overflow-wrap: anywhere;
}
.flash-success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.flash-error { background: var(--danger-soft); border-color: var(--danger); color: #a30d0d; }
.flash-close {
    background: none; border: 0; cursor: pointer;
    font-size: 1.1rem; line-height: 1; color: inherit; opacity: .6; padding: 0;
}
.flash-close:hover { opacity: 1; }

/* ---- Auth (sign-in) pages ------------------------------------------------ */
body.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--ink);
    padding: 24px;
}
.auth-wrap { width: 100%; max-width: 430px; }
.auth-brand {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    margin-bottom: 26px;
}
.auth-brand .brand-name { font-size: 2.2rem; }
.auth-card {
    background: #fff;
    border-top: 4px solid var(--teal);
    padding: 34px 36px;
}
.auth-title { font-size: 2rem; margin-bottom: 2px; }
.auth-sub { color: var(--muted); margin-bottom: 22px; }
.auth-foot {
    text-align: center;
    color: var(--border);
    font-family: var(--font-ui);
    font-size: .72rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-top: 20px;
}

.divider {
    display: flex; align-items: center; gap: 12px;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: .72rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin: 20px 0;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }

@media (max-width: 820px) {
    body.app { flex-direction: column; }

    /* Sidebar collapses to a slim top bar with a hamburger menu. */
    .sidebar {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        z-index: 60;
        padding: 10px 14px;
        box-shadow: 0 2px 12px rgba(3, 27, 32, .3);
    }
    .sidebar-brand { padding: 0 2px; }
    .nav-toggle { display: block; }
    .sidebar-menu { display: none; }
    .sidebar.is-open .sidebar-menu { display: flex; padding-top: 12px; }
    .sidebar-footer { margin-top: 14px; }

    .main { padding: 20px 14px 44px; }
    .topbar { margin-bottom: 16px; }
    .page-title { font-size: 1.9rem; }
    .content { gap: 14px; }

    /* Cards edge to edge, wide tables scroll inside their card. */
    .card { padding: 18px 16px; }
    .card { overflow-x: auto; }
    .table { min-width: 560px; }
    .auth-card { padding: 26px 20px; }
    .btn-row form { flex: 1; }
    .btn-row .btn { width: 100%; }
}

/* Admin budget growth grids: compact (not full width), right-aligned
 * region columns, % suffix behind each input. */
table.growth-table { width: auto; min-width: 0; }
table.growth-table th.num { text-align: right; }
table.growth-table td.fc-cell-input { width: 108px; }
.pct-wrap { display: inline-flex; align-items: center; gap: 2px; width: 100%; justify-content: flex-end; }
.pct-wrap input.fc-input { flex: 1; width: auto; }
.pct-wrap .pct-sign { color: #7a8484; font-size: .85rem; flex: none; }

/* Error variant of the notice block (e.g. failed Athena export). */
.notice.notice-error { border-color: var(--danger); color: var(--danger); }

/* Dashboard toggles (segmented controls) and clickable stat cards. */
.toggle-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border-soft); background: #fff; }
.seg-btn {
    padding: 8px 14px;
    font-family: var(--font-ui); font-size: .72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .1em;
    color: var(--ink); text-decoration: none;
    border-right: 1px solid var(--border-soft);
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: #f2f5f5; }
.seg-btn.is-on { background: var(--ink); color: #fff; }
a.stat-link { text-decoration: none; color: inherit; display: block; }
a.stat-link:hover { border-color: var(--ink); }
.stat-value.warn { color: var(--danger); }
.stat-value.ok { color: var(--success); }
.badge-warn { background: #f6ecc8; color: #7a5c00; border: 1px solid #e3cd7d; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #f0b4b4; }

/* Sync modal: the three phases of one query (chunks / indexes / summaries). */
.sync-steps { display: flex; flex-direction: column; gap: 3px; text-align: left; }
.sync-step { display: flex; align-items: baseline; gap: 8px; font-size: .85rem; color: var(--muted); }
.sync-step .step-icon { width: 18px; flex: none; text-align: center; }
.sync-step.step-busy { color: var(--ink); }
.sync-step.step-ok { color: var(--success); }
.sync-step.step-err { color: var(--danger); }
.sync-step.step-pending, .sync-step.step-skip { color: var(--muted); }

/* Stat cards: big value on top, label line under it, description last. */
a.stat-link { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
a.stat-link .stat-value { order: 1; line-height: 1.1; }
a.stat-link .stat-label { order: 2; }
a.stat-link .muted { order: 3; font-size: .85rem; }

/* Bridge (waterfall) charts on the dashboard. */
.bridge { display: flex; align-items: flex-end; gap: 10px; padding-top: 6px; }
.br-col { flex: 1; min-width: 0; text-decoration: none; color: inherit; text-align: center; }
.br-col:hover .br-bar { filter: brightness(1.15); }
.br-plot { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 218px; }
.br-val { font-family: var(--font-ui); font-size: .72rem; font-weight: 600; margin-bottom: 3px; white-space: nowrap; }
.br-val.neg { color: var(--danger); }
.br-bar { display: block; width: 70%; max-width: 90px; }
.br-total { background: var(--ink); }
.br-pos { background: var(--success); }
.br-neg { background: var(--danger); }
.br-zero { background: var(--border-soft); }
.br-name {
    display: block; margin-top: 8px; padding-top: 6px;
    border-top: 1px solid var(--border-soft);
    font-family: var(--font-ui); font-size: .64rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .08em; color: #5b6666;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Sticky brand navigator on customer/budget pages: the customer name stays
 * visible, every brand is one click away, plus a back-to-top button. */
html { scroll-behavior: smooth; }
.fc-navbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 14px;
    background: var(--ink); color: #fff;
    padding: 10px 16px;
    margin: 0 0 4px;
}
.fc-nav-name {
    font-family: var(--font-ui); font-size: .78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .1em;
    white-space: nowrap; flex: none;
    border-right: 1px solid rgba(255, 255, 255, .25); padding-right: 14px;
}
.fc-nav-brands {
    display: flex; gap: 6px; align-items: center;
    overflow-x: auto; scrollbar-width: thin; flex: 1; min-width: 0;
}
.fc-nav-pill {
    flex: none;
    font-family: var(--font-ui); font-size: .68rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
    color: #fff; text-decoration: none;
    border: 1px solid rgba(255, 255, 255, .35);
    padding: 4px 9px; white-space: nowrap;
}
.fc-nav-pill:hover { background: #fff; color: var(--ink); }
.fc-nav-top {
    flex: none; cursor: pointer;
    font-family: var(--font-ui); font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    color: var(--ink); background: #fff; border: 0;
    padding: 6px 11px;
}
.fc-nav-top:hover { background: var(--teal); color: #fff; }
.fc-block { scroll-margin-top: 64px; }   /* anchors land below the sticky bar */

/* Brand navigator: no visible scrollbar — arrow buttons scroll the row. */
.fc-nav-brands { scrollbar-width: none; -ms-overflow-style: none; }
.fc-nav-brands::-webkit-scrollbar { display: none; }
.fc-nav-arrow {
    flex: none; cursor: pointer;
    width: 28px; height: 28px; line-height: 1;
    font-size: 1.1rem; font-weight: 700;
    color: #fff; background: transparent;
    border: 1px solid rgba(255, 255, 255, .35);
    padding: 0;
}
.fc-nav-arrow:hover { background: #fff; color: var(--ink); }
.fc-nav-arrow.is-hidden { display: none; }

/* Site-styled hover tooltips: adjustment-cell change log and the proposed
 * budget calculation. Parent cell carries .has-tip. */
td.has-tip { position: relative; }
.fc-tip {
    display: none; position: absolute; z-index: 70;
    bottom: calc(100% + 6px); right: -2px;
    min-width: 250px; max-width: 340px;
    background: var(--ink); color: #fff;
    padding: 10px 12px;
    flex-direction: column; gap: 5px; text-align: left;
    font-family: var(--font-ui); font-size: .7rem; font-weight: 500;
    letter-spacing: .02em; line-height: 1.5;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
    pointer-events: none;
}
td.has-tip:hover > .fc-tip { display: flex; }
td.has-tip:focus-within > .fc-tip { display: none; }   /* not while typing */
.fc-tip-title {
    font-size: .6rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .14em;
    color: var(--teal);
}
.fc-tip-row { white-space: nowrap; }
.fc-row-label.has-tip .fc-tip { right: auto; left: 0; }

/* "Remember me" checkbox on the sign-in form. */
.check-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .92rem; }
.check-row input[type="checkbox"] {
    width: 18px; height: 18px; margin: 0; flex: none;
    accent-color: var(--ink);
}

/* Forecast accuracy charts: grouped bars per forecast month (M1, M2, …). */
.acc-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.acc-key { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-ui); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.acc-swatch { width: 12px; height: 12px; display: inline-block; }
.acc-chart { display: flex; gap: 14px; align-items: flex-end; }
.acc-group { flex: 1; min-width: 0; text-align: center; }
.acc-bars { display: flex; gap: 3px; align-items: flex-end; justify-content: center; height: 196px; }
.acc-bar-wrap { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; }
.acc-val { font-family: var(--font-ui); font-size: .58rem; font-weight: 600; white-space: nowrap; margin-bottom: 2px; color: var(--muted); }
.acc-bar { width: 16px; }
.acc-x { display: block; margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--border-soft); font-family: var(--font-ui); font-size: .66rem; font-weight: 700; letter-spacing: .1em; color: #5b6666; }
.acc-c0 { background: var(--ink); }
.acc-c1 { background: var(--teal); }
.acc-c2 { background: var(--teal-dim); }
.acc-c3 { background: #b7c3c4; }
.acc-c4 { background: var(--danger); }

/* Accuracy bars: zero axis with negative values hanging below it. */
.acc-bars { position: relative; }
.acc-bars::after {
    content: ''; position: absolute; left: -2px; right: -2px; bottom: 80px;
    border-bottom: 1px solid var(--border);
}
.acc-below { opacity: .5; }
.acc-val.neg { color: var(--danger); }

/* Numeric column headers align right like their values — everywhere. */
.table th.num { text-align: right; }
/* Cells where the outlook was completely wrong (deep negative accuracy). */
td.acc-bad { background: var(--danger-soft); color: var(--danger); font-weight: 700; }

/* "My accuracy": single-series bars in the brand teal. */
.acc-my { background: var(--teal); width: 34px; }

/* Collapsible Administration group: keeps the sidebar on one screen. */

button.nav-group-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: auto; background: none; border: 0; cursor: pointer;   /* flex-stretch: margins stay inside */
    text-align: left; padding: 0; padding-right: 10px;
    font: inherit;
    font-family: var(--font-ui); font-size: .68rem; font-weight: 600;
    letter-spacing: .14em; text-transform: uppercase;
    color: var(--border);
}
button.nav-group-toggle:hover { color: #fff; }
.nav-caret { display: inline-block; transition: transform .15s ease; transform: rotate(-90deg); }
.nav-group-toggle.is-open .nav-caret { transform: rotate(0deg); }
.nav-group.is-closed { display: none; }

/* Clickable user chip (bottom of the sidebar) → My profile. */
a.user-chip { text-decoration: none; }
a.user-chip:hover { background: var(--ink-offset); }
a.user-chip:hover .user-name { color: var(--teal); }

/* Accuracy trend line chart (inline SVG). */
.acc-trend { display: block; width: 100%; height: auto; max-height: 300px; }

/* Anchor target of the trend card: land just below the viewport top. */
#trend { scroll-margin-top: 16px; }

/* Settings → Notification settings: weekday and per-region time pickers. */
.check-grid { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.time-grid { display: flex; flex-wrap: wrap; gap: 12px 22px; }
.time-grid .field { min-width: 120px; }

/* Customer summary page: brand filter, per-brand table, sales chart, build-up. */
.sum-filter { align-items: flex-end; }
.sum-filter-label { display: flex; flex-direction: column; gap: 4px; }
.sum-filter select { min-width: 180px; }
.sum-table td.neg { color: var(--danger); }
.sum-table tfoot td { border-top: 2px solid var(--ink); }
.sum-build td, .sum-build th { white-space: nowrap; }
.sum-muted-row td { font-size: .85rem; }
.sum-legend { display: flex; gap: 18px; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.sum-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.sum-swatch { width: 12px; height: 12px; display: inline-block; }
.sum-swatch-prev { background: #9fb0b3; }
.sum-swatch-cur { background: var(--teal); }
.sum-chart { display: block; width: 100%; height: auto; max-height: 320px; }
.sum-chart .sum-bar-prev { fill: #9fb0b3; }
.sum-chart .sum-bar-cur { fill: var(--teal); }
.sum-chart .sum-axis { stroke: var(--border); stroke-width: 1; }
.sum-chart .sum-label { fill: var(--muted); font-size: 11px; font-family: var(--font-ui); }

/* Build-up fold-out rows and the extra chart series. */
.sum-fold { cursor: pointer; }
.sum-fold:hover td { background: #e8ecec; }
.sum-caret { display: inline-block; margin-right: 4px; color: var(--muted); transition: transform .12s ease; }
.sum-fold.is-open .sum-caret { transform: rotate(90deg); }
.sum-line-row td { font-size: .85rem; color: var(--muted); background: #eef1f1; }
.sum-line-label { padding-left: 26px; }
.sum-chart .sum-bar-fc, .sum-swatch.sum-bar-fc { fill: #4a6867; background: #4a6867; }
.sum-swatch.sum-bar-prev { background: #9fb0b3; }
.sum-swatch.sum-bar-cur { background: var(--teal); }
.sum-chart .sum-value { fill: var(--ink); font-size: 9.5px; font-family: var(--font-ui); }

/* Accuracy bias: small signed second line under each accuracy percentage.
 * + (is-under) = actuals above the outlook (sandbagged), − = outlook too high. */
.acc-bias { display: block; font-size: .72rem; font-weight: 600; line-height: 1.2; }
.acc-bias.is-under { color: var(--success); }
.acc-bias.is-over { color: var(--danger); }
p .acc-bias { display: inline; }

/* Actions → no-outlook check: the group's customer keys under the name. */
.sum-keys { display: block; font-size: .75rem; color: var(--muted); }
.sum-keys code { font-size: .95em; }

/* Feedback tickets (Admin → Feedback) and the sidebar feedback modal. */
.fb-ticket { background: #fff; margin-bottom: 16px; }
.fb-message { white-space: pre-wrap; }
.fb-response { white-space: pre-wrap; background: var(--success-soft); padding: 10px 14px; }
[data-feedback-modal] textarea { width: 100%; resize: vertical; }

/* Feedback bubble (bottom right) + popover — Family Planner style. */
.fb-fab {
    position: fixed; right: 24px; bottom: 24px; z-index: 190;
    width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--ink); color: var(--teal);
    display: grid; place-items: center;
    box-shadow: 0 4px 14px rgba(3, 27, 32, .35);
}
.fb-fab:hover { background: var(--ink-offset); }
.fb-fab svg { width: 24px; height: 24px; }
.fb-pop {
    position: fixed; right: 24px; bottom: 90px; z-index: 195;
    width: 340px; max-width: calc(100vw - 48px);
    background: #fff; border: 1px solid var(--border-soft);
    box-shadow: 0 12px 34px rgba(3, 27, 32, .25);
    padding: 18px 20px;
}
.fb-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fb-pop-head .card-title { margin: 0; }
.fb-pop-head .flash-close { color: var(--muted); background: none; border: 0; font-size: 1.3rem; cursor: pointer; line-height: 1; }
.fb-pop textarea { width: 100%; resize: vertical; }
/* Toasts stack above the bubble instead of behind it. */
.toast-stack { bottom: 90px; }

/* Flyout submenus (Administration / Super admin): a real submenu that opens
 * to the RIGHT of the item on hover, focus or tap. */
.nav-fly { position: relative; }
.nav-fly-parent { width: 100%; background: none; border: 0; border-left: 3px solid transparent; text-align: left; cursor: pointer; }
.nav-fly-parent.is-active { background: var(--ink-offset); color: var(--teal); border-left-color: var(--teal); }
.nav-fly-caret { margin-left: auto; opacity: .7; }
.nav-fly-menu {
    display: none; position: absolute; left: 100%; top: 0; z-index: 300;
    min-width: 240px;
    background: var(--ink); border: 1px solid var(--ink-offset);
    box-shadow: 10px 12px 28px rgba(0, 0, 0, .38);
    padding: 6px;
}
.nav-fly:hover .nav-fly-menu,
.nav-fly:focus-within .nav-fly-menu,
.nav-fly.is-open .nav-fly-menu { display: block; }
@media (max-width: 820px) {
    /* No hover on touch: the submenu unfolds inline below the item. */
    .nav-fly-menu { position: static; box-shadow: none; border: 0; padding: 0 0 0 18px; }
    .nav-fly:hover .nav-fly-menu, .nav-fly:focus-within .nav-fly-menu { display: none; }
    .nav-fly.is-open .nav-fly-menu { display: block; }
}

/* Outlook refine: the two per-row action forms sit side by side. */
.refine-form { display: inline-block; margin-right: 4px; }

/* Environment banner (config app.test_banner): impossible to miss. */
.env-banner {
    position: fixed; top: 0; left: 0; right: 0; z-index: 90;
    background: repeating-linear-gradient(-45deg, #eb1212, #eb1212 18px, #c00d0d 18px, #c00d0d 36px);
    color: #fff; text-align: center; padding: 8px 16px;
    font-family: var(--font-ui); font-weight: 700; font-size: .85rem;
    letter-spacing: .1em; text-transform: uppercase;
}
body.has-env-banner { padding-top: 38px; }
body.has-env-banner .sidebar { top: 38px; height: calc(100vh - 38px); }
@media (max-width: 820px) {
    body.has-env-banner .sidebar { top: 38px; height: auto; }
}
