/* =============================================================================
   iFatora interface
   =============================================================================

   One stylesheet, one set of tokens. This used to live in a <style> block in
   the layout, which meant every screen that needed something slightly different
   invented its own colour and its own spacing, and twenty screens drifted into
   twenty designs. Everything visual is defined once here and used by name.

   Two rules this file follows throughout:

   1. Logical properties only - inset-inline-start, margin-inline, padding-block.
      The interface runs right-to-left in Arabic and left-to-right in English
      off the same CSS, and a single "left" would break one of them.

   2. No colour literals outside the token block. A hard-coded #hex in a rule is
      a colour that cannot be changed, and the reason a product ends up with
      nine slightly different greys.
   ========================================================================== */

/* =============================================================================
   Cairo
   =============================================================================
   Shipped with the product, not loaded from Google. These servers sit behind
   firewalls with no outbound internet, where a webfont request simply never
   returns and the interface falls back to whatever Windows has - which for
   Arabic is usually Tahoma, and looks like a different product.

   Three files, 81 KB in total: one variable font per character range, so a
   Latin-only screen never downloads the Arabic set and vice versa.
   ========================================================================== */

@font-face {
    font-family: 'Cairo';
    font-style: normal;
    /* One variable file per subset covers 400 to 700, so three files
       carry every weight the interface uses. */
    font-weight: 400 700;
    font-display: swap;
    src: url('fonts/cairo-arabic.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
@font-face {
    font-family: 'Cairo';
    font-style: normal;
    /* One variable file per subset covers 400 to 700, so three files
       carry every weight the interface uses. */
    font-weight: 400 700;
    font-display: swap;
    src: url('fonts/cairo-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Cairo';
    font-style: normal;
    /* One variable file per subset covers 400 to 700, so three files
       carry every weight the interface uses. */
    font-weight: 400 700;
    font-display: swap;
    src: url('fonts/cairo-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* Surfaces ------------------------------------------------------------- */
    --ifr-bg: #ffffff;
    --ifr-surface: #ffffff;
    --ifr-sunken: #f8fafc;

    /* Ink: four weights, which is enough for any screen and few enough to
       stay consistent. Anything lighter than muted fails contrast on white. */
    --ifr-ink: #111827;
    --ifr-ink-2: #374151;
    --ifr-muted: #6b7280;
    --ifr-faint: #9ca3af;

    /* Lines ---------------------------------------------------------------- */
    --ifr-line: #e7ebf3;
    --ifr-line-strong: #d7dee9;

    /* Brand ---------------------------------------------------------------- */
    --ifr-accent: #4f7cff;
    --ifr-accent-ink: #3b68e8;
    --ifr-accent-soft: #eef3ff;
    --ifr-dark: #141b2d;
    --ifr-dark-2: #1e2742;

    /* Status. One green, one amber, one red, each with a tint for backgrounds.
       Used by pills, checklists, health rows and charts alike, so a colour
       means the same thing wherever it appears. */
    --ifr-good: #0ca30c;
    --ifr-good-soft: #e8f6e8;
    --ifr-warn: #fab219;
    --ifr-warn-soft: #fff6e2;
    /* Amber is a fine fill and an unreadable text colour on white. */
    --ifr-warn-ink: #8a5d00;
    --ifr-bad: #d03b3b;
    --ifr-bad-soft: #fdeaea;
    --ifr-info: #256abf;
    --ifr-info-soft: #e9f1fb;

    /* Spacing: a scale, so padding is chosen from a list rather than typed. */
    --ifr-1: 4px;
    --ifr-2: 8px;
    --ifr-3: 12px;
    --ifr-4: 16px;
    --ifr-5: 24px;
    --ifr-6: 32px;

    --ifr-radius: 12px;
    --ifr-radius-lg: 14px;
    --ifr-radius-pill: 999px;

    --ifr-shadow: 0 1px 3px rgba(20, 27, 45, .05);
    --ifr-shadow-lg: 0 6px 24px rgba(20, 27, 45, .10);

    --ifr-font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;


    /* Kept because the existing screens use them by these names. */
    --dark: var(--ifr-dark);
    --dark2: var(--ifr-dark-2);
    --accent: var(--ifr-accent);
}

/* =============================================================================
   Base
   ========================================================================== */

body {
    background: var(--ifr-bg);
    color: var(--ifr-ink-2);
    font-family: var(--ifr-font);
}

/* Inputs and buttons do not inherit the page font on their own. Without this
   the forms render in the system font while everything around them is Cairo,
   which is the single most obvious way a page looks unfinished. */
input, select, textarea, button, .form-control, .form-select, .btn {
    font-family: inherit;
}

/* Figures line up in a column when every digit is the same width. Applied to
   tables wholesale, because a money column that jitters is hard to scan. */
.num,
.table td.num,
.table th.num {
    font-variant-numeric: tabular-nums;
}

/* A figure is read left to right whatever the page: on an Arabic page a
   negative one showed its minus at the wrong end ("1,044.17-"). And text that
   came from somewhere else - an item's description, a buyer's name - is laid
   out in its own direction, so "Room (Half Board)" does not come out as
   ")Room (Half Board". The direction is taken from the text itself; a box
   that names its own (dir="ltr") already reads right and is left alone. */
.num:not([dir]),
.bidi-auto:not([dir]),
.tabulator-row .tabulator-cell:not([dir]) {
    unicode-bidi: plaintext;
}

/* ...and it stays where the page put it. Read in its own direction, a box
   also starts from its own side: every figure on an Arabic page would move to
   the left edge of its box. This takes the side from the box around it
   instead. Inside :where(), so any rule that aligns one of these still
   decides. */
:where(.num:not([dir]), .bidi-auto:not([dir]), .tabulator-row .tabulator-cell:not([dir])) {
    /* Chrome and Edge know it under the first name only. */
    text-align: -webkit-match-parent;
    text-align: match-parent;
}


/* =============================================================================
   Frame
   ========================================================================== */

.content {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* The top bar: the brand, the screens under a few menus, and the tools on
   the far side. The page under it runs the full width of the window. */
.appbar {
    background: var(--ifr-surface);
    border-bottom: 1px solid var(--ifr-line);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.appbar .navbar { padding-block: 6px; }

.appbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--ifr-ink);
    font-size: 1.05rem;
}

.appbar-logo { width: 32px; height: 32px; display: inline-block; flex-shrink: 0; }

.appbar-menu { gap: 2px; margin-inline: var(--ifr-4); }

.appbar-menu .nav-link {
    color: var(--ifr-ink-2);
    font-weight: 600;
    font-size: .92rem;
    padding: 8px 12px !important;
    border-radius: var(--ifr-radius);
    display: flex;
    align-items: center;
    gap: 6px;
}

.appbar-menu .nav-link i { color: var(--ifr-muted); font-size: 1rem; }

.appbar-menu .nav-link:hover { background: var(--ifr-sunken); color: var(--ifr-ink); }

.appbar-menu .nav-link.active {
    background: var(--ifr-accent-soft);
    color: var(--ifr-accent-ink);
}

.appbar-menu .nav-link.active i { color: var(--ifr-accent); }

.appbar .dropdown-menu {
    border: 1px solid var(--ifr-line);
    border-radius: var(--ifr-radius);
    box-shadow: var(--ifr-shadow-lg);
    padding: 6px;
    min-width: 230px;
}

.appbar .dropdown-item {
    border-radius: 8px;
    padding: 8px 12px;
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.appbar .dropdown-item i { color: var(--ifr-muted); width: 18px; text-align: center; }

.appbar .dropdown-item.active,
.appbar .dropdown-item:active { background: var(--ifr-accent-soft); color: var(--ifr-accent-ink); }

.appbar .dropdown-item.active i { color: var(--ifr-accent); }

.appbar .dropdown-header {
    font-size: .72rem;
    font-weight: 700;
    color: var(--ifr-faint);
    padding: 10px 12px 4px;
}

.appbar-tools {
    display: flex;
    align-items: center;
    gap: var(--ifr-2);
    margin-inline-start: auto;
    flex-wrap: wrap;
}

.appbar-icon { color: var(--ifr-ink-2); }

/* The property on screen. A pill in the brand colour carrying its name, so
   nobody reads one hotel's figures as the other's; amber while every
   property is listed together, since then the figures are both. */
.property-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 12px;
    border-radius: 999px;
    border: 2px solid var(--ifr-accent);
    background: var(--ifr-accent-soft);
    color: var(--ifr-accent-ink);
    font-weight: 600;
    max-width: 100%;
}
[dir=rtl] .property-switch { padding: 3px 12px 3px 4px; }
.property-switch > .bi { font-size: 1.05rem; }
.property-switch-label { font-size: .75rem; font-weight: 500; opacity: .8; margin: 0; white-space: nowrap; }
.property-switch-select,
.property-switch-name {
    border: 0;
    border-radius: 999px;
    background-color: var(--ifr-accent);
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
    padding: 4px 30px 4px 12px;
    min-width: 150px;
    max-width: 260px;
    text-overflow: ellipsis;
    cursor: pointer;
}
.property-switch-name { padding: 4px 12px; cursor: default; min-width: 0; white-space: nowrap; overflow: hidden; }
.property-switch-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}
[dir=rtl] .property-switch-select { padding: 4px 12px 4px 30px; background-position: left 10px center; }
.property-switch-select:focus { outline: 2px solid var(--ifr-accent-ink); outline-offset: 2px; }
.property-switch-select option { background: #fff; color: var(--ifr-ink, #1f2937); font-weight: 500; }
.property-switch.is-all { border-color: var(--ifr-warn); background: var(--ifr-warn-soft); color: var(--ifr-warn-ink); }
/* The bar stays one line on a laptop: the nav labels never break, and below
   a wide screen the pill drops its "Property" caption - the icon and the
   name still say which. */
@media (min-width: 1200px) {
    .appbar .navbar-nav .nav-link { white-space: nowrap; }
}
@media (min-width: 1200px) and (max-width: 1439.98px) {
    .appbar .navbar-nav .nav-link > .bi { display: none; }
    .appbar-user span { display: none; }
    .appbar-tools { gap: 6px; }
}
@media (max-width: 1599.98px) {
    .property-switch-label { display: none; }
    .property-switch-select { min-width: 120px; max-width: 190px; }
}
.property-switch.is-all .property-switch-select { background-color: var(--ifr-warn); color: var(--ifr-warn-ink); background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238a5d00' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }

.appbar-user span { max-width: 160px; display: inline-block; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

.navbar-toggler { border: 1px solid var(--ifr-line); font-size: 1.4rem; padding: 2px 10px; }

/* The page itself: the whole width of the window, with room at the sides. */
.page-body {
    flex: 1;
    padding: var(--ifr-5) clamp(16px, 2.5vw, 40px);
}

/* =============================================================================
   Page header
   =============================================================================
   Every screen opens the same way: what you are looking at, one line saying
   what it is for, and the thing you came here to do. Before this, the title was
   a small line in the top bar and screens began with a filter row or a button
   floating on its own - which reads as an unfinished page, and leaves somebody
   guessing what the screen is even for.
   ========================================================================== */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ifr-4);
    flex-wrap: wrap;
    margin-bottom: var(--ifr-4);
}

.page-head h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ifr-ink);
    margin: 0;
    line-height: 1.3;
}

.page-head .page-sub {
    color: var(--ifr-muted);
    font-size: .88rem;
    margin-top: var(--ifr-1);
    max-width: 70ch;
}

.page-head .page-actions {
    display: flex;
    gap: var(--ifr-2);
    flex-wrap: wrap;
    align-items: center;
}

/* =============================================================================
   Cards
   ========================================================================== */

.table-card,
.panel {
    background: var(--ifr-surface);
    border-radius: var(--ifr-radius-lg);
    /* On a white page a card is drawn by its edge, not by its shade. */
    border: 1px solid var(--ifr-line);
    box-shadow: var(--ifr-shadow);
}

/* A titled section. The header is part of the card rather than a heading
   floating above it, so it is obvious which content the title belongs to. */
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ifr-3);
    padding: var(--ifr-3) var(--ifr-4);
    border-bottom: 1px solid var(--ifr-line);
}

