/* ==========================================================================
   base.css  —  styles for the Django CRM/ERM shell (dark theme)
   Place this file at: static/css/base.css
   base.html loads it with the Django static tag.

   SCOPE
   The file has two parts:
     1. The chrome of the application:
            tokens · reset · skip link · top ribbon · module bar · footer
     2. The shared module styles: the furniture that the modules share
        (layout, side panel, tools, sheet, page, cards, tables, tab set,
        notes, print). Refer to the SHARED MODULE STYLES section.
   A module stylesheet (the module_css block of base.html) holds only the
   parts that are special to the module. It comes after this file, thus
   it wins a tie.

   The Django admin also loads this file (templates/admin/base_site.html).
   admin.css resets the shared rules that touch an admin class.

   The tokens below stay available to every module. Use them, so that all
   modules keep one identity.
   ========================================================================== */

/* ---- Palette and design tokens ------------------------------------ */
:root {
    --cream:   #181A1F;   /* app canvas — deep neutral charcoal */
    --navy:    #363b44;   /* ribbon, footer, headings */
    --gold:    #F0BE72;   /* accent, active state */
    --white:   #252932;   /* panels, cards, fields */
    --black:   #000000;

    /* Tints that stay inside the family */
    --ink:        #E8E6DE;                    /* body text */
    --ink-soft:   #A7ACB5;                    /* secondary text */
    --line:       rgba(232, 230, 222, 0.10);
    --line-strong:rgba(232, 230, 222, 0.16);
    --gold-soft:  rgba(240, 190, 114, 0.14); /* active row tint */
    --gold-line:  rgba(240, 190, 114, 0.45);
    --on-navy:    rgba(255, 255, 255, 0.72);  /* muted text on navy */
    --on-navy-dim:rgba(255, 255, 255, 0.10); /* dividers on navy */

    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.20);
    --shadow-md:  0 8px 24px rgba(0, 0, 0, 0.28);

    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --ribbon-h:  60px;
    --context-h: 52px;
    --radius:    12px;
    --radius-sm: 8px;

    /* Shared module tokens */
    --credit:      #7FBF9A;                    /* money or stock that comes in */
    --debit:       #E0785E;                    /* money or stock that goes out */
    --overdue:     #fff38c;                    /* overdue money, or stock that asks for an order */
    --credit-soft: rgba(127, 191, 154, 0.14);
    --debit-soft:  rgba(224, 120, 94, 0.14);
    --rule:        rgba(232, 230, 222, 0.07);  /* table hairline */
    --gold-deep:   #C79A4E;                    /* dark gold: card labels, field labels */
    --tool-h:      36px;                       /* the height of a .tool */
    --tool-action: #808080;                    /* the Info button of the title */
    --sidebar-w:   244px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

/* The page does not bounce when the user scrolls past its top or its
   bottom. Thus the ribbon and the footer do not move off the edge. */
html, body { overscroll-behavior: none; }

/* iOS makes the text larger when the phone turns to landscape. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--cream);
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

code { font-family: var(--font-mono); font-size: 0.9em; background: var(--line); color: var(--ink); padding: 1px 5px; border-radius: 5px; }

button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}


/* The body is a column: ribbon · module bar · layout · footer.
   Put this class on the top element of the module layout. The element
   then takes the free height, and the footer stays at the bottom. The
   element scrolls if its content is higher, thus the content does not
   go below the footer. */
.fill { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: none; }

.ribbon, .context, .footer { flex: 0 0 auto; }

/* ---- Keyboard access ---------------------------------------------- */
:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: 4px;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    background: var(--gold);
    color: var(--navy);
    font-weight: 600;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

.icon { width: 20px; height: 20px; flex: none; stroke-width: 1.6; }

/* ================================================================== */
/*  TOP RIBBON                                                        */
/* ================================================================== */
.ribbon {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--ribbon-h);
    min-height: var(--ribbon-h);
    background: var(--navy);
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
}

