﻿/*
    The signed-in shell: dark rail on the left, white bar over the content.

    A file of its own rather than more of site.css, which is already long enough that finding
    anything in it is a search. Loaded after site.css by _Head, so it may rely on the tokens and
    override the components it needs to.

    site.css still carries the previous shell's rules — .admin-layout, .sidebar*, .topbar*,
    .auth-layout, .auth-card — and no markup references any of them any more. They are dead rather
    than harmful, and deleting 400 lines out of the middle of a 100KB stylesheet is its own change
    with its own way of going wrong, so it is one: see docs/_calisma-plani.md.
*/

.shell {
    display: grid;
    grid-template-columns: 14.75rem 1fr;
    min-height: 100vh;
    background: var(--bg);
}

/* ==========================================================================================
   Rail
   ========================================================================================== */

.shell-rail {
    background: var(--brand-900);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    min-width: 0;
}

.shell-brand {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: 1.25rem 1.125rem 1.125rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.shell-brand-mark {
    width: 1.875rem;
    height: 1.875rem;
    border-radius: .5rem;
    flex: none;
}

/*
    An uploaded logo (BRD-002). The Fleent mark above is square and can be given both dimensions;
    a customer's may be any proportion, so this bounds it and lets the width follow the height.
*/
.shell-brand-mark.is-custom {
    width: auto;
    max-width: 7rem;
    object-fit: contain;
}

.shell-brand-text {
    min-width: 0;
}

.shell-brand-name {
    display: block;
    font-size: .9375rem;
    font-weight: 600;
    letter-spacing: -.2px;
    color: #fff;
    line-height: 1.2;
}

/* The organisation, in mono and small caps: it is a label, not a heading. */
.shell-brand-org {
    display: block;
    font-family: var(--font-mono);
    font-size: .65625rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #6e9a94;
    margin-top: .125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell-nav {
    padding: .875rem .625rem;
    display: flex;
    flex-direction: column;
    gap: .125rem;
    flex: 1;
    overflow-y: auto;
}

.shell-nav-group {
    font-family: var(--font-mono);
    font-size: .65625rem;
    font-weight: 500;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #5e8a84;
    padding: .75rem .75rem .5rem;
    margin-top: .375rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.shell-nav-group:first-child {
    border-top: 0;
    margin-top: 0;
}

.shell-nav-item {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem .75rem;
    border-radius: .5rem;
    font-size: .8125rem;
    color: #9fbdb9;
    text-decoration: none;
    transition: background-color .12s, color .12s;
}

.shell-nav-item:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
    text-decoration: none;
}

.shell-nav-item.is-active {
    background: var(--brand-600);
    color: #fff;
    font-weight: 600;
}

/*
    The design gives each item a coloured dot reporting how much attention that area needs. There
    is no such signal yet, so the dot is a position marker: dim, and lit on the current page.
*/
.shell-nav-dot {
    width: .4375rem;
    height: .4375rem;
    border-radius: 50%;
    flex: none;
    background: rgba(255, 255, 255, .22);
}

.shell-nav-item.is-active .shell-nav-dot {
    background: #fff;
}

.shell-nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell-rail-foot {
    padding: .875rem 1.125rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.shell-health {
    display: flex;
    align-items: center;
    gap: .5625rem;
    font-size: .75rem;
    color: #9fbdb9;
}

.shell-health-dot {
    width: .4375rem;
    height: .4375rem;
    border-radius: 50%;
    background: #3fbf8f;
    box-shadow: 0 0 0 3px rgba(63, 191, 143, .18);
    flex: none;
}

.shell-build {
    display: block;
    font-family: var(--font-mono);
    font-size: .65625rem;
    color: #557e79;
    margin-top: .625rem;
}

/* ==========================================================================================
   Main column
   ========================================================================================== */

.shell-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.shell-topbar {
    height: 3.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.shell-topbar-spacer {
    flex: 1;
}

/* Only a drawer handle, and only where there is a drawer. */
.shell-rail-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: .5rem;
    background: var(--surface-3);
    color: var(--text-muted);
    cursor: pointer;
    flex: none;
}

/* ---- user menu ------------------------------------------------------------------------------
   A <details> so that it opens with the keyboard and without script; the panel is placed under
   its summary like the design's (250px, right-aligned). _ThemeScript closes it on an outside
   click and on Esc.
   ------------------------------------------------------------------------------------------- */

.shell-user-menu {
    position: relative;
    flex: none;
}

.shell-user {
    display: flex;
    align-items: center;
    gap: .5625rem;
    max-width: 16rem;
    padding: .25rem .375rem .25rem .25rem;
    border-radius: .5625rem;
    cursor: pointer;
    list-style: none;
    color: inherit;
}

.shell-user::-webkit-details-marker {
    display: none;
}

.shell-user:hover,
.shell-user-menu[open] > .shell-user {
    background: var(--surface-2);
}

.shell-user:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

.shell-user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--brand-600);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 600;
    flex: none;
}

.shell-user-text {
    min-width: 0;
    line-height: 1.25;
}

.shell-user-name {
    display: block;
    font-size: .78125rem;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell-user-caret {
    width: .4375rem;
    height: .4375rem;
    margin: -.25rem .125rem 0 .25rem;
    border-right: 1.6px solid var(--text-muted);
    border-bottom: 1.6px solid var(--text-muted);
    transform: rotate(45deg);
    flex: none;
}

.shell-user-panel {
    position: absolute;
    top: calc(100% + .375rem);
    right: 0;
    width: 15.625rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .75rem;
    box-shadow: 0 18px 44px rgba(16, 24, 32, .2);
    overflow: hidden;
    z-index: 70;
}

.shell-user-panel-head {
    padding: .75rem .875rem;
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: .71875rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell-user-panel-items,
.shell-user-panel-foot {
    padding: .375rem;
}

.shell-user-panel-foot {
    border-top: 1px solid var(--border-subtle);
}

.shell-user-panel-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: .5rem .625rem;
    border: none;
    border-radius: .4375rem;
    background: none;
    font: inherit;
    font-size: .78125rem;
    font-weight: 500;
    color: var(--text);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.shell-user-panel-item:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.shell-user-panel-item.is-danger {
    color: var(--danger-text);
}

.shell-user-panel-item.is-danger:hover {
    background: var(--danger-bg);
}

/* -------------------------------------------------------------------------------------------
   The working scope selector (F1-07): a <details> beside the user menu, built the same way. The
   summary reads "Scope: All Authorized Branches (N)", or the branch's name, highlighted, once the
   work is narrowed to one.
   ------------------------------------------------------------------------------------------- */

.shell-scope-menu {
    position: relative;
    flex: none;
    margin-right: .5rem;
}

.shell-scope {
    display: flex;
    align-items: center;
    gap: .375rem;
    max-width: 22rem;
    padding: .4375rem .625rem;
    border: 1px solid var(--border);
    border-radius: .5625rem;
    background: var(--surface);
    font-size: .78125rem;
    cursor: pointer;
    list-style: none;
    color: var(--text);
}

.shell-scope::-webkit-details-marker {
    display: none;
}

.shell-scope:hover,
.shell-scope-menu[open] > .shell-scope {
    background: var(--surface-2);
}

.shell-scope:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

.shell-scope-label {
    color: var(--text-muted);
    white-space: nowrap;
}

.shell-scope-value {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Narrowed to one branch: the button says so with the brand colour, as the design does. */
.shell-scope.is-narrowed {
    border-color: var(--brand-300);
    background: var(--brand-100);
    color: var(--brand-800);
}

.shell-scope.is-narrowed .shell-scope-label {
    color: var(--brand-700);
}

.shell-scope-panel {
    position: absolute;
    top: calc(100% + .375rem);
    right: 0;
    width: 18.75rem;
    max-width: calc(100vw - 2rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .75rem;
    box-shadow: 0 18px 44px rgba(16, 24, 32, .2);
    overflow: hidden;
    z-index: 70;
}

.shell-scope-title {
    padding: .75rem .875rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.shell-scope-options {
    padding: .375rem;
    max-height: 20rem;
    overflow-y: auto;
}

.shell-scope-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .0625rem;
    width: 100%;
    padding: .5rem .625rem;
    border: none;
    border-radius: .4375rem;
    background: none;
    font: inherit;
    font-size: .78125rem;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.shell-scope-option:hover {
    background: var(--surface-2);
}

.shell-scope-option.is-selected {
    background: var(--brand-100);
    color: var(--brand-800);
}

.shell-scope-option-name {
    font-weight: 500;
}

.shell-scope-option-sub {
    font-family: var(--font-mono);
    font-size: .6875rem;
    color: var(--text-muted);
}

.shell-scope-note {
    margin: 0;
    padding: .625rem .875rem .75rem;
    border-top: 1px solid var(--border-subtle);
    font-size: .71875rem;
    line-height: 1.4;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    /* Room for the rail button and the user menu: the label gives way, the value stays. */
    .shell-scope-label {
        display: none;
    }
}

.shell-content {
    padding: 1.5rem 1.5rem 6rem;
    /* backwards, not both: a transform left on after the animation would make this the containing
       block of every position: fixed descendant (an island's drawer or overlay) instead of the window. */
    animation: shell-fade .22s ease backwards;
}

@keyframes shell-fade {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .shell-content { animation: none; }
}

/* ==========================================================================================
   Narrow windows: the rail becomes a drawer.
   ========================================================================================== */

@media (max-width: 48rem) {
    .shell {
        grid-template-columns: 1fr;
    }

    .shell-rail {
        position: fixed;
        top: 0;
        left: 0;
        width: 14.75rem;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform .18s ease;
    }

    .shell.rail-open .shell-rail {
        transform: none;
        box-shadow: 0 0 40px rgba(7, 16, 15, .45);
    }

    .shell.rail-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(7, 16, 15, .45);
        z-index: 30;
    }

    .shell-rail-toggle {
        display: inline-flex;
    }

    .shell-user-text {
        display: none;
    }

    .shell-content {
        padding: 1.25rem 1rem 5rem;
    }

    .shell-topbar {
        padding: 0 1rem;
    }
}

/* ==========================================================================================
   Signed-out pages: the teal pitch panel beside the form.
   ========================================================================================== */

.auth-split {
    display: grid;
    grid-template-columns: 1fr 34rem;
    min-height: 100vh;
}

.auth-pitch {
    background: linear-gradient(160deg, #0b3b37 0%, #0f766e 62%, #127f72 100%);
    padding: 4rem 4.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

/* Two thin rings bleeding off the right edge — the design's only ornament. */
.auth-pitch-ring {
    position: absolute;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 50%;
    pointer-events: none;
}

.auth-pitch-ring-lg {
    right: -8.75rem;
    top: 7.5rem;
    width: 32.5rem;
    height: 32.5rem;
}

.auth-pitch-ring-sm {
    right: -2.5rem;
    top: 16.25rem;
    width: 20rem;
    height: 20rem;
    border-color: rgba(255, 255, 255, .10);
}

.auth-pitch-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    position: relative;
}

.auth-pitch-mark {
    width: 2.125rem;
    height: 2.125rem;
    border-radius: .5625rem;
    background: #fff;
    color: var(--brand-600);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.0625rem;
    font-weight: 700;
}

/*
    An uploaded sign-in logo, in place of the lettered mark (BRD-002). Bounded rather than sized:
    a customer's logo can be any proportion, and letting it set its own width would push the name
    off the panel.
*/
.auth-pitch-logo {
    max-width: 9rem;
    max-height: 2.5rem;
    object-fit: contain;
}

.auth-pitch-name {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -.2px;
    color: #fff;
}

.auth-pitch-body {
    position: relative;
    max-width: 32.5rem;
}

.auth-pitch-kicker {
    font-family: var(--font-mono);
    font-size: .8125rem;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: #8fd8cd;
    margin: 0 0 1.25rem;
}

.auth-pitch-head {
    font-size: 2.75rem;
    line-height: 1.14;
    font-weight: 600;
    letter-spacing: -1.1px;
    color: #fff;
    margin: 0 0 1.25rem;
    text-wrap: pretty;
}

.auth-pitch-sub {
    font-size: 1rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, .72);
    margin: 0;
    max-width: 27.5rem;
    text-wrap: pretty;
}

.auth-pitch-facts {
    display: flex;
    gap: 2.25rem;
    position: relative;
    margin: 0;
}

.auth-pitch-facts dt {
    font-family: var(--font-mono);
    font-size: 1.375rem;
    font-weight: 600;
    color: #fff;
}

.auth-pitch-facts dd {
    font-size: .75rem;
    color: rgba(255, 255, 255, .6);
    margin: .125rem 0 0;
}

/* ---- the form column --------------------------------------------------------------------- */

.auth-panel {
    background: var(--surface);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    padding: 3rem 4.5rem;
    min-width: 0;
}

.auth-panel-inner {
    width: 100%;
    max-width: 25rem;
    margin: 0 auto;
}

.auth-theme-btn {
    position: absolute;
    top: 1.75rem;
    right: 2rem;
    padding: .5rem;
    border-radius: .5rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-faint);
    cursor: pointer;
    line-height: 0;
}

.auth-theme-btn:hover {
    border-color: var(--input-border);
    color: var(--text-muted);
}

.auth-title {
    font-size: 1.625rem;
    font-weight: 600;
    letter-spacing: -.5px;
    color: var(--text);
    margin: 0 0 .375rem;
}

.auth-subtitle {
    font-size: .875rem;
    color: var(--text-muted);
    margin: 0 0 1.75rem;
}

.auth-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: .375rem;
}

.auth-label-row .form-label {
    margin-bottom: 0;
}

.auth-label-row .auth-footer-link {
    font-size: .8rem;
    margin: 0;
}

.btn-tall {
    height: 3rem;
}

.auth-note {
    margin-top: 1.625rem;
    padding: .75rem .875rem;
    border: 1px solid var(--border);
    border-radius: .5rem;
    background: var(--surface-2);
    font-size: .78125rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.auth-product {
    margin-top: 1.5rem;
    font-family: var(--font-mono);
    font-size: .6875rem;
    color: var(--text-faint);
    text-align: center;
}

/*
   Below roughly 62rem the pitch panel would squeeze the form rather than inform anyone, so it
   goes and the form takes the window. Nothing is lost: it carries no control.
*/
@media (max-width: 62rem) {
    .auth-split {
        grid-template-columns: 1fr;
    }

    .auth-pitch {
        display: none;
    }

    .auth-panel {
        padding: 3rem 1.5rem;
    }
}

/* ==========================================================================================
   The application surface

   Page headers, cards, tables and chips, tuned to the Fleent design. These are the classes every
   module page already uses, so tuning them here moves all of them at once rather than sixteen
   files being edited to say the same thing.

   Density is deliberate. UX-004 asks for compact rows, around 32-36px, because these screens are
   read by people working a list rather than browsing one; UX-009 is why every state chip carries a
   word and not only a colour.
   ========================================================================================== */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.125rem;
}

.page-header-left {
    min-width: 0;
}

.page-title {
    font-size: 1.3125rem;
    font-weight: 700;
    letter-spacing: -.4px;
    color: var(--text);
    margin: 0;
}

.page-subtitle {
    font-size: .8125rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin: .25rem 0 0;
    max-width: 56rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex: none;
}

/* ---- Administration page ------------------------------------------------------------------
   docs/ui/mockup-screen-inventory.md 2.25: one title over every setup screen, a 250px grouped
   menu on the left and the screen on the right. The screen keeps its own page header inside the
   right column. Below the drawer breakpoint the menu sits above the screen.
   ------------------------------------------------------------------------------------------- */

.admin-header {
    margin-bottom: 1rem;
}

.admin-title {
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -.4px;
    color: var(--text);
    margin: 0;
}

.admin-subtitle {
    font-size: .8125rem;
    color: var(--text-muted);
    margin: .25rem 0 0;
}

.admin-layout {
    display: grid;
    grid-template-columns: 15.625rem minmax(0, 1fr);
    gap: .875rem;
    align-items: start;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .75rem;
    padding: .5rem;
}

.admin-nav-group {
    padding: .75rem .75rem .25rem;
    font-size: .65625rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.admin-nav-item {
    display: block;
    padding: .5625rem .75rem;
    border-radius: .5rem;
    font-size: .8125rem;
    color: var(--text);
    text-decoration: none;
}

.admin-nav-item:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.admin-nav-item.is-active {
    background: var(--brand-50);
    color: var(--brand-700);
    font-weight: 600;
}

.admin-content {
    min-width: 0;
}

@media (max-width: 48rem) {
    .admin-layout {
        grid-template-columns: 1fr;
    }
}

/* ---- cards -------------------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .75rem;
    overflow: hidden;
}

.card-padded {
    padding: .9375rem 1rem;
}

/* ---- tables ------------------------------------------------------------------------------- */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .75rem;
    overflow: hidden;
    font-size: .8125rem;
}

.table-th {
    text-align: left;
    font-size: .71875rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: .625rem .75rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-2);
    white-space: nowrap;
}

/*
   GRD-005 wants the header to stay put on a long list. Not done here: position:sticky inside a
   table that is itself the rounded, overflow:hidden card resolves against the wrong containing
   block and lands the header on top of the first rows. It needs the table to sit in a scroll
   container of its own, which is a change to the markup of every list page rather than a line of
   CSS — see docs/_calisma-plani.md.
*/

.table-td {
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text);
    vertical-align: middle;
}

.table-row:last-child .table-td {
    border-bottom: 0;
}

.table-row:hover .table-td {
    background: var(--brand-50);
}

/* Numbers that are compared down a column line up, so they are set in the mono face. */
.table-num,
.table-td-num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

/* ---- state chips -------------------------------------------------------------------------- */

.badge-success,
.badge-warning,
.badge-danger,
.badge-neutral,
.badge-info {
    display: inline-flex;
    align-items: center;
    gap: .3125rem;
    height: 1.375rem;
    padding: 0 .5625rem;
    border-radius: .375rem;
    font-size: .71875rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-text); }
