/* ==========================================================================
   RCB Restaurant CRM - Design System
   --------------------------------------------------------------------------
   A single stylesheet, authored by hand, with no build step and no external
   font or CSS dependency. That keeps deployment to Hostinger a file copy and
   keeps the Content-Security-Policy strict.

   Structure
     1. Tokens
     2. Reset & base
     3. Typography
     4. Layout shell (sidebar / header / content)
     5. Components
     6. States (loading / empty / error)
     7. Auth screens
     8. Utilities
     9. Responsive
   ========================================================================== */

/* ==========================================================================
   1. TOKENS
   ========================================================================== */

:root {
    /* --- Brand palette (final) ------------------------------------------ */
    --royal-gold: #F5C400;
    --royal-red:  #C62828;
    --deep-black: #111111;
    --warm-white: #FAFAF8;

    --success: #28A745;
    --warning: #FF9800;
    --neutral: #6C757D;

    /* --- Derived brand tints --------------------------------------------
       Used sparingly for hover/active/soft backgrounds so the interface stays
       predominantly neutral rather than becoming a wash of gold and red.      */
    --gold-700: #C69E00;
    --gold-600: #DDB100;
    --gold-100: #FFF6D6;
    --gold-050: #FFFBEC;

    --red-700: #9E1F1F;
    --red-100: #FBE4E4;
    --red-050: #FDF2F2;

    --success-100: #E3F5E8;
    --warning-100: #FFF0DC;

    /* --- Neutral scale --------------------------------------------------- */
    --ink-900: #111111;
    --ink-800: #1D1D1D;
    --ink-700: #2E2E2E;
    --ink-600: #4A4A4A;
    --ink-500: #6C757D;
    --ink-400: #8E959C;
    --ink-300: #C7CBD0;
    --ink-200: #E3E5E8;
    --ink-100: #EFF0F2;
    --ink-050: #F6F6F4;
    --white:    #FFFFFF;

    /* --- Semantic surfaces ----------------------------------------------- */
    --bg-app:      var(--warm-white);
    --bg-surface:  var(--white);
    --bg-muted:    var(--ink-050);
    --border:      var(--ink-200);
    --border-strong: var(--ink-300);

    --text-primary:   var(--ink-900);
    --text-secondary: var(--ink-600);
    /*
     * Deliberately NOT var(--ink-500). The brand Neutral (#6C757D) measures
     * 4.49:1 on the warm-white background - a hair under the 4.5:1 WCAG AA
     * threshold for text this size, and 4.33:1 on the muted surface. The brand
     * token is unchanged and still used for non-text elements (status dots,
     * icons, borders); only the TEXT colour is darkened enough to pass on
     * every surface the CRM uses.
     */
    --text-muted:     #646C74;
    --text-inverse:   #FFFFFF;
    /*
     * Same reasoning as --text-muted above, for the Success token. Brand
     * Success (#28A745) measures 3.13:1 on white and 2.90:1 on the muted
     * surface - fine for a status dot or an icon, well under AA for TEXT. This
     * is the darkened value the success badges and alerts were already using;
     * tokenising it stops the next green caption re-introducing the problem.
     * The brand token itself is untouched and still drives dots, borders and
     * backgrounds.
     */
    --text-success:   #1B6E31;

    /* --- Sidebar --------------------------------------------------------- */
    --sidebar-bg:          var(--deep-black);
    --sidebar-bg-hover:    #1E1E1E;
    --sidebar-bg-active:   #262525;
    --sidebar-text:        #B9B9B6;
    --sidebar-text-active: #FFFFFF;
    --sidebar-border:      #262626;
    --sidebar-width:       264px;
    --sidebar-width-collapsed: 76px;

    --header-height: 64px;

    /* --- Typography ------------------------------------------------------ */
    --font-sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue",
                 Roboto, "Noto Sans", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
                 "Liberation Mono", monospace;

    --fs-display: 1.75rem;   /* 28px - page title on large screens */
    --fs-h1:      1.375rem;  /* 22px - page title                  */
    --fs-h2:      1.0625rem; /* 17px - section heading              */
    --fs-h3:      0.9375rem; /* 15px - card heading                 */
    --fs-body:    0.875rem;  /* 14px - body / table                 */
    --fs-sm:      0.8125rem; /* 13px - labels, secondary            */
    --fs-xs:      0.75rem;   /* 12px - helper text, badges          */
    --fs-2xs:     0.6875rem; /* 11px - overline                     */

    --lh-tight: 1.25;
    --lh-base:  1.55;

    --fw-regular:  400;
    --fw-medium:   500;
    --fw-semibold: 600;
    --fw-bold:     700;

    /* --- Spacing (4px scale) --------------------------------------------- */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.25rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;

    /* --- Radius & elevation ---------------------------------------------- */
    --radius-sm: 4px;
    --radius:    8px;
    --radius-lg: 12px;
    --radius-pill: 999px;

    --shadow-xs: 0 1px 2px rgba(17, 17, 17, 0.05);
    --shadow-sm: 0 1px 3px rgba(17, 17, 17, 0.08), 0 1px 2px rgba(17, 17, 17, 0.04);
    --shadow-md: 0 4px 12px rgba(17, 17, 17, 0.08), 0 2px 4px rgba(17, 17, 17, 0.04);
    --shadow-lg: 0 12px 32px rgba(17, 17, 17, 0.14);

    --focus-ring: 0 0 0 3px rgba(245, 196, 0, 0.45);
    --focus-ring-danger: 0 0 0 3px rgba(198, 40, 40, 0.30);

    --transition: 140ms cubic-bezier(0.4, 0, 0.2, 1);

    --z-sidebar: 40;
    --z-header:  30;
    --z-overlay: 60;
    --z-modal:   70;
    --z-toast:   80;
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-base);
    color: var(--text-primary);
    background: var(--bg-app);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, svg { vertical-align: middle; }
img { max-width: 100%; height: auto; }

a {
    color: var(--ink-800);
    text-decoration: none;
}
a:hover { color: var(--royal-red); }

/*
 * A link inside a sentence has to be distinguishable from the text around it
 * by something other than colour (WCAG 1.4.1) - someone who cannot separate
 * the two hues would otherwise never know it was a link. Standalone links -
 * navigation, buttons, table cells, cards - are their own block and read as
 * links from their position, so they stay undecorated.
 */
p a,
li a:not(.nav-sub__item),
.timeline__summary a,
.section__description a,
.alert__body a,
.kpi__note a,
.card__subtitle a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* A button that happens to sit in a paragraph is still a button. */
p a.btn, li a.btn, .alert__body a.btn { text-decoration: none; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: var(--sp-6) 0;
}

::selection {
    background: var(--gold-100);
    color: var(--ink-900);
}

/* Consistent, visible focus for keyboard users everywhere. */
:focus-visible {
    outline: 2px solid var(--royal-gold);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   3. TYPOGRAPHY
   ========================================================================== */

h1, h2, h3, h4 {
    margin: 0;
    line-height: var(--lh-tight);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }

.overline {
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger    { color: var(--royal-red); }
.text-success   { color: var(--text-success); }
.text-warning   { color: #B36A00; }
.text-sm        { font-size: var(--fs-sm); }
.text-xs        { font-size: var(--fs-xs); }
.text-mono      { font-family: var(--font-mono); font-size: var(--fs-xs); }
.fw-medium      { font-weight: var(--fw-medium); }
.fw-semibold    { font-weight: var(--fw-semibold); }

/* ==========================================================================
   4. LAYOUT SHELL
   ========================================================================== */

.app {
    min-height: 100vh;
    display: flex;
}

/* --- Sidebar ------------------------------------------------------------- */

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-sidebar);
    border-right: 1px solid var(--sidebar-border);
    transition: transform var(--transition);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    min-height: var(--header-height);
    border-bottom: 1px solid var(--sidebar-border);
}

/* The logo is rendered at its native 1:1 ratio inside a fixed square box.
   object-fit: contain guarantees the artwork is never stretched or cropped. */
.sidebar__logo {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.sidebar__brand-text { min-width: 0; }

.sidebar__brand-name {
    display: block;
    font-size: var(--fs-2xs);
    font-weight: var(--fw-bold);
    /* Tightened tracking so the full restaurant name fits the rail on two
       lines rather than being truncated. */
    letter-spacing: 0.035em;
    color: var(--sidebar-text-active);
    text-transform: uppercase;
    line-height: 1.25;
    text-wrap: balance;
}

.sidebar__brand-product {
    display: block;
    font-size: var(--fs-2xs);
    font-weight: var(--fw-medium);
    letter-spacing: 0.045em;
    color: var(--royal-gold);
    text-transform: uppercase;
    line-height: 1.4;
}

.sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4) var(--sp-3);
    /* Thin scrollbar so the dark rail stays clean. */
    scrollbar-width: thin;
    scrollbar-color: #3A3A3A transparent;
}
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: #3A3A3A; border-radius: 3px; }