/* The brand mark. .brand__mark--logo is the application logo (static/img/icons/pothos.png). */
.brand { display: flex; align-items: center; gap: 12px; flex: none; }
.brand__mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--gold);
    color: var(--navy);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.5px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.brand__mark--logo {
    background: none;
    box-shadow: none;
    border-radius: 0;
    object-fit: contain;
}
.brand__text {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
.brand__text small {
    display: block;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 10px;
    color: var(--on-navy);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Module switch — the signature element of this shell. The active
   module carries a gold marker that joins the ribbon to the bar
   below it, so the current module owns a continuous gold spine.
   The row scrolls sideways on a small screen. Thus the switch does
   not depend on a drawer that a module supplies.
   The .module rules start with .modules, because the Django admin
   also uses the class .module (see templates/admin/base_site.html). */
.modules {
    display: flex;
    align-items: stretch;
    height: 100%;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.modules::-webkit-scrollbar { display: none; }

.modules .module {
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 16px;
    color: var(--on-navy);
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.15s ease, background 0.15s ease;
}
.modules .module:hover { color: var(--gold); background: var(--gold-soft); }
.modules .module .icon { stroke: currentColor; opacity: 0.9; }

.modules .module.is-active { color: var(--ink); }
.modules .module.is-active::after {
    /* the gold spine — reaches the bottom edge of the ribbon */
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 3px;
    background: var(--gold);
    border-radius: 3px 3px 0 0;
}

/* Global search */
/* The basis 0 lets the search shrink before the module switch, thus the
   company switch at its right does not push the modules out of view. */
.search {
    position: relative;
    flex: 1 1 0;
    min-width: 160px;
    max-width: 520px;
    margin-left: auto;
}
.search__field {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.search__field:hover { border-color: var(--gold-line); }
.search__field:focus-within {
    background: var(--white);
    border-color: var(--gold);
}
.search__field .icon { stroke: var(--on-navy); }
.search__field:focus-within .icon { stroke: var(--ink-soft); }
.search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    font-size: 14px;
    outline: none;
}
.search input::placeholder { color: var(--on-navy); }
.search__field:focus-within input { color: var(--ink); }
.search__field:focus-within input::placeholder { color: var(--ink-soft); }
.kbd {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--on-navy);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 5px;
    padding: 2px 6px;
    white-space: nowrap;
}
.search__field:focus-within .kbd { display: none; }

/* Company switch — at the right of the search. The button has the look
   of the search field. The menu has the colours of the ribbon, and each
   item has the look of the button. Thus the menu and the button match. */
.company-switch { position: relative; flex: none; }
.company-switch__btn,
.company-switch__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.company-switch__btn { width: auto; max-width: 220px; }
.company-switch__btn:hover,
.company-switch__btn[aria-expanded="true"],
.company-switch__item:hover { border-color: var(--gold-line); }
.company-switch__item:hover { color: var(--gold); }
.company-switch__btn:focus-visible,
.company-switch__item:focus-visible { outline: none; border-color: var(--gold); }
.company-switch .icon { width: 18px; height: 18px; stroke: var(--on-navy); }
.company-switch__item:hover .icon { stroke: var(--gold); }
.company-switch .caret { width: 16px; height: 16px; margin-left: auto; transition: transform 0.15s ease; }
.company-switch__btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
.company-switch__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A long name pans from left to right on hover or focus, thus the user
   can read all of it. base.js sets --pan (the distance) and --pan-time.
   The inner span must be an inline-block to move. Thus it is an
   inline-block only during the pan, and the ellipsis shows at rest. */
.company-switch__btn:is(:hover, :focus-visible) .company-switch__name,
.company-switch__item:is(:hover, :focus-visible) .company-switch__name { text-overflow: clip; }
.company-switch__btn:is(:hover, :focus-visible) .company-switch__name > span,
.company-switch__item:is(:hover, :focus-visible) .company-switch__name > span {
    display: inline-block;
    transform: translateX(var(--pan, 0));
    transition: transform var(--pan-time, 0s) linear 0.3s;
}
@media (prefers-reduced-motion: reduce) {
    .company-switch__name > span { transition: none !important; }
}

.company-switch__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: max(100%, 240px);
    display: grid;
    grid-template-columns: minmax(0, 1fr);      /* An item can be narrower than its text. */
    gap: 6px;
    padding: 6px;
    background: var(--navy);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}
.company-switch__menu[data-open="true"] { opacity: 1; visibility: visible; transform: translateY(0); }
.company-switch__menu form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 0; min-width: 0; }
.company-switch__item .check { visibility: hidden; stroke: var(--gold); }
.company-switch__item.is-current { border-color: var(--gold-line); background: var(--gold-soft); }
.company-switch__item.is-current .check { visibility: visible; }
.company-switch__sep { height: 1px; background: var(--on-navy-dim); margin: 0 4px; }

/* Ribbon actions and profile */
.ribbon__actions { display: flex; align-items: center; gap: 6px; flex: none; }

/* The general ribbon button. A module also uses this class for a
   drawer button, in the ribbon_lead block of base.html. */
.icon-btn {
    position: relative;
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: var(--on-navy);
    transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--gold-soft); color: var(--gold); }
.icon-btn .icon { stroke: currentColor; }

.dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 2px var(--navy);
}

/* Profile menu */
.profile { position: relative; }
.profile__btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px 4px 4px;
    border-radius: 10px;
    transition: background 0.15s ease;
}
.profile__btn:hover { background: var(--gold-soft); }
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--navy);
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 13px;
    box-shadow: 0 0 0 2px rgba(240, 190, 114, 0.35);
}
/* An avatar shows an image when there is one, else the initials.
   See the avatar tag (shared/templatetags/avatar_tags.py). */
.avatar { flex: none; overflow: hidden; line-height: 1; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* With an image, only the image shows: no gold circle and no ring. */
.avatar:has(img) { background: transparent; box-shadow: none; }
.avatar--sm { width: 24px; height: 24px; font-size: 10px; box-shadow: none; }
.avatar--lg { width: 56px; height: 56px; font-size: 18px; }
.avatar--xl { width: 96px; height: 96px; font-size: 30px; }
.profile__btn .caret { stroke: var(--on-navy); width: 16px; height: 16px; }

.menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}
.menu[data-open="true"] { opacity: 1; visibility: visible; transform: translateY(0); }
.menu__head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu__name { font-weight: 600; color: var(--ink); }
.menu__mail { font-size: 12px; color: var(--ink-soft); }
/* A menu item is an <a>, or a <button> when the action needs a POST
   (sign out). The two share every rule below. The global button reset
   removes the border, the background and the browser font already;
   width and text-align make the button fill the row like a link. */