.badge-neutral { background: var(--surface-3);  color: var(--text-muted); }
.badge-info    { background: var(--info-bg);    color: var(--info-text); }

/* ---- the empty state ---------------------------------------------------------------------- */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .75rem;
}

/* ---- stat tiles ---------------------------------------------------------------------------
   The design's KPI row: a label, one large figure, and a line of context under it.
   ------------------------------------------------------------------------------------------ */

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: .75rem;
    margin-bottom: 1.125rem;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .6875rem;
    padding: .9375rem 1rem;
    min-width: 0;
}

.stat-label {
    display: block;
    font-size: .75rem;
    color: var(--text-muted);
    margin-bottom: .375rem;
}

.stat-value {
    display: block;
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* A name rather than a number: the mono face and the tabular figures buy nothing, and a long one
   has to be allowed to wrap instead of pushing the tile wider. */
.stat-value-text {
    font-family: var(--font-sans);
    font-size: 1.125rem;
    line-height: 1.3;
    word-break: break-word;
}

.stat-value-of {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-faint);
}

.stat-meta {
    display: block;
    font-size: .71875rem;
    color: var(--text-faint);
    margin-top: .4375rem;
}

/* ==========================================================================================
   Form controls, buttons and the smaller shared pieces

   Metrics from the Fleent design: 44px fields, 38px buttons, 8px corners, and a border that is
   visible without being loud. Colours already arrived with the tokens; this is the geometry.
   ========================================================================================== */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: .78125rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: .375rem;
}

