/* Yamete's public and operational pages share one source of truth. The PDF is a design reference;
   route data and status semantics remain owned by the application. */
:root {
    color-scheme: dark;
    --cafe-canvas: #090b17;
    --cafe-surface: #0d1020;
    --cafe-surface-raised: #121728;
    --cafe-surface-soft: #171d30;
    --cafe-surface-popover: #222940;
    --cafe-primary: #8b3dff;
    --cafe-primary-hover: #a366ff;
    --cafe-primary-pressed: #6b25d7;
    --cafe-accent: #4278ff;
    --cafe-accent-soft: #c69aff;
    --cafe-pink: #ec43d8;
    --cafe-cyan: #39d7f2;
    --cafe-text: #f5f6ff;
    --cafe-text-muted: #d4daea;
    --cafe-text-subtle: #adb5d0;
    --cafe-text-disabled: #737e9b;
    --cafe-border: #333a55;
    --cafe-border-strong: #56617e;
    --cafe-line: #29314a;
    --cafe-success: #32d79a;
    --cafe-warning: #f7bb63;
    --cafe-danger: #fa697d;
    --cafe-info: #39d7f2;
    --cafe-price: #32d79a;
    --cafe-radius-card: 12px;
    --cafe-radius-control: 9px;
    --cafe-control-height: 42px;
    --cafe-control-gap: 12px;
    --cafe-mobile-control-gap: 8px;
    --cafe-shadow-card: 0 6px 20px rgb(0 0 0 / 24%);
    --cafe-shadow-primary: 0 8px 28px rgb(139 61 255 / 12%);
    --cafe-shadow-dialog: 0 6px 20px rgb(0 0 0 / 24%);
    --cafe-motion-fast: 140ms ease-out;
    --cafe-gradient-brand: linear-gradient(110deg, #8b3dff 0%, #7042ef 55%, #4278ff 100%);
    --cafe-gradient-canvas: radial-gradient(ellipse at 18% 0%, rgb(139 61 255 / 16%), transparent 42%);
    --cafe-gradient-card: linear-gradient(145deg, #171d30 0%, #121728 100%);
}

/* The application shell is the frame around operator and public routes alike. */
.unified-shell,
.shell-frame,
.shell-drawer-container { background-color: var(--cafe-canvas); }

.unified-shell .vscode-sidebar.mud-drawer {
    border-color: var(--cafe-border);
    background: linear-gradient(180deg, var(--cafe-surface), var(--cafe-canvas) 70%);
}

.unified-shell .vscode-sidebar .mud-drawer-content,
.vscode-sidebar-footer { background-color: var(--cafe-surface); }

.shell-drawer-header,
.vscode-sidebar-footer { border-color: var(--cafe-border); }

/* The brand and active navigation labels need pale lavender against the near-black drawer; primary purple sinks too far. */
.unified-shell .shell-drawer-header .shell-brand { color: #d6c2ff; }

.unified-shell .vscode-sidebar .mud-nav-link.active,
.unified-shell .vscode-sidebar .mud-nav-link.mud-nav-link-active {
    border-left-color: var(--cafe-primary);
    color: var(--cafe-accent);
    background: linear-gradient(90deg, rgb(113 28 255 / 21%), rgb(113 28 255 / 5%));
}

.unified-shell .vscode-sidebar .mud-navmenu .mud-nav-link:is(.active, .mud-nav-link-active) {
    color: #f1eaff;
}

.shell-main .content {
    box-shadow:
        inset 30px 0 30px -30px rgb(0 0 0 / 24%),
        inset -30px 0 30px -30px rgb(0 0 0 / 24%);
}

/* MudBlazor is the default widget layer on many legacy routes; reset its old square gray controls here. */
.mud-navmenu .mud-nav-group > .mud-nav-link,
.mud-navmenu .mud-nav-link { border-radius: 10px; }

/* Active rows stay square so the highlight reads as part of the drawer, not a floating chip. */
.unified-shell .vscode-sidebar .mud-navmenu .mud-nav-link:is(.active, .mud-nav-link-active),
.unified-shell .vscode-sidebar .mud-navmenu .mud-nav-group > .mud-nav-link:is(.active, .mud-nav-link-active),
.unified-shell .vscode-sidebar .mud-navmenu .mud-nav-link:is(.active, .mud-nav-link-active)::before,
.unified-shell .vscode-sidebar .mud-navmenu .mud-nav-link:is(.active, .mud-nav-link-active)::after {
    border-radius: 0 !important;
}

.mud-button-root { border-radius: 12px; }
.mud-button-root.mud-button-filled-primary { background: var(--cafe-primary); color: var(--cafe-text); }
.mud-button-root.mud-button-filled-primary:hover { background: var(--cafe-primary-hover); }
.mud-button-root.mud-button-outlined { border-color: var(--cafe-border-strong); color: var(--cafe-accent-soft); }

.mud-input-control .mud-input-outlined-border { border-color: var(--cafe-border-strong) !important; }
.mud-input-control:hover .mud-input-outlined-border,
.mud-input-control.mud-input-focused .mud-input-outlined-border { border-color: var(--cafe-accent) !important; }

.mud-dialog {
    border: 1px solid var(--cafe-border);
    border-radius: 18px;
    background: linear-gradient(145deg, var(--cafe-surface-raised), var(--cafe-surface));
    box-shadow: var(--cafe-shadow-dialog);
}
.mud-dialog-title { border-bottom: 1px solid var(--cafe-border); background: var(--cafe-surface-soft); }
.mud-dialog-actions { border-top: 1px solid var(--cafe-border); }
.mud-chip {
    border: 1px solid var(--cafe-border);
    border-radius: 999px;
    background: var(--cafe-surface-raised);
    color: var(--cafe-text-muted);
}

/* State badges read from domain classes; Mud palette defaults must not turn them blue or muddy the status. */
.tournament-count-badge { border-color: color-mix(in srgb, var(--cafe-accent) 48%, transparent); background: color-mix(in srgb, var(--cafe-primary) 18%, var(--cafe-surface-raised)); color: var(--cafe-accent-soft); font-weight: 800; }
.tournament-state-chip { border: 1px solid currentColor; background: color-mix(in srgb, currentColor 12%, var(--cafe-surface-raised)); font-weight: 800; }
.tournament-state-chip--open { color: var(--cafe-success); }
.tournament-state-chip--closed { color: var(--cafe-warning); }
.tournament-state-chip--active { color: var(--cafe-accent-soft); }
.tournament-state-chip--champion { color: var(--cafe-warning); }
.tournament-state-chip--cancelled { color: var(--cafe-danger); }
.tournament-state-chip--unknown { color: var(--cafe-text-muted); }
.tournament-artwork-badge { border: 1px solid currentColor; border-radius: 999px; background: color-mix(in srgb, currentColor 12%, var(--cafe-surface-raised)); font-weight: 800; }
.tournament-artwork-badge--updating { color: var(--cafe-accent-soft); }
.tournament-artwork-badge--warning { color: var(--cafe-warning); }

.mud-button-root:focus-visible,
.mud-icon-button:focus-visible { outline: 2px solid var(--cafe-accent-soft); outline-offset: 2px; }

/* MudTable and MudDataGrid toolbars share one control rhythm, including older pages without report wrappers. */
.mud-table-toolbar {
    /* Wrapped controls must grow the toolbar instead of painting over the first row. */
    height: auto;
    min-height: var(--mud-internal-toolbar-height);
    align-items: flex-end !important;
    min-width: 0;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    gap: var(--cafe-control-gap) !important;
}
.mud-table-toolbar > .mud-stack {
    align-items: flex-end !important;
    flex: 0 0 auto;
    flex-wrap: nowrap !important;
    gap: var(--cafe-control-gap) !important;
}
.mud-table-toolbar .mud-tooltip-root {
    display: flex;
    height: var(--cafe-control-height);
    min-height: var(--cafe-control-height);
    max-height: var(--cafe-control-height);
    align-items: flex-end;
}
.mud-table-toolbar .mud-chip,
.mud-table-toolbar .mud-button-root {
    box-sizing: border-box;
    height: var(--cafe-control-height) !important;
    min-height: var(--cafe-control-height) !important;
    max-height: var(--cafe-control-height) !important;
    margin: 0 !important;
}
/* A field includes its helper/error text. Fix only the input shell's height, never the whole field. */
.mud-table-toolbar .mud-input-control {
    box-sizing: border-box;
    height: auto !important;
    min-height: var(--cafe-control-height) !important;
    max-height: none !important;
    margin: 0 !important;
}
.mud-table-toolbar .mud-input-control-input-container,
.mud-table-toolbar .mud-input-control-input-container > .mud-input {
    box-sizing: border-box;
    flex: 0 0 auto;
    height: var(--cafe-control-height);
    min-height: var(--cafe-control-height);
    max-height: var(--cafe-control-height);
}
/* These two legacy stacks already own horizontal scrolling; nested scrollbars make a small toolbar feel like a drawer. */
.rag-ingestion-grid .mud-table-toolbar,
.solar-products-page .mud-table-toolbar { overflow-x: visible; }

/* Filter rows share one alignment contract; component defaults used to make search, select, and action controls drift. */
.cafe-filter-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: flex-end !important;
    gap: var(--cafe-control-gap) !important;
}
.cafe-filter-row > .mud-input-control,
.cafe-filter-row > .mud-button-root,
.cafe-filter-row > .mud-tooltip-root,
.cafe-filter-row > button,
.cafe-filter-row > label,
.cafe-filter-row > .debtor-search {
    box-sizing: border-box;
    align-self: flex-end !important;
    height: var(--cafe-control-height) !important;
    min-height: var(--cafe-control-height) !important;
    /* MudBlazor's outlined labels can inflate flex items unless the shared control box has a firm ceiling. */
    max-height: var(--cafe-control-height) !important;
    margin: 0 !important;
}
.cafe-filter-row > .mud-tooltip-root { display: flex; align-items: flex-end; }
.cafe-filter-row > .mud-tooltip-root .mud-chip {
    box-sizing: border-box;
    height: var(--cafe-control-height);
    min-height: var(--cafe-control-height);
    max-height: var(--cafe-control-height);
}
/* Labels may wrap on narrow screens; only input shells need a fixed-height ceiling. */
.cafe-filter-row .mud-button-root { box-sizing: border-box; height: auto !important; min-height: var(--cafe-control-height) !important; max-height: none !important; padding-block: 6px !important; }
.cafe-filter-row > .mud-input-control {
    flex: 1 1 220px !important;
    width: auto !important;
    min-width: 0;
}
.cafe-filter-control { box-sizing: border-box; height: var(--cafe-control-height) !important; min-height: var(--cafe-control-height) !important; max-height: var(--cafe-control-height) !important; margin: 0 !important; }
/* MudBlazor's 56px input otherwise overflows the compact shell and paints a second, offset focus ring. */
.cafe-filter-control input.mud-input-slot,
.cafe-filter-row input.mud-input-slot {
    box-sizing: border-box;
    height: 100%;
    min-height: 0;
    padding-block: 0;
}
.cafe-filter-control input.mud-input-slot:focus,
.cafe-filter-row input.mud-input-slot:focus { outline: none !important; box-shadow: none !important; }
.cafe-filter-control .mud-input:focus-within,
.cafe-filter-row .mud-input:focus-within { box-shadow: var(--cafe-shadow-focus); }
.cafe-filter-control .mud-input-control-input-container,
.cafe-filter-control .mud-input-control-input-container > .mud-input {
    box-sizing: border-box;
    height: 100%;
    min-height: 0;
    max-height: 100%;
}
.cafe-filter-row > .mud-input-control:not(:first-child) { flex: 0 1 220px !important; }
.cafe-filter-row > .mud-input-control-input-container,
.cafe-filter-row > .mud-input-control .mud-input-control-input-container,
.cafe-filter-row > .mud-input-control .mud-input-control-input-container > .mud-input {
    box-sizing: border-box;
    height: 100%;
    min-height: 0;
    max-height: 100%;
}
.cafe-filter-row > .mud-button-root,
.cafe-filter-row > button { flex: 0 0 auto !important; width: auto !important; padding-block: 0 !important; white-space: nowrap; }
.cafe-filter-row.operations-options > .mud-input-control { flex: 0 1 180px !important; }
.cafe-filter-row > label { flex: 1 1 220px !important; min-width: 0; margin: 0 !important; }
.cafe-filter-row > .debtor-search { flex: 1 1 220px !important; min-width: 0; }
.cafe-filter-row > span { flex: 0 0 auto; align-self: center; }
.cafe-filter-row.purchase-toolbar > .purchase-toolbar-actions { display: flex; align-items: flex-end; gap: var(--cafe-control-gap) !important; }

/* Segmented status filters stay on one rail beside the same-height search and select controls. */
.cafe-choice-row { flex-wrap: nowrap !important; gap: var(--cafe-control-gap) !important; }
.cafe-choice-row > button { box-sizing: border-box; height: var(--cafe-control-height) !important; min-height: var(--cafe-control-height) !important; max-height: var(--cafe-control-height) !important; margin: 0; }

@media (max-width: 700px) {
    .mud-table-toolbar { flex-wrap: wrap !important; overflow-x: visible; gap: var(--cafe-mobile-control-gap) !important; }
    .mud-table-toolbar > .mud-stack {
        flex: 1 1 100%;
        min-width: 0;
        width: 100%;
        flex-wrap: wrap !important;
        gap: var(--cafe-mobile-control-gap) !important;
    }
    .mud-table-toolbar > .mud-spacer { display: none; }
    .cafe-filter-row { flex-direction: column; align-items: stretch !important; gap: var(--cafe-mobile-control-gap) !important; }
    .cafe-filter-row > .mud-input-control,
    .cafe-filter-row > .mud-button-root,
    .cafe-filter-row > .mud-tooltip-root,
    .cafe-filter-row > button,
    .cafe-filter-row > label,
    .cafe-filter-row > .debtor-search { align-self: stretch !important; padding-bottom: 0 !important; }
    .cafe-filter-row > span { align-self: flex-start; padding-bottom: 0 !important; }
    .cafe-filter-row > .mud-input-control,
    .cafe-filter-row > .mud-button-root,
    .cafe-filter-row > button,
    .cafe-filter-row > label,
    .cafe-filter-row > .debtor-search { flex: 0 0 auto !important; width: 100% !important; }
    .cafe-filter-row.purchase-toolbar > .purchase-toolbar-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--cafe-mobile-control-gap) !important; width: 100%; }
    .cafe-filter-row.purchase-toolbar > .purchase-toolbar-actions .mud-button-root { width: 100% !important; }
    .cafe-choice-row { flex-wrap: wrap !important; gap: var(--cafe-mobile-control-gap) !important; }
}