.menu a, .menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-weight: 500;
    transition: background 0.12s ease;
    width: 100%;
    text-align: left;
}
.menu a:hover, .menu button:hover { background: var(--gold-soft); color: var(--gold); }
.menu a:hover .icon, .menu button:hover .icon { stroke: var(--gold); }
.menu a .icon, .menu button .icon { stroke: var(--ink-soft); width: 18px; height: 18px; }
.menu__sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu form { margin: 0; }
.menu a.is-danger, .menu button.is-danger { color: #E0785E; }
.menu a.is-danger .icon, .menu button.is-danger .icon { stroke: #E0785E; }
.menu a.is-danger:hover, .menu button.is-danger:hover { background: rgba(224, 120, 94, 0.14); color: #E0785E; }
.menu a.is-danger:hover .icon, .menu button.is-danger:hover .icon { stroke: #E0785E; }

/* ================================================================== */
/*  MODULE BAR  (the module fills this, base.html only opens a block) */
/* ================================================================== */
.context {
    height: var(--context-h);
    min-height: var(--context-h);
    background: var(--white);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); min-width: 0; }
.crumbs a:hover { color: var(--gold); }
.crumbs .sep { font-family: var(--font-mono); color: var(--line-strong); }
.crumbs .here { color: var(--ink); font-weight: 600; }
.context__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* The module fills this group with its own buttons. The group scrolls
   sideways if the bar becomes too narrow. The module styles the
   buttons, because each module names them itself. */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.toolbar > * { flex: none; }

/* ================================================================== */
/*  FOOTER                                                            */
/* ================================================================== */
/* The footer always sticks to the bottom of the screen, also when the
   full page scrolls (small screen). */
.footer {
    position: sticky;
    bottom: 0;
    z-index: 40;
    background: var(--navy);
    color: var(--on-navy);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    font-size: 12px;
}
.footer a { color: var(--on-navy); transition: color 0.12s ease; }
.footer a:hover { color: var(--gold); }
.footer__links { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.footer__version { font-family: var(--font-mono); color: rgba(255, 255, 255, 0.45); }


/* ---- Warning ribbon ------------------------------------------------ */
/* The warning of an overlay (modal), e.g. an invoice without bank
   details, or a journal entry that is not balanced. It goes directly
   below the head of the overlay and takes its full width.
       .warn-ribbon    one ribbon. It is not visible when it is empty.
       .warn-ribbons   a stack of ribbons. Each child <p> is one ribbon,
                       thus a script can add one <p> for each warning.
   The icon comes from CSS, thus a script can set the text only. */
.warn-ribbons { display: flex; flex-direction: column; flex: none; }
.warn-ribbons[hidden] { display: none; }
.warn-ribbon,
.warn-ribbons > p {
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    color: #1B1D22;
    background: #F2994A;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}
.warn-ribbon::before,
.warn-ribbons > p::before {
    content: "";
    flex: none;
    width: 20px;
    height: 20px;
    background: currentColor;
    -webkit-mask: var(--warn-icon) center / contain no-repeat;
    mask: var(--warn-icon) center / contain no-repeat;
}
.warn-ribbon:empty,
.warn-ribbon[hidden] { display: none; }
:root {
    /* The same icon as the no-JS banner of base.html. */
    --warn-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6'%3E%3Cpath d='M12 3.5L22 20H2L12 3.5z' stroke-linejoin='round'/%3E%3Cpath d='M12 10.5v4' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='17.2' r='0.9' fill='black' stroke='none'/%3E%3C/svg%3E");
}


/* ---- No-JS warning banner ----------------------------------------- */
.no-js-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: #E0785E;
    color: #1B1D22;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    flex: 0 0 auto;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}
.no-js-banner .icon { stroke: currentColor; width: 20px; height: 20px; }
.no-js-banner strong { font-weight: 700; margin-right: 4px; }

/* base.js adds this class; the banner then leaves the layout. */
.no-js-banner.is-hidden { display: none; }


/* ================================================================== */
/*  RESPONSIVE  (chrome only — the module holds its own breakpoints)  */
/* ================================================================== */
@media (max-width: 1024px) {
    .brand__text { display: none; }
}

@media (max-width: 900px) {
    .ribbon { gap: 12px; padding: 0 14px; }
    .context { padding: 0 16px; gap: 10px; }
    .company-switch__btn { max-width: 180px; }

    /* The module switch shows only the icons. The text stays for a
       screen reader. base.js scrolls the active module into view. */
    .modules .module { padding: 0 12px; gap: 0; font-size: 0; }
    .modules .module.is-active::after { left: 6px; right: 6px; }

    /* A small screen scrolls the full page, not an inner panel. The
       ribbon stays at the top, and the footer stays at the bottom of
       the screen. The module stylesheet also removes the scroll of .main. */
    html, body { height: auto; }
    body { min-height: 100dvh; }
    .fill { overflow: visible; }

    /* The toolbar scrolls sideways, thus it does not go below the
       actions at the right of the module bar. The selector has two
       classes, because a module stylesheet removes the scroll for its
       drop-down menus. These menus are not visible at this width. */
    .context .toolbar { overflow-x: auto; padding: 4px 0; }
    .context__actions { flex: none; }
}

/* The company switch needs the space of the search more. */
@media (max-width: 760px) {
    .search { display: none; }
    .company-switch { margin-left: auto; }
}

@media (max-width: 560px) {
    .ribbon { gap: 8px; padding: 0 10px; }
    .profile__btn .caret { display: none; }

    .search { display: none; }         /* replace with an icon trigger as needed */
    .company-switch__btn { max-width: 150px; }
    .crumbs a, .crumbs .sep { display: none; } /* keep the current page only */
    .footer { flex-wrap: wrap; gap: 8px; }
    .footer__links { gap: 12px; }
}

/* A touch screen. iOS Safari zooms into a field that has text smaller
   than 16px, and the zoom stays after the field loses focus. */
@media (pointer: coarse) {
    input, select, textarea { font-size: 16px !important; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}


/* ##########################################################################
   SHARED MODULE STYLES
   The furniture that the modules share (Accounting, Sales, Inventory):
   the layout, the side panel, the tools, the sheet, the page, the cards,
   the tables, the tab set, the notes and the print rules. The rules come
   after the chrome above, thus they win a tie against the chrome. A
   module stylesheet adds the parts that only the module has.
   Change a rule here, not in a module file, so that all modules stay
   the same.
   ########################################################################## */

/* ================================================================== */
/*  LAYOUT  (the shell of a module page)                              */
/* ================================================================== */
.shell { display: flex; min-height: 0; }

.main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 26px 30px 44px;
}
.page__empty { color: var(--ink-soft); }

/* ================================================================== */
/*  SIDE PANEL                                                        */
/* ================================================================== */
/* The panel stays on the canvas color. Only a hairline divides it from
   the content, thus the figures on the right hold the attention. */
.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--cream);
    border-right: 1px solid var(--line);
    padding: 18px 10px 28px;
    overflow-y: auto;
}

.sidebar__title {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--gold-deep);
    padding: 2px 12px 16px;
}

.nav { display: flex; flex-direction: column; gap: 1px; }

/* The group label carries a rule to the right edge. The rule separates
   the parts of the ledger without a heading that shouts. */
.nav__group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 6px;
    padding: 0 12px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--ink-soft);
    white-space: nowrap;
}
.nav__group::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: var(--line);
}
.nav__group:first-child { margin-top: 0; }