.panel-head h2,
.panel-head h6 {
    font-size: .95rem;
    font-weight: 700;
    color: var(--ifr-ink);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--ifr-2);
}

.panel-head h2 i,
.panel-head h6 i { color: var(--ifr-accent); }

.panel-head .panel-hint {
    font-size: .8rem;
    color: var(--ifr-muted);
    font-weight: 400;
}

.panel-body { padding: var(--ifr-4); }

/* A filter row. Visually quieter than the content it filters - it is a control,
   not a result. */
.toolbar {
    background: var(--ifr-sunken);
    border: 1px solid var(--ifr-line);
    border-radius: var(--ifr-radius);
    padding: var(--ifr-3) var(--ifr-4);
}

.toolbar .form-label {
    font-size: .78rem;
    color: var(--ifr-muted);
    margin-bottom: var(--ifr-1);
    font-weight: 500;
}

/* =============================================================================
   Figures
   ========================================================================== */

.kpi-card {
    border: 1px solid var(--ifr-line);
    border-radius: var(--ifr-radius-lg);
    overflow: hidden;
    box-shadow: var(--ifr-shadow);
    background: var(--ifr-surface);
    height: 100%;
}

.kpi-card .kpi-body { padding: var(--ifr-3) var(--ifr-4) var(--ifr-1); }

.kpi-card .kpi-nums {
    font-size: .8rem;
    color: var(--ifr-muted);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 10px;
}

.kpi-card .kpi-nums b {
    color: var(--ifr-ink);
    font-weight: 600;
}

.kpi-card .kpi-foot {
    padding: var(--ifr-2) var(--ifr-4);
    font-size: .8rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    justify-content: space-between;
}

/* A single number with its label, for rows of totals. */
.stat {
    padding: var(--ifr-3) var(--ifr-4);
}

.stat .stat-label {
    font-size: .78rem;
    color: var(--ifr-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat .stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--ifr-ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    margin-top: 2px;
}

.stat .stat-foot {
    font-size: .78rem;
    color: var(--ifr-muted);
    margin-top: 2px;
}

/* =============================================================================
   Status Cards (dashboard)
   ========================================================================== */

/* One card per status: the five money figures on white, and the status
   itself - name and count - on a footer in its colour. Read across a row,
   the footers are the status flow; read down a card, the figures add up. */
.status-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: var(--ifr-ink);
    background: #fff;
    border: 1px solid var(--sc, var(--ifr-accent));
    border-radius: 4px;
    overflow: hidden;
    transition: box-shadow .15s, transform .15s;
}
.status-card:hover { box-shadow: var(--ifr-shadow-lg); transform: translateY(-2px); color: var(--ifr-ink); }

.sc-rows { padding: 6px 10px 4px; flex: 1; }
.sc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--ifr-2);
    font-size: .88rem;
    padding: 9px 0;
    border-bottom: 1px solid var(--ifr-line);
}
.sc-row:last-child { border-bottom: 0; }
.sc-row > span:first-child { color: var(--ifr-ink-2); }
.sc-row .num { color: var(--ifr-ink); font-variant-numeric: tabular-nums; }
.sc-row.is-gross > span { font-weight: 700; }