.form-label-required::after {
    content: " *";
    color: var(--danger);
}

.form-input,
select.form-input,
textarea.form-input {
    width: 100%;
    height: 2.75rem;
    border: 1px solid var(--input-border);
    border-radius: .5rem;
    background: var(--input-bg);
    padding: 0 .8125rem;
    font-family: var(--font-sans);
    font-size: .875rem;
    color: var(--text);
    outline: none;
    transition: border-color .12s, box-shadow .12s;
}

textarea.form-input {
    height: auto;
    min-height: 6rem;
    padding: .625rem .8125rem;
    line-height: 1.5;
}

.form-input:focus {
    border-color: var(--brand-600);
    box-shadow: 0 0 0 3px var(--ring);
}

.form-input:disabled {
    background: var(--surface-3);
    color: var(--text-faint);
    cursor: not-allowed;
}

.form-input-error,
.form-input-error:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(180, 35, 24, .12);
}

.form-error {
    display: block;
    font-size: .75rem;
    color: var(--danger-text);
    margin-top: .25rem;
}

.form-hint {
    font-size: .75rem;
    line-height: 1.45;
    color: var(--text-faint);
    margin-top: .25rem;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: .625rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: .625rem;
    margin-bottom: .875rem;
}

.form-checkbox {
    width: 1rem;
    height: 1rem;
    flex: none;
    accent-color: var(--brand-600);
    cursor: pointer;
}