.nav__item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-weight: 500;
    transition: color 0.12s ease, background 0.12s ease;
}
.nav__item:hover { color: var(--ink); background: rgba(232, 230, 222, 0.05); }

/* The script of base.html adds is-active to the item that matches the
   data-page attribute of the body. */
.nav__item.is-active {
    color: var(--gold);
    font-weight: 600;
    background: transparent;
}
.nav__item.is-active::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 9px;
    bottom: 9px;
    width: 2px;
    border-radius: 2px;
    background: var(--gold);
}

.nav__count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-soft);
    background: var(--white);
    border: 1px solid var(--line);
    padding: 0 7px;
    border-radius: 20px;
}
.nav__item.is-active .nav__count {
    color: var(--gold);
    background: var(--gold-soft);
    border-color: var(--gold-line);
}

/* The drawer button in the ribbon. It appears on a small screen only.
   Refer to the media query at 900px. */
.drawer-toggle { display: none; }
.scrim { display: none; }

/* ================================================================== */
/*  TOOLBAR  (module_base.html fills .toolbar with .tool buttons)     */
/* ================================================================== */

/* The toolbar itself should center its controls vertically. */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--tool-h);
}

/* Every tool is a self-contained, vertically and horizontally centered
   control. Explicit line-height prevents font metrics from making the
   label appear a few pixels too high or low. */
.tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    gap: 7px;

    flex: 0 0 auto;
    min-width: 34px;
    height: var(--tool-h);
    box-sizing: border-box;

    padding: 0 13px;
    margin: 0;

    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--ink-soft);

    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;

    text-align: center;
    vertical-align: middle;
    white-space: nowrap;

    appearance: none;
    -webkit-appearance: none;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

/* SVGs/icons don't participate in the text baseline. */
.tool .icon {
    display: block;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    margin: 0;
    stroke: currentColor;
    stroke-width: 1.8;
}

/* If the icon is the only content, it remains exactly centered. */
.tool:has(.icon:only-child) {
    padding-left: 8px;
    padding-right: 12px;
}

/* Text inside a tool is centered independently of font rendering. */
.tool > span,
.tool > label {
    display: block;
    margin: 0;
    padding: 0;
    line-height: 1;
    text-align: center;
}

/* Hover ------------------------------------------------------------- */
.tool:hover {
    background: var(--gold-soft);
    border-color: var(--gold-line);
    color: var(--gold);
}

/* Primary. One button of a bar, at most. It starts the main task of
   the page: a new entry, a new account, or the acceptance of a list. */
.tool--primary,
.tool.is-primary {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy);
}
.tool--primary:hover,
.tool.is-primary:hover {
    background: #F5CB8C;
    border-color: #F5CB8C;
    color: var(--navy);
}
.tool--primary .icon,
.tool.is-primary .icon { stroke: var(--navy); }

/* Ghost ------------------------------------------------------------- */
.tool--ghost { background: transparent; }
.tool--ghost:hover { background: var(--gold-soft); }

.tool--neutral {
    color: var(--ink);
    border-color: var(--ink);
    background: transparent;
}
.tool--neutral:hover { background: var(--gold-soft); }

/* Small. For a button inside a table row. */
.tool--sm {
    min-width: 28px;
    height: 28px;
    padding: 0 10px;
    gap: 6px;
    font-size: 12px;
}
.tool--sm .icon {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
}

/* Disabled ---------------------------------------------------------- */
.tool[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}
.tool[disabled]:hover {
    background: var(--white);
    border-color: var(--line);
    color: var(--ink-soft);
}

/* Divider ----------------------------------------------------------- */
.tool__sep {
    flex: 0 0 1px;
    width: 1px;
    height: 20px;
    margin: 0 4px;
    padding: 0;
    background: var(--line-strong);
    align-self: center;
}

/* If the toolbar contains native buttons alongside .tool elements,
   normalize their box model so they line up identically. */
.toolbar > button,
.toolbar > a {
    box-sizing: border-box;
    vertical-align: middle;
}

/* ------------------------------------------------------------------ */
/*  TOOLBAR MENUS                                                     */
/*                                                                    */
/*  The prefix tbar- keeps these rules away from the .menu rules      */
/*  above, which belong to the profile drop-down of the ribbon.       */
/* ------------------------------------------------------------------ */

/* The chrome above makes .toolbar a scroll container. A scroll
   container clips a panel that hangs below the bar. A module page thus
   removes the scroll. The media queries below keep the bar inside the
   screen instead. */
.context { overflow: visible; }
.toolbar {
    overflow: visible;
    flex-wrap: nowrap;
}

.tbar-menu {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-self: center;
}