@media (prefers-reduced-motion: reduce) {
    .cafe-home *, .cafe-page *, .auth-page *, .tournament-page *,
    .cafe-home *::before, .cafe-page *::before, .auth-page *::before, .tournament-page *::before,
    .cafe-home *::after, .cafe-page *::after, .auth-page *::after, .tournament-page *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

/* Corporate system contract. This final layer normalizes legacy MudBlazor routes without
   rewriting each page into a different little kingdom. */
html,
body,
#app {
    background: var(--cafe-canvas);
    color: var(--cafe-text);
    font-family: var(--hannah-font-ui);
}

body {
    background-image: var(--cafe-gradient-canvas);
    background-attachment: fixed;
    font-size: 14px;
    line-height: 1.57;
}

h1, h2, h3, h4, h5, h6,
.mud-typography-h1, .mud-typography-h2, .mud-typography-h3,
.mud-typography-h4, .mud-typography-h5, .mud-typography-h6 {
    color: var(--cafe-text);
    font-family: var(--hannah-font-ui);
}

h1, .mud-typography-h1 { font-size: 32px; line-height: 38px; font-weight: 750; }
h2, .mud-typography-h2 { font-size: 24px; line-height: 30px; font-weight: 700; }
h3, .mud-typography-h3 { font-size: 18px; line-height: 24px; font-weight: 700; }