.sidebar__section-label {
    padding: var(--sp-4) var(--sp-3) var(--sp-2);
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.09em;
    text-transform: uppercase;
    /* 5.7:1 against the sidebar; the previous #6E6E6B was 3.69:1. */
    color: #8E8E88;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: 2px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: var(--fs-body);
    font-weight: var(--fw-medium);
    transition: background var(--transition), color var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
}

.nav-item.is-active {
    background: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
}

/* Royal Gold marks the active destination - the one place gold appears in the
   navigation rail, so it reads as a signal rather than decoration. */
.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 2px 2px 0;
    background: var(--royal-gold);
}

.nav-item.is-active .nav-item__icon { color: var(--royal-gold); }

.nav-item__icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    color: #85857F;
    transition: color var(--transition);
}
.nav-item:hover .nav-item__icon { color: var(--sidebar-text-active); }

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

.nav-sub {
    margin: 2px 0 var(--sp-2) 0;
    padding-left: calc(var(--sp-3) + 18px + var(--sp-3));
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-sub__item {
    display: block;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    color: #8E8E88;
}
.nav-sub__item:hover { color: #FFF; background: var(--sidebar-bg-hover); }
.nav-sub__item.is-active { color: var(--royal-gold); font-weight: var(--fw-medium); }

.sidebar__footer {
    padding: var(--sp-3) var(--sp-5);
    border-top: 1px solid var(--sidebar-border);
    font-size: var(--fs-2xs);
    /* 5.7:1 against the sidebar; the previous #6E6E6B was 3.69:1. */
    color: #8E8E88;
    line-height: 1.5;
}

/* --- Main column --------------------------------------------------------- */

.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* --- Header -------------------------------------------------------------- */

.header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: 0 var(--sp-6);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(160%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.header__toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    cursor: pointer;
}

.header__titles { flex: 1; min-width: 0; }

.header__title {
    font-size: var(--fs-h1);
    font-weight: var(--fw-semibold);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header__subtitle {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.header__icon-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink-600);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}
.header__icon-button:hover {
    background: var(--bg-muted);
    border-color: var(--border);
    color: var(--ink-900);
}

/* The search box sits between the page title and the actions, and gives up
   its width first when the header gets tight. */
.header__search {
    flex: 0 1 320px;
    min-width: 0;
    margin-right: var(--sp-2);
}

.header__search .input { width: 100%; }

/* A count on the bell. aria-hidden - the number is in the button's label. */
.header__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-pill);
    background: var(--royal-red);
    color: #fff;
    font-size: 10px;
    font-weight: var(--fw-semibold);
    line-height: 16px;
    text-align: center;
}

.header__divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 var(--sp-1);
}

/* --- User menu ----------------------------------------------------------- */

.user-menu { position: relative; }

.user-menu__trigger {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-1);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: transparent;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}
.user-menu__trigger:hover { background: var(--bg-muted); border-color: var(--border); }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 50%;
    background: var(--deep-black);
    color: var(--royal-gold);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.02em;
}

.user-menu__meta { text-align: left; line-height: 1.25; }
.user-menu__name { display: block; font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.user-menu__role { display: block; font-size: var(--fs-2xs); color: var(--text-muted); }

.dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 232px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: var(--sp-1);
    display: none;
}
.dropdown.is-open { display: block; }

.dropdown__header {
    padding: var(--sp-3);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-1);
}
.dropdown__header-name  { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.dropdown__header-email { font-size: var(--fs-xs); color: var(--text-muted); word-break: break-all; }

.dropdown__item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: var(--fs-sm);
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
}
.dropdown__item:hover { background: var(--bg-muted); color: var(--text-primary); }
.dropdown__item--danger { color: var(--royal-red); }
.dropdown__item--danger:hover { background: var(--red-050); color: var(--red-700); }
.dropdown__item svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--ink-500); }
.dropdown__item--danger svg { color: var(--royal-red); }

.dropdown__divider { height: 1px; background: var(--border); margin: var(--sp-1) 0; }

/* --- Content ------------------------------------------------------------- */

.content {
    flex: 1;
    padding: var(--sp-6);
    max-width: 1600px;
    width: 100%;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
}
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--royal-red); }
.breadcrumbs__sep { color: var(--ink-300); }

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

.section {
    margin-bottom: var(--sp-8);
}
.section__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
}
.section__title { font-size: var(--fs-h2); }
.section__description { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }

/* ==========================================================================
   5. COMPONENTS
   ========================================================================== */

/* --- Card ---------------------------------------------------------------- */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border);
}
.card__title { font-size: var(--fs-h3); font-weight: var(--fw-semibold); }
.card__subtitle { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.card__body { padding: var(--sp-5); }
.card__footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border);
    background: var(--bg-muted);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

/* --- KPI card ------------------------------------------------------------ */

.kpi {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-height: 132px;
}

.kpi__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
}

.kpi__label {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
}

.kpi__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    background: var(--bg-muted);
    color: var(--ink-500);
}
.kpi__icon svg { width: 17px; height: 17px; }

.kpi__value {
    font-size: 1.75rem;
    font-weight: var(--fw-semibold);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.kpi__value--empty {
    color: var(--ink-300);
    font-size: 1.5rem;
}

.kpi__note {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: auto;
}

/*
 * The link out of a KPI card is how somebody gets from "twelve bookings today"
 * to the bookings, so it has to be comfortably tappable. At this type size the
 * text alone is about 15px tall; the padding takes the target to 24px without
 * changing how the card looks.
 */
.kpi__note a {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 0;
}

/* --- Buttons ------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 0 var(--sp-4);
    height: 38px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: var(--fs-body);
    font-weight: var(--fw-medium);
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition),
                color var(--transition), box-shadow var(--transition);
    text-decoration: none;
}

.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled, .btn.is-disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex: 0 0 16px; }

/* Primary = Royal Gold on Deep Black text. Gold is bright, so black type is the
   only combination that clears WCAG AA on it. */
.btn--primary {
    background: var(--royal-gold);
    color: var(--deep-black);
    border-color: var(--royal-gold);
    font-weight: var(--fw-semibold);
}
.btn--primary:hover { background: var(--gold-600); border-color: var(--gold-600); color: var(--deep-black); }
.btn--primary:active { background: var(--gold-700); border-color: var(--gold-700); }

/* Secondary emphasis = Royal Red, for important but non-primary actions. */
.btn--secondary {
    background: var(--royal-red);
    color: var(--text-inverse);
    border-color: var(--royal-red);
}
.btn--secondary:hover { background: var(--red-700); border-color: var(--red-700); color: var(--text-inverse); }
.btn--secondary:focus-visible { box-shadow: var(--focus-ring-danger); }

.btn--dark {
    background: var(--deep-black);
    color: var(--text-inverse);
    border-color: var(--deep-black);
}
.btn--dark:hover { background: var(--ink-700); border-color: var(--ink-700); color: var(--text-inverse); }

.btn--outline {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn--outline:hover { background: var(--bg-muted); border-color: var(--ink-400); color: var(--text-primary); }

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn--ghost:hover { background: var(--bg-muted); color: var(--text-primary); }

.btn--danger {
    background: var(--bg-surface);
    color: var(--royal-red);
    border-color: var(--red-100);
}
.btn--danger:hover { background: var(--red-050); border-color: var(--royal-red); color: var(--red-700); }

.btn--sm { height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn--lg { height: 44px; padding: 0 var(--sp-5); font-size: 0.9375rem; }
.btn--block { width: 100%; }

/* --- Forms --------------------------------------------------------------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-5);
}
.form-grid--single { grid-template-columns: minmax(0, 1fr); }
.form-grid__full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: var(--sp-2); }

.field__label {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
}

.field__required { color: var(--royal-red); margin-left: 2px; }

.field__help {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.field__error {
    font-size: var(--fs-xs);
    color: var(--royal-red);
    font-weight: var(--fw-medium);
}

.input,
.select,
.textarea {
    width: 100%;
    height: 40px;
    padding: 0 var(--sp-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-surface);
    font-size: var(--fs-body);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.textarea { height: auto; min-height: 96px; padding: var(--sp-3); resize: vertical; line-height: var(--lh-base); }

.input::placeholder, .textarea::placeholder { color: var(--ink-400); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-400); }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--royal-gold);
    box-shadow: var(--focus-ring);
}

.input:disabled, .select:disabled, .textarea:disabled {
    background: var(--bg-muted);
    color: var(--text-muted);
    cursor: not-allowed;
}

.input.is-invalid, .select.is-invalid, .textarea.is-invalid {
    border-color: var(--royal-red);
}
.input.is-invalid:focus, .select.is-invalid:focus, .textarea.is-invalid:focus {
    box-shadow: var(--focus-ring-danger);
}

.select {
    appearance: none;
    padding-right: var(--sp-8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%236C757D' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-3) center;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 38px; }
.input-group__icon {
    position: absolute;
    left: var(--sp-3);
    width: 16px;
    height: 16px;
    color: var(--ink-400);
    pointer-events: none;
}
.input-group__action {
    position: absolute;
    right: var(--sp-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-500);
    cursor: pointer;
}
.input-group__action:hover { background: var(--bg-muted); color: var(--ink-800); }
.input-group:has(.input-group__action) .input { padding-right: 42px; }

/* Checkbox / switch */
.checkbox {
    display: inline-flex;
    align-items: flex-start;
    gap: var(--sp-3);
    cursor: pointer;
    font-size: var(--fs-sm);
}
.checkbox input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin: 2px 0 0;
    accent-color: var(--royal-gold);
    cursor: pointer;
    flex: 0 0 17px;
}
.checkbox__text { line-height: 1.45; }
.checkbox__hint { display: block; font-size: var(--fs-xs); color: var(--text-muted); }

/* --- Badges -------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    line-height: 1.5;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge--neutral { background: var(--ink-100); color: var(--ink-600); border-color: var(--ink-200); }
.badge--success { background: var(--success-100); color: var(--text-success); border-color: #BFE6C9; }
.badge--warning { background: var(--warning-100); color: #A35C00; border-color: #F7D9AE; }
.badge--danger  { background: var(--red-100); color: var(--red-700); border-color: #F2C4C4; }
.badge--gold    { background: var(--gold-100); color: #7A6200; border-color: #F0DC93; }
.badge--dark    { background: var(--ink-800); color: #FFF; border-color: var(--ink-800); }

.badge__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 6px;
}

/* --- Tables -------------------------------------------------------------- */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-body);
}