/* The caret is smaller than a tool icon. */
.tbar-menu__btn .icon--caret {
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    opacity: 0.75;
}

.tbar-menu__panel {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 70;
    min-width: 196px;
    margin-top: 6px;
    padding: 6px;

    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);

    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition:
        opacity 0.12s ease,
        transform 0.12s ease,
        visibility 0.12s;
}

/* A gap of 6px is between the button and the panel. This bridge
   fills the gap, thus the pointer does not lose the menu. */
.tbar-menu::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 8px;
}

.tbar-menu:hover .tbar-menu__panel,
.tbar-menu:focus-within .tbar-menu__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* The button keeps the hover tone while the panel is open. */
.tbar-menu:hover .tbar-menu__btn,
.tbar-menu:focus-within .tbar-menu__btn {
    background: var(--gold-soft);
    border-color: var(--gold-line);
    color: var(--gold);
}

.tbar-menu__item {
    display: block;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    transition: background 0.12s ease, color 0.12s ease;
}
.tbar-menu__item:hover,
.tbar-menu__item:focus-visible {
    background: var(--gold-soft);
    color: var(--gold);
    outline: none;
}

.tbar-menu__sep {
    display: block;
    height: 1px;
    margin: 6px 8px;
    background: var(--line);
}

/* The last menu is near the right edge. Its panel opens to the left. */
.tbar-menu__panel--right { left: auto; right: 0; }

/* A device without a pointer has no hover. A touch gives focus, thus
   focus-within opens the panel. */
@media (hover: none) {
    .tbar-menu:hover .tbar-menu__panel {
        opacity: 0;
        visibility: hidden;
    }
    .tbar-menu:focus-within .tbar-menu__panel {
        opacity: 1;
        visibility: visible;
    }
}

/* The toolbar has no scroll. The menus therefore go away before the
   bar becomes too wide. The side panel holds the same links. */
@media (max-width: 1100px) {
    .toolbar .tbar-menu { display: none; }
    .toolbar .tool__sep:first-of-type { display: none; }
}

/* ================================================================== */
/*  SHEET  (a dialog that holds a form, e.g. a new account)           */
/* ================================================================== */
.sheet {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--ink);
    box-shadow: var(--shadow-md);
}
.sheet::backdrop {
    background: rgba(24, 26, 31, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.sheet__head { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.sheet__title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.sheet__body { display: grid; gap: 14px; padding: 18px; }

.sheet__foot [data-dialog-cancel] { order: 1; }
.sheet__foot .tool--primary       { order: 2; }
.sheet__errors[hidden] { display: none; }
.sheet__errors p { margin: 0; }


/* ---- Form field --------------------------------------------------- */
.field__label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--gold-deep);
}
.field__control:focus { outline: none; border-color: var(--gold-line); }
.field__control:disabled { opacity: 0.55; cursor: not-allowed; }
/* A multi-line field, e.g. the address of the lead form. */
textarea.field__control { height: auto; padding: 8px 12px; resize: vertical; }

/* ---- Wide sheet: two columns of fields ---------------------------- */
/* Put sheet--wide on the dialog and sheet__body--split on the body.
   A field with the class field--wide takes both columns. */
.sheet--wide { width: min(60vw, calc(100vw - 32px)); }
.sheet__body--split {
    grid-template-columns: 1fr 1fr;
    column-gap: 18px;
    align-items: start;     /* A field stays at the top when the field next to it is higher, e.g. an open search. */
}
@media (max-width: 900px) {
    .sheet--wide { width: calc(100vw - 32px); }
    /* minmax(0, …) and min-width: 0 let a field with a long option
       become narrower than its text. */
    .sheet__body--split { grid-template-columns: minmax(0, 1fr); }
    .sheet__body--split .field__control { min-width: 0; }
}

/* ---- Switch: one option that is on or off -------------------------- */
.switch {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--tool-h);
    cursor: pointer;
}
.switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}
.switch__track {
    position: relative;
    flex: none;
    width: 38px;
    height: 20px;
    border-radius: 999px;
    background: var(--cream);
    border: 1px solid var(--line-strong);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.switch__track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--ink-soft);
    transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .switch__track {
    background: var(--gold-soft);
    border-color: var(--gold-line);
}
.switch input:checked + .switch__track::after {
    transform: translateX(18px);
    background: var(--gold);
}
.switch input:focus-visible + .switch__track {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}
.switch__text { font-size: 13px; color: var(--ink-soft); }
.switch input:checked ~ .switch__text { color: var(--ink); }

/* ---- Toggle: one option of two or more is on, e.g. Internal | Public --- */
/* Each option is a label with a radio button. The radio button stays for
   the keyboard and the screen reader, but it is not visible. */
.toggle {
    display: flex;
    gap: 2px;
    width: fit-content;
    height: var(--tool-h);
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--cream);
}
.toggle__option {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.toggle__option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle__option:hover { color: var(--gold); }
.toggle__option:has(input:checked) { background: var(--gold-soft); color: var(--gold); }
.toggle__option:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ================================================================== */
/*  PAGE                                                              */
/* ================================================================== */
/* Every page takes the full width of the content area. A statement
   thus has the same width as the ledger and the chart of accounts. */
.page,
.page--statement {
    width: 100%;
    max-width: none;
    margin: 0;
}

.page__title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--ink);
}

.page__subtitle {
    margin: 34px 0 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
}

/* ---- The page head ------------------------------------------------- */
/* The head is the same on every page: the title, and one paragraph
   below it. The paragraph tells the reader what the page is, what the
   figures are for, and which period and currency they hold. */
.page__head { margin: 0 0 20px; }