/* ---- buttons ------------------------------------------------------------------------------ */

.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    height: 2.375rem;
    padding: 0 1rem;
    border-radius: .5rem;
    font-family: var(--font-sans);
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background-color .12s, border-color .12s, color .12s;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-ghost:hover,
.btn-danger:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--brand-600);
    color: #fff;
}

.btn-primary:hover { background: var(--brand-700); color: #fff; }
.btn-primary:active { background: var(--brand-800); }

.btn-secondary {
    background: var(--surface);
    border-color: var(--input-border);
    color: var(--text);
}

.btn-secondary:hover { border-color: var(--brand-600); background: var(--brand-50); color: var(--text); }

.btn-ghost {
    background: none;
    color: var(--text-muted);
}

.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover { background: var(--danger-text); color: #fff; }

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-ghost:disabled,
.btn-danger:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-sm {
    height: 2rem;
    padding: 0 .75rem;
    font-size: .75rem;
}

.btn-full {
    width: 100%;
}

.btn-tall {
    height: 3rem;
    font-size: .90625rem;
}

/* ---- breadcrumb --------------------------------------------------------------------------- */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: .375rem;
    font-size: .75rem;
    color: var(--text-faint);
    margin-bottom: .625rem;
}

.breadcrumb-item {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb-item:hover {
    color: var(--brand-600);
}

.breadcrumb-item-active {
    color: var(--text);
    font-weight: 500;
}

.breadcrumb-sep {
    color: var(--text-faint);
}

/* ---- card internals ----------------------------------------------------------------------- */

.card-body {
    padding: 1.125rem 1.25rem;
}

.card-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 .875rem;
}

.section-title {
    font-size: .8125rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--text-muted);
    margin: 1.5rem 0 .625rem;
}