/*
 * A link that IS a table cell - a customer's name, an order reference - is how
 * the row is opened, and on a phone it has to be big enough to hit. The
 * minimum height costs nothing on a desktop row, which is already taller.
 */
.table td > a:only-child,
.table td .cell-stack__primary,
.table__sort,
.result-list__title {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
}

.table thead th {
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border);
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.table tbody td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--ink-100);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
/* Only tint on devices with a real hover state: on touch the tint sticks
   after a tap and reads as a permanent selection. */
@media (hover: hover) {
    .table tbody tr:hover { background: var(--gold-050); }
}

.table__cell--numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table__cell--actions { text-align: right; white-space: nowrap; }

/* --- Pagination ---------------------------------------------------------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.pagination__summary { font-size: var(--fs-xs); color: var(--text-muted); }
.pagination__pages { display: flex; align-items: center; gap: var(--sp-1); }

.pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 var(--sp-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    background: var(--bg-surface);
}
.pagination__link:hover { border-color: var(--ink-400); color: var(--text-primary); }
.pagination__link.is-active {
    background: var(--deep-black);
    border-color: var(--deep-black);
    color: var(--royal-gold);
    font-weight: var(--fw-semibold);
}
.pagination__link.is-disabled { opacity: 0.45; pointer-events: none; }

/* --- Alerts -------------------------------------------------------------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-4);
}
.alert svg { width: 17px; height: 17px; flex: 0 0 17px; margin-top: 1px; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: var(--fw-semibold); margin-bottom: 2px; }

.alert--success { background: var(--success-100); border-color: #BFE6C9; color: var(--text-success); }
.alert--error   { background: var(--red-050);  border-color: #F2C4C4; color: var(--red-700); }
.alert--warning { background: var(--warning-100); border-color: #F7D9AE; color: #8A4F00; }
.alert--info    { background: var(--ink-050); border-color: var(--border); color: var(--text-secondary); }

/* --- Toasts -------------------------------------------------------------- */

.toast-stack {
    position: fixed;
    top: var(--sp-4);
    right: var(--sp-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    max-width: min(380px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--neutral);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: var(--fs-sm);
    pointer-events: auto;
    animation: toast-in 200ms ease-out;
}

.toast--success { border-left-color: var(--success); }
.toast--error   { border-left-color: var(--royal-red); }
.toast--warning { border-left-color: var(--warning); }
.toast--info    { border-left-color: var(--neutral); }

.toast__body { flex: 1; min-width: 0; }

.toast__close {
    border: 0;
    background: transparent;
    color: var(--ink-400);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 1.1rem;
}
.toast__close:hover { color: var(--ink-800); }

.toast.is-leaving { animation: toast-out 180ms ease-in forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* --- Modal & drawer ------------------------------------------------------ */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 17, 17, 0.45);
    z-index: var(--z-overlay);
    display: none;
}
.overlay.is-open { display: block; }

.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
}
.modal.is-open { display: flex; }

.modal__panel {
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modal-in 160ms ease-out;
}
.modal--wide .modal__panel { max-width: 760px; }

@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

.modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-5);
    border-bottom: 1px solid var(--border);
}
.modal__title { font-size: var(--fs-h2); }
.modal__body { padding: var(--sp-5); }
.modal__footer {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

.modal__close {
    border: 0;
    background: transparent;
    color: var(--ink-400);
    cursor: pointer;
    padding: var(--sp-1);
    border-radius: var(--radius-sm);
    line-height: 0;
}
.modal__close:hover { background: var(--bg-muted); color: var(--ink-800); }

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(460px, 100vw);
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-modal);
    transform: translateX(100%);
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
}
.drawer.is-open { transform: none; }
.drawer__header { padding: var(--sp-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--sp-5); }
.drawer__footer { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-3); }

/* --- Tabs ---------------------------------------------------------------- */

.tabs {
    display: flex;
    gap: var(--sp-1);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-6);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 2px solid transparent;
    font-size: var(--fs-body);
    font-weight: var(--fw-medium);
    color: var(--text-muted);
    white-space: nowrap;
    margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab.is-active {
    color: var(--text-primary);
    border-bottom-color: var(--royal-gold);
    font-weight: var(--fw-semibold);
}

/* ==========================================================================
   6. STATES
   ========================================================================== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--sp-12) var(--sp-6);
    gap: var(--sp-3);
}

.empty-state__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    background: var(--bg-muted);
    color: var(--ink-400);
    margin-bottom: var(--sp-1);
}
.empty-state__icon svg { width: 24px; height: 24px; }

.empty-state__title { font-size: var(--fs-h3); font-weight: var(--fw-semibold); }
.empty-state__text { font-size: var(--fs-sm); color: var(--text-muted); max-width: 44ch; }
.empty-state__actions { margin-top: var(--sp-2); display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; }

.error-state .empty-state__icon { background: var(--red-050); color: var(--royal-red); }

/* Loading */

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--ink-200);
    border-top-color: var(--royal-gold);
    border-radius: 50%;
    animation: spin 640ms linear infinite;
}
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-12);
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

.skeleton {
    background: linear-gradient(90deg, var(--ink-100) 25%, var(--ink-050) 37%, var(--ink-100) 63%);
    background-size: 400% 100%;
    animation: skeleton 1.4s ease infinite;
    border-radius: var(--radius-sm);
}
.skeleton--text { height: 12px; margin-bottom: var(--sp-2); }
.skeleton--title { height: 20px; width: 45%; margin-bottom: var(--sp-3); }

@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ==========================================================================
   7. AUTH SCREENS
   ========================================================================== */

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

/* Left panel: Deep Black brand stage carrying the full RCB logo. */
.auth__brand {
    background:
        radial-gradient(circle at 22% 18%, rgba(245, 196, 0, 0.10), transparent 55%),
        radial-gradient(circle at 78% 82%, rgba(198, 40, 40, 0.13), transparent 55%),
        var(--deep-black);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--sp-12) var(--sp-8);
    text-align: center;
    position: relative;
}

.auth__brand::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 3px;
    background: linear-gradient(90deg, var(--royal-gold), var(--royal-red));
}

/* Fixed square box + object-fit: contain keeps the supplied artwork at its
   original proportions at every viewport size. */
.auth__logo {
    width: 190px;
    height: 190px;
    object-fit: contain;
    margin-bottom: var(--sp-6);
}

.auth__brand-name {
    /* Explicit: the base h1 rule sets a dark colour, which would be invisible
       on the Deep Black brand stage. */
    color: var(--text-inverse);
    font-size: 1.375rem;
    font-weight: var(--fw-bold);
    letter-spacing: 0.055em;
    text-transform: uppercase;
    line-height: 1.35;
    margin-bottom: var(--sp-2);
}