.sc-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--ifr-2);
    padding: 11px 10px;
    color: #fff;
    background: linear-gradient(to left, var(--sc2, var(--sc)), var(--sc));
}
[dir="rtl"] .sc-foot { background: linear-gradient(to right, var(--sc2, var(--sc)), var(--sc)); }
.sc-name { font-weight: 700; font-size: 1.1rem; line-height: 1.2; }
.sc-name small { font-size: .78rem; font-weight: 600; opacity: .95; margin-inline-start: 2px; }
.sc-count { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Each status's colours: pending in oranges, sent in greens, refused in
   reds, received in blues. */
.status-card[data-status="pending_new"] { --sc: #f79a73; --sc2: #fbb994; }
.status-card[data-status="pending_valid"] { --sc: #ec8458; --sc2: #f3a982; }
.status-card[data-status="pending_invalid"] { --sc: #d2602f; --sc2: #e7875c; }
.status-card[data-status="submitted"] { --sc: #0cbf78; --sc2: #2fd393; }
.status-card[data-status="submitted_valid"] { --sc: #0a7446; --sc2: #139e62; }
.status-card[data-status="submitted_invalid"] { --sc: #062d1d; --sc2: #0c5537; }
.status-card[data-status="not_accepted"] { --sc: #7a1c2b; --sc2: #a63345; }
.status-card[data-status="cancelled"] { --sc: #6e6360; --sc2: #a69c98; }
.status-card[data-status="rejected"] { --sc: #c4122f; --sc2: #df4b60; }
.status-card[data-status="received"] { --sc: #6a78c8; --sc2: #98a6ea; }
.status-card[data-status="received_cancelled"] { --sc: #1c4ea6; --sc2: #3d72d2; }
.status-card[data-status="received_rejected"] { --sc: #0a2460; --sc2: #14387f; }

/* The headline figures: a large number with its label, an icon in a soft
   circle of its tone. */
.kpi-tile {
    display: flex;
    align-items: flex-start;
    gap: var(--ifr-4);
    background: var(--ifr-surface);
    border: 1px solid var(--ifr-line);
    border-radius: var(--ifr-radius-lg);
    padding: var(--ifr-5);
    text-decoration: none;
    color: var(--ifr-ink);
    transition: box-shadow .15s;
}
a.kpi-tile:hover { box-shadow: var(--ifr-shadow-lg); color: var(--ifr-ink); }
.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    background: var(--ifr-accent-soft);
    color: var(--ifr-accent);
}
.kpi-tile.tone-warning .kpi-icon { background: var(--ifr-warn-soft); color: var(--ifr-warn-ink); }
.kpi-tile.tone-danger .kpi-icon { background: var(--ifr-bad-soft); color: var(--ifr-bad); }
.kpi-tile.tone-muted .kpi-icon { background: var(--ifr-sunken); color: var(--ifr-faint); }
.kpi-label { font-size: .95rem; font-weight: 600; color: var(--ifr-muted); }
.kpi-value { font-size: 2.1rem; font-weight: 700; line-height: 1.15; margin-top: 2px; }
.kpi-sub { font-size: .85rem; color: var(--ifr-muted); margin-top: 2px; }

/* =============================================================================
   Tables
   =============================================================================
   Lighter lines and a quieter header than Bootstrap's default: on a screen
   that is mostly table, heavy rules are the loudest thing on the page and the
   numbers are what somebody came to read.
   ========================================================================== */

.table-card .table { margin-bottom: 0; }

.table-card .table > thead > tr > th {
    background: var(--ifr-sunken);
    color: var(--ifr-muted);
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--ifr-line);
    white-space: nowrap;
    padding-block: var(--ifr-3);
}

.table-card .table > tbody > tr > td {
    border-bottom: 1px solid var(--ifr-line);
    vertical-align: middle;
    padding-block: var(--ifr-3);
}

.table-card .table > tbody > tr:last-child > td { border-bottom: 0; }

.table-card .table > tbody > tr:hover > td { background: var(--ifr-sunken); }

/* The first and last cells line up with the card's own padding rather than
   sitting flush against its edge. */
.table-card .table > :not(caption) > * > *:first-child { padding-inline-start: var(--ifr-4); }
.table-card .table > :not(caption) > * > *:last-child  { padding-inline-end: var(--ifr-4); }

/* A table wider than the screen scrolls inside its card instead of pushing the
   whole page sideways. */
.table-scroll {
    overflow-x: auto;
    border-radius: var(--ifr-radius-lg);
}

/* =============================================================================
   Status
   ========================================================================== */

.status-pill {
    font-size: .75rem;
    padding: 3px 10px;
    border-radius: var(--ifr-radius-pill);
    color: #fff;
    white-space: nowrap;
    display: inline-block;
    font-weight: 600;
}

/* A quieter pill for states that are not an outcome - counts, labels, types.
   A grey chip beside a coloured one reads as "this is context, not a verdict". */
.chip {
    font-size: .75rem;
    padding: 3px 10px;
    border-radius: var(--ifr-radius-pill);
    background: var(--ifr-sunken);
    color: var(--ifr-ink-2);
    border: 1px solid var(--ifr-line);
    white-space: nowrap;
    display: inline-block;
}

.chip-good { background: var(--ifr-good-soft); color: var(--ifr-good); border-color: transparent; }
.chip-warn { background: var(--ifr-warn-soft); color: var(--ifr-warn-ink); border-color: transparent; }
.chip-bad  { background: var(--ifr-bad-soft);  color: var(--ifr-bad);   border-color: transparent; }
.chip-info { background: var(--ifr-info-soft); color: var(--ifr-info);  border-color: transparent; }

/* =============================================================================
   Empty states
   =============================================================================
   A blank table says "broken". A short explanation of why there is nothing here
   and what to do about it says "working, and waiting for you".
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: var(--ifr-6) var(--ifr-4);
    color: var(--ifr-muted);
}

.empty-state .empty-icon {
    font-size: 2rem;
    color: var(--ifr-faint);
    display: block;
    margin-bottom: var(--ifr-3);
}

.empty-state .empty-title {
    font-weight: 600;
    color: var(--ifr-ink-2);
    margin-bottom: var(--ifr-1);
}

.empty-state .empty-body {
    font-size: .87rem;
    max-width: 46ch;
    margin-inline: auto;
}

.empty-state .empty-action { margin-top: var(--ifr-4); }

/* =============================================================================
   Buttons
   ========================================================================== */

.btn-accent {
    background: var(--ifr-accent);
    color: #fff;
    border: 0;
}

.btn-accent:hover,
.btn-accent:focus {
    background: var(--ifr-accent-ink);
    color: #fff;
}

/* =============================================================================
   Forms
   =============================================================================
   The hint under a field is the difference between a form somebody fills in and
   one they guess at, so it is styled to be read rather than hidden.
   ========================================================================== */

/* A field is a label, a control and a hint, and they have to read as one
   group. Before this they sat in a single undifferentiated column at the same
   spacing, so a hint floated between the field it described and the next
   label - and the whole form ran together. */
.form-label {
    font-weight: 600;
    font-size: .84rem;
    color: var(--ifr-ink);
    margin-bottom: 5px;
    display: block;
}

/* Tight to the control it belongs under, and clearly looser to the next field. */
.form-text {
    font-size: .78rem;
    color: var(--ifr-muted);
    margin-top: 5px;
    line-height: 1.5;
}

.form-control,
.form-select {
    border-color: var(--ifr-line-strong);
    border-radius: 9px;
    padding: 9px 12px;
    color: var(--ifr-ink);
    background-color: var(--ifr-surface);
    transition: border-color .12s, box-shadow .12s;
}

.form-control::placeholder { color: var(--ifr-faint); }

.form-control:focus,
.form-select:focus {
    border-color: var(--ifr-accent);
    box-shadow: 0 0 0 3px var(--ifr-accent-soft);
}

.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    background-color: var(--ifr-sunken);
    color: var(--ifr-muted);
}

.form-control.is-invalid,
.form-select.is-invalid { border-color: var(--ifr-bad); }

.form-control-sm, .form-select-sm { padding: 6px 10px; border-radius: 7px; }

/* A form card breathes: the rows are further apart than the parts of one field,
   which is what makes each field read as a unit rather than as one long list of
   equally spaced lines. */
.panel-body .row > [class^="col"],
.panel-body .row > [class*=" col"],
.table-card .row > [class^="col"],
.table-card .row > [class*=" col"] { margin-bottom: var(--ifr-2); }

/* A titled group inside a form - "Issuer", "Address", "Signing". Without one,
   a long form is thirty fields with no shape. */
.field-group {
    border-top: 1px solid var(--ifr-line);
    margin-top: var(--ifr-5);
    padding-top: var(--ifr-4);
}

.field-group > .field-group-title {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ifr-muted);
    margin-bottom: var(--ifr-3);
}

/* Buttons: the same vertical rhythm as the inputs beside them, so a row of a
   field and a button does not sit crooked. */
.btn {
    border-radius: 9px;
    padding: 9px 16px;
    font-weight: 600;
    font-size: .9rem;
}

.btn-sm { padding: 6px 12px; font-size: .84rem; border-radius: 7px; }

.btn i { vertical-align: -1px; }

.help-icon {
    cursor: help;
    color: #a5b0c4;
    margin-inline-start: 5px;
    font-size: .82rem;
    vertical-align: middle;
}

.help-icon:hover,
.help-icon:focus { color: var(--ifr-accent); }

/* =============================================================================
   Timeline
   ========================================================================== */

.timeline {
    position: relative;
    padding-inline-start: 22px;
}

.timeline::before {
    content: '';
    position: absolute;
    inset-inline-start: 6px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: #e5e9f2;
}

.timeline .t-item {
    position: relative;
    padding-bottom: var(--ifr-4);
}

.timeline .t-item::before {
    content: '';
    position: absolute;
    inset-inline-start: -20px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ifr-accent);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--ifr-accent);
}

/* =============================================================================
   Licence banner
   ========================================================================== */

.license-banner {
    border-radius: var(--ifr-radius);
    padding: var(--ifr-3) 18px;
    display: flex;
    gap: var(--ifr-3);
    align-items: center;
    margin: var(--ifr-4) 22px 0;
    box-shadow: var(--ifr-shadow-lg);
    position: relative;
}

.license-banner.info    { background: linear-gradient(120deg, #fff7e6, #ffefc2); border: 1px solid #ffd97a; }
.license-banner.grace   { background: linear-gradient(120deg, #ffe9e9, #ffd4d4); border: 1px solid #ff9c9c; }
.license-banner.expired { background: linear-gradient(120deg, #2b2b2b, #1a1a1a); color: #fff; border: 1px solid #000; }

.license-banner .lb-icon { font-size: 1.6rem; }

.license-banner .btn-close-lb {
    position: absolute;
    inset-inline-end: var(--ifr-3);
    top: 10px;
    border: 0;
    background: transparent;
    font-size: 1.1rem;
    opacity: .6;
}

/* =============================================================================
   Data grid
   =============================================================================
   Every list is one grid (assets/js/ifatora-grid.js over Tabulator). Its own
   stylesheet draws the mechanics; this makes it look like the rest of the
   system - the same lines, the same type, the same quiet header.
   ========================================================================== */

.grid-shell {
    background: var(--ifr-surface);
    border: 1px solid var(--ifr-line);
    border-radius: var(--ifr-radius-lg);
    overflow: hidden;
}

.grid-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ifr-2) var(--ifr-3);
    padding: var(--ifr-3) var(--ifr-4);
    border-bottom: 1px solid var(--ifr-line);
}

.grid-search { position: relative; min-width: 220px; flex: 0 1 300px; }
.grid-search i {
    position: absolute;
    inset-inline-start: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ifr-faint);
    pointer-events: none;
}
.grid-search input { padding-inline-start: 32px; }

.grid-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ifr-2);
    margin-inline-start: auto;
}

.grid-columns-menu { max-height: 360px; overflow-y: auto; min-width: 220px; }
.grid-columns-menu .dropdown-item { cursor: pointer; font-size: .88rem; }

.grid-selection { padding: 6px var(--ifr-4); background: var(--ifr-sunken); border-bottom: 1px solid var(--ifr-line); }

.grid-shell .tabulator {
    border: 0;
    background: var(--ifr-surface);
    font-family: var(--ifr-font);
    font-size: .9rem;
}

.grid-shell .tabulator .tabulator-header {
    background: var(--ifr-sunken);
    border-bottom: 1px solid var(--ifr-line-strong);
    color: var(--ifr-ink-2);
    font-weight: 700;
}

.grid-shell .tabulator .tabulator-header .tabulator-col {
    background: var(--ifr-sunken);
    border-inline-end: 1px solid var(--ifr-line);
}

.grid-shell .tabulator .tabulator-header .tabulator-col .tabulator-col-content { padding: 10px 12px 6px; }

.grid-shell .tabulator .tabulator-header-filter input,
.grid-shell .tabulator .tabulator-header-filter select {
    border: 1px solid var(--ifr-line-strong);
    border-radius: 6px;
    padding: 3px 6px;
    font-size: .8rem;
    font-weight: 400;
    background: var(--ifr-surface);
}

.grid-shell .tabulator-row {
    border-bottom: 1px solid var(--ifr-line);
    background: var(--ifr-surface);
    min-height: 44px;
}

.grid-shell .tabulator-row.tabulator-row-even { background: var(--ifr-surface); }
.grid-shell .tabulator-row .tabulator-cell { padding: 10px 12px; border-inline-end: 0; }
.grid-shell .tabulator-row.tabulator-selectable:hover { background: var(--ifr-accent-soft); cursor: pointer; }
.grid-shell .tabulator-row.grid-row-link { cursor: pointer; }
.grid-shell .tabulator-row.grid-row-link:hover { background: var(--ifr-accent-soft); }
.grid-shell .tabulator-row.grid-row-link .tabulator-cell.grid-editable { cursor: text; }
.grid-shell .tabulator-row.tabulator-selected { background: var(--ifr-accent-soft); }

/* Compact: more rows on the screen, for somebody working through a long list. */
.grid-shell.grid-compact .tabulator-row { min-height: 32px; }
.grid-shell.grid-compact .tabulator-row .tabulator-cell { padding: 4px 10px; }
.grid-shell.grid-compact .tabulator { font-size: .84rem; }

.grid-shell .tabulator .tabulator-footer {
    background: var(--ifr-sunken);
    border-top: 1px solid var(--ifr-line);
    color: var(--ifr-muted);
}

.grid-shell .tabulator .tabulator-footer .tabulator-calcs-holder {
    background: var(--ifr-accent-soft);
    border-bottom: 1px solid var(--ifr-line);
}

.grid-shell .tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row { background: var(--ifr-accent-soft); }

.grid-shell .tabulator .tabulator-footer .tabulator-page {
    border-radius: 6px;
    border: 1px solid var(--ifr-line-strong);
    background: var(--ifr-surface);
}

.grid-shell .tabulator .tabulator-footer .tabulator-page.active {
    background: var(--ifr-accent);
    border-color: var(--ifr-accent);
    color: var(--ifr-surface);
}

.grid-shell .tabulator-row.tabulator-group {
    background: var(--ifr-sunken);
    border-bottom: 1px solid var(--ifr-line-strong);
    padding: 8px 12px;
    font-weight: 600;
    color: var(--ifr-ink);
}

.grid-group-name { margin-inline-end: var(--ifr-2); }
.grid-group-count {
    background: var(--ifr-accent);
    color: var(--ifr-surface);
    border-radius: var(--ifr-radius-pill);
    padding: 0 8px;
    font-size: .75rem;
    margin-inline-end: var(--ifr-3);
}
.grid-group-sum { color: var(--ifr-muted); font-weight: 400; margin-inline-end: var(--ifr-3); font-size: .82rem; }
.grid-group-sum b { color: var(--ifr-ink); }
.grid-shell .tabulator-row.tabulator-group span { color: inherit; }

.grid-shell .tabulator-cell.grid-editable { background: var(--ifr-sunken); cursor: text; }
.grid-shell .tabulator-cell.grid-editable:hover { outline: 1px solid var(--ifr-line-strong); outline-offset: -1px; }
.grid-shell .tabulator-cell.grid-saving { opacity: .5; }
.grid-shell .tabulator-cell.grid-saved { background: var(--ifr-good-soft); }

.grid-empty { padding: var(--ifr-6); color: var(--ifr-muted); text-align: center; }
.grid-empty i { font-size: 2rem; display: block; color: var(--ifr-faint); }

/* The invoice lines typed as a grid: cells without boxes until they are
   being typed in, like a spreadsheet. */
.entry-grid { border: 1px solid var(--ifr-line); }
.entry-grid thead th { background: var(--ifr-sunken); font-size: .8rem; color: var(--ifr-muted); white-space: nowrap; }
.entry-grid td { padding: 2px 4px; border-color: var(--ifr-line); }
.entry-grid .grid-cell { border-color: transparent; background: transparent; box-shadow: none; }
.entry-grid .grid-cell:hover { border-color: var(--ifr-line-strong); }
.entry-grid .grid-cell:focus { border-color: var(--ifr-accent); background: var(--ifr-surface); }
.entry-grid .extra-row td { border-top: 0; }
.entry-grid .extra-row .extra-list:empty { display: none !important; }
.entry-grid .extra-row:has(.extra-list:empty) { display: none; }
/* Spinner arrows take a third of a narrow cell; the keyboard does the job. */
.entry-grid input[type=number]::-webkit-outer-spin-button,
.entry-grid input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.entry-grid input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* Cards: the totals follow the page down. Grid: they sit under it, in a row. */
.entry-totals { position: sticky; top: 76px; }
.entry-side-wide .entry-totals { position: static; }
@media (min-width: 992px) {
    .entry-side-wide .entry-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--ifr-5); align-items: start; }
    .entry-side-wide .entry-totals > * { grid-column: auto; }
    .entry-side-wide .entry-totals > h6 { grid-column: 1 / -1; }
}

/* =============================================================================
   Narrow screens
   ========================================================================== */

@media (max-width: 1199px) {
    .appbar-menu { margin-inline: 0; padding-block: var(--ifr-2); }
    .appbar-tools { margin-inline-start: 0; padding-block: var(--ifr-2) var(--ifr-3); border-top: 1px solid var(--ifr-line); }
    .appbar .dropdown-menu { box-shadow: none; border: 0; padding-inline-start: var(--ifr-4); }
}

@media (max-width: 991px) {
    .page-head { flex-direction: column; align-items: stretch; }
    .page-head .page-actions { width: 100%; }
}

/* Print: the frame is navigation, and navigation does not belong on paper. */
@media print {
    .sidebar, .topbar, .appbar, .toolbar, .page-actions, .license-banner { display: none !important; }
    .table-card, .panel { box-shadow: none; border: 1px solid var(--ifr-line); }
    body { background: #fff; }
}

/* =============================================================================
   The invoice a note corrects, picked from a list (partials/invoice-picker)
   ========================================================================== */

.ref-picker { position: relative; }
.ref-picker-list {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 2px);
    z-index: 1050;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--ifr-line);
    border-radius: var(--ifr-radius);
    box-shadow: var(--ifr-shadow-lg);
}
.ref-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 14px;
    width: 100%;
    text-align: start;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--ifr-line);
    padding: 9px 12px;
    font-size: .88rem;
    color: var(--ifr-ink);
}
.ref-item:last-child { border-bottom: 0; }
.ref-item small { color: var(--ifr-muted); }
.ref-item:hover, .ref-item.active { background: var(--ifr-info-soft, #eef4ff); }
.ref-empty { padding: 12px; color: var(--ifr-muted); font-size: .88rem; }
/* The item codes list hangs off whichever line's field is in use, so it sits
   on the page itself rather than inside a picker box. */
.item-picker-list { position: absolute; inset-inline: auto; max-width: calc(100vw - 16px); }

/* =============================================================================
   Density
   =============================================================================
   Everything a little smaller and closer: the fields, the cards' padding, the
   gaps between rows, the figures. A form that needed a page of scrolling fits
   a screen, and a screen that is mostly fields reads as a form rather than as
   a sequence of boxes. Later in the file on purpose - at equal specificity
   the last rule wins, so these are the sizes every screen gets.
   ========================================================================== */

body { font-size: .9rem; }

.page-body { padding: var(--ifr-3) clamp(12px, 2vw, 28px); }

/* The whole width beside the side menu: the menu already frames the page,
   and a page held to the middle left the cards and the lists narrow with
   empty bands either side. */
.page-body { width: 100%; }

.page-head { margin-bottom: var(--ifr-3); gap: var(--ifr-3); }
.page-head h1 { font-size: 1.1rem; }
.page-head .page-sub { font-size: .8rem; margin-top: 2px; }

/* Cards: the utility paddings the screens use, brought down together. */
.page-body .table-card.p-4,
.page-body .panel.p-4,
.page-body .table-card.p-3 { padding: 12px 16px !important; }
.panel-body { padding: var(--ifr-3) var(--ifr-4); }
.panel-head { padding: var(--ifr-2) var(--ifr-4); }
.page-body .table-card > h6.fw-bold,
.page-body .table-card > .d-flex > h6.fw-bold,
.page-body .table-card h6.fw-bold.mb-3 { font-size: .9rem; margin-bottom: 8px !important; }
.page-body .table-card > h5.fw-bold { font-size: 1rem; }

/* The gaps between rows and sections. */
.page-body .row.g-3 { --bs-gutter-x: 12px; --bs-gutter-y: 8px; }
.page-body .row.g-2 { --bs-gutter-y: 6px; }
.page-body .mb-4 { margin-bottom: 12px !important; }
.page-body .mt-4 { margin-top: 12px !important; }
.page-body .mb-3 { margin-bottom: 10px !important; }
.page-body .pt-3 { padding-top: 10px !important; }
.page-body .p-4 { padding: 12px 16px !important; }

/* Fields: a line of text and little more. */
.form-label { font-size: .8rem; margin-bottom: 3px; }
.form-text { font-size: .74rem; margin-top: 3px; line-height: 1.4; }
.form-control,
.form-select { padding: 5px 10px; font-size: .86rem; border-radius: 7px; min-height: 32px; }
.form-select { background-position: left 8px center; }
[dir="ltr"] .form-select { background-position: right 8px center; }
textarea.form-control { min-height: 64px; }
.form-control-sm,
.form-select-sm { padding: 3px 8px; font-size: .8rem; min-height: 28px; }
.input-group-text { padding: 4px 10px; font-size: .86rem; }
.form-check-input { margin-top: .2em; }
.form-switch .form-check-input { height: 1.1em; }

.btn { font-size: .86rem; padding: 5px 12px; border-radius: 7px; }
.btn-sm { font-size: .78rem; padding: 3px 9px; }
.btn-lg { font-size: .95rem; padding: 7px 16px; }

.alert { padding: 8px 12px; font-size: .86rem; margin-bottom: 10px; border-radius: 8px; }
.alert .fs-5 { font-size: 1.1rem !important; }

/* Tables and the grid: a row is a line. */
.table-card .table > thead > tr > th { padding: 6px 10px; font-size: .78rem; }
.table-card .table > tbody > tr > td { padding: 6px 10px; font-size: .86rem; }
.table-sm > :not(caption) > * > * { padding: 4px 8px; }
.tabulator .tabulator-row .tabulator-cell { padding: 5px 8px; }

/* The dashboard's figures. */
.kpi-tile { padding: var(--ifr-3) var(--ifr-4); gap: var(--ifr-3); }
.kpi-icon { width: 40px; height: 40px; font-size: 1.1rem; }
.kpi-label { font-size: .84rem; }
.kpi-value { font-size: 1.6rem; }
.kpi-sub { font-size: .78rem; }
.sc-rows { padding: 4px 10px 2px; }
.sc-row { padding: 5px 0; font-size: .82rem; }
.sc-foot { padding: 7px 10px; }
.sc-name { font-size: .98rem; }
.sc-count { font-size: .95rem; }

/* The typed-in invoice: the lines' cards and totals. */
.entry-totals .table > tbody > tr > td { padding: 4px 6px; }
.eta-line .card-body,
.page-body .table-card .card .card-body { padding: 10px 12px; }
details > summary { cursor: pointer; }

/* =============================================================================
   Shell: the side menu
   =============================================================================
   The screens down the side, grouped under quiet headings, on a dark column
   that sets them apart from the work; folded to icons unless the person opens
   it, so the page keeps its width. The page itself sits on a pale grey, and
   every card on it is white - the cards read as the content, the rest steps
   back. Last in the file: it is what the screens look like now.
   ========================================================================== */

:root {
    --ifr-bg: #f4f6fa;
    --ifr-side: #0f1b2d;
    --ifr-side-2: #1b2a44;
    --ifr-side-ink: #c5cede;
    --ifr-side-ink-hi: #ffffff;
    --ifr-side-faint: #6f7d95;
    --ifr-side-line: rgba(255, 255, 255, .06);
    --ifr-scrim: rgba(15, 27, 45, .35);
    --side-w: 64px;
    --side-w-open: 236px;
    --topbar-h: 58px;
}

body { background: var(--ifr-bg); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: var(--ifr-3);
    padding-inline: var(--ifr-3) var(--ifr-4);
    background: var(--ifr-surface);
    border-bottom: 1px solid var(--ifr-line);
}
.topbar-toggle,
.topbar-icon {
    width: 38px;
    height: 38px;
    border: 1px solid var(--ifr-line);
    border-radius: 10px;
    background: var(--ifr-surface);
    color: var(--ifr-ink-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1.05rem;
    padding: 0;
}
.topbar-toggle { font-size: 1.35rem; }
.topbar-toggle:hover,
.topbar-icon:hover,
.topbar-icon.active { background: var(--ifr-accent-soft); color: var(--ifr-accent-ink); border-color: var(--ifr-accent-soft); }
.topbar-brand {
    display: flex;
    align-items: center;
    gap: var(--ifr-2);
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--ifr-ink);
    text-decoration: none;
    white-space: nowrap;
}
.topbar-tools { margin-inline-start: auto; display: flex; align-items: center; gap: var(--ifr-2); }
.topbar-user {
    display: inline-flex;
    align-items: center;
    gap: var(--ifr-2);
    border: 0;
    background: transparent;
    padding: 2px 4px;
    color: var(--ifr-ink-2);
    font-weight: 600;
    font-size: .86rem;
}
.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ifr-accent);
    color: var(--ifr-side-ink-hi);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.topbar-user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .dropdown-item i { color: var(--ifr-muted); width: 18px; text-align: center; margin-inline-end: 4px; }

.app-body { display: flex; align-items: flex-start; flex: 1; }
.app-body > .page-body { flex: 1; min-width: 0; padding-top: var(--ifr-5); }

.sidebar {
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    flex: 0 0 var(--side-w);
    width: var(--side-w);
    background: var(--ifr-side);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--ifr-side-2) transparent;
    transition: flex-basis .2s, width .2s;
}
html.sidebar-open .sidebar { flex-basis: var(--side-w-open); width: var(--side-w-open); }

.side-nav { padding: var(--ifr-2) var(--ifr-2) var(--ifr-5); }
.side-group { padding-block: 6px; border-bottom: 1px solid var(--ifr-side-line); }
.side-group:last-child { border-bottom: 0; }
.side-head { display: none; font-size: .7rem; font-weight: 600; color: var(--ifr-side-faint); padding: 8px 12px 4px; white-space: nowrap; }
/* A group's heading folds it, with the sidebar open; folded to icons, every
   screen stays one click away. */
button.side-head { inline-size: 100%; background: none; border: 0; text-align: start; cursor: pointer; border-radius: 8px; align-items: center; justify-content: space-between; gap: 8px; }
button.side-head:hover { color: var(--ifr-side-ink-hi); background: var(--ifr-side-2); }
.side-chevron { font-size: .7rem; transition: transform .15s; }
/* Folded, the arrow points the way the text reads. */
.side-group.is-folded .side-chevron { transform: rotate(-90deg); }
[dir="rtl"] .side-group.is-folded .side-chevron { transform: rotate(90deg); }
html.sidebar-open .side-group.is-folded .side-link { display: none; }
.side-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 9px 0;
    margin-block: 2px;
    border-radius: 10px;
    color: var(--ifr-side-ink);
    text-decoration: none;
    font-size: .86rem;
    white-space: nowrap;
}
.side-link i { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }
.side-label { display: none; overflow: hidden; text-overflow: ellipsis; }
.side-link:hover { background: var(--ifr-side-2); color: var(--ifr-side-ink-hi); }
.side-link.active { background: var(--ifr-accent); color: var(--ifr-side-ink-hi); }

html.sidebar-open .side-head { display: flex; }
html.sidebar-open .side-link { justify-content: flex-start; padding: 9px 12px; }
html.sidebar-open .side-label { display: inline; }

.sidebar-scrim { display: none; }

/* A narrow screen: the menu slides over the page, whole, and a tap beside it
   closes it. */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        top: var(--topbar-h);
        bottom: 0;
        inset-inline-start: 0;
        height: auto;
        width: var(--side-w-open);
        z-index: 1040;
        transition: transform .2s;
    }
    [dir=rtl] .sidebar { transform: translateX(100%); }
    [dir=ltr] .sidebar { transform: translateX(-100%); }
    html.sidebar-shown .sidebar { transform: none; }
    .sidebar .side-head { display: block; }
    .sidebar .side-link { justify-content: flex-start; padding: 9px 12px; }
    .sidebar .side-label { display: inline; }
    html.sidebar-shown .sidebar-scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: var(--ifr-scrim); z-index: 1035; }
    .topbar-user-name,
    .property-switch-label { display: none; }
}
@media (max-width: 575.98px) {
    .topbar-brand span:last-child { display: none; }
}