/* ---- detail rows -------------------------------------------------------------------------- */

.detail-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: .875rem 1.5rem;
}

.detail-row {
    min-width: 0;
}

.detail-label {
    display: block;
    font-size: .71875rem;
    color: var(--text-muted);
    margin-bottom: .125rem;
}

.detail-value {
    display: block;
    font-size: .875rem;
    color: var(--text);
    word-break: break-word;
}

/* ---- table extras ------------------------------------------------------------------------- */

/* A table is allowed to scroll sideways when its columns genuinely do not fit; the page is not
   (UX-003). This is the only element that carries that permission. */
.table-container {
    overflow-x: auto;
    border-radius: .75rem;
}

.table-td-muted {
    color: var(--text-muted);
}

.table-th-action,
.table-td-action {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}

.empty-state-text {
    font-size: .875rem;
}

/* ---- alerts ------------------------------------------------------------------------------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    border: 1px solid transparent;
    border-radius: .625rem;
    padding: .8125rem 1rem;
    font-size: .8125rem;
    line-height: 1.5;
}

.auth-error-banner {
    border: 1px solid rgba(180, 35, 24, .25);
    background: var(--danger-bg);
    color: var(--danger-text);
    border-radius: .625rem;
    padding: .75rem .875rem;
    font-size: .8125rem;
    margin-bottom: 1rem;
}

.auth-footer-link {
    color: var(--brand-600);
    font-size: .8125rem;
    text-decoration: none;
}

.auth-footer-link:hover {
    text-decoration: underline;
}

/* ---- utilities the pages already use ------------------------------------------------------ */

