/* MSG Desk HQ design system (docs/DESIGN-SYSTEM.md, approved by the owner on 20 Nov 2026). Loaded after hq.css: it sets
   the colours, the frame and the shared pieces; pages rebuilt on it use only these. Night look: data-theme="dark" on <html>. */

/* ---------- 2. Colours ---------- */
:root {
    color-scheme: light;
    --band: #000000;
    --surface-canvas: #F4F4F5; --surface-card: #FFFFFF; --surface-subtle: #F7F7F8; --surface-row-alt: #F7F7F8; --surface-row-stripe: #FFFFFF;
    --surface-row-hover: #F6F6F7; --surface-row-failure: #FEF2F2; --surface-header: #FFFFFF;
    --border-subtle: #EDEDF0; --border-layout: #E7E7EA; --border-control: #D4D4D8;
    --text-primary: #18181B; --text-headline: #18181B; --text-secondary: #52525B; --text-muted: #71717A;
    --action-primary: #0A6CFF; --action-primary-hover: #005CE6; --action-primary-pressed: #0052CC; --action-accent: #3385FF; --action-text: #005CE6;
    --nav-active-text: #005CE6; --nav-active-bg: #EEF4FF; --nav-hover-bg: #EFEFF1; --selection-background: #F0F6FF;
    --success-text: #15803D; --success-bg: #DCFCE7; --warning-text: #B45309; --warning-bg: #FEF3C7; --danger-text: #B91C1C; --danger-bg: #FEE2E2;
    --info-text: #1D4ED8; --info-bg: #DBEAFE; --neutral-text: #52525B; --neutral-bg: #F4F4F5; --expired-text: #9A3412; --expired-bg: #FFEDD5;
    --lifetime-text: #6B21A8; --lifetime-bg: #F3E8FF; --disabled-bg: #F4F4F5; --disabled-text: #71717A;
    --tab-on: #FFFFFF; --frame-shadow: 0 24px 60px rgba(0, 0, 0, 0.16);
    --shadow-medium: 0 12px 32px rgba(0, 0, 0, 0.14); --shadow-strong: 0 24px 56px rgba(0, 0, 0, 0.24);
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --surface-canvas: #000000; --surface-card: #111111; --surface-subtle: #161616; --surface-row-alt: #161616; --surface-row-stripe: #111111;
    --surface-row-hover: #1A1A1A; --surface-row-failure: #2A1414; --surface-header: #111111;
    --border-subtle: #1F1F1F; --border-layout: #232323; --border-control: #2E2E2E;
    --text-primary: #EDEDED; --text-headline: #FFFFFF; --text-secondary: #A3A3A3; --text-muted: #8A8A8A;
    --action-primary-hover: #2E80FF; --action-text: #7AB0FF; --nav-active-text: #8FBBFF; --nav-active-bg: rgba(10, 108, 255, 0.16); --nav-hover-bg: #1A1A1A;
    --selection-background: rgba(255, 255, 255, 0.06);
    --success-text: #4ADE80; --success-bg: rgba(34, 197, 94, 0.15); --warning-text: #FBBF24; --warning-bg: rgba(245, 158, 11, 0.15);
    --danger-text: #F87171; --danger-bg: rgba(239, 68, 68, 0.15); --info-text: #93C5FD; --info-bg: rgba(59, 130, 246, 0.17);
    --neutral-text: #A3A3A3; --neutral-bg: #1F1F1F; --expired-text: #FB923C; --expired-bg: rgba(249, 115, 22, 0.15);
    --lifetime-text: #D8B4FE; --lifetime-bg: rgba(168, 85, 247, 0.17); --disabled-bg: #1F1F1F; --disabled-text: #6B6B6B;
    --greeting-from: #161616; --greeting-to: #111111; --greeting-border: #262626; --scrim: rgba(0, 0, 0, 0.62);
    --tab-on: #262626; --frame-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    --shadow-faint: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-medium: 0 12px 32px rgba(0, 0, 0, 0.55); --shadow-strong: 0 24px 56px rgba(0, 0, 0, 0.7);
}
/* Fixed light colours in older rules and in chart drawings follow the night look. */
:root[data-theme="dark"] svg [stroke="#EEF2F7"], :root[data-theme="dark"] svg [stroke="#E2E8F0"] { stroke: var(--border-subtle); }
:root[data-theme="dark"] svg [stroke="#CBD5E1"] { stroke: var(--border-control); }
:root[data-theme="dark"] svg [stroke="#FFFFFF"], :root[data-theme="dark"] svg [stroke="#fff"] { stroke: var(--surface-card); }
:root[data-theme="dark"] svg [fill="#FFFFFF"], :root[data-theme="dark"] svg [fill="#fff"] { fill: var(--surface-card); }
:root[data-theme="dark"] .month-chart-on-track, :root[data-theme="dark"] .trend-line-on-track { fill: var(--action-text); }
:root[data-theme="dark"] .guest { background-color: var(--surface-canvas); }