/* The paragraph stays hidden until the user clicks the Info button of
   the title. page_note.js adds the button, and the button sets the
   class is-open on the head. */
.page__head > .page__note {
    display: none;
    margin: 8px 0 0;
    width: 100%;
    max-width: none;
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.55;
}
.page__head.is-open > .page__note { display: block; }

/* The Info button. It is small and grey, thus it does not pull the eye. */
.page__info {
    align-self: center;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin-left: -4px;
    border-radius: 50%;
    color: var(--tool-action);
    transition: color 0.12s ease;
}
.page__info:hover,
.page__info[aria-expanded="true"] { color: var(--ink-soft); }
.page__info .icon { width: 16px; height: 16px; stroke: currentColor; }

.page__note {
    margin: 0;
    max-width: 78ch;
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.55;
}

/* ---- The action bar ------------------------------------------------ */
/* One bar on every page. It goes below the page head and above the
   content, and it moves away when the user scrolls down. Its buttons
   are in this order:
       the primary task of the page, if the page has one
       a separator
       Print and Export, as plain tools
       more tools of the page
   The hint at the right end explains the state of the bar. */
.actionbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    min-height: 62px;
    margin: 0 0 22px;
    padding: 13px 16px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
/* The old name of the bar above the content. It changes nothing now,
   because every bar is at the top. It stays for a template that still
   uses it. */
.actionbar--top { position: static; }

.actionbar__group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.actionbar__hint {
    margin: 0 0 0 auto;
    color: var(--ink-soft);
    font-size: 12px;
}

/* ================================================================== */
/*  BALANCE CARDS                                                     */
/* ================================================================== */
/* Five cards fill the full width of the content area. The tracks stay
   equal, thus the row reads as one band of figures. */
.cards {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 16px 18px 18px;
    background: var(--white);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* The label of the 5th card is long. The value keeps to the bottom
   edge, thus all five figures stay on one line. */
.card__label {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    line-height: 1.4;
    color: var(--gold-deep);
}

/* Money must align on the decimal point. Tabular figures do this. */
.card__value {
    margin-top: auto;
    padding-top: 10px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 24px;
    font-weight: 500;
    letter-spacing: -0.4px;
    white-space: nowrap;
    color: var(--ink);
}
/* Set the currency in the template: <div class="card__value" data-unit="ZAR"> */
.card__value[data-unit]::after {
    content: attr(data-unit);
    margin-left: 6px;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--ink-soft);
    vertical-align: 2px;
}

/* Direction of the money. It touches the figure only. */
.card__value.is-debit,
.card--debit  .card__value { color: var(--debit); }

.card__value.is-credit,
.card--credit .card__value { color: var(--credit); }

/* Money at risk. It is receivable, thus it is not a debit. */
.card__value.is-overdue { color: var(--overdue); }

/* A count is not money. The figure then loses the currency spacing. */
.card__value.is-count,
.card--count .card__value { font-size: 26px; letter-spacing: 0; }

/* ================================================================== */
/*  TABLE  (the base of every table of a module)                      */
/*  Columns: Date · Reference · Account · Amount                      */
/* ================================================================== */
/* Every table takes the full width of the page. The variants below
   change the columns only, not the frame. */
.table {
    width: 100%;
    font-size: 13px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    table-layout: auto;
}
.table th,
.table td { text-align: left; white-space: nowrap; }

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 13px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--line-strong);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.table tbody td {
    border-bottom: 1px solid var(--rule);
    padding: 12px 16px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.12s ease; }
.table tbody tr:hover { background: var(--gold-soft); }

/* Column 1 = Date, column 2 = Reference. Both are machine data. */
.table td:first-child,
.table td:nth-child(2) {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-soft);
}
.table td:nth-child(2) { color: var(--ink); }

/* Column 3 = Account. It takes the free space. */
.table th:nth-child(3),
.table td:nth-child(3) { width: 100%; white-space: normal; }

/* Column 4 = Amount. It stays on the right edge of the row. */
.table th:last-child,
.table td:last-child { text-align: right; }
.table td:last-child {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: var(--ink);
}
/* Add is-debit or is-credit to the amount cell to show the direction. */
.table td.is-debit  { color: var(--debit); }
.table td.is-credit { color: var(--credit); }

/* The empty state. It tells the user what the period holds. */
.table td[colspan] {
    padding: 34px 16px;
    text-align: center;
    color: var(--ink-soft);
}
.table tbody tr:hover td[colspan] { background: transparent; }

/* ---- The foot of a table ------------------------------------------- */
/* The foot holds the figure that the reader looks for first. All
   variants use the same foot. */
.table tfoot td {
    border-top: 1px solid var(--line-strong);
    padding: 13px 16px;
    background: rgba(232, 230, 222, 0.03);
    font-weight: 600;
    color: var(--ink);
}
.table tfoot td[colspan] {
    padding: 13px 16px;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--ink-soft);
}

/* ---- Shared row states --------------------------------------------- */
/*  is-group  a heading row inside the table                            */
/*  is-nest   a line that belongs to the group above it                 */
/*  accounting.css adds is-sum, is-open and is-prior.                   */

/* The group row uses the label of the side panel, thus all lists of
   the module read the same. */
.table tbody tr.is-group td {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--gold-deep);
    background: rgba(232, 230, 222, 0.04);
}
.table tbody tr.is-group:hover td { background: rgba(232, 230, 222, 0.04); }

/* A group row spans the full width. The rule below removes the large
   space of the empty state, which uses the same colspan attribute. */
.table tbody tr.is-group td[colspan] {
    padding: 11px 16px;
    text-align: left;
}

/* The space shows that the line belongs to the group above it. */
.table tbody tr.is-nest td:first-child { padding-left: 34px; }