.font-mono { font-family: var(--font-mono); }
.text-sm   { font-size: .75rem; }
.mt-4      { margin-top: 1rem; }

/* ---- a long form with a summary beside it (the vehicle form, F2-11) -------------------------
   Direction-independent: logical properties only (K-58). A block marked .form-conditional is shown
   or hidden by a page's small script through the hidden attribute; the rule below makes hidden win
   over the display of the grid classes the block may also carry. */

.form-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 21.25rem;
    gap: 1.25rem;
    align-items: start;
}

.form-split-main > .card,
.form-split-main > .form-hint {
    margin-block-end: 1rem;
}

.form-split-side {
    position: sticky;
    inset-block-start: 1rem;
}

@media (max-width: 64rem) {
    .form-split {
        grid-template-columns: minmax(0, 1fr);
    }

    .form-split-side {
        position: static;
    }
}

.form-conditional[hidden] {
    display: none !important;
}

/* An amount and its currency, or a value and its unit, side by side. */
.form-money {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.form-money > .form-input:first-child {
    flex: 1 1 auto;
    min-inline-size: 0;
}

.form-money > select.form-input {
    flex: 0 0 9rem;
    inline-size: 9rem;
}

.form-unit {
    font-size: .875rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.form-readonly {
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
}

.form-readonly > .form-label {
    margin-block-end: 0;
}

.summary-list > div {
    padding-block: .5rem;
    border-block-end: 1px solid var(--border);
}

.summary-list > div:last-child {
    border-block-end: 0;
}

.summary-list dt {
    font-size: .75rem;
    color: var(--text-faint);
}

.summary-list dd {
    margin: 0;
    margin-inline-start: 0;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text);
    text-align: start;
    overflow-wrap: anywhere;
}

/* ---- the vehicle detail page (F2-12) -------------------------------------------------------
   Full width, no side rail: a status band, a fact strip, three tabs, and cards in one column or a
   balanced two. Direction-independent: logical properties only (K-58). The tabs are plain links
   (each opens its own panel on the server), so they work without script. */

.detail-heading {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .625rem;
}

.detail-band {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-block-start: 1rem;
}

.detail-band > form {
    margin: 0;
}

.detail-tabs {
    display: flex;
    gap: .25rem;
    margin-block: 1.25rem 1rem;
    border-block-end: 1px solid var(--border);
    overflow-x: auto;
}

.detail-tab {
    padding: .625rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-block-end: 2px solid transparent;
    margin-block-end: -1px;
    white-space: nowrap;
}

.detail-tab:hover {
    color: var(--text);
}

.detail-tab.is-active {
    color: var(--brand-600);
    border-block-end-color: var(--brand-600);
    font-weight: 600;
}

/* The count badge on a tab title (documents, incidents). */
.detail-tab-count {
    margin-inline-start: .375rem;
}

.detail-list-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .875rem 1.5rem;
}

.detail-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-block-start: 1rem;
    align-items: start;
}

@media (max-width: 64rem) {
    .detail-list-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detail-cards {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 40rem) {
    .detail-list-3 {
        grid-template-columns: minmax(0, 1fr);
    }
}

.detail-meter {
    block-size: .5rem;
    border-radius: .25rem;
    background: var(--surface-3);
    overflow: hidden;
    margin-block: .375rem;
}

.detail-meter > span {
    display: block;
    block-size: 100%;
    background: var(--brand-600);
}

.detail-meter.is-exceeded > span {
    background: var(--danger-text);
}

.detail-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.detail-timeline > li {
    display: flex;
    gap: .75rem;
    padding-block: .5rem;
    border-block-end: 1px solid var(--border);
    font-size: .8125rem;
}

.detail-timeline > li:last-child {
    border-block-end: 0;
}

.detail-timeline-when {
    flex: 0 0 9.5rem;
    color: var(--text-faint);
}

.detail-timeline-what {
    min-inline-size: 0;
    overflow-wrap: anywhere;
}

.detail-fold > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: .9375rem;
}

.detail-fold[open] > summary {
    margin-block-end: .875rem;
}