/* Cards on the grey: white, a hairline and the faintest shadow. */
.table-card,
.panel,
.grid-shell,
.kpi-tile { border-color: var(--ifr-line); box-shadow: 0 1px 2px rgba(20, 27, 45, .04); }

/* =============================================================================
   The grid, calmer
   =============================================================================
   One row of tools above the table, the tools as icons; the filter under each
   heading folded away until asked for; what to do with ticked rows only once
   some are; and rows with room to breathe.
   ========================================================================== */

.grid-toolbar { padding: var(--ifr-3) var(--ifr-4); gap: var(--ifr-2) var(--ifr-3); }
.grid-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.grid-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--ifr-radius-pill);
    background: var(--ifr-sunken);
    border: 1px solid var(--ifr-line);
    color: var(--ifr-ink-2);
    font-size: .8rem;
    text-decoration: none;
    white-space: nowrap;
}
.grid-chip:hover { background: var(--ifr-accent-soft); color: var(--ifr-accent-ink); }
.grid-chip.active { background: var(--ifr-dark); border-color: var(--ifr-dark); color: var(--ifr-side-ink-hi); }
.grid-search { flex: 1 1 220px; max-width: 340px; }
.grid-dates { display: flex; align-items: center; gap: 4px; }
.grid-dates input { width: 136px; }
.grid-dates .grid-date-label { font-size: .8rem; color: var(--bs-secondary-color, #6c757d); white-space: nowrap; }
.grid-tools { gap: 6px; }
.grid-tool {
    position: relative;
    height: 32px;
    min-width: 34px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid var(--ifr-line-strong);
    border-radius: 8px;
    background: var(--ifr-surface);
    color: var(--ifr-ink-2);
}
.grid-tool:hover { background: var(--ifr-sunken); color: var(--ifr-ink); }
.grid-tool.active { background: var(--ifr-accent-soft); border-color: var(--ifr-accent); color: var(--ifr-accent-ink); }
.grid-tool-excel { color: var(--ifr-good); }
.grid-filter-count {
    position: absolute;
    top: -6px;
    inset-inline-end: -6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--ifr-radius-pill);
    background: var(--ifr-accent);
    color: var(--ifr-side-ink-hi);
    font-size: .65rem;
    line-height: 16px;
}
.grid-filter-count:empty { display: none; }
.grid-view-menu { min-width: 250px; padding: var(--ifr-3); }

.grid-selection {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ifr-2) var(--ifr-3);
    padding: 8px var(--ifr-4);
    background: var(--ifr-accent-soft);
    border-bottom: 1px solid var(--ifr-line);
}
.grid-selection[hidden] { display: none; }
.grid-selection-count { font-size: .84rem; color: var(--ifr-accent-ink); }