.auth__brand-product {
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--royal-gold);
}

.auth__brand-tagline {
    margin-top: var(--sp-6);
    padding-top: var(--sp-6);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: var(--fs-sm);
    color: #9C9C97;
    max-width: 34ch;
}

.auth__form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-8);
    background: var(--bg-app);
}

.auth__form {
    width: 100%;
    max-width: 400px;
}

/* Compact brand lock-up shown above the form on narrow screens. */
.auth__mobile-brand {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-8);
}
.auth__mobile-logo { width: 84px; height: 84px; object-fit: contain; }
.auth__mobile-name {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.auth__mobile-product {
    font-size: var(--fs-xs);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-500);
}

.auth__title { font-size: var(--fs-display); margin-bottom: var(--sp-2); }
.auth__subtitle { font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--sp-8); }

.auth__fields { display: flex; flex-direction: column; gap: var(--sp-5); }

.auth__footer {
    margin-top: var(--sp-8);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--border);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-align: center;
    line-height: 1.7;
}

/* Standalone error page (404/403/500). */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-8);
    background: var(--bg-app);
}
.error-page__inner {
    max-width: 480px;
    text-align: center;
}
.error-page__logo { width: 96px; height: 96px; object-fit: contain; margin-bottom: var(--sp-6); }
.error-page__status {
    font-size: 3.25rem;
    font-weight: var(--fw-bold);
    letter-spacing: -0.03em;
    color: var(--deep-black);
    line-height: 1;
    margin-bottom: var(--sp-3);
}
.error-page__title { font-size: var(--fs-h1); margin-bottom: var(--sp-3); }
.error-page__text { color: var(--text-muted); margin-bottom: var(--sp-6); }
.error-page__detail {
    text-align: left;
    background: var(--ink-050);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-4);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 320px;
    overflow: auto;
    margin-top: var(--sp-6);
}

/* Missing-brand-asset fallback: a text lock-up so the layout never collapses
   if the PNG files have not been uploaded. */
.logo-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--deep-black);
    color: var(--royal-gold);
    border: 2px solid var(--royal-gold);
    border-radius: var(--radius);
    font-weight: var(--fw-bold);
    letter-spacing: 0.06em;
}

/* ==========================================================================
   7b. CUSTOMER MODULE
   --------------------------------------------------------------------------
   Extends the shared component vocabulary rather than introducing a parallel
   one: badges, cards, tables and buttons are the Phase 1 primitives. Only
   patterns that genuinely did not exist yet are defined here.
   ========================================================================== */

/* --- Stat strip (list header counts) ------------------------------------- */

.stat-strip {
    display: flex;
    align-items: center;
    gap: var(--sp-6);
    flex-wrap: wrap;
}

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

.stat-strip__value {
    font-size: 1.25rem;
    font-weight: var(--fw-semibold);
    line-height: 1.1;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.stat-strip__label {
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-strip__divider {
    width: 1px;
    height: 30px;
    background: var(--border);
}

/* --- Filter bar ---------------------------------------------------------- */

.card__header--filters {
    display: block;
    padding: var(--sp-4) var(--sp-5);
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

.filter-bar__search { flex: 1 1 280px; min-width: 220px; }

.filter-bar__controls {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

/* Compact select for dense filter rows. */
.select--compact {
    width: auto;
    min-width: 132px;
    height: 36px;
    font-size: var(--fs-sm);
}

/* While a debounced search is in flight the results dim slightly rather than
   being replaced by a spinner - the previous rows stay readable. */
[data-customer-results][aria-busy="true"] {
    opacity: 0.55;
    transition: opacity 120ms ease-out;
    pointer-events: none;
}

/* --- Table cells --------------------------------------------------------- */

.table__sort {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    white-space: nowrap;
}
.table__sort:hover { color: var(--royal-red); }

.cell-identity { display: flex; align-items: center; gap: var(--sp-3); }

.cell-identity__text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cell-identity__name {
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
}
.cell-identity__name:hover { color: var(--royal-red); }

.cell-identity__meta { font-size: var(--fs-xs); color: var(--text-muted); }

.cell-stack { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-stack__primary { font-size: var(--fs-body); color: var(--text-primary); }
.cell-stack__primary:hover { color: var(--royal-red); }
.cell-stack__secondary {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.row-actions { display: inline-flex; gap: var(--sp-1); }

/* An archived row is muted, but the archive state is ALSO carried by a badge -
   colour alone never communicates status. */
.table tbody tr.is-archived { background: var(--bg-muted); }
.table tbody tr.is-archived .cell-identity__name { color: var(--text-muted); }

.avatar--sm { width: 30px; height: 30px; flex: 0 0 30px; font-size: var(--fs-2xs); }
.avatar--lg { width: 60px; height: 60px; flex: 0 0 60px; font-size: 1.125rem; }

.badge--xs { font-size: var(--fs-2xs); padding: 1px 6px; }

/* --- Tags ---------------------------------------------------------------- */

.tag-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.tag-list--tight { gap: 4px; }

.tag-chip { display: inline-flex; align-items: center; gap: 2px; }
.tag-chip__form { display: inline-flex; }

.tag-chip__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-400);
    cursor: pointer;
    line-height: 0;
}
.tag-chip__remove:hover { background: var(--red-050); color: var(--royal-red); }

.tag-option {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.tag-option:hover { border-color: var(--ink-400); background: var(--bg-muted); }
.tag-option input { accent-color: var(--royal-gold); cursor: pointer; margin: 0 0 0 var(--sp-1); }
.tag-option:has(input:checked) { border-color: var(--royal-gold); background: var(--gold-050); }
.tag-option:has(input:focus-visible) { box-shadow: var(--focus-ring); }

.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
}

.fieldset { border: 0; margin: 0; padding: 0; }

/* --- Form ---------------------------------------------------------------- */

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-3);
    padding-top: var(--sp-2);
    flex-wrap: wrap;
}

.field-with-hint { display: flex; flex-direction: column; }

/* Live duplicate-check feedback under the mobile field. */
.field__async {
    margin-top: var(--sp-2);
    font-size: var(--fs-xs);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius);
    border: 1px solid transparent;
}
.field__async--warning {
    background: var(--warning-100);
    border-color: #F7D9AE;
    color: #8A4F00;
}
.field__async--error {
    background: var(--red-050);
    border-color: #F2C4C4;
    color: var(--red-700);
}
.field__async a { color: inherit; font-weight: var(--fw-semibold); text-decoration: underline; }

/* --- Profile ------------------------------------------------------------- */

.profile-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-5);
    padding: var(--sp-5);
    flex-wrap: wrap;
    margin-bottom: var(--sp-6);
}

.profile-header__main { display: flex; align-items: flex-start; gap: var(--sp-4); min-width: 0; }

.profile-header__identity { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-2); }

.profile-header__name {
    font-size: var(--fs-display);
    font-weight: var(--fw-semibold);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.profile-header__contact {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}
.profile-header__contact a {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    color: var(--text-secondary);
}
.profile-header__contact a:hover { color: var(--royal-red); }

.profile-header__badges { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

.profile-header__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: flex-start; }
.profile-header__actions form { display: inline-flex; }

.profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--sp-5);
    align-items: start;
}

.consent-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.consent-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
}
.consent-list__channel { font-size: var(--fs-sm); font-weight: var(--fw-medium); }

/* --- Notes --------------------------------------------------------------- */

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

.note {
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border);
}

.note--pinned { background: var(--gold-050); }

.note__body {
    font-size: var(--fs-body);
    line-height: var(--lh-base);
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.note__meta {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-top: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    flex-wrap: wrap;
}
.note__meta form { display: inline-flex; }

.note__remove {
    border: 0;
    background: transparent;
    padding: 0;
    font-size: var(--fs-xs);
    /* --ink-400 is a border/icon tone; as 12px text it fails AA. */
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
}
.note__remove:hover { color: var(--royal-red); }

/* --- Timeline ------------------------------------------------------------ */

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

/* The connecting rail sits behind the markers. */
.timeline::before {
    content: "";
    position: absolute;
    left: 11px;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: var(--border);
}

.timeline__item {
    position: relative;
    display: flex;
    gap: var(--sp-3);
    padding-bottom: var(--sp-5);
}
.timeline__item:last-child { padding-bottom: 0; }

.timeline__marker {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 23px;
    height: 23px;
    flex: 0 0 23px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--ink-500);
}