code, pre, .agent-guid, .md-codeblock, .mud-table .mud-table-cell[data-label*="UID"],
[class*="hash"], [class*="hotkey"] { font-family: var(--hannah-font-code); }

.unified-shell,
.shell-frame,
.shell-drawer-container { background: var(--cafe-canvas); }

.unified-shell .vscode-sidebar.mud-drawer {
    width: 240px;
    border-right: 1px solid var(--cafe-border);
    background: var(--cafe-surface);
}

.shell-drawer-header {
    min-height: 84px;
    border-bottom: 1px solid var(--cafe-border);
}

.unified-shell .vscode-sidebar .mud-navmenu { padding: 12px 0 16px; }
.unified-shell .vscode-sidebar .mud-nav-link,
.unified-shell .vscode-sidebar .mud-nav-group > .mud-nav-link {
    min-height: 44px;
    margin: 0;
    padding-inline: 16px;
    border-radius: 0;
    color: var(--cafe-text-muted);
    font-size: 14px;
}

.unified-shell .vscode-sidebar .mud-nav-link .mud-nav-link-icon,
.unified-shell .vscode-sidebar .mud-nav-group > .mud-nav-link .mud-nav-link-icon {
    width: 20px;
    height: 20px;
    margin-inline-end: 12px;
    color: var(--cafe-text-subtle);
}

.unified-shell .vscode-sidebar .mud-nav-link:hover,
.unified-shell .vscode-sidebar .mud-nav-group > .mud-nav-link:hover {
    background: var(--cafe-surface-soft);
    color: var(--cafe-text);
}

.unified-shell .vscode-sidebar .mud-nav-link.active,
.unified-shell .vscode-sidebar .mud-nav-link.mud-nav-link-active {
    border-left: 3px solid var(--cafe-primary);
    background: rgb(139 61 255 / 14%);
    color: var(--cafe-text);
    box-shadow: 0 0 8px rgb(139 61 255 / 22%);
}

.shell-main.mud-main-content { background: var(--cafe-canvas); }
.shell-main .content { max-width: 1600px; margin: 0 auto; padding: 28px 32px 40px; }

/* Switch bases share the button class, but their height must follow their small/medium/large track. */
.mud-button-root:not(.mud-switch-base) { min-height: 40px; }
.mud-button-root {
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    transition: background-color 140ms ease-out, border-color 140ms ease-out, transform 140ms ease-out, box-shadow 140ms ease-out;
}

.mud-button-root.mud-button-filled-primary {
    background: var(--cafe-gradient-brand);
    border: 1px solid rgb(255 255 255 / 10%);
}

.mud-button-root.mud-button-filled-primary:hover {
    background: var(--cafe-primary-hover);
    box-shadow: var(--cafe-shadow-primary);
}

.mud-button-root.mud-button-filled-primary:active { background: var(--cafe-primary-pressed); transform: translateY(1px); box-shadow: none; }
.mud-button-root.mud-button-outlined { border-color: var(--cafe-border-strong); color: var(--cafe-text); background: var(--cafe-surface-soft); }
.mud-button-root.mud-button-text { color: var(--cafe-text-muted); }

.mud-input-control .mud-input-outlined-border,
.mud-input-control .mud-input-underline:before { border-color: var(--cafe-border) !important; }
.mud-input-control:hover .mud-input-outlined-border,
.mud-input-control.mud-input-focused .mud-input-outlined-border { border-color: var(--cafe-border-strong) !important; }