/* ---------- 5. The frame (computers; phones keep the earlier frame until the phone round) ---------- */
.frame-band, .frame-brand { display: none; }
@media (min-width: 1024px) {
    html.has-shell body { background: var(--surface-canvas); }
    html.has-shell body::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 440px; background: var(--band); z-index: 0; }
    .frame-band { display: block; position: relative; z-index: 1; max-width: 1880px; margin: 0 auto; padding: 40px 32px 28px; color: #fff; }
    .frame-date { font-size: 14px; color: #A3A3A3; }
    .frame-back { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 12px; border: 1px solid #333; border-radius: 999px; color: #E5E5E5; font-size: 13px; text-decoration: none; }
    .frame-back:hover { background: #1A1A1A; text-decoration: none; }
    .frame-title { margin-top: 6px; font-size: 48px; line-height: 56px; font-weight: 700; letter-spacing: -0.02em; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .shell { position: relative; z-index: 1; display: grid; grid-template-columns: 228px minmax(0, 1fr); grid-template-areas: "head head" "side body"; gap: 0 28px;
        width: calc(100% - 48px); max-width: 1880px; min-height: 0; margin: 0 auto 32px; padding: 0 28px 28px; background: var(--surface-card);
        border: 1px solid var(--border-layout); border-radius: 28px; box-shadow: var(--frame-shadow); }
    .main { display: contents; }
    .topbar { grid-area: head; position: static; height: 84px; padding: 0; margin-bottom: 26px; background: none; border-bottom: 1px solid var(--border-layout); }
    .frame-brand { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: var(--text-headline); text-decoration: none; }
    .frame-brand:hover { text-decoration: none; }
    .topbar-title, .menu-button { display: none !important; }
    .sidebar { grid-area: side; position: sticky; top: 24px; align-self: start; inset: auto; width: auto; height: auto; max-height: calc(100vh - 48px);
        border: 1px solid var(--border-layout); border-radius: 20px; background: var(--surface-subtle); }
    .sidebar-head { display: none; }
    .sidebar-nav { padding: 16px 12px; }
    .sidebar-foot { border-top: 1px solid var(--border-layout); }
    .nav-group-label { font-size: 11px; letter-spacing: 0.09em; }
    .page-scroll { grid-area: body; overflow: visible !important; height: auto !important; min-width: 0; }
    .content { max-width: none; padding: 0; }
    body.sidebar-closed .shell { grid-template-columns: 0 minmax(0, 1fr); gap: 0; }
}

/* Name menu: name and role, the Light or Night button on the right. */
.menu-header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 34px; height: 34px; border: 1px solid var(--border-control);
    border-radius: 10px; background: var(--surface-card); color: var(--text-secondary); cursor: pointer; }
.theme-toggle:hover { background: var(--surface-row-hover); color: var(--text-primary); }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- 6. Buttons ---------- */
.btn { border-radius: 10px; }
.btn-round { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border-radius: 12px; }
.btn-round .icon { width: 20px; height: 20px; }
.btn-outline-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--border-control);
    border-radius: 12px; background: var(--surface-card); color: var(--text-secondary); }
.btn-outline-icon:hover { background: var(--surface-row-hover); color: var(--text-primary); text-decoration: none; }
/* Main action on the right in every dialog and form footer. */
.modal-foot, .form-foot, .dialog-foot, .panel-foot { justify-content: flex-end; }

/* ---------- 7. Tabs ---------- */
.tabs { gap: 2px; padding: 4px; border: 1px solid var(--border-layout); border-radius: 999px; background: var(--surface-subtle); }
.tab { min-height: 38px; padding: 0 18px; border-radius: 999px; color: var(--text-secondary); font-size: 14px; font-weight: 500; }
.tab .icon { display: none; }
.tab:hover { background: transparent; color: var(--text-primary); }
.tab[aria-selected="true"], .tab[aria-current="page"] { background: var(--tab-on); color: var(--text-headline); font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border-layout); }
:root[data-theme="dark"] .tab[aria-current="page"], :root[data-theme="dark"] .tab[aria-selected="true"] { box-shadow: none; }