.timeline__marker--success { border-color: #BFE6C9; background: var(--success-100); color: var(--text-success); }
.timeline__marker--gold    { border-color: #F0DC93; background: var(--gold-100);    color: #7A6200; }
.timeline__marker--warning { border-color: #F7D9AE; background: var(--warning-100); color: #A35C00; }
.timeline__marker--danger  { border-color: #F2C4C4; background: var(--red-100);     color: var(--red-700); }

.timeline__content { min-width: 0; padding-top: 2px; }
.timeline__summary { font-size: var(--fs-sm); color: var(--text-primary); overflow-wrap: anywhere; }
.timeline__meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 1px; }

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 1200px) {
    .profile-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1024px) {
    .filter-bar__search { flex-basis: 100%; }
    .filter-bar__controls { width: 100%; }
    .select--compact { flex: 1 1 140px; min-width: 0; }
}

@media (max-width: 768px) {
    /*
     * The customer table becomes a stack of cards.
     *
     * One table in the DOM, transformed by CSS: each cell shows its column
     * name from the data-label attribute. No duplicated markup to keep in
     * step, and no shrunken desktop layout.
     */
    .table--cards,
    .table--cards tbody,
    .table--cards tr,
    .table--cards td { display: block; width: 100%; }

    .table--cards thead {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .table--cards tr {
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: var(--sp-3);
        padding: var(--sp-3);
        background: var(--bg-surface);
    }
    .table--cards tbody tr.is-archived { background: var(--bg-muted); }

    .table--cards td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: var(--sp-4);
        padding: var(--sp-2) 0;
        border-bottom: 1px solid var(--ink-100);
        text-align: left;
    }
    .table--cards td:last-child { border-bottom: 0; padding-bottom: 0; }

    .table--cards td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: var(--fs-2xs);
        font-weight: var(--fw-semibold);
        letter-spacing: 0.07em;
        text-transform: uppercase;
        color: var(--text-muted);
    }

    /* The identity cell reads as the card's title, so it drops the label. */
    .table--cards td:first-child {
        padding-top: 0;
        padding-bottom: var(--sp-3);
    }
    .table--cards td:first-child::before { display: none; }

    .table--cards td > * { text-align: right; }
    .table--cards td:first-child > * { text-align: left; }

    .table--cards .cell-stack { align-items: flex-end; }
    .table--cards .tag-list { justify-content: flex-end; }
    .table--cards .row-actions { justify-content: flex-end; }

    .profile-header { flex-direction: column; align-items: stretch; }
    .profile-header__actions { width: 100%; }
    .profile-header__actions .btn,
    .profile-header__actions form { flex: 1 1 auto; }
    .profile-header__actions form .btn { width: 100%; }
    .profile-header__name { font-size: var(--fs-h1); }

    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }

    .stat-strip { gap: var(--sp-4); }
    .stat-strip__divider { display: none; }
}

/* ==========================================================================
   7c. RESERVATIONS & TABLES
   --------------------------------------------------------------------------
   Reuses the Phase 1/2 vocabulary - badges, cards, tables, timeline. Only
   genuinely new patterns are defined here: the floor-plan board, the calendar,
   and the customer/table pickers.
   ========================================================================== */

/* --- Floor plan board ---------------------------------------------------- */

.board-group { margin-bottom: var(--sp-6); }

.board-group__head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.board-group__marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-muted);
    color: var(--ink-500);
}
.board-group__marker--success { background: var(--success-100); border-color: #BFE6C9; color: var(--text-success); }
.board-group__marker--gold    { background: var(--gold-100);    border-color: #F0DC93; color: #7A6200; }
.board-group__marker--danger  { background: var(--red-100);     border-color: #F2C4C4; color: var(--red-700); }
.board-group__marker--warning { background: var(--warning-100); border-color: #F7D9AE; color: #A35C00; }

.board-group__title {
    font-size: var(--fs-h3);
    font-weight: var(--fw-semibold);
}

.board-group__count {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--text-muted);
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 1px 8px;
}

.board-group__empty { margin: 0 0 0 var(--sp-8); }

.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(214px, 1fr));
    gap: var(--sp-3);
}

.table-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-4);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    /* A 3px status edge rather than a saturated fill: the board stays calm
       even when every table is busy. */
    border-left: 3px solid var(--ink-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}

.table-card--success { border-left-color: var(--success); }
.table-card--gold    { border-left-color: var(--royal-gold); }
.table-card--danger  { border-left-color: var(--royal-red); }
.table-card--warning { border-left-color: var(--warning); }
.table-card--neutral { border-left-color: var(--neutral); }

.table-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
}

.table-card__name {
    font-size: var(--fs-h3);
    font-weight: var(--fw-semibold);
    letter-spacing: -0.01em;
}

.table-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}
.table-card__meta span { display: inline-flex; align-items: center; gap: 4px; }

.table-card__context {
    display: block;
    padding: var(--sp-2) var(--sp-3);
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}
.table-card__context:hover { background: var(--gold-050); color: var(--text-primary); }
.table-card__context-name { display: block; font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.table-card__context-meta { display: block; font-size: var(--fs-2xs); color: var(--text-muted); }

.table-card__note {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin: 0;
}

.table-card__actions {
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: var(--sp-2);
    border-top: 1px solid var(--ink-100);
}
.table-card__actions form { display: inline-flex; }

.section-list { list-style: none; margin: 0; padding: 0; }
.section-list__item {
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--ink-100);
}
.section-list__item:last-child { border-bottom: 0; }

.d-block { display: block; }

/* --- Calendar ------------------------------------------------------------ */

.calendar-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
}

.calendar-nav { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

.calendar-title {
    font-size: var(--fs-h3);
    font-weight: var(--fw-semibold);
    margin-left: var(--sp-2);
}

.calendar-views { display: flex; gap: var(--sp-1); }

.calendar--week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: var(--sp-2);
}

.calendar-day { min-width: 0; }

.calendar--week .calendar-day {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-2);
}

.calendar--week .calendar-day--today {
    background: var(--gold-050);
    border-color: var(--royal-gold);
}

.calendar-day__heading {
    display: flex;
    align-items: baseline;
    gap: var(--sp-1);
    padding-bottom: var(--sp-2);
    margin-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border);
}

.calendar-day__weekday {
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.calendar-day__date { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.calendar-day__count {
    margin-left: auto;
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    color: var(--text-muted);
}

.calendar-day__empty { margin: 0; padding: var(--sp-2) 0; }

.calendar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }

.calendar-item {
    border: 1px solid var(--border);
    border-left: 3px solid var(--ink-300);
    border-radius: var(--radius);
    background: var(--bg-surface);
}
.calendar-item--success { border-left-color: var(--success); }
.calendar-item--gold    { border-left-color: var(--royal-gold); }
.calendar-item--danger  { border-left-color: var(--royal-red); }
.calendar-item--warning { border-left-color: var(--warning); }
.calendar-item--dark    { border-left-color: var(--deep-black); }
.calendar-item--neutral { border-left-color: var(--neutral); }

.calendar-item__link {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    color: var(--text-primary);
    min-width: 0;
}
.calendar-item__link:hover { background: var(--bg-muted); color: var(--text-primary); }

.calendar-item__time {
    flex: 0 0 auto;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    font-variant-numeric: tabular-nums;
    min-width: 68px;
}

.calendar-item__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.calendar-item__customer { font-size: var(--fs-body); font-weight: var(--fw-medium); }
.calendar-item__meta { font-size: var(--fs-xs); color: var(--text-muted); }

/* Week view is dense: stack the item instead of a single row. */
.calendar--week .calendar-item__link { flex-direction: column; align-items: flex-start; gap: var(--sp-1); padding: var(--sp-2); }
.calendar--week .calendar-item__time { min-width: 0; }
.calendar--week .calendar-item__customer { font-size: var(--fs-sm); }

/* --- Reservation detail -------------------------------------------------- */

.reservation-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-3) var(--sp-4);
    background: var(--deep-black);
    color: var(--text-inverse);
    border-radius: var(--radius);
    min-width: 96px;
}
.reservation-time__time {
    font-size: 1.125rem;
    font-weight: var(--fw-semibold);
    color: var(--royal-gold);
    white-space: nowrap;
}
.reservation-time__date { font-size: var(--fs-2xs); color: #B9B9B6; white-space: nowrap; }

/* --- Customer picker ----------------------------------------------------- */

.picker-results {
    list-style: none;
    margin: var(--sp-2) 0 0;
    padding: var(--sp-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    max-height: 280px;
    overflow-y: auto;
}

.picker-result {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.picker-result:hover,
.picker-result.is-active { background: var(--gold-050); }
.picker-result__name { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.picker-result__meta { font-size: var(--fs-xs); color: var(--text-muted); }
.picker-result__empty { padding: var(--sp-3); font-size: var(--fs-sm); color: var(--text-muted); }

.customer-pill {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-muted);
}
.customer-pill > div { flex: 1; min-width: 0; }

.new-customer__fields {
    padding: var(--sp-4);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-muted);
}

/* --- Table availability picker ------------------------------------------- */

.availability-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--sp-2);
}