.mud-table-body .mud-table-row:nth-child(even) { background: #151b2c; }

.mud-dialog {
    border: 1px solid var(--cafe-border);
    border-radius: 16px;
    background: var(--cafe-gradient-card);
    box-shadow: var(--cafe-shadow-dialog);
}

.mud-chip { border-radius: 7px; }
.mud-button-root:focus-visible,
.mud-icon-button:focus-visible,
.mud-nav-link:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible { outline: 3px solid rgb(198 154 255 / 45%); outline-offset: 2px; }

/* Row actions keep touch targets; switch bases reuse this class but have framework-sized thumb geometry. */
.mud-table-body .mud-icon-button:not(.mud-switch-base),
.mud-table .mud-table-row .mud-icon-button:not(.mud-switch-base),
.mud-datagrid .mud-table-body .mud-icon-button:not(.mud-switch-base),
.mud-data-grid .mud-table-body .mud-icon-button:not(.mud-switch-base) {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 9px;
}

@media (max-width: 1439.98px) { .shell-main .content { padding-inline: 24px; } }
@media (max-width: 1199.98px) { .shell-main .content { padding-inline: 20px; } }
@media (max-width: 767.98px) {
    h1, .mud-typography-h1 { font-size: 26px; line-height: 32px; }
    h2, .mud-typography-h2 { font-size: 20px; line-height: 26px; }
    .shell-main .content { padding: 24px 16px max(32px, env(safe-area-inset-bottom)); }
    .mud-button-root:not(.mud-switch-base), .mud-icon-button:not(.mud-switch-base) { min-height: 44px; }
    /* Icon actions need a full touch target; switch thumbs have their own geometry. */
    .mud-icon-button:not(.mud-switch-base) { min-width: 44px; }
    .mud-switch { min-height: 44px; }
    /* Native number entry stays available on phones; Mud's stacked 15x19px spin buttons cannot be tapped reliably. */
    .mud-input-number-control.mud-input-showspin .mud-input-numeric-spin { display: none; }
    .mud-table-body .mud-icon-button:not(.mud-switch-base),
    .mud-table .mud-table-row .mud-icon-button:not(.mud-switch-base),
    .mud-datagrid .mud-table-body .mud-icon-button:not(.mud-switch-base),
    .mud-data-grid .mud-table-body .mud-icon-button:not(.mud-switch-base) {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
    .mud-input-control { min-height: 44px; }
    .mud-table, .mud-datagrid, .mud-data-grid { overflow-x: auto; }
}

/* PDF conformance layer: the old shell skin had oversized glowing icons and
   rainbow navigation. Keep the product calm, instrument-like, and readable. */
:root {
    --cafe-gradient-brand: linear-gradient(110deg, #8b3dff 0%, #7042ef 55%, #4278ff 100%);
    --cafe-gradient-canvas: radial-gradient(ellipse at 18% 0%, rgb(139 61 255 / 16%), transparent 42%);
    --cafe-gradient-card: linear-gradient(145deg, #171d30 0%, #121728 100%);
    --cafe-shadow-low: 0 6px 20px rgb(0 0 0 / 24%);
    --cafe-shadow-focus: 0 0 0 3px rgb(198 154 255 / 45%);
}

body { background-image: var(--cafe-gradient-canvas); }

.unified-shell .vscode-sidebar .mud-navmenu .mud-nav-link,
.unified-shell .vscode-sidebar .mud-navmenu .mud-nav-group > .mud-nav-link {
    min-height: 44px !important;
    height: 44px;
    padding-inline: 16px !important;
    color: var(--cafe-text-muted) !important;
    font-size: 14px !important;
    letter-spacing: normal;
    text-shadow: none;
}

.unified-shell .vscode-sidebar .mud-navmenu .mud-nav-link .mud-nav-link-icon,
.unified-shell .vscode-sidebar .mud-navmenu .mud-nav-group > .mud-nav-link .mud-nav-link-icon {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    flex-basis: 20px !important;
    margin-inline-end: 12px !important;
    font-size: 20px !important;
    filter: none !important;
}

.unified-shell .vscode-sidebar .mud-nav-link .mud-icon-root,
.unified-shell .vscode-sidebar .mud-nav-group > .mud-nav-link .mud-icon-root {
    color: var(--cafe-text-subtle) !important;
}

.unified-shell .vscode-sidebar .mud-nav-link:hover,
.unified-shell .vscode-sidebar .mud-nav-group > .mud-nav-link:hover {
    background: var(--cafe-surface-soft) !important;
    color: var(--cafe-text) !important;
}

.unified-shell .vscode-sidebar .mud-nav-link.active,
.unified-shell .vscode-sidebar .mud-nav-link.mud-nav-link-active {
    border-left: 3px solid var(--cafe-primary) !important;
    background: rgb(139 61 255 / 14%) !important;
    color: var(--cafe-text) !important;
    box-shadow: none !important;
}

.unified-shell .vscode-sidebar .mud-nav-link.active .mud-icon-root,
.unified-shell .vscode-sidebar .mud-nav-link.mud-nav-link-active .mud-icon-root {
    color: #b47bff !important;
}

/*
   The navigation is a tree, not a bag of similarly dressed buttons.
   MudNavGroup renders nested menus through collapse wrappers, so the rail
   belongs on the nested menu itself. That keeps the hierarchy visible on the
   temporary mobile/tablet drawer without changing route behavior.
*/
.unified-shell .vscode-sidebar .shell-nav-tree > .mud-nav-group {
    position: relative;
    margin-block: 4px;
}

.unified-shell .vscode-sidebar .shell-nav-tree > .mud-nav-group > .mud-nav-link {
    min-height: 48px !important;
    height: 48px;
    border: 1px solid transparent;
    border-inline-start: 3px solid color-mix(in srgb, var(--nav-accent) 72%, transparent);
    border-radius: 0 12px 12px 0 !important;
    background: linear-gradient(90deg, color-mix(in srgb, var(--nav-accent) 10%, transparent), transparent 78%);
    color: var(--cafe-text) !important;
    font-size: 13px !important;
    font-weight: 800;
    letter-spacing: .055em;
    text-transform: uppercase;
}

.unified-shell .vscode-sidebar .shell-nav-tree > .mud-nav-group > .mud-nav-link .mud-nav-link-expand-icon {
    opacity: .9;
}

/* Keep the palette deliberate and visible even when the older shell rules
   force every icon to the same muted gray. One accent per branch; no rainbow
   casino nonsense. */
.unified-shell .vscode-sidebar .shell-nav-tree .nav-group-bittensor { --nav-accent: #a98bff; }
.unified-shell .vscode-sidebar .shell-nav-tree .nav-group-cafe { --nav-accent: #47d7df; }
.unified-shell .vscode-sidebar .shell-nav-tree .nav-group-cameras { --nav-accent: #ff9caa; }
.unified-shell .vscode-sidebar .shell-nav-tree .nav-group-rag { --nav-accent: #d09aff; }
.unified-shell .vscode-sidebar .shell-nav-tree .nav-group-collab { --nav-accent: #76d7bd; }
.unified-shell .vscode-sidebar .shell-nav-tree .nav-group-agents { --nav-accent: #c49aff; }
.unified-shell .vscode-sidebar .shell-nav-tree .nav-group-system { --nav-accent: #8bb8ff; }

.unified-shell .vscode-sidebar .shell-nav-tree .mud-nav-group > .mud-nav-link .mud-nav-link-icon .mud-icon-root,
.unified-shell .vscode-sidebar .shell-nav-tree .mud-nav-group > .mud-nav-link .mud-icon-root {
    color: var(--nav-accent) !important;
}

.unified-shell .vscode-sidebar .shell-nav-tree .mud-nav-group > .mud-nav-link {
    color: color-mix(in srgb, var(--cafe-text) 82%, var(--nav-accent)) !important;
}

.unified-shell .vscode-sidebar .shell-nav-tree .mud-nav-group > .mud-nav-link:hover,
.unified-shell .vscode-sidebar .shell-nav-tree .mud-nav-group > .mud-nav-link:focus-visible {
    color: var(--cafe-text) !important;
    background: color-mix(in srgb, var(--nav-accent) 13%, transparent) !important;
}

/* Child menus form a visible branch. The inset is intentional: it is the
   one cheap visual cue that survives narrow overlay drawers and touch scale. */
.unified-shell .vscode-sidebar .shell-nav-tree .mud-nav-group .mud-navmenu {
    position: relative;
    margin: 2px 12px 8px 24px;
    padding: 4px 0 4px 10px;
    border-inline-start: 1px solid color-mix(in srgb, var(--nav-accent) 42%, transparent);
    border-radius: 0 12px 12px 0;
    background: linear-gradient(90deg, color-mix(in srgb, var(--nav-accent) 7%, transparent), transparent 88%);
}

.unified-shell .vscode-sidebar .shell-nav-tree .mud-nav-group .mud-navmenu::before {
    position: absolute;
    inset: 8px auto 8px -1px;
    width: 1px;
    content: "";
    background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--nav-accent) 72%, transparent) 18%, color-mix(in srgb, var(--nav-accent) 72%, transparent) 82%, transparent);
}

/* MudNavLink wraps its anchor in mud-nav-item; match that wrapper so leaves align with group buttons. */
.unified-shell .vscode-sidebar .shell-nav-tree .mud-nav-group .mud-navmenu > .mud-nav-item > .mud-nav-link,
.unified-shell .vscode-sidebar .shell-nav-tree .mud-nav-group .mud-navmenu > .mud-nav-group > .mud-nav-link {
    position: relative;
    min-height: 40px !important;
    height: 40px;
    padding-inline: 10px 12px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
}

/* Small branch stubs make the parent/child relationship legible even when
   the drawer is open over artwork and the background is visually busy. */
.unified-shell .vscode-sidebar .shell-nav-tree .mud-nav-group .mud-navmenu > .mud-nav-item > .mud-nav-link::before,
.unified-shell .vscode-sidebar .shell-nav-tree .mud-navmenu > .mud-nav-group > .mud-nav-link::before {
    position: absolute;
    inset: 50% auto auto -11px;
    width: 9px;
    height: 1px;
    content: "";
    background: color-mix(in srgb, var(--nav-accent) 66%, transparent);
}

.unified-shell .vscode-sidebar .shell-nav-tree .mud-navmenu > .mud-nav-group > .mud-nav-link {
    color: color-mix(in srgb, var(--cafe-text) 94%, var(--nav-accent)) !important;
    font-weight: 700;
}

.unified-shell .vscode-sidebar .shell-nav-tree .mud-navmenu > .mud-nav-group > .mud-navmenu {
    margin-inline-start: 14px;
    padding-inline-start: 10px;
    background: transparent;
}

.unified-shell .vscode-sidebar .shell-nav-tree .mud-navmenu .mud-nav-link.active,
.unified-shell .vscode-sidebar .shell-nav-tree .mud-navmenu .mud-nav-link.mud-nav-link-active {
    border-inline-start: 2px solid var(--nav-accent) !important;
    background: color-mix(in srgb, var(--nav-accent) 14%, transparent) !important;
    color: var(--cafe-text) !important;
    box-shadow: inset 8px 0 18px color-mix(in srgb, var(--nav-accent) 8%, transparent) !important;
}

.shell-drawer-header { min-height: 84px !important; }
.shell-brand { color: #f5f6ff !important; letter-spacing: .1em; }
.shell-main .content { padding: 28px 32px 40px; }

.mud-button-root.mud-button-filled-primary {
    background: var(--cafe-gradient-brand) !important;
    color: #fff !important;
}

.mud-button-root.mud-button-outlined {
    background: var(--cafe-surface-soft) !important;
    border-color: var(--cafe-border-strong) !important;
    color: var(--cafe-text) !important;
}

.mud-button-root:focus-visible,
.mud-icon-button:focus-visible,
.mud-nav-link:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible { box-shadow: var(--cafe-shadow-focus); outline: 0; }

.mud-table,
.mud-datagrid,
.mud-data-grid,
.cafe-report-grid,
.operations-panel {
    border-radius: var(--cafe-radius-card) !important;
    box-shadow: var(--cafe-shadow-low) !important;
}

.mud-table-head .mud-table-cell,
.mud-data-grid thead .mud-table-cell { letter-spacing: .06em; text-transform: uppercase; }

/* Shared record-table contract: grouped store and operations pages use one visual rail
   even when the row interaction is an accordion, action record, or account card. */
.cafe-record-surface {
    min-width: 0;
    border: 1px solid var(--cafe-border) !important;
    border-radius: var(--cafe-radius-card) !important;
    background: linear-gradient(145deg, var(--cafe-surface-raised), var(--cafe-surface) 72%) !important;
    box-shadow: var(--cafe-shadow-low) !important;
    overflow: hidden;
}

.cafe-record-surface > .operations-group-heading {
    min-height: 52px;
    margin: 0;
    padding: 14px 16px;
    border-bottom: 1px solid var(--cafe-border);
    background: linear-gradient(145deg, var(--cafe-surface-soft), var(--cafe-surface));
}

.cafe-record-surface > :is(.unit-record, .store-product-record, .store-day, .debtor-account) {
    border-color: var(--cafe-line);
}

.cafe-record-surface :is(.unit-overview, .store-product-overview, .store-day summary) {
    transition: background-color 140ms ease;
}

.cafe-record-surface :is(.unit-record, .store-product-record, .store-day):hover {
    background: color-mix(in srgb, var(--cafe-accent) 6%, transparent);
}

.cafe-record-surface .unit-column-heading,
.cafe-record-surface .store-day-columns {
    background: color-mix(in srgb, var(--cafe-surface-soft) 86%, var(--cafe-primary));
}

.cafe-record-surface .debtor-account {
    margin: 14px;
    border-color: var(--cafe-border);
    background: color-mix(in srgb, var(--cafe-surface) 92%, transparent);
}

@media (max-width: 700px) {
    .cafe-record-surface > .operations-group-heading { padding-inline: 12px; }
    .cafe-record-surface .debtor-account { margin: 10px; }
}

@media (max-width: 1199.98px) {
    .shell-main .content { padding-inline: 20px; }
}

@media (max-width: 1199.98px) {
    /* Compact navigation is a real 56px bar. Every report page starts below it;
       page-specific shells may tune side gutters, but cannot hide their eyebrow. */
    .cafe-report-page { padding-top: 68px !important; }

    .shell-mobile-menu-bar {
        inset: 0 0 auto;
        width: 100%;
        height: 56px;
        border-radius: 0;
        box-shadow: 0 6px 20px rgb(0 0 0 / 24%);
    }
    .shell-mobile-menu-bar::before {
        border-radius: 0;
        background: var(--cafe-surface);
        border-bottom: 1px solid var(--cafe-border);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .shell-mobile-brand { color: var(--cafe-text) !important; text-shadow: none; font-size: 14px !important; }
    .shell-mobile-menu-bar.drawer-open { height: 56px; padding-inline: 16px; }
    .unified-shell .vscode-sidebar.mud-drawer--open { inset-block-start: 56px; width: min(300px, 86vw) !important; max-width: 86vw !important; }
    .shell-main .content { padding-top: 24px; }
}

/* Tablets use the same hidden drawer and top menu bar as phones; only page gutters grow. */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .shell-main .content { padding-inline: 20px; }
}

@media (max-width: 767.98px) {
    .shell-main .content { padding: 24px 16px max(32px, env(safe-area-inset-bottom)); }
}

/* Reference-fidelity layer: operational routes get the same cinematic header
   atmosphere as the metagraph without turning real data into decorative soup. */
:root {
    --cafe-gradient-accent-line: linear-gradient(90deg, #8b3dff 0%, #ec43d8 55%, #4278ff 100%);
    --cafe-hero-scrim: linear-gradient(90deg, rgb(9 11 23 / 96%), rgb(9 11 23 / 78%) 45%, rgb(9 11 23 / 18%));
    --cafe-shadow-selected: 0 8px 28px rgb(139 61 255 / 12%);
}

/* The shell owns the artwork and its readability scrim. Cards stay opaque;
   page wrappers must not paint over the generated header. */
.shell-main { position: relative; isolation: isolate; }
.shell-main-atmosphere {
    position: absolute;
    z-index: -2;
    inset: 0 0 auto auto;
    width: min(1080px, 78vw);
    height: 360px;
    overflow: hidden;
    pointer-events: none;
    opacity: .78;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, rgb(0 0 0 / 90%) 58%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 0%, rgb(0 0 0 / 90%) 58%, transparent 100%);
}
.shell-main-atmosphere::after {
    position: absolute;
    inset: 0;
    content: "";
    background: var(--cafe-hero-scrim);
}
.shell-main-atmosphere img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center right;
    filter: saturate(.9) brightness(.72);
}
.shell-main::before {
    position: absolute;
    z-index: -1;
    inset: 0 0 auto auto;
    width: min(1080px, 78vw);
    height: 360px;
    content: "";
    pointer-events: none;
    background-image: var(--cafe-hero-scrim), var(--cafe-gradient-canvas);
    background-position: center, center right;
    background-size: cover;
    opacity: .72;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, rgb(0 0 0 / 90%) 58%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 0%, rgb(0 0 0 / 90%) 58%, transparent 100%);
}

.shell-main:has(.cafe-home)::before { display: none; }
/* The image already carries the readable scrim; stacking the fallback over it hides the artwork. */
.shell-main:has(.shell-main-atmosphere)::before { display: none; }
.shell-main .content { position: relative; z-index: 0; }

/* A page header is the hand-off point between atmosphere and facts. */
.cafe-report-page,
.cafe-page,
.cafe-utility-page,
.cafe-threads-page {
    position: relative;
    isolation: isolate;
    min-height: 100%;
}

.cafe-report-page::before,
.cafe-page::before,
.cafe-utility-page::before,
.cafe-threads-page::before {
    position: absolute;
    z-index: -1;
    inset: -28px -32px auto;
    height: 260px;
    content: "";
    pointer-events: none;
    background: var(--cafe-gradient-canvas);
    opacity: .9;
}

.cafe-report-heading,
.operations-heading,
.cafe-page-heading { position: relative; padding-top: 8px; padding-bottom: 16px; }

/* Decoration sits below content, never as a third flex item competing with header actions. */
.cafe-report-heading::after,
.operations-heading::after,
.cafe-page-heading::after {
    display: block;
    position: absolute;
    inset-inline-start: 0;
    bottom: 0;
    width: min(240px, 42vw);
    height: 2px;
    content: "";
    background: var(--cafe-gradient-accent-line);
    border-radius: 99px;
    opacity: .9;
}

/* Gradient borders carry the neon signature; the surface remains readable. */
.cafe-kpi-card,
.operations-metrics > div,
.cafe-energy-card,
.cafe-utility-card,
.cafe-settings-table-card {
    border: 1px solid transparent !important;
    background: linear-gradient(var(--cafe-surface-raised), var(--cafe-surface-raised)) padding-box,
        var(--cafe-gradient-accent-line) border-box !important;
}

.cafe-kpi-card:hover,
.operations-metrics > div:hover,
.cafe-energy-card:hover,
.cafe-utility-card:hover,
.cafe-settings-table-card:hover {
    box-shadow: var(--cafe-shadow-selected) !important;
}

.mud-button-root.mud-button-filled-primary,
.cafe-button-primary {
    border: 1px solid rgb(255 255 255 / 10%) !important;
    background: var(--cafe-gradient-brand) !important;
    box-shadow: var(--cafe-shadow-selected);
}

.mud-button-root.mud-button-outlined,
.cafe-button-outline {
    border: 1px solid transparent !important;
    background: linear-gradient(var(--cafe-surface-soft), var(--cafe-surface-soft)) padding-box,
        var(--cafe-gradient-accent-line) border-box !important;
    color: var(--cafe-text) !important;
}

.mud-button-root.mud-button-outlined:hover,
.cafe-button-outline:hover { background: linear-gradient(var(--cafe-surface-popover), var(--cafe-surface-popover)) padding-box, var(--cafe-gradient-accent-line) border-box !important; }

.mud-input-control .mud-input-outlined-border,
.mud-input-outlined-border,
.cafe-filter-control,
.operations-order,
input:not([type='checkbox']):not([type='radio']):not(.mud-input-slot),
select,
textarea { border-radius: var(--cafe-radius-control) !important; }

.mud-table,
.mud-datagrid,
.mud-data-grid,
.cafe-report-grid {
    border-color: var(--cafe-border) !important;
    box-shadow: var(--cafe-shadow-card) !important;
}

.mud-table-head .mud-table-cell,
.mud-data-grid thead .mud-table-cell {
    background: linear-gradient(180deg, var(--cafe-surface-soft), var(--cafe-surface-raised));
    text-transform: uppercase;
}

@media (max-width: 1199.98px) {
    .shell-main::before { width: 90vw; height: 310px; }
    .shell-main-atmosphere { width: 90vw; height: 310px; }
    .cafe-report-page::before,
    .cafe-page::before,
    .cafe-utility-page::before,
    .cafe-threads-page::before { inset-inline: -20px; }
}

@media (max-width: 767.98px) {
    .shell-main::before { inset: 0 0 auto; width: 100%; height: 260px; opacity: .56; }
    .shell-main-atmosphere { inset: 0; width: 100%; height: 260px; opacity: .64; }
    .cafe-report-page::before,
    .cafe-page::before,
    .cafe-utility-page::before,
    .cafe-threads-page::before { inset: -24px -16px auto; height: 220px; }
    .cafe-report-heading,
    .operations-heading,
    .cafe-page-heading { padding-top: 0; padding-bottom: 12px; }
}

/* Codex access lives outside the app shell, so give its cards the same border
   language and CTA weight instead of letting the isolated route drift away. */
.codex-login-card,
.codex-welcome-card {
    border: 1px solid transparent !important;
    background:
        linear-gradient(145deg, var(--cafe-surface-raised), var(--cafe-surface) 68%) padding-box,
        var(--cafe-gradient-accent-line) border-box !important;
}

.codex-login-card .mud-button-filled-primary,
.codex-welcome-card .mud-button-filled-primary {
    border: 1px solid rgb(255 255 255 / 10%) !important;
    background: var(--cafe-gradient-brand) !important;
    color: var(--cafe-text) !important;
    box-shadow: var(--cafe-shadow-selected) !important;
}

.codex-login-card .mud-button-outlined-primary,
.codex-welcome-card .mud-button-outlined-primary,
.codex-access-header .mud-button-outlined-primary {
    border: 1px solid transparent !important;
    background: linear-gradient(var(--cafe-surface-soft), var(--cafe-surface-soft)) padding-box,
        var(--cafe-gradient-accent-line) border-box !important;
    color: var(--cafe-text) !important;
}

/* Shared component contract. Page styles can arrange content, but these rules
   own the visual language so every route still belongs to the same product. */
.cafe-report-page,
.cafe-page,
.cafe-utility-page,
.cafe-privacy-page,
.cafe-threads-page { background: transparent !important; }

.cafe-report-heading,
.operations-heading,
.cafe-page-heading { margin-bottom: 20px; }

.cafe-report-heading h1,
.operations-heading h1,
.cafe-page-heading h1 {
    color: var(--cafe-text) !important;
    font-size: 32px !important;
    font-weight: 750 !important;
    line-height: 38px !important;
    letter-spacing: -.025em;
}

.cafe-page-eyebrow,
.cafe-report-heading .cafe-page-eyebrow,
.operations-heading .cafe-page-eyebrow {
    color: var(--cafe-text-muted) !important;
    font-size: 11px !important;
    font-weight: 500;
    letter-spacing: .1em;
}

.cafe-report-description,
.cafe-page-lead,
.operations-heading p { color: var(--cafe-text-muted) !important; font-size: 14px; line-height: 22px; }

/* KPI and metric surfaces: one selected surface may glow; the whole dashboard
   must not look like it has been plugged into a defective Christmas tree. */
.cafe-energy-card,
.cafe-utility-card,
.cafe-kpi-card,
.operations-metrics > div,
.cafe-settings-table-card {
    border: 1px solid var(--cafe-border) !important;
    border-radius: var(--cafe-radius-card) !important;
    background: var(--cafe-gradient-card) !important;
    box-shadow: var(--cafe-shadow-low) !important;
}

/* Metric blocks became cards; reserve inner space instead of painting borders against the text. */
.operations-metrics > div { box-sizing: border-box; max-width: 100%; padding: 14px 18px; }
.cafe-energy-card { min-height: 104px; padding: 20px !important; }
.cafe-energy-card-title { color: var(--cafe-text-muted) !important; font-size: 12px !important; font-weight: 500 !important; }
.cafe-energy-card .mud-typography-h4,
.cafe-kpi-card strong,
.operations-metrics strong { color: var(--cafe-text) !important; font-size: 26px !important; line-height: 32px; font-variant-numeric: tabular-nums; }
.cafe-energy-card .mud-typography-caption,
.cafe-kpi-card small { color: var(--cafe-text-muted) !important; font-size: 11px !important; line-height: 16px; }
.cafe-energy-card .mud-divider { border-color: var(--cafe-line) !important; }

.cafe-energy-cycle,
.cafe-filter-chip,
.mud-chip { min-height: 24px; border-radius: 7px !important; }

.cafe-energy-cycle { border-color: var(--cafe-border) !important; background: var(--cafe-surface-raised) !important; color: var(--cafe-text-muted) !important; }

/* The outlined fieldset sits above the input. Keep it transparent so text and adornments remain visible. */
.mud-input-control .mud-input-outlined-border,
.mud-input-outlined-border {
    border-radius: var(--cafe-radius-control) !important;
    border-color: var(--cafe-border) !important;
    background: transparent !important;
    pointer-events: none;
}

/* Put the surface on the control itself, never on its decorative fieldset. */
.mud-input.mud-input-outlined,
.cafe-filter-control,
.operations-order,
input:not([type='checkbox']):not([type='radio']):not(.mud-input-slot),
select,
textarea {
    border-radius: var(--cafe-radius-control) !important;
    border-color: var(--cafe-border) !important;
    background: var(--cafe-surface) !important;
    color: var(--cafe-text) !important;
}

.mud-input-control:hover .mud-input-outlined-border,
.mud-input-control.mud-input-focused .mud-input-outlined-border,
.operations-order:focus,
input:focus:not(.mud-input-slot),
select:focus,
textarea:focus { border-color: var(--cafe-primary) !important; }

/* Outlined controls have a label notch; a shadow ring cuts across it, so focus is shown by border color alone. */
.mud-input.mud-input-outlined:focus-within { box-shadow: none; }
.mud-input.mud-input-outlined > .mud-input-slot:focus,
.mud-input.mud-input-outlined > .mud-input-slot:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}
.mud-input.mud-input-outlined > .mud-input-outlined-border { box-shadow: none !important; }

.mud-input-label,
.mud-input-slot::placeholder,
input::placeholder,
textarea::placeholder { color: var(--cafe-text-subtle) !important; }

.mud-input-slot,
.mud-select-input,
.mud-input { color: var(--cafe-text) !important; }

/* Status language remains textual and color-assisted, never color-only. */
.cafe-success { color: var(--cafe-success) !important; }
.cafe-warning { color: var(--cafe-warning) !important; }
.cafe-danger { color: var(--cafe-danger) !important; }
.cafe-status-badge { display: inline-flex; min-height: 24px; align-items: center; gap: 6px; padding-inline: 8px; border-radius: 6px; font-size: 11px; font-weight: 500; }
.cafe-status-badge::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ''; }
.cafe-status-badge.is-online { background: rgb(50 215 154 / 12%); color: var(--cafe-success); }
.cafe-status-badge.is-idle { background: rgb(247 187 99 / 12%); color: var(--cafe-warning); }
.cafe-status-badge.is-offline { background: var(--cafe-surface-soft); color: var(--cafe-text-muted); }

.agents-chat-root { background: var(--cafe-canvas) !important; }
.agents-history { flex-basis: 280px; background: var(--cafe-surface) !important; border-color: var(--cafe-border) !important; }
.agents-chat-toolbar { background: var(--cafe-surface-soft) !important; border-color: var(--cafe-border) !important; }
.agents-center { background: transparent !important; }
.agents-runtime-error-card { border-color: var(--cafe-danger); border-left-width: 1px; border-radius: var(--cafe-radius-card); background: var(--cafe-surface-raised); box-shadow: var(--cafe-shadow-low); }

@media (min-width: 1200px) {
    .cafe-report-shell,
    .operations-shell { max-width: 1600px; }
    /* MudGrid uses padded percentage columns; an extra flex gap forces its third column to wrap. */
}

@media (max-width: 1199.98px) {
    .cafe-energy-card { min-height: 96px; padding: 20px !important; }
}

@media (max-width: 767.98px) {
    .cafe-report-heading h1,
    .operations-heading h1,
    .cafe-page-heading h1 { font-size: 26px !important; line-height: 32px !important; }
    .cafe-energy-card { min-height: 0; padding: 16px !important; }
    .mud-table,
    .mud-datagrid,
    .mud-data-grid,
    .cafe-report-grid { overflow-x: auto; }
    .mud-table-head .mud-table-cell,
    .mud-data-grid thead .mud-table-cell { height: 48px; }
    .mud-table-body .mud-table-cell,
    .mud-data-grid tbody .mud-table-cell { height: 48px; }
    .agents-history { flex-basis: 300px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Mud's stacked cells are flex boxes, so a fixed desktop row height clips labels and editors.
   These boundaries match Mud's generated table media rules, not the breakpoint's lower bound. */
@media (max-width: 600px) {
    .mud-xs-table .mud-table-body .mud-table-cell { height: auto; min-height: 48px; }
}
@media (max-width: 960px) {
    .mud-sm-table .mud-table-body .mud-table-cell { height: auto; min-height: 48px; }
}
@media (max-width: 1280px) {
    .mud-md-table .mud-table-body .mud-table-cell { height: auto; min-height: 48px; }
}
@media (max-width: 1920px) {
    .mud-lg-table .mud-table-body .mud-table-cell { height: auto; min-height: 48px; }
}
@media (max-width: 2560px) {
    .mud-xl-table .mud-table-body .mud-table-cell { height: auto; min-height: 48px; }
}

/* Route families: same system, different information density. */
.auth-page {
    background: var(--cafe-canvas) !important;
    padding: clamp(24px, 5vh, 64px) clamp(16px, 4vw, 64px) !important;
}

.auth-layout {
    min-height: min(690px, calc(100dvh - 72px));
    border: 1px solid var(--cafe-border) !important;
    border-radius: var(--cafe-radius-dialog) !important;
    background: var(--cafe-gradient-card) !important;
    box-shadow: var(--cafe-shadow-low) !important;
}

.auth-story {
    border-color: var(--cafe-border) !important;
    background: linear-gradient(145deg, var(--cafe-surface-soft), var(--cafe-surface) 72%) !important;
}

.auth-story h1 { font-size: 48px; line-height: 52px; text-shadow: none; }
.auth-story h1 span { color: var(--cafe-accent-soft); text-shadow: none; }
.auth-mode-pill { border-color: var(--cafe-border-strong); border-radius: 7px; background: rgb(139 61 255 / 12%); color: var(--cafe-text-muted); }
.auth-panel-icon { border-color: var(--cafe-border); border-radius: var(--cafe-radius-card); background: var(--cafe-surface-soft); box-shadow: none; }
.auth-form .mud-input-root { background: var(--cafe-surface) !important; }
.auth-primary-button.mud-button-root { background: var(--cafe-gradient-brand) !important; box-shadow: var(--cafe-shadow-primary) !important; }
.auth-secondary-button.mud-button-root { border-color: var(--cafe-border-strong); color: var(--cafe-text) !important; background: var(--cafe-surface-soft); }

.tournament-card,
.pricing-page .pricing-card,
.pricing-page .service-price-card {
    border-radius: var(--cafe-radius-card) !important;
    border-color: var(--cafe-border) !important;
    box-shadow: var(--cafe-shadow-low) !important;
}

.tournament-card-body { border-radius: var(--cafe-radius-card); background: color-mix(in srgb, var(--cafe-surface-raised) 94%, transparent); box-shadow: var(--cafe-shadow-low); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.rules-panel,
.pricing-page .pricing-rules { border-color: var(--cafe-border) !important; border-radius: var(--cafe-radius-card) !important; background: var(--cafe-gradient-card) !important; box-shadow: var(--cafe-shadow-low) !important; }
.fact-card,
.rate-item,
.pricing-total,
.service-price-card__icon { border-color: var(--cafe-border) !important; border-radius: var(--cafe-radius-control) !important; background: var(--cafe-surface-soft) !important; }
.view-bracket-button,
.enlist-button { box-shadow: var(--cafe-shadow-primary) !important; }

.store-page .store-icon { border-radius: var(--cafe-radius-control); background: var(--cafe-surface-soft); }
.store-page .store-search .mud-input-outlined-border,
.store-page .store-search .mud-input { border-radius: var(--cafe-radius-control); }

.home-image-console-dialog,
.home-settings-dialog,
.mud-dialog { border-radius: var(--cafe-radius-dialog) !important; background: var(--cafe-gradient-card) !important; box-shadow: var(--cafe-shadow-low) !important; }


@media (max-width: 767.98px) {
    .auth-story h1 { font-size: 32px; line-height: 38px; }
    .auth-page { padding: 72px 16px max(24px, env(safe-area-inset-bottom)) !important; }
    .tournament-card-body { padding: 16px !important; }
}

/* Operational families: data is the focal point, decorative art stays quiet. */
.statistics-summary article,
.statistics-month-card,
.statistics-empty,
.unit-earnings-summary article,
.unit-earnings-day,
.room-booking-overview article,
.room-booking-card,
.room-booking-empty,
.energy-cost-summary article,
.energy-cost-month,
.energy-rate-summary article,
.energy-rate-year,
.monitor-grid,
.agents-grid-scroll,
.camera-hub-page .camera-hub-card,
.mini-graph-shell,
.graph-details {
    border-color: var(--cafe-border) !important;
    border-radius: var(--cafe-radius-card) !important;
    background: var(--cafe-gradient-card) !important;
    box-shadow: var(--cafe-shadow-low) !important;
}

.statistics-summary article,
.unit-earnings-summary article,
.room-booking-overview article,
.energy-cost-summary article,
.energy-rate-summary article { padding: 20px; }

.statistics-summary span,
.statistics-key-figures span,
.statistics-net span,
.statistics-deductions > span,
.statistics-month-card footer > span,
.unit-earnings-summary span,
.unit-earnings-day-total span,
.unit-earnings-facts span,
.unit-earnings-name > span,
.room-booking-overview span,
.room-booking-stay > div > span,
.room-booking-card dt,
.energy-cost-summary span,
.energy-rate-summary span,
.energy-cost-card time,
.energy-cost-facts span,
.energy-rate-card time,
.energy-rate-value span {
    color: var(--cafe-text-muted) !important;
    font-size: 12px !important;
    line-height: 17px;
}

.statistics-summary strong,
.unit-earnings-summary strong,
.unit-earnings-day-total strong,
.room-booking-overview strong,
.energy-cost-summary strong,
.energy-rate-summary strong { color: var(--cafe-text) !important; font-size: 26px; line-height: 32px; }

.statistics-breakdown,
.room-booking-stay,
.rag-inspection-grid,
.rag-identity-grid {
    border-color: var(--cafe-line) !important;
    background: var(--cafe-surface-raised) !important;
}

.statistics-month-card > header,
.unit-earnings-day > header,
.energy-cost-month > header,
.energy-rate-year > header { border-color: var(--cafe-line) !important; background: var(--cafe-surface-soft); }

.statistics-month-card h2,
.unit-earnings-day h2,
.room-booking-card h2,
.energy-cost-month h2,
.energy-rate-year h2 { font-size: 18px; line-height: 24px; }

.camera-hub-page .camera-hub-card { overflow: hidden; }
.camera-hub-page .camera-hub-details { padding: 16px; }
.camera-hub-page .camera-hub-details .mud-typography-subtitle1 { color: var(--cafe-text) !important; font-size: 14px; }
.camera-hub-page .camera-hub-details .mud-typography-caption { color: var(--cafe-text-muted) !important; font-size: 11px; }

.mini-graph-shell { width: 100%; height: calc(100dvh - 32px); margin: 16px 0; }
.mini-graph-canvas,
.graph-details { border-radius: var(--cafe-radius-card); border-color: var(--cafe-border); }
.mini-graph-toolbar { border-radius: var(--cafe-radius-control); background: var(--cafe-surface-soft); -webkit-backdrop-filter: none; backdrop-filter: none; }

@media (min-width: 768px) and (max-width: 1199.98px) {
    .mini-graph-shell { height: calc(100dvh - 32px); margin: 16px 0; }
}

@media (max-width: 767.98px) {
    .statistics-summary article,
    .unit-earnings-summary article,
    .room-booking-overview article,
    .energy-cost-summary article,
    .energy-rate-summary article { padding: 16px; }
    .statistics-summary strong,
    .unit-earnings-summary strong,
    .unit-earnings-day-total strong,
    .room-booking-overview strong,
    .energy-cost-summary strong,
    .energy-rate-summary strong { font-size: 22px; line-height: 28px; }
    .mini-graph-shell { width: 100%; height: auto; min-height: calc(100dvh - 88px); margin: 72px 0 0; border-radius: var(--cafe-radius-card); }
}

/* Final cascade contract: legacy route sheets load before this file, so these
   shared states must be last or the old purple ghosts crawl back in. */
.auth-layout,
.auth-panel-icon,
.auth-form .mud-input-root,
.auth-captcha-preview,
.auth-form .code-entry-slot {
    border-color: var(--cafe-border) !important;
}

.auth-primary-button.mud-button-root,
.view-bracket-button.mud-button-root,
.enlist-button.mud-button-root {
    border: 1px solid rgb(255 255 255 / 10%) !important;
    background: var(--cafe-gradient-brand) !important;
    color: var(--cafe-text) !important;
    box-shadow: var(--cafe-shadow-selected) !important;
}

.auth-secondary-button.mud-button-root {
    border: 1px solid transparent !important;
    background: linear-gradient(var(--cafe-surface-soft), var(--cafe-surface-soft)) padding-box,
        var(--cafe-gradient-accent-line) border-box !important;
    color: var(--cafe-text) !important;
}

.auth-form .mud-input-root.mud-input-focused .mud-input-outlined-border,
.auth-form .code-entry-slot:focus-visible {
    border-color: var(--cafe-primary) !important;
    box-shadow: var(--cafe-shadow-focus) !important;
}

.tournament-card,
.pricing-page .pricing-card,
.pricing-page .service-price-card,
.promo-hero,
.promo-image-button,
.promo-image-placeholder {
    border-color: var(--cafe-border) !important;
    box-shadow: var(--cafe-shadow-low) !important;
}

.tournament-card-body,
.promo-hero,
.promo-image-placeholder {
    background: var(--cafe-gradient-card) !important;
}

.tournament-state-chip,
.tournament-artwork-badge,
.lifecycle-badge {
    border-radius: 7px !important;
}

@media (max-width: 767.98px) {
    .auth-primary-button.mud-button-root,
    .auth-secondary-button.mud-button-root,
    .view-bracket-button.mud-button-root,
    .enlist-button.mud-button-root { min-height: 44px; }
}

/* Disabled actions must not inherit the brand gradient or hover glow: a blocked
   form is not advertising a clickable submit button. Keep its label readable. */
.mud-button-root.mud-button:disabled,
.mud-button-root.mud-button[aria-disabled="true"] {
    color: var(--cafe-text-disabled) !important;
    box-shadow: none !important;
    transform: none !important;
}

.mud-button-root.mud-button:is(.mud-button-filled, .mud-button-outlined):disabled,
.mud-button-root.mud-button:is(.mud-button-filled, .mud-button-outlined)[aria-disabled="true"] {
    background: var(--cafe-surface-soft) !important;
    border-color: var(--cafe-border) !important;
}

/* One table contract for operational data. Units, Basket, Debtors, and Products
   use raised records instead of framework-gray spreadsheets; every Mud table
   must speak the same visual language when a route still needs columns. */
.mud-table,
.mud-datagrid,
.mud-data-grid,
.cafe-report-grid {
    overflow: hidden;
    border: 1px solid transparent !important;
    border-radius: 16px !important;
    background: linear-gradient(var(--cafe-surface), var(--cafe-surface)) padding-box,
        var(--cafe-gradient-accent-line) border-box !important;
    box-shadow: var(--cafe-shadow-card) !important;
}

.mud-table-container,
.mud-data-grid .mud-table-container,
.mud-datagrid .mud-table-container {
    max-width: 100%;
    overflow-x: auto;
    background: transparent !important;
    overscroll-behavior-x: contain;
    scrollbar-color: var(--cafe-border-strong) transparent;
    scrollbar-width: thin;
}

.mud-table-container > table,
.mud-data-grid .mud-table-container > table,
.mud-datagrid .mud-table-container > table {
    width: 100%;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.mud-table-head .mud-table-cell,
.mud-data-grid thead .mud-table-cell {
    height: 50px !important;
    padding: 12px 14px !important;
    border-bottom: 1px solid var(--cafe-border) !important;
    background: linear-gradient(180deg, var(--cafe-surface-soft), var(--cafe-surface-raised)) !important;
    color: var(--cafe-text-muted) !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    letter-spacing: .08em;
    line-height: 1.25;
    text-transform: uppercase;
    vertical-align: middle;
}

.mud-table-body .mud-table-cell,
.mud-data-grid tbody .mud-table-cell {
    min-height: 48px;
    padding: 12px 14px !important;
    border-bottom: 1px solid var(--cafe-line) !important;
    background: var(--cafe-surface) !important;
    color: var(--cafe-text-muted) !important;
    font-size: 14px !important;
    line-height: 1.4;
    overflow-wrap: anywhere;
    vertical-align: middle;
}

.mud-table-body .mud-table-row:nth-child(even) .mud-table-cell,
.mud-data-grid tbody tr:nth-child(even) .mud-table-cell { background: var(--cafe-surface-raised) !important; }

.mud-table-body .mud-table-row:hover .mud-table-cell,
.mud-data-grid tbody tr:hover .mud-table-cell {
    background: color-mix(in srgb, var(--cafe-accent) 9%, var(--cafe-surface-raised)) !important;
}

.mud-table-body .mud-table-row:last-child .mud-table-cell,
.mud-data-grid tbody tr:last-child .mud-table-cell { border-bottom: 0 !important; }

.mud-table-foot .mud-table-cell,
.mud-data-grid tfoot .mud-table-cell {
    padding: 12px 14px !important;
    border-top: 1px solid var(--cafe-border) !important;
    background: var(--cafe-surface-soft) !important;
    color: var(--cafe-text-muted) !important;
}

.mud-table .mud-icon-button,
.mud-data-grid .mud-icon-button {
    border: 1px solid var(--cafe-border) !important;
    border-radius: 9px;
    background: var(--cafe-surface-raised);
    color: var(--cafe-accent-soft);
}

.mud-table-pagination,
.mud-data-grid .mud-table-pagination {
    min-height: 52px;
    border-top: 1px solid var(--cafe-border);
    background: linear-gradient(145deg, var(--cafe-surface-raised), var(--cafe-surface));
}

.mud-table-pagination .mud-typography,
.mud-table-pagination .mud-select,
.mud-data-grid .mud-table-pagination .mud-typography,
.mud-data-grid .mud-table-pagination .mud-select { color: var(--cafe-text-muted); }

@media (max-width: 767.98px) {
    /* Keep columns intact on phones; horizontal table scroll belongs to the table,
       never to the shell, and stacked Mud rows may grow with their labels. */
    .mud-table,
    .mud-datagrid,
    .mud-data-grid,
    .cafe-report-grid { overflow: visible; }

    .mud-table-container,
    .mud-data-grid .mud-table-container,
    .mud-datagrid .mud-table-container { overflow-x: auto; }

    .mud-table-head .mud-table-cell,
    .mud-data-grid thead .mud-table-cell,
    .mud-table-body .mud-table-cell,
    .mud-data-grid tbody .mud-table-cell { height: auto !important; min-height: 48px; }
}

/* Full-bleed routes own their content spacing; report gutters created black strips and a second chat footer. */
.shell-main .content:has(.agents-chat-root),
.shell-main .content:has(.cafe-home) { max-width: none; margin: 0; padding: 0; box-shadow: none; }
.shell-main .content:has(.agents-chat-root) { overflow: hidden !important; }
@media (max-width: 1199.98px) {
    /* Reserve the fixed navigation cap exactly once, in the shell's border-box height. */
    .shell-main .content:has(.agents-chat-root),
    .shell-main .content:has(.cafe-home) { padding-top: 56px; }
}