/* ================================================================== */
/*  ROW BUTTON                                                        */
/* ================================================================== */

/* The button of a table row. Every table uses it, thus all row buttons
   have the same soft tone. It shows an icon only: the title gives the
   tooltip, the aria-label gives the name for a screen reader. */
.row-icon {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.row-icon:hover { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold); }
.row-icon:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.row-icon .icon { width: 16px; height: 16px; stroke: currentColor; }
.row-icon:disabled { opacity: 0.4; cursor: not-allowed; }
.row-icon:disabled:hover { background: none; border-color: var(--line); color: var(--ink-soft); }

/* A label that a screen reader gets, but the screen does not show,
   e.g. the head of a column of row buttons. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ================================================================== */
/*  STATUS PILL  (a state: ok, low, out, idle)                        */
/* ================================================================== */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border: 1px solid var(--line-strong);
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
    color: var(--ink-soft);
}
.status--ok   { color: var(--credit);  border-color: rgba(127, 191, 154, 0.45); background: var(--credit-soft); }
.status--low  { color: var(--overdue); border-color: rgba(255, 243, 140, 0.40); background: rgba(255, 243, 140, 0.12); }
.status--out  { color: var(--debit);   border-color: rgba(224, 120, 94, 0.45);  background: var(--debit-soft); }
.status--idle { color: var(--ink-soft); }

/* ================================================================== */
/*  TAB SET                                                           */
/* ================================================================== */
/* The active tab carries the gold spine of the module switch in the
   ribbon, thus the page keeps the identity of the shell. Each module
   sets the size of .tabset__list and .tabset__tab. */
.tabset__tab:hover { color: var(--gold); background: var(--gold-soft); }

/* The gold spine. It touches the hairline of the row, thus the tab and
   the table below it read as one panel. */
.tabset__tab[aria-selected="true"] { color: var(--ink); }
.tabset__tab[aria-selected="true"]::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: -1px;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--gold);
}

/* journals.js closes a panel with the hidden attribute. The rule below
   is necessary, because a class rule beats the browser default. */
.tabset__panel[hidden] { display: none; }

/* ================================================================== */
/*  NOTES                                                             */
/* ================================================================== */
/* Each note is a card of the module. The list gives the cards one
   column, because a person reads a note as text. */
.notes {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.notes .card { padding: 14px 16px 16px; }
.notes .card__label { margin: 0 0 8px; }

.notes__text {
    margin: 0;
    max-width: 74ch;
    color: var(--ink-soft);
    font-size: 13px;
}
.notes__text + .notes__text { margin-top: 8px; }

/* A wide screen gets two columns. A note is short, thus two columns
   keep the page in one screen. */
@media (min-width: 1240px) {
    .notes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ================================================================== */
/*  PAGE NOTES  (the notes that users write, see _notes.html)          */
/*  The Notes pill · the Commentary and Footnotes cards · the editor   */
/* ================================================================== */

/* The pill at the right end of the page title. It stays grey, because a
   note is extra information, not an alert. */
.notes-pill {
    margin-left: auto;
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 3px 4px 3px 11px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1.2px;
    line-height: 1.5;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink-soft);
}
.notes-pill__count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: 20px;
    background: var(--line);
    color: var(--ink);
    text-align: center;
    letter-spacing: 0;
}
.notes-pill[href]:hover { border-color: var(--line-strong); color: var(--ink); }

/* The two groups below the content of the page. */
.page-notes { display: grid; gap: 22px; margin-top: 34px; }

.note-group__head {
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
}
.note-group__head::marker { color: var(--ink-soft); }

/* A card stays small: the title, three lines of the description, the
   files and one line of data. A click on the card opens the full note. */
.note-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.note-card {
    gap: 8px;
    min-width: 0;
    padding: 12px 14px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.note-card:hover { background: var(--gold-soft); border-color: var(--gold-line); }

.note-card__title { margin: 0; min-width: 0; font-size: 13px; font-weight: 600; }
.note-card__title button {
    display: block;
    max-width: 100%;
    padding: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    font-weight: inherit;
    color: var(--ink);
}

.note-card__meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2px 10px;
    margin: auto 0 0;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-soft);
}

/* The rich text of a note: the description in a card and in the overlay. */
.note-text { font-size: 13px; line-height: 1.55; color: var(--ink); overflow-wrap: anywhere; }
.note-text :is(p, ol, ul) { margin: 0 0 6px; }
.note-text :is(ol, ul) { padding-left: 20px; }
.note-text > :last-child { margin-bottom: 0; }
.note-text a[href] { color: var(--gold); text-decoration: underline; }

/* In a card, the description shows three lines at most. */
.note-card__text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    max-height: 4.65em;
    overflow: hidden;
    font-size: 12px;
    color: var(--ink-soft);
}
.note-card__text :is(p, ol, ul) { margin: 0; }

/* A supporting file. The icon is a paper clip. */
.note-file {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--gold);
}
.note-file:hover { text-decoration: underline; }

/* The overlays: a value that the user reads, and the hint of the form. */
.note-read { margin: 0; font-size: 13px; color: var(--ink); }
.note-hint { margin: 0; font-size: 12px; line-height: 1.5; color: var(--ink-soft); }

/* The Quill editor. quill.snow.css has a light theme. These rules give
   it the colors of the module. The id wins over the rules of Quill. */