.availability-option {
    display: block;
    cursor: pointer;
}
.availability-option input {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
}

.availability-option__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    transition: border-color var(--transition), background var(--transition);
}
.availability-option:hover .availability-option__body { border-color: var(--ink-400); }
.availability-option input:checked + .availability-option__body {
    border-color: var(--royal-gold);
    background: var(--gold-050);
    box-shadow: inset 0 0 0 1px var(--royal-gold);
}
.availability-option input:focus-visible + .availability-option__body { box-shadow: var(--focus-ring); }

.availability-option__name { font-size: var(--fs-body); font-weight: var(--fw-semibold); }
.availability-option__meta { font-size: var(--fs-xs); color: var(--text-muted); }

.availability-status { font-size: var(--fs-sm); color: var(--text-muted); }

/* --- Customer profile: reservation history ------------------------------- */

.reservation-summary {
    display: flex;
    gap: var(--sp-6);
    flex-wrap: wrap;
}
.reservation-summary__item { display: flex; flex-direction: column; gap: 1px; }
.reservation-summary__value {
    font-size: 1.125rem;
    font-weight: var(--fw-semibold);
    font-variant-numeric: tabular-nums;
}
.reservation-summary__label {
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.reservation-history { list-style: none; margin: 0; padding: 0; }
.reservation-history__item { border-top: 1px solid var(--border); }

.reservation-history__link {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-3) var(--sp-5);
    color: var(--text-primary);
}
.reservation-history__link:hover { background: var(--bg-muted); color: var(--text-primary); }

.reservation-history__when { display: flex; flex-direction: column; min-width: 104px; }
.reservation-history__detail { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 1024px) {
    /* A seven-column week is unreadable on a tablet; two rows of days keeps
       every booking legible. */
    .calendar--week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .table-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (max-width: 768px) {
    .calendar--week { grid-template-columns: minmax(0, 1fr); }
    .calendar--week .calendar-item__link { flex-direction: row; align-items: center; padding: var(--sp-3); }
    .calendar--week .calendar-item__time { min-width: 68px; }

    .table-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

    .calendar-bar { flex-direction: column; align-items: stretch; }
    .calendar-nav { justify-content: space-between; }
    .calendar-title { margin-left: 0; width: 100%; order: -1; }
    .calendar-views { justify-content: stretch; }
    .calendar-views .btn { flex: 1; }

    .reservation-time { min-width: 0; width: 100%; flex-direction: row; gap: var(--sp-2); }

    .reservation-history__link { flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); }
    .reservation-history__when { min-width: 0; flex-direction: row; gap: var(--sp-2); align-items: baseline; }

    .availability-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ==========================================================================
   8. UTILITIES
   ========================================================================== */

.grid { display: grid; gap: var(--sp-5); }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(228px, 1fr)); }
/* The customer profile shows five metrics; a slightly narrower minimum keeps
   them on one row at desktop width instead of wrapping four-plus-one. */
.grid--kpi-5 { grid-template-columns: repeat(auto-fit, minmax(186px, 1fr)); }
.grid--2   { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3   { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.stack   { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack--sm { gap: var(--sp-2); }
.row     { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end     { justify-content: flex-end; }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }

.w-full { width: 100%; }
.hidden { display: none !important; }

/*
 * The `hidden` ATTRIBUTE must actually hide.
 *
 * The browser's own rule is [hidden] { display: none }, which lives in the user
 * agent stylesheet and therefore loses to ANY author `display` declaration. So
 * every component given a display - .customer-pill is flex, .menu-picker__item
 * is grid - silently ignored el.hidden = true and stayed on screen. Both bugs
 * shipped that way before this rule existed; stating it once here is the fix
 * for the whole class of them, including the ones not written yet.
 */
[hidden] { display: none !important; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Definition list used for read-only detail panels. */
.detail-list { display: grid; gap: var(--sp-4); margin: 0; }
.detail-list__row { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: var(--sp-4); }
.detail-list__label { font-size: var(--fs-sm); color: var(--text-muted); }
.detail-list__value { font-size: var(--fs-body); word-break: break-word; }

/* ==========================================================================
   9. RESPONSIVE
   --------------------------------------------------------------------------
   Priority: desktop, then tablet, then mobile. The sidebar becomes an
   off-canvas drawer below 1024px rather than a squeezed rail, and dense
   two-column forms collapse to one column.
   ========================================================================== */

@media (max-width: 1280px) {
    .content { padding: var(--sp-5); }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: none; }

    .main { margin-left: 0; }

    .header__toggle { display: inline-flex; }

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

    .detail-list__row { grid-template-columns: minmax(0, 1fr); gap: var(--sp-1); }

    .auth { grid-template-columns: 1fr; }
    .auth__brand { display: none; }
    .auth__mobile-brand { display: flex; }
}

@media (max-width: 768px) {
    .content { padding: var(--sp-4); }

    .header { padding: 0 var(--sp-4); gap: var(--sp-3); }
    .header__subtitle { display: none; }
    .header__title { font-size: var(--fs-h2); }

    .user-menu__meta { display: none; }

    .card__body, .card__header, .card__footer { padding: var(--sp-4); }

    .card__footer { flex-direction: column-reverse; align-items: stretch; }
    .card__footer .btn { width: 100%; }

    .grid--kpi { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-3); }
    .kpi { padding: var(--sp-4); min-height: 110px; }
    .kpi__value { font-size: 1.5rem; }

    .toast-stack { left: var(--sp-3); right: var(--sp-3); max-width: none; }

    .pagination { flex-direction: column; align-items: stretch; }

    .modal__footer { flex-direction: column-reverse; }
    .modal__footer .btn { width: 100%; }
}

@media (max-width: 480px) {
    .auth__form-panel { padding: var(--sp-5); }
    .auth__title { font-size: var(--fs-h1); }
    .error-page__status { font-size: 2.5rem; }
}

/* ==========================================================================
   Orders & Billing (Phase 4)
   ========================================================================== */

/* --- Order type badge on the detail header ------------------------------- */

.order-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 84px;
    padding: var(--sp-3);
    border-radius: var(--radius);
    background: var(--deep-black);
    color: var(--text-inverse);
}
.order-badge__icon { display: flex; color: var(--royal-gold); }
.order-badge__type {
    font-size: var(--fs-2xs);
    font-weight: var(--fw-medium);
    letter-spacing: 0.02em;
    text-align: center;
    white-space: nowrap;
}

/* --- Workflow track ------------------------------------------------------
   Where an order is in the workflow FOR ITS TYPE. Rendered from the same
   transition table the buttons come from, so it can never show a step the
   order could not actually reach.                                           */

.workflow {
    margin: var(--sp-5) 0;
    overflow-x: auto;
}

.workflow__track {
    display: flex;
    align-items: flex-start;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    min-width: min-content;
}

.workflow__step {
    position: relative;
    flex: 1 1 0;
    min-width: 96px;
    padding-top: 22px;
    text-align: center;
    font-size: var(--fs-2xs);
    color: var(--text-muted);
}

/* The connector is drawn on the step, not between steps, so it cannot fall
   out of alignment when a workflow has a different number of stages. */
.workflow__step::before {
    content: "";
    position: absolute;
    top: 6px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--border);
}
.workflow__step:first-child::before { display: none; }

.workflow__dot {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    background: var(--bg-surface);
}

.workflow__label { display: block; padding: 0 var(--sp-1); }

.workflow__step--done { color: var(--text-secondary); }
.workflow__step--done::before { background: var(--royal-gold); }
.workflow__step--done .workflow__dot { border-color: var(--royal-gold); background: var(--royal-gold); }

.workflow__step--current { color: var(--text-primary); font-weight: var(--fw-medium); }
.workflow__step--current::before { background: var(--royal-gold); }
.workflow__step--current .workflow__dot {
    border-color: var(--royal-gold);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px var(--gold-100);
}

/* --- Money list ----------------------------------------------------------
   The bill breakdown. Figures are monospaced and right-aligned so the column
   reads as a column whatever the amounts.                                   */

.money-list { display: grid; gap: var(--sp-2); margin: 0; }

.money-list__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--sp-4);
    align-items: baseline;
    font-size: var(--fs-sm);
}
.money-list__row dt { margin: 0; color: var(--text-secondary); }
.money-list__row dd { margin: 0; text-align: right; white-space: nowrap; }

.money-list__row--credit dd { color: var(--text-success); }

.money-list__row--total {
    margin-top: var(--sp-2);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--border-strong);
    font-size: var(--fs-h2);
    font-weight: var(--fw-semibold);
}
.money-list__row--total dt { color: var(--text-primary); }