/* ---------- 8. Toolbar and Filters window ---------- */
.table-toolbar { gap: 12px; padding: 0 0 16px; border-bottom: 0; }
.table-card .table-toolbar { padding: 16px 16px; border-bottom: 1px solid var(--border-layout); }
.table-toolbar .search-field { flex: 1 1 320px; max-width: 520px; }
.table-toolbar .input, .table-toolbar .filter-button { height: 42px; border-radius: 10px; font-size: 14px; }
.table-toolbar .count { margin-left: auto; order: 10; color: var(--text-secondary); font-size: 14px; }
.filters-button { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border: 1px solid var(--border-control);
    border-radius: 10px; background: var(--surface-card); color: var(--text-primary); font-weight: 600; font-size: 14px; cursor: pointer; }
.filters-button:hover { background: var(--surface-row-hover); }
.filters-button.is-set { border-color: var(--action-primary); color: var(--action-text); }
.filters-button .icon { width: 18px; height: 18px; }
.filters-dot { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--action-primary); color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; }
.menu.filter-panel { width: 580px; max-width: calc(100vw - 32px); padding: 20px; border-radius: 18px; white-space: normal; text-align: left; }
.filter-panel-head { display: none; }
.filter-panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.filter-panel-grid .field { margin: 0; }
.filter-panel-grid .label { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.filter-panel-grid .input { height: 44px; border-radius: 10px; font-size: 14px; }
.filter-panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.menu.filter-panel .filter-panel-foot .btn { display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 18px; border-radius: 10px; font-weight: 600; width: auto; }
.menu.filter-panel .filter-panel-foot .btn-primary { flex: 0 1 260px; background: var(--action-primary); color: #fff; border: 0; }
.menu.filter-panel .filter-panel-foot .btn-primary:hover { background: var(--action-primary-hover); }
.menu.filter-panel .filter-panel-foot .btn-secondary { background: var(--surface-card); color: var(--text-primary); border: 1px solid var(--border-control); }
@media (max-width: 767px) {
    .menu.filter-panel, .menu.filter-panel.is-floating { position: fixed !important; inset: auto 0 0 0 !important; width: 100% !important; max-width: none !important;
        max-height: 85vh !important; overflow-y: auto; border-radius: 18px 18px 0 0; z-index: 90; }
    .filter-panel-grid { grid-template-columns: 1fr; }
}

/* ---------- 9. Tables ---------- */
.table-card { border: 1px solid var(--border-layout); border-radius: 16px; overflow: hidden; box-shadow: none; }
.table { font-size: 13px; line-height: 18px; }
.table thead th { height: 46px; font-size: 12px; font-weight: 600; color: var(--text-secondary); background: var(--surface-card); border-bottom: 1px solid var(--border-layout); }
.table tbody td { height: 60px; border-bottom: 1px solid var(--border-subtle); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:nth-child(even) td { background: transparent; }
.table tbody tr:hover td { background: var(--surface-row-hover); }
.table .pill { gap: 6px; font-size: 12px; }
.table .pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.table .caption { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.row-check { width: 16px; height: 16px; accent-color: var(--action-primary); cursor: pointer; vertical-align: middle; }
.table .cell-check { width: 44px; padding-left: 16px; padding-right: 4px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 4px 0; color: var(--text-secondary); font-size: 13px; }
.bulk-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--selection-background); border-bottom: 1px solid var(--border-layout); font-size: 13px; font-weight: 600; }
.bulk-bar[hidden] { display: none; }

/* The order row (Orders, a customer's orders). */
.order-table .order-number { font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; letter-spacing: 0.02em; }
.order-table .order-name { font-weight: 600; color: var(--text-primary); }
.order-table .cell-total { font-weight: 600; text-align: right; }
.order-table th, .order-table td { padding-left: 10px; padding-right: 10px; white-space: nowrap; }
.row-more { color: var(--text-muted); }
.menu .is-danger, .menu .is-danger .icon { color: var(--danger-text); }

/* ---------- 11. Segmented choices (fill their slot exactly, same spacing on every side) ---------- */
.seg { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border-layout); border-radius: 14px; background: var(--surface-subtle); }
.seg > label, .seg > button { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; height: 38px; border-radius: 10px; color: var(--text-secondary); font-weight: 500; cursor: pointer; }
.seg input:checked + span { background: var(--tab-on); color: var(--text-headline); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border-layout); }
.seg input:focus-visible + span { outline: 2px solid var(--action-accent); outline-offset: 1px; }