#note-new .ql-toolbar.ql-snow,
#note-new .ql-container.ql-snow { border-color: var(--line); background: var(--cream); }
#note-new .ql-toolbar.ql-snow { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
#note-new .ql-container.ql-snow {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--ink);
}
#note-new .ql-container.ql-snow:focus-within { border-color: var(--gold-line); }
#note-new .ql-editor { min-height: 140px; }
#note-new .ql-editor:focus-visible { outline: none; }
#note-new .ql-editor.ql-blank::before { color: var(--ink-soft); font-style: normal; }
#note-new .ql-snow .ql-stroke { stroke: var(--ink-soft); }
#note-new .ql-snow .ql-fill { fill: var(--ink-soft); }
#note-new .ql-snow button:hover .ql-stroke,
#note-new .ql-snow button.ql-active .ql-stroke { stroke: var(--gold); }
#note-new .ql-snow button:hover .ql-fill,
#note-new .ql-snow button.ql-active .ql-fill { fill: var(--gold); }
#note-new .ql-snow .ql-tooltip {
    background: var(--white);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-md);
    color: var(--ink);
}
#note-new .ql-snow .ql-tooltip input[type=text] {
    background: var(--cream);
    border-color: var(--line);
    color: var(--ink);
}
#note-new .ql-snow .ql-tooltip a { color: var(--gold); }

/* Paper gets the footnotes only. A comment is for the screen. */
@media print {
    .note-card { break-inside: avoid; }
    .note-group__head, .note-card__title button, .note-text { color: #000000; }
    .note-card__meta { color: #333333; }
}

/* ================================================================== */
/*  RESPONSIVE                                                        */
/* ================================================================== */
@media (max-width: 1240px) {
    .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    /* The side panel becomes a drawer. base.js sets data-drawer on the
       body when the user operates the button or the scrim. */
    .drawer-toggle { display: grid; }

    .sidebar {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        z-index: 60;
        width: 272px;
        background: var(--white);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-md);
    }
    body[data-drawer="true"] .sidebar { transform: translateX(0); }

    .scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 50;
        background: rgba(24, 26, 31, 0.55);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s;
    }
    body[data-drawer="true"] .scrim { opacity: 1; visibility: visible; }

    /* The full page scrolls on a small screen. Refer to RESPONSIVE above. */
    .main { padding: 20px; overflow: visible; }
    .page__subtitle { margin-top: 28px; }
    .card__value { font-size: 22px; }

    .actionbar { gap: 10px; }
    .actionbar__hint { margin-left: 0; }

    /* Every table scrolls sideways. Thus each column keeps its content,
       and no column takes the free width. The block display removes the
       corner clip, thus the radius moves to a scroll frame that the
       border makes. The relative position keeps a visually-hidden label
       inside the scroll frame. */
    .table {
        display: block;
        position: relative;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table thead th { position: static; }
    .table th, .table td { width: auto; white-space: nowrap; }
}

@media (max-width: 560px) {
    .toolbar { gap: 6px; }
    .tool { padding-left: 10px; padding-right: 10px; }
    .tool:has(.icon:only-child) { padding-left: 7px; padding-right: 7px; }
    .tool__sep { margin-left: 2px; margin-right: 2px; }

    .actionbar { padding: 11px 12px; }
    .actionbar__group { gap: 6px; }

    .table tbody tr.is-nest td:first-child { padding-left: 26px; }

    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .card { padding: 13px 14px 15px; }
    /* A large amount pushes the currency to a second line. The amount
       itself stays on one line. */
    .card__value {
        font-size: 19px;
        padding-top: 8px;
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        column-gap: 6px;
    }
    .card__value[data-unit]::after { margin-left: 0; }
}

/* ================================================================== */
/*  PRINT  (a module page goes into a file or to an auditor)          */
/* ================================================================== */
@media print {
    .shell { display: block; }
    .main { padding: 0; overflow: visible; }
    body { background: #FFFFFF; color: #000000; }

    .page__title, .page__subtitle, .card__value { color: #000000; }
    .page__note { color: #333333; }
    .page__head > .page__note { display: block; }   /* Paper always shows the paragraph. */
    .card__label { color: #7A5B22; }
    .card, .table {
        background: #FFFFFF;
        border: 1px solid #999999;
        box-shadow: none;
    }
    .table thead { display: table-header-group; }
    .table tfoot { display: table-footer-group; }
    .table tbody tr { page-break-inside: avoid; }

    .table td { color: #000000; }
    .table tbody tr.is-group td { color: #7A5B22; background: #FFFFFF; }

    .notes .card { break-inside: avoid; }
    .notes__text { color: #000000; }

    /* Ink is expensive and a gold pill prints grey. */
    .status { color: #000000; border-color: #999999; background: #FFFFFF; }
}


/* ---- Phone input: the country code (see js/phone.js) ---------------- */
/* The flag emoji of the font show only the flags. Other text keeps its font. */
@font-face {
    font-family: "Twemoji Country Flags";
    src: url("../vendor/flags/TwemojiCountryFlags.woff2") format("woff2");
    unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E007F;
    font-display: swap;
}
.phone {
    position: relative;
    display: flex;
    min-width: 0;
}
.phone > input { flex: 1; min-width: 0; padding-left: 86px; }
/* The country shows at the left side, inside the border of the input.
   The select is on top of it, but transparent: a click opens the list. */
.phone__country,
.phone__select {
    position: absolute;
    top: 1px;
    bottom: 1px;
    left: 1px;
    width: 76px;
}
.phone__country {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    border-right: 1px solid var(--line);
    font-family: "Twemoji Country Flags", var(--font-mono);
    font-size: 12px;
    color: var(--ink-soft);
    white-space: nowrap;
    pointer-events: none;
}
.phone__select {
    z-index: 1;
    opacity: 0;
    cursor: pointer;
    font-family: "Twemoji Country Flags", var(--font-sans);
}
.phone:has(.phone__select:focus-visible) > input { border-color: var(--gold-line); }
.phone__select:disabled { cursor: not-allowed; }