.money-list__row--due {
    font-weight: var(--fw-semibold);
    color: var(--royal-red);
}
.money-list__row--due dt, .money-list__row--due dd { color: var(--royal-red); }

/* --- Menu picker ---------------------------------------------------------
   The basket IS the menu list: every dish carries its own quantity input, so
   the form submits correctly with JavaScript disabled.                      */

.menu-picker {
    max-height: 560px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

.menu-picker__group { border-bottom: 1px solid var(--border); }

.menu-picker__heading {
    display: flex;
    align-items: baseline;
    gap: var(--sp-2);
    margin: 0;
    padding: var(--sp-2) var(--sp-5);
    background: var(--bg-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.menu-picker__list { list-style: none; margin: 0; padding: 0; }

.menu-picker__item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "detail controls"
        "note   note";
    gap: var(--sp-2) var(--sp-4);
    align-items: center;
    padding: var(--sp-3) var(--sp-5);
    border-bottom: 1px solid var(--ink-100);
}
.menu-picker__item:last-child { border-bottom: 0; }
.menu-picker__item.is-selected { background: var(--gold-050); }

.menu-picker__detail { grid-area: detail; min-width: 0; }
.menu-picker__name {
    display: block;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    word-break: break-word;
}
.menu-picker__price {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.menu-picker__controls {
    grid-area: controls;
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

/* Hidden until the line is in the basket: a note field against every dish on a
   200-item menu is noise, and it is only meaningful once a quantity is set.

   :focus-within is what keeps this usable without JavaScript. The is-selected
   class is applied by the script (and server-side when editing an order that
   already has the line), so on a fresh form with scripting off nothing would
   reveal the field - tabbing into the row does. */
.menu-picker__note { grid-area: note; display: none; }
.menu-picker__item.is-selected .menu-picker__note,
.menu-picker__item:focus-within .menu-picker__note { display: block; }

.menu-picker__empty {
    padding: var(--sp-6) var(--sp-5);
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* --- Quantity stepper ---------------------------------------------------- */

.qty-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* 40px: comfortably tappable on the tablets used on the floor without
       towering over the input between them. */
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: var(--fs-h2);
    line-height: 1;
    cursor: pointer;
}
.qty-btn:hover { background: var(--bg-muted); }
.qty-btn:focus-visible { outline: 2px solid var(--royal-gold); outline-offset: 1px; }

.input--qty {
    width: 62px;
    padding-left: var(--sp-2);
    padding-right: var(--sp-2);
    text-align: center;
    font-family: var(--font-mono);
}

.input--sm { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs); }

/* --- Order type chooser -------------------------------------------------- */

.choice-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--sp-2);
    margin: 0;
    padding: 0;
    border: 0;
}

.choice { position: relative; display: block; cursor: pointer; }

/* The radio stays in the accessibility tree and keeps native keyboard
   behaviour; only its default rendering is replaced. */
.choice input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.choice__body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: 48px;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    font-size: var(--fs-sm);
    text-align: center;
}
.choice input[type="radio"]:checked + .choice__body {
    border-color: var(--royal-gold);
    background: var(--gold-050);
    font-weight: var(--fw-medium);
}
.choice input[type="radio"]:focus-visible + .choice__body {
    outline: 2px solid var(--royal-gold);
    outline-offset: 2px;
}

/* --- Small shared pieces ------------------------------------------------- */

.diet-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 4px;
    border: 1.5px solid var(--success);
    border-radius: 2px;
    position: relative;
    vertical-align: middle;
}
.diet-dot--veg::after {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: var(--success);
}

.button-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-4);
}

.checkbox-row { display: flex; flex-wrap: wrap; gap: var(--sp-4) var(--sp-5); }

.inline-note {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    padding: var(--sp-3);
    border-radius: var(--radius);
    background: var(--bg-muted);
    font-size: var(--fs-xs);
    color: var(--text-secondary);
}
.inline-note svg { flex: 0 0 auto; color: var(--text-muted); margin-top: 1px; }

.disclosure > summary {
    cursor: pointer;
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    padding: var(--sp-1) 0;
}
.disclosure > summary:focus-visible { outline: 2px solid var(--royal-gold); outline-offset: 2px; }

.plain-list { list-style: none; margin: var(--sp-2) 0 0; padding: 0; display: grid; gap: var(--sp-2); }

/* --- Record list ---------------------------------------------------------
   A compact list of related records on a detail page (a customer's orders, for
   example). Generic rather than order-specific, so the next module that needs
   "recent related things" does not invent a fourth variant.                  */

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

.record-list__item { border-bottom: 1px solid var(--ink-100); }
.record-list__item:last-child { border-bottom: 0; }

.record-list__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-3) var(--sp-5);
    color: inherit;
    text-decoration: none;
}
.record-list__link:hover { background: var(--bg-muted); }
.record-list__link:focus-visible { outline: 2px solid var(--royal-gold); outline-offset: -2px; }

.record-list__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.record-list__title { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.record-list__meta { font-size: var(--fs-xs); color: var(--text-muted); }

.record-list__aside {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex: 0 0 auto;
    font-size: var(--fs-sm);
}

@media (max-width: 520px) {
    .record-list__link { flex-direction: column; align-items: flex-start; gap: var(--sp-2); }
}

/* A row for something no longer on the menu: readable, but visibly retired. */
.is-muted { color: var(--text-muted); }
.is-muted .cell-stack__primary { color: var(--text-muted); }

@media (max-width: 640px) {
    .menu-picker__item {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "detail" "controls" "note";
        align-items: stretch;
    }
    .menu-picker__controls { justify-content: flex-start; }
    .order-badge { min-width: 0; flex-direction: row; }
}

/* ==========================================================================
   Segmentation, Communication & Analytics (Phase 5)
   ========================================================================== */

/* --- Segment cards -------------------------------------------------------
   A count, its label, and the rule that produced it. The rule is on the card
   rather than behind a tooltip because "why is this 672?" is the first thing
   anybody asks, and an unexplained number in a CRM is a number nobody trusts. */

.grid--segments { grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); }

.segment-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    padding: var(--sp-4) var(--sp-5) var(--sp-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    color: inherit;
    text-decoration: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.segment-card:hover {
    border-color: var(--royal-gold);
    box-shadow: var(--shadow-sm);
}
.segment-card:focus-visible { outline: 2px solid var(--royal-gold); outline-offset: 2px; }

/* An empty segment is still worth showing - "no inactive customers" is good
   news - but it should not compete with the ones carrying people. */
.segment-card--empty { background: var(--bg-muted); }
.segment-card--empty .segment-card__count { color: var(--text-muted); }

.segment-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
}
.segment-card__icon { display: flex; color: var(--text-muted); }

.segment-card__count {
    font-size: 1.75rem;
    font-weight: var(--fw-semibold);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.segment-card__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.segment-card__share { font-size: var(--fs-2xs); color: var(--text-muted); }

.segment-card__basis {
    margin-top: var(--sp-2);
    padding-top: var(--sp-2);
    border-top: 1px solid var(--ink-100);
    font-size: var(--fs-2xs);
    line-height: 1.5;
    color: var(--text-muted);
}

.section__head--tight { margin-bottom: var(--sp-3); }

/* --- Segment banner, on a segment's member list -------------------------- */

.segment-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    max-width: 78ch;
}
.segment-banner__icon { display: flex; flex: 0 0 auto; color: var(--royal-gold); margin-top: 2px; }
.segment-banner__description { font-size: var(--fs-sm); }
.segment-banner__basis { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

/* --- Segment chips on a customer profile --------------------------------- */

.segment-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.segment-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 3px var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-muted);
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    text-decoration: none;
}
.segment-chip:hover { border-color: var(--royal-gold); color: var(--text-primary); }
.segment-chip:focus-visible { outline: 2px solid var(--royal-gold); outline-offset: 2px; }
.segment-chip svg { color: var(--text-muted); }

/* --- Communication -------------------------------------------------------- */

.comm-direction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-xs);
    white-space: nowrap;
}
.comm-direction--incoming { color: var(--text-success); }
.comm-direction--outgoing { color: var(--text-secondary); }

.comm-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: var(--fs-sm);
    line-height: 1.6;
}

/* --- Analytics ------------------------------------------------------------ */