/* ---------- 12. Settings ---------- */
.health-strip { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px; margin-bottom: 28px; border: 1px solid var(--border-layout); border-radius: 999px; background: var(--surface-subtle); }
.health-item { display: inline-flex; align-items: center; gap: 8px; flex: 1 1 200px; min-height: 40px; padding: 0 16px; border-radius: 999px; font-size: 14px; color: var(--text-secondary); white-space: nowrap; }
.health-item .icon { width: 16px; height: 16px; color: var(--text-muted); }
.health-label { font-weight: 600; color: var(--text-primary); }
.health-item.is-main { flex: 0 1 auto; font-weight: 600; }
.health-item.is-ok { background: var(--success-bg); color: var(--success-text); }
.health-item.is-warn { background: var(--warning-bg); color: var(--warning-text); }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.settings-group-label { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.settings-group-label::after { content: ""; flex: 1; height: 1px; background: var(--border-layout); }
.settings-groups { gap: 32px; }
.settings-cards > * { flex: 0 1 calc((100% - 16px) / 2); }
.settings-card { min-height: 72px; padding: 14px 18px; border-radius: 14px; }
.settings-card-icon { width: 40px; height: 40px; border: 1px solid var(--border-layout); background: var(--surface-subtle); }
.settings-card-name { font-size: 15px; line-height: 22px; }
@media (max-width: 767px) { .health-strip { border-radius: 16px; } .health-item { flex: 1 1 100%; } .settings-cards > * { flex-basis: 100%; } }
/* Orders at 1440 px: 12.5 px text, and only a very long email is cut (full text on hover). */
.order-table { font-size: 12.5px; }
.order-table th, .order-table td { padding-left: 8px; padding-right: 8px; }
.order-table td:first-child, .order-table th:first-child { padding-left: 16px; }
.order-table .cell-customer { max-width: 230px; }
.order-table .cell-customer .order-name, .order-table .cell-customer .caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-table .cell-customer .caption .copy-text { display: inline; }

/* ---------- Fixes after the owner's review (20 Nov 2026) ---------- */
/* The whole page scrolls in the new frame (the old frame locked the page to one screen and scrolled an inner box). */
@media (min-width: 1024px) {
    html.has-shell, html.has-shell body { height: auto; overflow: visible; overscroll-behavior: auto; }
    html.has-shell .shell { height: auto; min-height: 0; }
}
/* Name menu: wide enough that a name never wraps. */
#avatar-menu { min-width: 260px; }
.menu-header-row .name { white-space: nowrap; }
/* Sidebar group labels like NS: plain small labels, no fold arrow or line (a click still folds the group). */
.nav-group-label { font-size: 11px; color: var(--text-muted); }
.nav-group-label .icon, .nav-group-label::after { display: none; }
.nav-group[data-folded] .nav-group-label { opacity: 0.7; }
/* The date dropdown in a toolbar has no funnel: only the Filters button has one. */
.table-toolbar .date-filter .filter-button > .icon:first-child { display: none; }
/* The back link sits on the black band ("‹ Customers"); the breadcrumb row under the title is not repeated. */
@media (min-width: 1024px) {
    .content nav.breadcrumb[data-moved] { display: none; }
    .frame-back-row { margin-bottom: 8px; }
}
/* Dashboard: the band greets, so the card under it keeps only the status line (computers). */
@media (min-width: 1024px) {
    .greeting .greeting-title, .greeting .greeting-date { display: none; }
    .greeting { padding: 14px 18px; min-height: 0; }
    .greeting-line { justify-content: flex-end; }
}
/* Dashboard: the band greets, so the old greeting card keeps only its status pills, with no empty box around them. */
@media (min-width: 1024px) { .greeting { background: none; border: 0; box-shadow: none; padding: 0; margin-bottom: 4px; } .greeting::before, .greeting::after { display: none; } }
/* Dashboard number cards: the big number and its trend line share one row without touching. */
.kpi-body .stat-value { font-size: 28px; line-height: 34px; overflow: hidden; text-overflow: ellipsis; }
.kpi .sparkline { width: 76px; height: 30px; }
/* Every date button reads its period without the funnel (the funnel belongs to Filters only). */
.date-filter .filter-button > .icon:first-child { display: none; }
/* Filters window: field names in sentence case ("Paid with", not "Paid With"). */
.filter-panel .label { text-transform: none; }
/* Email previews (Reminder Engine, Templates): the From and Subject strip follows Light and Night; the email itself stays white like an inbox. */
.inbox-head { background: var(--surface-subtle); color: var(--text-primary); }
/* Dashboard number cards: the label wraps to a second line instead of being cut ("Fit the data, never cut it", Design System 9). */
.kpi-head .stat-label { white-space: normal; overflow: visible; text-overflow: clip; }
.kpi-head { align-items: flex-start; }