.grid-shell:not(.grid-filters-open) .tabulator .tabulator-header .tabulator-col .tabulator-header-filter { display: none; }
.grid-shell .tabulator .tabulator-header { font-weight: 600; font-size: .8rem; color: var(--ifr-muted); border-bottom-color: var(--ifr-line); }
.grid-shell .tabulator .tabulator-header .tabulator-col { border-inline-end: 0; }
.grid-shell .tabulator .tabulator-header .tabulator-col .tabulator-col-content { padding: 11px 14px; }
.grid-shell .tabulator .tabulator-row { min-height: 48px; }
.grid-shell .tabulator .tabulator-row .tabulator-cell { padding: 13px 14px; }
.grid-shell.grid-compact .tabulator .tabulator-row { min-height: 34px; }
.grid-shell.grid-compact .tabulator .tabulator-row .tabulator-cell { padding: 6px 12px; }
/* Lines between rows only, as a list reads; none between the cells. */
.grid-shell .tabulator.tabulator .tabulator-row .tabulator-cell,
.grid-shell .tabulator.tabulator .tabulator-header .tabulator-col,
.grid-shell .tabulator.tabulator .tabulator-row .tabulator-row-header,
.grid-shell .tabulator.tabulator .tabulator-header .tabulator-frozen,
.grid-shell .tabulator.tabulator .tabulator-row .tabulator-frozen,
.grid-shell .tabulator.tabulator .tabulator-row .tabulator-cell.tabulator-frozen,
.grid-shell .tabulator.tabulator .tabulator-header .tabulator-col.tabulator-frozen { border-inline: 0; }
.grid-shell .tabulator .tabulator-footer .tabulator-calcs-holder { border-top: 1px solid var(--ifr-line); }
.grid-shell .tabulator .tabulator-row .tabulator-cell.grid-cell-action { padding-inline: 4px; }

/* =============================================================================
   Dashboard
   ========================================================================== */

/* The filters as one quiet row in a white strip. */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ifr-2);
    padding: var(--ifr-2) var(--ifr-3);
    background: var(--ifr-surface);
    border: 1px solid var(--ifr-line);
    border-radius: var(--ifr-radius-lg);
}
.filter-bar .form-select { width: auto; min-width: 150px; }
.filter-bar-dates { display: inline-flex; align-items: center; gap: 4px; }
.filter-bar-dates input { width: 140px; }


/* =============================================================================
   One invoice
   =============================================================================
   The document on the wide side - its head, its lines, what is wrong with
   it; on the narrow side what can be done with it, stacked with the send
   first, then its figures on dark with the total large, then whether it
   is ready and what happened to it.
   ========================================================================== */

:root { --ifr-summary-total: #34d399; }

.doc-actions { display: flex; flex-direction: column; gap: var(--ifr-2); }
.doc-actions > *,
.doc-actions .btn { width: 100%; }
.doc-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding-block: 8px; }
.doc-actions #submitForm { order: -2; }
.doc-actions [data-validate] { order: -1; }

.doc-summary {
    background: var(--ifr-side);
    color: var(--ifr-side-ink);
    border-radius: var(--ifr-radius-lg);
    padding: var(--ifr-4) var(--ifr-4) var(--ifr-3);
}
.doc-summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 1rem;
    color: var(--ifr-side-ink-hi);
    padding-bottom: var(--ifr-3);
    margin-bottom: var(--ifr-2);
    border-bottom: 1px solid var(--ifr-side-line);
}
.doc-summary-eta {
    font-size: .7rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: var(--ifr-radius-pill);
    border: 1px solid var(--ifr-side-2);
    color: var(--ifr-side-ink);
}
.doc-summary-eta::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ifr-summary-total); margin-inline-end: 6px; vertical-align: middle; }
.doc-summary-table { width: 100%; }
.doc-summary-table td { padding: 6px 0; font-size: .86rem; border: 0; background: transparent; color: inherit; }
.doc-summary-table td.text-end { text-align: end; }
.doc-summary-table tr.table-primary td {
    padding-top: var(--ifr-3);
    border-top: 1px solid var(--ifr-side-line);
    font-size: 1.15rem;
    color: var(--ifr-side-ink-hi);
}
.doc-summary-table tr.table-primary td.num { color: var(--ifr-summary-total); font-size: 1.35rem; }

.doc-lines > thead > tr > th { font-size: .78rem; font-weight: 600; color: var(--ifr-muted); background: var(--ifr-sunken); padding: 10px 14px; }
.doc-lines > tbody > tr > td { padding: 12px 14px; }

/* =============================================================================
   Roles
   ========================================================================== */

.role-areas { display: grid; gap: 6px; }
.role-area { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-radius: 8px; background: var(--ifr-sunken); font-size: .84rem; }
.role-area.is-all { background: var(--ifr-good-soft); color: var(--ifr-good); }
.role-area.is-none { color: var(--ifr-faint); }
.role-all { padding: 10px; border-radius: 8px; background: var(--ifr-good-soft); color: var(--ifr-good); font-weight: 600; }

.perm-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--ifr-line); cursor: pointer; }
.perm-row:last-child { border-bottom: 0; }
.perm-row .form-check-input { margin-top: .25em; flex-shrink: 0; }
.perm-name { display: block; font-weight: 600; color: var(--ifr-ink); font-size: .88rem; }
.perm-hint { display: block; color: var(--ifr-muted); font-size: .78rem; }
.perm-row.is-locked { opacity: .5; cursor: not-allowed; }

/* =============================================================================
   Settings: sections with the way to each always in view
   ========================================================================== */

.settings-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: var(--ifr-4);
    align-items: start;
}
.settings-nav { position: sticky; inset-block-start: 76px; }
.settings-nav nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--ifr-2);
    background: var(--ifr-surface);
    border: 1px solid var(--ifr-line);
    border-radius: var(--ifr-radius-lg);
}
.settings-nav a {
    display: flex;
    align-items: center;
    gap: var(--ifr-2);
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--ifr-ink-2);
    text-decoration: none;
    font-size: .88rem;
    white-space: nowrap;
}
.settings-nav a:hover { background: var(--ifr-sunken); color: var(--ifr-ink); }
.settings-nav a.active { background: var(--ifr-accent-soft); color: var(--ifr-accent); font-weight: 600; }
.settings-nav a i { font-size: 1rem; }
.settings-main { display: flex; flex-direction: column; gap: var(--ifr-4); min-width: 0; }
.settings-main > form { display: flex; flex-direction: column; gap: var(--ifr-4); }
.settings-section { scroll-margin-block-start: 80px; }
.settings-section .form-label { margin-block-end: 4px; }
.settings-signing th { color: var(--ifr-muted); font-weight: 600; white-space: nowrap; }
.settings-facts { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; padding-block-start: var(--ifr-3); border-block-start: 1px dashed var(--ifr-line); }
.settings-facts code { font-size: .8rem; }
.settings-savebar {
    position: sticky;
    inset-block-end: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ifr-3);
    padding: var(--ifr-3) var(--ifr-4);
    background: var(--ifr-surface);
    border: 1px solid var(--ifr-line);
    border-radius: var(--ifr-radius-lg);
    box-shadow: var(--ifr-shadow);
}