.analytics-range {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    padding: var(--sp-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
}

.analytics-range__option {
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
}
.analytics-range__option:hover { background: var(--bg-muted); color: var(--text-primary); }
.analytics-range__option:focus-visible { outline: 2px solid var(--royal-gold); outline-offset: -2px; }
.analytics-range__option.is-active {
    background: var(--deep-black);
    color: var(--text-inverse);
    font-weight: var(--fw-medium);
}

/*
 * Charts are inline SVG rendered on the server - no charting library, no CDN
 * (the CSP allows scripts from 'self' only), no build step, and no dataset
 * shipped to the browser to be re-aggregated there. They also print, and they
 * render with JavaScript disabled.
 */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart__grid   { stroke: var(--ink-200); stroke-width: 1; }
.chart__axis   { stroke: var(--border-strong); stroke-width: 1; }
.chart__label  { fill: var(--text-muted); font-size: 10px; font-family: var(--font-sans); }
.chart__line   { fill: none; stroke: var(--royal-gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__area   { fill: var(--gold-100); opacity: 0.55; }
.chart__point  { fill: var(--royal-gold); stroke: var(--bg-surface); stroke-width: 1.5; }
.chart__bar    { fill: var(--royal-gold); }
.chart__bar--muted { fill: var(--ink-300); }

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    margin-top: var(--sp-3);
    font-size: var(--fs-xs);
    color: var(--text-secondary);
}
.chart-legend__item { display: inline-flex; align-items: center; gap: var(--sp-2); }
.chart-legend__swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--royal-gold); }
.chart-legend__swatch--muted { background: var(--ink-300); }

/* --- Bar chart -----------------------------------------------------------
   HTML and CSS rather than SVG: a bar is a rectangle with a label and a number,
   which the browser lays out well on its own, and this way the labels wrap, the
   values stay selectable, and a screen reader gets a list rather than a picture
   that needs describing.                                                     */

.bar-chart { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }

.bar-chart__row {
    display: grid;
    grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--sp-3);
    font-size: var(--fs-sm);
}

.bar-chart__label { word-break: break-word; }

.bar-chart__track {
    height: 10px;
    border-radius: var(--radius-pill);
    background: var(--ink-100);
    overflow: hidden;
}

.bar-chart__fill {
    display: block;
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--royal-gold);
}

.bar-chart__value {
    font-family: var(--font-mono);
    font-weight: var(--fw-medium);
    white-space: nowrap;
    text-align: right;
}
.bar-chart__note {
    display: block;
    font-family: var(--font-sans);
    font-weight: var(--fw-regular);
    font-size: var(--fs-2xs);
    color: var(--text-muted);
}

.chart-figure { margin: 0; }

@media (max-width: 560px) {
    .bar-chart__row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "label value" "track track";
        gap: var(--sp-1) var(--sp-3);
    }
    .bar-chart__label { grid-area: label; }
    .bar-chart__value { grid-area: value; }
    .bar-chart__track { grid-area: track; }
}

/* A metric with no data behind it. Never a zero. */
.metric-empty { color: var(--text-muted); font-style: italic; }

@media (max-width: 640px) {
    .segment-card { padding: var(--sp-3) var(--sp-4) var(--sp-4); }
    .segment-card__count { font-size: 1.5rem; }
}

/* --------------------------------------------------------------------------
   Staff & Users
   --------------------------------------------------------------------------
   A heading that carries badges beside it, the grouped permission listing on
   an account page, and the rows of account actions beneath it. All built from
   the existing tokens.
   -------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------
   Attention bell and global search results
   -------------------------------------------------------------------------- */

.dropdown--wide { min-width: 330px; }

.dropdown__empty { padding: var(--sp-5) var(--sp-4); text-align: center; }

.attention { align-items: flex-start; gap: var(--sp-3); }
.attention__icon { display: flex; color: var(--text-muted); margin-top: 2px; }
.attention__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.attention__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.attention__detail { font-size: var(--fs-2xs); color: var(--text-muted); }

.result-list { list-style: none; margin: 0; padding: var(--sp-2); display: grid; gap: 2px; }

.result-list__item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: var(--sp-3);
    border-radius: var(--radius);
    color: inherit;
    text-decoration: none;
}

.result-list__item:hover { background: var(--bg-muted); }
.result-list__item:focus-visible { outline: 2px solid var(--royal-gold); outline-offset: -2px; }
.result-list__title { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.result-list__meta { font-size: var(--fs-xs); color: var(--text-muted); }

.narrow-page--wide { max-width: 780px; }

@media (max-width: 900px) {
    /* The page title matters more than the search box on a narrow header;
       search is still one tap away from the results page. */
    .header__search { display: none; }
}

/* --------------------------------------------------------------------------
   Privacy & Data
   -------------------------------------------------------------------------- */

.chip-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0; }

.chip {
    font-size: var(--fs-xs);
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-muted);
    color: var(--text-secondary);
}

.fieldset__legend {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0;
    margin-bottom: var(--sp-3);
}

/* Side by side deliberately: what goes and what stays are two halves of one
   decision, and reading them one after the other loses the comparison. */
.impact {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-4);
}

.impact__column {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-4);
}

.impact__column--erased { border-color: #F2C4C4; background: var(--red-100); }
.impact__column--kept   { border-color: #BFE6C9; background: var(--success-100); }

.impact__title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    margin: 0 0 var(--sp-3);
}

.impact__column--erased .impact__title { color: var(--red-700); }
.impact__column--kept   .impact__title { color: var(--text-success); }

.impact__list {
    margin: 0;
    padding-left: var(--sp-4);
    display: grid;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
}

@media (max-width: 768px) {
    .impact { grid-template-columns: minmax(0, 1fr); }
}

/* A single-purpose page - one form, nothing else - reads better constrained
   than stretched across a wide desktop content column. */
.narrow-page { max-width: 560px; }

.identity-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-bottom: 2px;
}

.permission-group + .permission-group { margin-top: var(--sp-5); }

.permission-group__title {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 var(--sp-2);
}

.permission-group__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--sp-2);
}

.permission-group__list li {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr) auto;
    align-items: baseline;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
}

.permission-group__icon { color: var(--text-success); display: flex; align-self: center; }

.permission-group__name {
    font-family: var(--font-mono);
    font-size: var(--fs-2xs);
    color: var(--text-muted);
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
    white-space: nowrap;
}

.manage-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-4) 0;
}

.manage-row + .manage-row { border-top: 1px solid var(--border); }
.manage-row:first-child { padding-top: 0; }
.manage-row:last-child { padding-bottom: 0; }

.manage-row__text { max-width: 62ch; }
.manage-row__title { font-size: var(--fs-sm); font-weight: var(--fw-medium); }

.manage-row__actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    flex: 0 0 auto;
}

@media (max-width: 768px) {
    .manage-row { flex-direction: column; align-items: stretch; }
    .permission-group__list li { grid-template-columns: 16px minmax(0, 1fr); }
    .permission-group__name { grid-column: 2; justify-self: start; }
}

/* --------------------------------------------------------------------------
   Dashboard
   --------------------------------------------------------------------------
   Two small layouts the dashboard needs and nothing else did: a row of
   supporting figures under a card heading, and a grid of status counts. Both
   reuse the existing spacing and colour tokens rather than introducing any.
   -------------------------------------------------------------------------- */

.stat-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-3);
}

.stat-row__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-muted);
}

.stat-row__value {
    font-size: 1.375rem;
    font-weight: var(--fw-semibold);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat-row__label {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
    gap: var(--sp-2);
}

.status-grid__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: inherit;
    text-decoration: none;
    transition: border-color var(--transition), background var(--transition);
}

.status-grid__item:hover { border-color: var(--royal-gold); background: var(--bg-muted); }
.status-grid__item:focus-visible { outline: 2px solid var(--royal-gold); outline-offset: 2px; }

.status-grid__count {
    font-size: 1.125rem;
    font-weight: var(--fw-semibold);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
    .stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
    .stat-row__item { padding: var(--sp-2); }
    .stat-row__value { font-size: 1.125rem; }
}

/* --------------------------------------------------------------------------
   Print
   --------------------------------------------------------------------------
   Printing a CRM PAGE - a customer profile, an order, a list somebody wants on
   paper. The 80mm thermal receipt is a different problem with a different page
   size and a different typographic scale, and lives in its own stylesheet
   (public/assets/css/receipt.css) served through layouts/receipt.php. Trying to
   serve both from here would mean one of them fighting the other's rules.
   -------------------------------------------------------------------------- */

@media print {
    .sidebar, .header, .toast-stack, .page-actions, .no-print { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; max-width: none; }
    .card { border: 1px solid #ccc; box-shadow: none; }
    body { background: #fff; }

    /* Interactive affordances mean nothing on paper. */
    .workflow, .qty-btn, .row-actions, .filter-bar { display: none !important; }

    /* A bill breakdown must never be split across a page break. */
    .money-list { page-break-inside: avoid; break-inside: avoid; }

    /* The picker scrolls on screen; on paper it must print in full. */
    .menu-picker { max-height: none; overflow: visible; }
}