@media (max-width: 991.98px) {
    .settings-layout { grid-template-columns: minmax(0, 1fr); }
    .settings-nav { inset-block-start: 56px; z-index: 6; }
    .settings-nav nav { flex-direction: row; overflow-x: auto; }
}

/* Exchange rates: each source and how its last fetch went, one per line. */
.fx-sources { display: flex; flex-direction: column; gap: 6px; }
.fx-source { display: flex; align-items: center; flex-wrap: wrap; gap: var(--ifr-2); }
.fx-source code { font-size: .78rem; }

/* An invoice's lines in another currency, for the accountant's eye only. */
.fx-info { font-size: .75rem; color: var(--ifr-muted); white-space: nowrap; }
.fx-note { font-size: .8rem; color: var(--ifr-muted); padding: var(--ifr-2) var(--ifr-4); border-block-end: 1px dashed var(--ifr-line); background: var(--ifr-sunken); }

/* The PIN kept by the system: set apart from the facts above it. */
.settings-pin { padding-block-start: var(--ifr-3); border-block-start: 1px dashed var(--ifr-line); }

/* Today's invoices: a quick filter on the date, set apart from the statuses. */
.grid-chip-today { margin-inline-start: var(--ifr-2); }
.grid-months { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.grid-cell-caption { color: var(--bs-secondary-color, #6c757d); font-size: .72rem; margin-inline-start: 4px; white-space: nowrap; }
.grid-months-sep { width: 1px; height: 18px; background: var(--ifr-line, #dee2e6); margin-inline: 4px; }
.grid-chip-today i { margin-inline-end: 2px; }

/* The status filters, each in its status's colour - the colour of its badge
   in the list - with a dot, an icon and how many: told apart at a glance. */
.grid-chip[data-status-chip] {
    gap: 6px;
    border-color: var(--chip);
    background: var(--ifr-surface);
    background: color-mix(in srgb, var(--chip) 9%, var(--ifr-surface));
    color: var(--ifr-ink);
    font-weight: 500;
}
.grid-chip[data-status-chip] > i { color: var(--chip); }
.grid-chip[data-status-chip]:hover { background: color-mix(in srgb, var(--chip) 20%, var(--ifr-surface)); color: var(--ifr-ink); }
.grid-chip[data-status-chip].active { background: var(--chip); border-color: var(--chip); color: #fff; font-weight: 600; }
.grid-chip[data-status-chip].active > i { color: #fff; }
.grid-chip .chip-count {
    min-width: 1.4em;
    padding: 0 6px;
    border-radius: var(--ifr-radius-pill);
    background: var(--chip, var(--ifr-muted));
    color: #fff;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
}
.grid-chip.active .chip-count { background: rgba(255, 255, 255, .25); }

/* The bell: the count of what has not been seen, and what happened, newest first. */
.alerts-bell { position: relative; }
.alerts-count, .side-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--ifr-radius-pill);
    background: #dc2626;
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--ifr-surface);
}
.alerts-count { position: absolute; top: -4px; inset-inline-end: -4px; }
.alerts-menu { width: min(400px, 92vw); padding: 0; overflow: hidden; }
.alerts-head { padding: var(--ifr-3) var(--ifr-4); font-weight: 700; border-block-end: 1px solid var(--ifr-line); }
.alerts-menu .alerts-item { max-height: none; }
.alerts-item {
    display: flex;
    gap: var(--ifr-3);
    align-items: flex-start;
    padding: var(--ifr-3) var(--ifr-4);
    border-block-end: 1px solid var(--ifr-line);
    color: var(--ifr-ink);
    text-decoration: none;
}
.alerts-item:hover { background: var(--ifr-sunken); color: var(--ifr-ink); }
.alerts-item > .bi:first-child { font-size: 1.05rem; margin-top: 1px; }
.alerts-item.level-success > .bi:first-child { color: #16a34a; }
.alerts-item.level-danger > .bi:first-child { color: #dc2626; }
.alerts-item.level-warning > .bi:first-child { color: #d97706; }
.alerts-item.level-info > .bi:first-child { color: #0284c7; }
.alerts-item.is-unread { background: color-mix(in srgb, #0284c7 6%, var(--ifr-surface)); }
.alerts-item.is-unread .alerts-title::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #dc2626; margin-inline-end: 6px; vertical-align: middle; }
.alerts-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.alerts-title { font-weight: 600; font-size: .86rem; }
.alerts-body { font-size: .78rem; color: var(--ifr-ink-2); overflow-wrap: anywhere; }
.alerts-time { font-size: .72rem; color: var(--ifr-muted); }
.alerts-go { color: var(--ifr-muted); align-self: center; }
.alerts-empty { padding: var(--ifr-4); text-align: center; color: var(--ifr-muted); font-size: .85rem; }
.alerts-foot { display: flex; justify-content: space-between; gap: var(--ifr-3); padding: var(--ifr-3) var(--ifr-4); background: var(--ifr-sunken); font-size: .82rem; }
.alerts-foot a { text-decoration: none; font-weight: 600; }

/* New supplier documents: counted beside the list's name, marked inside it. */
.side-link { position: relative; }
/* Folded to icons: on the icon's corner. Open: at the end of the line. */
.side-badge { position: absolute; top: 3px; inset-inline-end: 5px; margin: 0; }
html.sidebar-open .side-badge { position: static; margin-inline-start: auto; }
.tabulator-row.grid-row-new { background: color-mix(in srgb, #f59e0b 13%, var(--ifr-surface)) !important; box-shadow: inset 3px 0 0 #f59e0b; }
[dir="rtl"] .tabulator-row.grid-row-new { box-shadow: inset -3px 0 0 #f59e0b; }
/* The record just come back from: marked, wherever in the list it now is. */
.tabulator-row.grid-row-here { background: var(--ifr-accent-soft) !important; box-shadow: inset 4px 0 0 var(--ifr-accent); }
[dir="rtl"] .tabulator-row.grid-row-here { box-shadow: inset -4px 0 0 var(--ifr-accent); }
.received-new-note { display: flex; align-items: center; gap: var(--ifr-2); margin-block-end: var(--ifr-3); padding: var(--ifr-2) var(--ifr-3); border-radius: var(--ifr-radius); background: color-mix(in srgb, #f59e0b 13%, var(--ifr-surface)); border: 1px solid color-mix(in srgb, #f59e0b 40%, transparent); font-size: .85rem; font-weight: 600; }
.received-new-dot { width: 10px; height: 10px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 3px color-mix(in srgb, #f59e0b 25%, transparent); }
@media (max-width: 991.98px) { .sidebar .side-badge { position: static; margin-inline-start: auto; } }

/* A phone: the bar's tools fit the screen instead of pushing the page
   sideways - the property's name shortens, the sync and import buttons give
   way (both are on the dashboard and the invoice list), the bell stays. */
@media (max-width: 575.98px) {
    .topbar { gap: var(--ifr-2); padding-inline: var(--ifr-2); }
    .topbar-tools { min-width: 0; flex: 1 1 auto; justify-content: flex-end; gap: 6px; }
    .topbar-tools > form.d-inline { display: none !important; }
    .property-switch { min-width: 0; flex: 0 1 auto; padding-inline: 4px; }
    .property-switch > .bi { display: none; }
    .property-switch-select, .property-switch-name { min-width: 0; max-width: 42vw; text-overflow: ellipsis; font-size: .8rem; }
    .topbar-user.dropdown-toggle::after { display: none; }
    .alerts-menu { position: fixed !important; inset: var(--topbar-h) 8px auto 8px !important; width: auto; transform: none !important; }
}

/* The dashboard's status cards, smaller: five to a row on a laptop instead
   of three, and tighter inside - the thirteen of them fit one screen. */
.sc-rows { padding: 3px 10px 2px; }
.sc-row { font-size: .8rem; padding: 4px 0; }
.sc-foot { padding: 6px 10px; }
.sc-name { font-size: .92rem; }
.sc-name small { font-size: .72rem; }
.sc-count { font-size: .95rem; }

/* A table row that opens something: the hand, and a tint under it. */
tr[data-href] { cursor: pointer; }
tr[data-href]:hover > td { background: var(--ifr-accent-soft); }
tr[data-href]:focus-visible { outline: 2px solid var(--ifr-accent); outline-offset: -2px; }

/* The invoice's way to ETA, as a line of steps. */
.doc-stages { list-style: none; display: flex; margin: 0 0 var(--ifr-4); padding: 0; }
.doc-stages > li { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; min-width: 0; }
.doc-stages > li + li::before {
    content: "";
    position: absolute;
    top: 14px;
    inset-inline-end: 50%;
    width: 100%;
    height: 3px;
    background: var(--ifr-line-strong);
    z-index: 0;
}
.doc-stages > li.is-done + li::before { background: var(--ifr-good); }
.doc-stage-dot {
    position: relative;
    z-index: 1;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: .8rem;
    font-weight: 700;
    background: var(--ifr-surface);
    border: 2px solid var(--ifr-line-strong);
    color: var(--ifr-muted);
}
.doc-stage-name { font-size: .78rem; color: var(--ifr-muted); padding-inline: 4px; }
.doc-stages > li.is-done .doc-stage-dot { background: var(--ifr-good); border-color: var(--ifr-good); color: #fff; }
.doc-stages > li.is-done .doc-stage-name { color: var(--ifr-ink-2); }
.doc-stages > li.is-now .doc-stage-dot { border-color: var(--ifr-accent); color: var(--ifr-accent); box-shadow: 0 0 0 4px var(--ifr-accent-soft); }
.doc-stages > li.is-now .doc-stage-name { color: var(--ifr-ink); font-weight: 700; }
.doc-stages > li.is-bad .doc-stage-dot { background: var(--ifr-bad); border-color: var(--ifr-bad); color: #fff; }
.doc-stages > li.is-bad .doc-stage-name { color: var(--ifr-bad); font-weight: 700; }
.doc-stages-after { margin: calc(var(--ifr-3) * -1) 0 var(--ifr-4); font-size: .8rem; color: var(--ifr-muted); text-align: center; }

/* The invoice's buttons, following once they have scrolled away. It takes
   no room of its own, so the page does not jump as it comes and goes. */
.doc-bar { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 1020; height: 0; }
.doc-bar[hidden] { display: block; visibility: hidden; pointer-events: none; }
.doc-bar-in {
    position: absolute;
    inset-inline: 0;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ifr-3);
    flex-wrap: wrap;
    padding: 8px 14px;
    border-radius: var(--ifr-radius-lg);
    background: var(--ifr-surface);
    border: 1px solid var(--ifr-line);
    box-shadow: var(--ifr-shadow-lg);
}
.doc-bar-what { display: flex; align-items: center; gap: var(--ifr-2); min-width: 0; }
.doc-bar-total { font-weight: 700; color: var(--ifr-ink-2); }
.doc-bar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-bar-actions .btn { width: auto; display: inline-flex; align-items: center; gap: 5px; }

/* The panel beside a list: a record in brief, the list still behind it. */
.grid-drawer {
    position: fixed;
    inset-block: var(--topbar-h) 0;
    inset-inline-end: 0;
    width: min(460px, 94vw);
    z-index: 1045;
    display: flex;
    flex-direction: column;
    background: var(--ifr-surface);
    border-inline-start: 1px solid var(--ifr-line);
    box-shadow: -18px 0 40px -18px rgba(15, 27, 45, .28);
    transform: translateX(-104%);
    transition: transform .18s ease;
    visibility: hidden;
}
[dir=ltr] .grid-drawer { transform: translateX(104%); box-shadow: 18px 0 40px -18px rgba(15, 27, 45, .28); }
.grid-drawer.is-open { transform: none; visibility: visible; }
.grid-drawer-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-block-end: 1px solid var(--ifr-line); background: var(--ifr-sunken); }
.grid-drawer-keys { margin-inline-start: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-drawer-body { flex: 1; overflow-y: auto; padding: var(--ifr-4); transition: opacity .12s; }
.grid-drawer-body.is-loading { opacity: .45; }
.tabulator-row.grid-row-previewed { background: var(--ifr-accent-soft) !important; box-shadow: inset 3px 0 0 var(--ifr-accent); }
[dir=rtl] .tabulator-row.grid-row-previewed { box-shadow: inset -3px 0 0 var(--ifr-accent); }
@media (max-width: 575.98px) { .grid-drawer-keys { display: none; } }

.preview-head { display: flex; align-items: center; justify-content: space-between; gap: var(--ifr-2); margin-bottom: var(--ifr-4); }
.preview-title { font-weight: 700; font-size: 1.1rem; color: var(--ifr-ink); }
.preview .doc-stage-name { font-size: .7rem; }
.preview-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ifr-3); margin: 0 0 var(--ifr-4); }
.preview-facts dt { font-size: .72rem; font-weight: 500; color: var(--ifr-muted); }
.preview-facts dd { margin: 2px 0 0; font-size: .86rem; font-weight: 600; color: var(--ifr-ink); overflow-wrap: anywhere; }
.preview-lines { font-size: .82rem; }
.preview-lines thead th { font-size: .72rem; color: var(--ifr-muted); font-weight: 600; }
.preview-totals { width: 100%; margin: var(--ifr-3) 0 var(--ifr-4); font-size: .86rem; }
.preview-totals td { padding: 4px 0; }
.preview-totals td:last-child { text-align: end; }
.preview-totals .is-total td { border-block-start: 1px solid var(--ifr-line-strong); padding-top: 8px; font-weight: 700; font-size: 1.05rem; color: var(--ifr-ink); }
.preview-actions { display: flex; flex-wrap: wrap; gap: var(--ifr-2); position: sticky; bottom: calc(var(--ifr-4) * -1); padding: var(--ifr-3) 0; background: var(--ifr-surface); }
.preview-actions .btn { display: inline-flex; align-items: center; gap: 6px; }

/* A status card says its total and its count; the sales, discounts, net and
   tax behind the total open under it when it is pointed at or reached by
   the keyboard, over whatever is below. On a touch screen they are always
   there: nothing to point with. */
.status-card { position: relative; overflow: visible; }
.status-card .sc-foot { border-radius: 0 0 3px 3px; }
.sc-rows { padding: 6px 10px 4px; }
.sc-row.is-gross { font-size: .92rem; padding: 6px 0; }
.sc-more {
    display: none;
    position: absolute;
    top: 100%;
    inset-inline: -1px;
    z-index: 20;
    padding: 4px 10px 6px;
    background: var(--ifr-surface);
    border: 1px solid var(--sc, var(--ifr-accent));
    border-top: 0;
    border-radius: 0 0 6px 6px;
    box-shadow: var(--ifr-shadow-lg);
}
.status-card:hover .sc-more, .status-card:focus-visible .sc-more { display: block; }
.status-card:hover, .status-card:focus-visible { z-index: 21; transform: none; }
@media (hover: none) {
    .sc-more { display: block; position: static; padding: 0; border: 0; box-shadow: none; }
}

/* =============================================================================
   Dark
   =============================================================================
   The same screens on a dark ground, for a night shift's eyes: the tokens
   change and everything built on them follows. Bootstrap is told as well
   (data-bs-theme), and what was written in fixed colours - Tabulator's
   stylesheet, a few whites - is put on the tokens here. Printing is never
   dark: the print pages have their own stylesheet.
   ========================================================================== */
html[data-theme="dark"] {
    color-scheme: dark;
    --ifr-bg: #0e1422;
    --ifr-surface: #161d2e;
    --ifr-sunken: #1c2437;
    --ifr-ink: #edf0f6;
    --ifr-ink-2: #c5ccda;
    --ifr-muted: #93a0b6;
    --ifr-faint: #6b778e;
    --ifr-line: #263049;
    --ifr-line-strong: #34415e;
    --ifr-accent-ink: #a9bfff;
    --ifr-accent-soft: rgba(79, 124, 255, .17);
    --ifr-good: #2fbf4f;
    --ifr-good-soft: rgba(47, 191, 79, .16);
    --ifr-warn-soft: rgba(250, 178, 25, .15);
    --ifr-warn-ink: #f7c75f;
    --ifr-bad: #f06a6a;
    --ifr-bad-soft: rgba(240, 106, 106, .17);
    --ifr-info: #77adf2;
    --ifr-info-soft: rgba(119, 173, 242, .17);
    --ifr-shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --ifr-shadow-lg: 0 8px 28px rgba(0, 0, 0, .5);
    --ifr-scrim: rgba(0, 0, 0, .55);
    --ifr-side: #0a101c;
    --ifr-side-2: #141d30;
    --ifr-summary-total: #5fe0a0;

    --bs-body-bg: var(--ifr-bg);
    --bs-body-color: var(--ifr-ink-2);
    --bs-emphasis-color: var(--ifr-ink);
    --bs-secondary-color: var(--ifr-muted);
    --bs-secondary-bg: var(--ifr-sunken);
    --bs-tertiary-bg: var(--ifr-sunken);
    --bs-border-color: var(--ifr-line-strong);
    --bs-border-color-translucent: var(--ifr-line);
    --bs-heading-color: var(--ifr-ink);
    --bs-link-color: #8fb0ff;
    --bs-link-color-rgb: 143, 176, 255;
    --bs-link-hover-color: #b6caff;
    --bs-link-hover-color-rgb: 182, 202, 255;
    --bs-code-color: #f29ac0;
}
html[data-theme="dark"] body { background: var(--ifr-bg); color: var(--ifr-ink-2); }
html[data-theme="dark"] .topbar { background: var(--ifr-surface); border-color: var(--ifr-line); }
html[data-theme="dark"] .status-card { background: var(--ifr-surface); color: var(--ifr-ink); }
html[data-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-color: var(--ifr-ink-2); --bs-table-border-color: var(--ifr-line); --bs-table-striped-bg: rgba(255, 255, 255, .03); --bs-table-hover-bg: var(--ifr-accent-soft); --bs-table-hover-color: var(--ifr-ink); }
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select { background-color: var(--ifr-sunken); border-color: var(--ifr-line-strong); color: var(--ifr-ink); }
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus { background-color: var(--ifr-surface); border-color: var(--ifr-accent); color: var(--ifr-ink); }
html[data-theme="dark"] .form-control::placeholder { color: var(--ifr-faint); }
html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-control[readonly],
html[data-theme="dark"] .form-select:disabled { background-color: var(--ifr-bg); color: var(--ifr-muted); }
html[data-theme="dark"] .input-group-text { background: var(--ifr-sunken); border-color: var(--ifr-line-strong); color: var(--ifr-muted); }
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .popover,
html[data-theme="dark"] .card,
html[data-theme="dark"] .list-group-item { background-color: var(--ifr-surface); border-color: var(--ifr-line-strong); color: var(--ifr-ink-2); }
html[data-theme="dark"] .dropdown-item { color: var(--ifr-ink-2); }
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus { background: var(--ifr-accent-soft); color: var(--ifr-ink); }
html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-body-tertiary { background-color: var(--ifr-sunken) !important; color: var(--ifr-ink-2); }
html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-body { color: var(--ifr-ink) !important; }
html[data-theme="dark"] .text-muted { color: var(--ifr-muted) !important; }
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-bottom { border-color: var(--ifr-line-strong) !important; }
html[data-theme="dark"] .btn-light { --bs-btn-bg: var(--ifr-sunken); --bs-btn-border-color: var(--ifr-line-strong); --bs-btn-color: var(--ifr-ink-2); --bs-btn-hover-bg: var(--ifr-line); --bs-btn-hover-border-color: var(--ifr-line-strong); --bs-btn-hover-color: var(--ifr-ink); --bs-btn-active-bg: var(--ifr-line); --bs-btn-active-color: var(--ifr-ink); }
html[data-theme="dark"] .btn-outline-secondary { --bs-btn-color: var(--ifr-ink-2); --bs-btn-border-color: var(--ifr-line-strong); --bs-btn-hover-bg: var(--ifr-line); --bs-btn-hover-color: var(--ifr-ink); --bs-btn-hover-border-color: var(--ifr-line-strong); }
html[data-theme="dark"] .btn-outline-dark { --bs-btn-color: var(--ifr-ink); --bs-btn-border-color: var(--ifr-line-strong); --bs-btn-hover-bg: var(--ifr-line); --bs-btn-hover-color: var(--ifr-ink); }
html[data-theme="dark"] .btn-outline-primary { --bs-btn-color: var(--ifr-accent-ink); --bs-btn-border-color: var(--ifr-accent); }
html[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(1.6); }
html[data-theme="dark"] .alert-warning { background: var(--ifr-warn-soft); border-color: transparent; color: var(--ifr-warn-ink); }
html[data-theme="dark"] .alert-danger { background: var(--ifr-bad-soft); border-color: transparent; color: #ffc2c2; }
html[data-theme="dark"] .alert-success { background: var(--ifr-good-soft); border-color: transparent; color: #a8ecb8; }
html[data-theme="dark"] .alert-info { background: var(--ifr-info-soft); border-color: transparent; color: #c5dcfa; }
html[data-theme="dark"] .badge.bg-light { color: var(--ifr-ink-2) !important; }
html[data-theme="dark"] hr { border-color: var(--ifr-line-strong); opacity: 1; }
html[data-theme="dark"] .page-link { background: var(--ifr-surface); border-color: var(--ifr-line-strong); color: var(--ifr-ink-2); }
html[data-theme="dark"] .alerts-count,
html[data-theme="dark"] .side-badge { box-shadow: 0 0 0 2px var(--ifr-surface); }

/* The grid (Tabulator's stylesheet is all fixed light colours). */
html[data-theme="dark"] .tabulator,
html[data-theme="dark"] .tabulator .tabulator-tableholder,
html[data-theme="dark"] .tabulator .tabulator-tableholder .tabulator-table { background: var(--ifr-surface); color: var(--ifr-ink-2); }
html[data-theme="dark"] .tabulator .tabulator-header,
html[data-theme="dark"] .tabulator .tabulator-header .tabulator-col,
html[data-theme="dark"] .tabulator .tabulator-header .tabulator-frozen { background: var(--ifr-sunken); color: var(--ifr-muted); border-color: var(--ifr-line); }
html[data-theme="dark"] .tabulator .tabulator-header .tabulator-col.tabulator-sortable.tabulator-col-sorter-element:hover { background: var(--ifr-line); }
html[data-theme="dark"] .tabulator .tabulator-header .tabulator-col input,
html[data-theme="dark"] .tabulator .tabulator-header .tabulator-col select { background: var(--ifr-surface); border: 1px solid var(--ifr-line-strong); color: var(--ifr-ink); }
html[data-theme="dark"] .tabulator-row,
html[data-theme="dark"] .tabulator-row.tabulator-row-even { background: var(--ifr-surface); color: var(--ifr-ink-2); border-color: var(--ifr-line); }
html[data-theme="dark"] .tabulator-row .tabulator-cell,
html[data-theme="dark"] .tabulator-row .tabulator-frozen { border-color: var(--ifr-line); }
html[data-theme="dark"] .tabulator-row .tabulator-frozen { background: inherit; }
html[data-theme="dark"] .tabulator-row.tabulator-selectable:hover,
html[data-theme="dark"] .grid-shell .tabulator-row.grid-row-link:hover { background: var(--ifr-accent-soft); }
html[data-theme="dark"] .tabulator-row.tabulator-selected { background: rgba(79, 124, 255, .28); }
html[data-theme="dark"] .tabulator .tabulator-footer,
html[data-theme="dark"] .tabulator .tabulator-footer .tabulator-calcs-holder,
html[data-theme="dark"] .tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row,
html[data-theme="dark"] .tabulator .tabulator-header .tabulator-calcs-holder,
html[data-theme="dark"] .tabulator .tabulator-header .tabulator-calcs-holder .tabulator-row { background: var(--ifr-sunken) !important; color: var(--ifr-ink); border-color: var(--ifr-line); }
html[data-theme="dark"] .tabulator .tabulator-footer .tabulator-page { background: var(--ifr-surface); border-color: var(--ifr-line-strong); color: var(--ifr-ink-2); }
html[data-theme="dark"] .tabulator .tabulator-footer .tabulator-page.active { background: var(--ifr-accent); border-color: var(--ifr-accent); color: #fff; }
html[data-theme="dark"] .tabulator .tabulator-footer .tabulator-page-size,
html[data-theme="dark"] .tabulator .tabulator-footer select { background: var(--ifr-surface); border-color: var(--ifr-line-strong); color: var(--ifr-ink); }
html[data-theme="dark"] .tabulator .tabulator-placeholder,
html[data-theme="dark"] .tabulator .tabulator-tableholder .tabulator-placeholder .tabulator-placeholder-contents { color: var(--ifr-muted); }
html[data-theme="dark"] .tabulator .tabulator-row .tabulator-cell.tabulator-row-header { background: var(--ifr-surface); border-color: var(--ifr-line); }
html[data-theme="dark"] .tabulator-group { background: var(--ifr-sunken); border-color: var(--ifr-line); color: var(--ifr-ink); }
html[data-theme="dark"] .tabulator .tabulator-alert { background: rgba(0, 0, 0, .45); }
html[data-theme="dark"] .tabulator .tabulator-alert .tabulator-alert-msg { background: var(--ifr-surface); color: var(--ifr-ink); border-color: var(--ifr-line-strong); }
html[data-theme="dark"] .tabulator-menu,
html[data-theme="dark"] .tabulator-edit-list { background: var(--ifr-surface); border-color: var(--ifr-line-strong); color: var(--ifr-ink-2); }
html[data-theme="dark"] .tabulator-edit-list .tabulator-edit-list-item:hover,
html[data-theme="dark"] .tabulator-edit-list .tabulator-edit-list-item.active { background: var(--ifr-accent); color: #fff; }
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="datetime-local"] { color-scheme: dark; }

/* ------------------------------------------------------------------ */
/* Import and sync: one card a hotel, each in a colour of its own      */
/* ------------------------------------------------------------------ */
/* The colours come first and nothing below sets --sys again. */
.sync-card, .sync-chip { --sys: var(--ifr-accent); }
.sys-c1 { --sys: #3b68e8; }
.sys-c2 { --sys: #e07a10; }
.sys-c3 { --sys: #7c3aed; }
.sys-c4 { --sys: #0d9488; }
.sys-c5 { --sys: #db2777; }
.sys-c6 { --sys: #65a30d; }
.sys-c7 { --sys: #a16207; }
.sys-c8 { --sys: #475569; }

.sync-summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 4px 0; margin-bottom: var(--ifr-2); font-size: .8125rem; color: var(--ifr-muted); list-style: none; }
.sync-summary::-webkit-details-marker { display: none; }
.sync-summary > span:first-of-type { font-weight: 600; color: var(--ifr-ink-2); }
.sync-fold { margin-inline-start: auto; transition: transform .15s; }
.sync-panel[open] .sync-fold { transform: rotate(180deg); }
.sync-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.sync-panel[open] .sync-chips { display: none; }
.sync-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--ifr-radius-pill); border: 1px solid var(--ifr-line); background: var(--ifr-surface); color: var(--ifr-ink-2); font-weight: 600; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sys, var(--ifr-accent)); flex: none; }

.sync-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: var(--ifr-3); margin-bottom: var(--ifr-3); }
.sync-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 10px 14px; font-size: .8125rem; background: var(--ifr-surface); border: 1px solid var(--ifr-line); border-inline-start: 4px solid var(--sys); border-radius: var(--ifr-radius); box-shadow: var(--ifr-shadow); }
@supports (background: color-mix(in srgb, red 10%, white)) {
    .sync-card { background: color-mix(in srgb, var(--sys) 5%, var(--ifr-surface)); border-color: color-mix(in srgb, var(--sys) 28%, var(--ifr-line)); border-inline-start-color: var(--sys); }
    .sync-chip { border-color: color-mix(in srgb, var(--sys) 35%, var(--ifr-line)); background: color-mix(in srgb, var(--sys) 7%, var(--ifr-surface)); }
}
.sync-card.is-failed { background: var(--ifr-bad-soft); border-color: var(--ifr-bad); border-inline-start-color: var(--sys); }
.sync-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.sync-name { font-size: .9375rem; font-weight: 700; color: var(--sys); }
.sync-state { margin-inline-start: auto; font-size: .75rem; color: var(--ifr-muted); display: inline-flex; align-items: center; gap: 4px; }
.sync-state.ok i { color: var(--ifr-good); }
.sync-state.bad { color: var(--ifr-bad); font-weight: 700; }
.sync-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.sync-stat { flex: 1 1 0; min-width: 54px; max-width: 136px; padding: 4px 6px; text-align: center; line-height: 1.3; background: var(--ifr-surface); border: 1px solid var(--ifr-line); border-radius: 10px; }
.sync-stat b { display: block; font-size: 1.0625rem; color: var(--ifr-ink); font-variant-numeric: tabular-nums; }
.sync-stat span { font-size: .6875rem; color: var(--ifr-muted); white-space: nowrap; }
.sync-stat.is-new b { color: var(--sys); }
.sync-stat.is-bad { border-color: var(--ifr-bad); }
.sync-stat.is-bad b { color: var(--ifr-bad); }
.sync-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; font-size: .75rem; color: var(--ifr-muted); }
.sync-error { font-size: .75rem; color: var(--ifr-bad); text-align: start; overflow-wrap: anywhere; }
.sync-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: auto; }
.sync-act { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.sync-act .form-select { width: auto; }
.sync-more > summary { cursor: pointer; font-size: .75rem; color: var(--ifr-muted); }
.sync-more[open] { flex: 1 1 100%; order: 2; }
.sync-more-body { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--ifr-line-strong); display: grid; gap: 4px; font-size: .75rem; color: var(--ifr-ink-2); }



/* What came in with the latest import: a small mark beside its number. */
/* Its cell keeps the number whole and the mark beside it, never "S8-2253…". */
.tabulator-cell:has(.grid-fresh) { text-overflow: clip; }
.grid-fresh {
    display: inline-flex; align-items: center; gap: .3rem;
    margin-inline-start: .4rem; padding: .08rem .5rem;
    border-radius: var(--ifr-radius-pill, 999px);
    background: var(--ifr-good-soft, #dcfce7); color: var(--ifr-good, #15803d);
    border: 1px solid color-mix(in srgb, var(--ifr-good, #15803d) 28%, transparent);
    font-size: .68rem; font-weight: 700; line-height: 1.5; letter-spacing: .02em;
    vertical-align: middle; white-space: nowrap;
}
.grid-fresh i {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--ifr-good, #15803d);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--ifr-good, #15803d) 45%, transparent);
    animation: grid-fresh-pulse 2s ease-out infinite;
}
@keyframes grid-fresh-pulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ifr-good, #15803d) 45%, transparent); }
    70%, 100% { box-shadow: 0 0 0 5px transparent; }
}
@media (prefers-reduced-motion: reduce) { .grid-fresh i { animation: none; } }

/* The pages, above the table as well as below it. */
.grid-pager {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .5rem .75rem; margin-bottom: .5rem;
    background: var(--ifr-sunken); border: 1px solid var(--ifr-line);
    border-radius: var(--ifr-radius, 8px); color: var(--ifr-muted); font-size: .85rem;
}
.grid-pager[hidden] { display: none; }
.grid-pager-where b { color: var(--ifr-ink); }
.grid-pager-buttons { display: inline-flex; gap: .3rem; }
.grid-pager-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    min-width: 34px; height: 32px; padding: 0 .55rem;
    border: 1px solid var(--ifr-line-strong); border-radius: 6px;
    background: var(--ifr-surface); color: var(--ifr-ink); font-size: .84rem; font-weight: 600;
    transition: background .15s, border-color .15s, color .15s;
}
.grid-pager-btn.grid-pager-wide { padding: 0 .8rem; }
.grid-pager-btn:hover:not(:disabled) { background: var(--ifr-accent-soft); border-color: var(--ifr-accent); color: var(--ifr-accent-ink, var(--ifr-accent)); }
.grid-pager-btn:focus-visible { outline: 2px solid var(--ifr-accent); outline-offset: 1px; }
.grid-pager-btn:disabled { opacity: .45; cursor: default; }
@media (max-width: 576px) { .grid-pager-btn.grid-pager-wide span { display: none; } }
