@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* ===========================================================================
   QDine design tokens — QDine design language. Light is the default (POS-friendly,
   matches the bright restaurant floor); dark is available via [data-theme="dark"].
   =========================================================================== */
:root {
    --surface: #f1f5f9;
    --surface-alt: #ffffff;
    --surface-card: #ffffff;
    --surface-panel: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #526176;
    --text-heading: #1e293b;
    --accent: #4f46e5;
    --accent-strong: #4338ca;
    --accent-soft: rgba(79, 70, 229, 0.10);
    --warning: #f97316;
    --success: #16a34a;
    --info: #0ea5e9;
    --danger: #ef4444;
    --danger-strong: #dc2626;
    /* Semantic foregrounds keep status text readable without relying on color alone. */
    --warning-strong: #9a3412;
    --success-strong: #166534;
    --info-strong: #075985;
    --text-inverse: #ffffff;
    --border: rgba(15, 23, 42, 0.12);
    --border-strong: rgba(15, 23, 42, 0.18);
    /* System-first typography stays consistent without adding a font dependency to either QDine host. */
    --font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-page: clamp(1.5rem, 1.2rem + 1vw, 1.8rem);
    --line-height-tight: 1.2;
    --line-height-body: 1.5;
    --font-weight-regular: 400;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-heavy: 800;
    /* A four-pixel spacing scale keeps dense restaurant screens rhythmically aligned. */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --page-gap: var(--space-5);
    --grid-gap: var(--space-4);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;
    --field-height: 44px;
    --touch-target: 44px;
    --touch-target-large: 52px;
    --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-card: 0 10px 25px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 26px rgba(15, 23, 42, 0.12);
    /* Motion and state tokens give every component the same interaction cadence. */
    --motion-fast: 120ms;
    --motion-base: 180ms;
    --motion-slow: 240ms;
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);
    --focus-ring: #2563eb;
    --focus-ring-offset: #ffffff;
    --disabled-opacity: 0.58;
    --sidebar-w: 260px;
    --top-h: 64px;
    /* POS status hues: open=blue, kitchen/pending=orange, settled/done=green, void=red. */
    --badge-open-bg: #e0f2fe; --badge-open-text: #0369a1;
    --badge-pending-bg: #ffedd5; --badge-pending-text: #c2410c;
    --badge-done-bg: #dcfce7; --badge-done-text: #047857;
    --badge-void-bg: #fee2e2; --badge-void-text: #991b1b;
}

[data-theme="dark"] {
    --surface: #0f172a;
    --surface-alt: #111c2f;
    --surface-card: #111c2f;
    --surface-panel: #0f1a2c;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5f5;
    --text-heading: #ffffff;
    --accent: #60a5fa;
    --accent-strong: #3b82f6;
    --accent-soft: rgba(96, 165, 250, 0.14);
    --success: #34d399;
    --info: #38bdf8;
    /* Dark-mode semantic foregrounds retain contrast on tinted status surfaces. */
    --warning-strong: #fdba74;
    --success-strong: #6ee7b7;
    --info-strong: #7dd3fc;
    --text-inverse: #0f172a;
    --focus-ring: #93c5fd;
    --focus-ring-offset: #0f172a;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.16);
    --shadow-sm: 0 6px 16px rgba(0, 0, 0, 0.22);
    --shadow-card: 0 18px 40px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.35);
    --badge-open-bg: rgba(56, 189, 248, 0.15); --badge-open-text: #38bdf8;
    --badge-pending-bg: rgba(249, 115, 22, 0.16); --badge-pending-text: #fb923c;
    --badge-done-bg: rgba(52, 211, 153, 0.15); --badge-done-text: #34d399;
    --badge-void-bg: rgba(239, 68, 68, 0.16); --badge-void-text: #f87171;
}

html, body {
    font-family: var(--font-family);
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    line-height: var(--line-height-body);
}

/* Arabic and Farsi use right-to-left flow while keeping QDine's existing components intact. */
html[dir="rtl"],
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

/* The sidebar toggle moves to the visual left in Arabic/Farsi layouts. */
html[dir="rtl"] .sidebar-flash-toggle {
    right: auto;
    left: 0;
}

/* Navigation icons keep spacing between icon and text after direction flips. */
html[dir="rtl"] .nav-icon {
    margin-right: 0;
    margin-left: 5px;
}

/* The QDine brand remains aligned with the active reading direction. */
html[dir="rtl"] .container-fluid-nav {
    justify-content: right;
}

/* Table headers should follow the selected language direction instead of staying left aligned. */
html[dir="rtl"] .history-table th,
html[dir="rtl"] .review-table th {
    text-align: right;
}

/* Audit values stay readable when long IP, GPS, or browser strings wrap in RTL mode. */
html[dir="rtl"] .security-details strong {
    text-align: left;
}

/* Programmatically focused headings keep a visible keyboard-location indicator. */
h1:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: var(--space-1); }

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

/* Shared validation states use semantic tokens and remain visible in both themes. */
.valid.modified:not([type=checkbox]) { border-color: var(--success-strong); box-shadow: inset 0 0 0 1px var(--success-strong); }
.invalid,
[aria-invalid="true"] { border-color: var(--danger-strong); box-shadow: inset 0 0 0 1px var(--danger-strong); }
.validation-message { color: var(--danger-strong); font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); overflow-wrap: anywhere; }

#blazor-error-ui {
    /* The global host failure banner follows the same warning palette as in-app recovery states. */
    background: var(--badge-pending-bg);
    color: var(--badge-pending-text);
    border-top: 1px solid var(--warning);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--border-strong);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ---------------------------------------------------------------------------
   Mobile data cards: on phones, the wide audit grid is replaced by one
   readable card per row so users never have to side-scroll a table.
   These live in app.css because MobileDataList has no scoped stylesheet.
   --------------------------------------------------------------------------- */
.mobile-data-list {
    display: grid;
    gap: 10px;
    width: 100%;
}

.mobile-data-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-card);
    padding: var(--space-3);
    box-shadow: var(--shadow-sm);
}

.mobile-data-card-title {
    color: var(--text-heading);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.mobile-data-card-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 2px;
    overflow-wrap: anywhere;
}

.mobile-data-fields {
    display: grid;
    gap: 7px;
    margin-top: 10px;
}

.mobile-data-field {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.mobile-data-field span {
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.mobile-data-field strong {
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 650;
    text-align: right;
    overflow-wrap: anywhere;
}

.mobile-data-empty {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 14px;
    text-align: center;
}

.mobile-data-limit {
    background: var(--surface-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: .9rem;
    line-height: 1.35;
    padding: 10px 12px;
    text-align: center;
}

.mobile-data-pager {
    /* Card paging keeps long history lists usable on phones without the desktop grid pager. */
    align-items: center;
    display: grid;
    gap: 0.5rem;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    margin-top: 0.25rem;
}

.mobile-data-page-button {
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-weight: 700;
    min-height: 44px;
    padding: 0.55rem 0.75rem;
}

.mobile-data-page-button:disabled {
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.7;
}

.mobile-data-page-status {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ===========================================================================
   QDine restaurant POS — shared UI (open checks, floor/tables, order entry).
   Uses the design tokens above; touch-first, QDine-styled.
   =========================================================================== */
.rx-shell { display: grid; gap: var(--page-gap); min-width: 0; padding-bottom: var(--space-8); }
.rx-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); min-width: 0; flex-wrap: wrap; }
.rx-header h1 { margin: 0; font-size: var(--font-size-page); font-weight: var(--font-weight-heavy); line-height: var(--line-height-tight); color: var(--text-heading); overflow-wrap: anywhere; }
.rx-subtitle { margin: var(--space-1) 0 0; color: var(--text-secondary); font-size: 0.95rem; line-height: var(--line-height-body); overflow-wrap: anywhere; }
.rx-header-actions { display: flex; gap: var(--space-2); min-width: 0; flex-wrap: wrap; }
/* State panels share one calm surface while modifiers distinguish loading and empty content. */
.rx-state { display: grid; place-items: center; gap: var(--space-2); min-width: 0; padding: var(--space-10) var(--space-4); text-align: center; color: var(--text-secondary); background: var(--surface-card); border: 1px dashed var(--border); border-radius: var(--radius); line-height: var(--line-height-body); overflow-wrap: anywhere; }
.rx-state.empty,
.rx-state-empty { background: var(--surface-panel); box-shadow: none; }
.rx-state.loading,
.rx-state-loading,
.rx-state[aria-busy="true"] { cursor: wait; }
/* Alert variants use the same structure so errors, warnings, success, and information scan consistently. */
.rx-alert { display: grid; gap: var(--space-2); min-width: 0; border: 1px solid var(--danger); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); background: var(--badge-void-bg); color: var(--badge-void-text); font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); line-height: var(--line-height-body); overflow-wrap: anywhere; }
.rx-alert-error { border-color: var(--danger); background: var(--badge-void-bg); color: var(--badge-void-text); }
/* Post-commit hardware warnings use warning colors and keep their hardware-only recovery action adjacent. */
.rx-alert-warning { border-color: var(--warning); background: var(--badge-pending-bg); color: var(--badge-pending-text); }
.rx-alert-warning .rx-btn { justify-self: start; }
.rx-alert-success { border-color: var(--success); background: var(--badge-done-bg); color: var(--badge-done-text); }
.rx-alert-info { border-color: var(--info); background: var(--badge-open-bg); color: var(--badge-open-text); }
.hardware-recovery-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.rx-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--touch-target); min-width: var(--touch-target); padding: var(--space-2) 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-alt); color: var(--text-primary); font-weight: var(--font-weight-bold); line-height: var(--line-height-tight); cursor: pointer; text-align: center; text-decoration: none; touch-action: manipulation; overflow-wrap: anywhere; transition: filter var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard); }
.rx-btn:disabled { opacity: var(--disabled-opacity); cursor: not-allowed; }
.rx-btn:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
/* Loading buttons keep their label and add a compact progress cue without changing width. */
.rx-btn.is-loading,
.rx-btn[aria-busy="true"] { cursor: wait; }
.rx-btn.is-loading::before,
.rx-btn[aria-busy="true"]::before { width: 1rem; height: 1rem; flex: 0 0 auto; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: var(--radius-pill); content: ""; animation: qdine-spin 0.8s linear infinite; }
@keyframes qdine-spin { to { transform: rotate(360deg); } }
.rx-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.rx-btn-primary:hover:not(:disabled) { filter: brightness(0.95); }
.rx-btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.rx-btn-success:hover:not(:disabled) { filter: brightness(0.95); }
.rx-btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.rx-grid { display: grid; gap: var(--grid-gap); min-width: 0; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); }
.rx-card { display: grid; gap: var(--space-2); min-width: 0; background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: var(--space-4) 1.1rem; text-decoration: none; color: var(--text-primary); overflow-wrap: anywhere; transition: transform var(--motion-fast) var(--ease-standard), box-shadow var(--motion-base) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard); }
a.rx-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); border-color: var(--accent); color: var(--text-primary); }
.rx-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }

.rx-badge { display: inline-flex; align-items: center; max-width: 100%; padding: 0.15rem 0.6rem; border-radius: var(--radius-pill); font-size: var(--font-size-xs); font-weight: var(--font-weight-bold); line-height: var(--line-height-body); text-transform: uppercase; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.rx-badge-open { background: var(--badge-open-bg); color: var(--badge-open-text); }
.rx-badge-pending { background: var(--badge-pending-bg); color: var(--badge-pending-text); }
.rx-badge-done { background: var(--badge-done-bg); color: var(--badge-done-text); }
.rx-badge-void { background: var(--badge-void-bg); color: var(--badge-void-text); }

/* Open checks */
.check-no { font-weight: 800; color: var(--text-heading); }
.check-table { color: var(--text-primary); font-weight: 600; }
.check-meta, .check-foot { display: flex; align-items: baseline; justify-content: space-between; color: var(--text-secondary); font-size: 0.85rem; }
.check-total { font-size: 1.15rem; font-weight: 800; color: var(--text-heading); }
.muted { color: var(--text-secondary); }

/* Floor / tables */
.room-tabs, .cat-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.room-tab, .cat-tab { min-height: 40px; padding: 0 1rem; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-alt); color: var(--text-secondary); font-weight: 700; cursor: pointer; }
.room-tab.is-active, .cat-tab.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.floor-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.table-tile { display: grid; gap: 0.25rem; align-content: center; justify-items: center; min-height: 120px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface-card); cursor: pointer; padding: 0.75rem; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.table-tile:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.table-tile:disabled { cursor: default; }
.table-name { font-size: 1.1rem; font-weight: 800; color: var(--text-heading); }
.table-state { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; }
.table-seats { font-size: 0.75rem; color: var(--text-secondary); }
.table-tile.available { border-color: var(--badge-done-text); background: var(--badge-done-bg); }
.table-tile.available .table-state { color: var(--badge-done-text); }
.table-tile.occupied { border-color: var(--badge-open-text); background: var(--badge-open-bg); }
.table-tile.occupied .table-state { color: var(--badge-open-text); }
.table-tile.reserved { border-color: var(--badge-pending-text); background: var(--badge-pending-bg); }
.table-tile.reserved .table-state { color: var(--badge-pending-text); }
.table-tile { position: relative; }
/* Count badge shown when a table holds more than one open check (e.g. after a split). */
.table-checks-badge { position: absolute; top: 0.4rem; inset-inline-end: 0.4rem; min-width: 1.4rem; height: 1.4rem; padding: 0 0.35rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 99px; background: var(--accent); color: #fff; font-size: 0.72rem; font-weight: 800; line-height: 1; }

/* Resume picker / generic modal (a tile with multiple open checks lets the operator choose which to resume) */
.rx-modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 1000; }
.rx-modal { width: min(620px, 100%); max-height: 85vh; overflow-y: auto; background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 1.25rem; display: grid; gap: 0.85rem; }
.rx-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.rx-modal-head h2 { margin: 0; font-size: 1.15rem; font-weight: 800; color: var(--text-heading); }
.rx-modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* POS order entry */
.pos-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.25rem; align-items: start; }
.pos-menu { display: grid; gap: 1rem; align-content: start; }
.menu-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.menu-item { display: grid; gap: 0.35rem; align-content: space-between; min-height: 84px; text-align: left; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-card); padding: 0.7rem 0.8rem; cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease; }
.menu-item:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-card); border-color: var(--accent); }
.menu-item:disabled { opacity: 0.6; cursor: default; }
.menu-name { font-weight: 700; color: var(--text-heading); line-height: 1.2; }
.menu-price { color: var(--accent); font-weight: 800; }

/* Picture-menu tile: food illustration on top, then name + price (iPOS/AmigoPOS-style picture menu).
   The thumb is a fixed-aspect card so every tile lines up regardless of the illustration. */
.menu-item-pic { padding: 0; overflow: hidden; align-content: start; gap: 0; }
.menu-thumb { display: block; width: 100%; aspect-ratio: 16 / 10; background: var(--surface-panel); border-bottom: 1px solid var(--border); overflow: hidden; }
.menu-img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.18s ease; }
.menu-item-pic:hover:not(:disabled) .menu-img { transform: scale(1.05); }
.menu-item-pic .menu-name { padding: 0.55rem 0.7rem 0; font-size: 0.92rem; }
.menu-item-pic .menu-price { padding: 0.1rem 0.7rem 0.6rem; }

/* Picture category strip: image chip + label, scrollable horizontally on narrow terminals. */
.cat-tab-pic { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.85rem 0.3rem 0.35rem; }
.cat-tab-img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--surface-panel); flex: 0 0 auto; }
.cat-tab-label { white-space: nowrap; }
.pos-check { position: sticky; top: calc(var(--top-h) + 1rem); background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 1rem; display: grid; gap: 0.75rem; }
.check-head { display: flex; align-items: center; justify-content: space-between; }
.check-head h2 { margin: 0; font-size: 1.15rem; font-weight: 800; color: var(--text-heading); }
.check-empty { color: var(--text-secondary); padding: 1.5rem 0.5rem; text-align: center; }
.check-lines { display: grid; gap: 0.4rem; max-height: 46vh; overflow-y: auto; }
.check-line { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 0.5rem; align-items: center; padding: 0.25rem 0.3rem; border-radius: var(--radius-sm); cursor: pointer; }
.check-line:hover { background: var(--accent-soft); }
.check-line.is-selected { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.cl-qty { color: var(--text-secondary); font-weight: 700; }
.cl-name { color: var(--text-primary); overflow-wrap: anywhere; display: grid; gap: 0.15rem; }
.cl-amt { font-weight: 700; color: var(--text-heading); }
.cl-note { display: block; color: var(--text-secondary); font-size: 0.78rem; font-style: italic; line-height: 1.2; }
.cl-child { cursor: default; }
.cl-child:hover { background: transparent; }
.cl-child .cl-name { color: var(--text-secondary); padding-left: 0.4rem; }
.cl-plus { min-width: 44px; min-height: 32px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-alt); color: var(--accent); font-weight: 800; cursor: pointer; }
.cl-plus:hover:not(:disabled) { border-color: var(--accent); }
.cl-plus:disabled { opacity: 0.5; cursor: default; }
.cl-child .cl-plus { display: none; }

/* Void control + voided-line presentation */
.cl-void { min-width: 32px; min-height: 32px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-alt); color: var(--danger, #c0392b); font-weight: 800; line-height: 1; cursor: pointer; }
.cl-void:hover:not(:disabled) { border-color: var(--danger, #c0392b); }
.cl-void:disabled { opacity: 0.5; cursor: default; }
.check-line.cl-voided { opacity: 0.6; }
.check-line.cl-voided .cl-name, .check-line.cl-voided .cl-amt { text-decoration: line-through; }
.cl-void-tag { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; color: var(--danger, #c0392b); letter-spacing: 0.04em; }

/* Modifier bar for the selected line */
.cl-modbar { display: grid; gap: 0.5rem; padding: 0.6rem; border: 1px dashed var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); }
.cl-modbar-label { font-size: 0.85rem; color: var(--text-secondary); overflow-wrap: anywhere; }
.cl-modbar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.cl-modbar-btn { min-height: 44px; width: 100%; }

/* Quantity stepper (add-item step) */
.qty-stepper { display: grid; grid-template-columns: 56px 1fr 56px; gap: 0.5rem; align-items: stretch; }
.qty-btn { min-height: 52px; border: 2px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-alt); color: var(--accent); font-size: 1.5rem; font-weight: 800; line-height: 1; cursor: pointer; }
.qty-btn:hover:not(:disabled) { border-color: var(--accent); }
.qty-btn:disabled { opacity: 0.5; cursor: default; }
.qty-value { min-height: 52px; width: 100%; text-align: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-panel); color: var(--text-primary); font-size: 1.3rem; font-weight: 800; }
.qty-value:focus { outline: none; border-color: var(--accent); }
.check-total-row { display: flex; align-items: baseline; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 0.6rem; }
.pos-actions { display: grid; gap: 0.5rem; }
.pos-actions .rx-btn { width: 100%; }
.pos-info { color: var(--badge-done-text); font-size: 0.85rem; }

/* Settlement / payment panel */
.settle-backdrop { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(15, 23, 42, 0.45); }
.settle-panel { width: 100%; max-width: 420px; max-height: 92vh; overflow-y: auto; display: grid; gap: 0.9rem; background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 1.25rem; }
.settle-head { display: flex; align-items: center; justify-content: space-between; }
.settle-head h2 { margin: 0; font-size: 1.25rem; font-weight: 800; color: var(--text-heading); }
.settle-x { min-width: 44px; min-height: 44px; border: none; background: transparent; font-size: 1.6rem; line-height: 1; color: var(--text-secondary); cursor: pointer; }
.settle-total-row, .settle-change-row { display: flex; align-items: baseline; justify-content: space-between; }
.settle-total-row { border-bottom: 1px solid var(--border); padding-bottom: 0.6rem; }
.settle-total-row > span:first-child, .settle-change-row > span:first-child { color: var(--text-secondary); font-weight: 600; }
.settle-total { font-size: 1.5rem; font-weight: 800; color: var(--text-heading); }
.settle-discount-line > span:last-child { color: var(--danger); font-weight: 800; }
.settle-discount { display: grid; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-alt); }
.settle-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.settle-section-head h3 { margin: 0; color: var(--text-heading); font-size: 1rem; }
.settle-section-head p { margin: var(--space-1) 0 0; color: var(--text-secondary); font-size: 0.8rem; line-height: 1.4; }
.settle-link-danger { min-height: 36px; border: 0; background: transparent; color: var(--danger); font-weight: 800; cursor: pointer; }
.settle-link-danger:hover:not(:disabled) { text-decoration: underline; }
.settle-link-danger:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
.settle-link-danger:disabled { opacity: var(--disabled-opacity); cursor: not-allowed; }
.settle-segment { display: grid; grid-template-columns: 64px 1fr; gap: var(--space-1); padding: var(--space-1); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-panel); }
.settle-segment button, .settle-discount-presets button { min-height: 40px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font-weight: 800; cursor: pointer; }
.settle-segment button:hover, .settle-discount-presets button:hover { background: var(--accent-soft); color: var(--accent); }
.settle-segment button:focus-visible, .settle-discount-presets button:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 1px; }
.settle-segment button.is-active, .settle-discount-presets button.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.settle-discount-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
.settle-discount-presets button { border-color: var(--border); background: var(--surface-panel); }
.settle-discount-grid { display: grid; grid-template-columns: minmax(100px, .7fr) minmax(0, 1.3fr); gap: var(--space-3); }
.settle-discount-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.settle-discount-foot > span { color: var(--text-secondary); font-size: .8rem; font-weight: 700; }
.settle-discount-foot .rx-btn { min-height: 42px; }
.settle-tenders { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.settle-tender { min-height: 52px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface-alt); color: var(--text-secondary); font-weight: 800; font-size: 1rem; cursor: pointer; }
.settle-tender.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.settle-fields { display: grid; gap: 0.7rem; }
.settle-field { display: grid; gap: 0.3rem; }
.settle-field > span { color: var(--text-secondary); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.settle-input { width: 100%; min-height: 48px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-panel); color: var(--text-primary); font-size: 1.05rem; font-weight: 700; padding: 0 0.8rem; }
.settle-input:focus { outline: none; border-color: var(--accent); }
.settle-input:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 1px; }
.settle-change { font-size: 1.25rem; font-weight: 800; color: var(--success); }
.settle-change.is-short { color: var(--danger); }
.settle-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 0.6rem; }
.settle-actions .rx-btn { width: 100%; }

/* Multi-tender / split payment: a stack of tender rows, each a tender toggle + account + amount. */
.settle-tender-list { display: grid; gap: 0.8rem; }
.settle-tender-row { display: grid; gap: 0.5rem; padding: 0.7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-alt); }
.settle-tender-remove { justify-self: end; min-height: 36px; border: none; background: transparent; color: var(--danger); font-weight: 700; font-size: 0.85rem; cursor: pointer; }
.settle-add-tender { width: 100%; }

/* Split / Transfer / Merge secondary action row */
.pos-actions-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }
.pos-actions-row .rx-btn { width: 100%; }

/* Pick list (split line selection, merge candidate selection) */
.pick-list { display: grid; gap: 0.4rem; max-height: 46vh; overflow-y: auto; }
.pick-row { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 0.55rem; min-height: 52px; padding: 0 0.7rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-panel); color: var(--text-primary); cursor: pointer; }
.pick-row.is-picked { border-color: var(--accent); background: var(--accent-soft); }
.pick-check { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.pick-qty { font-weight: 800; color: var(--text-secondary); }
.pick-name { font-weight: 700; overflow-wrap: anywhere; display: flex; flex-direction: column; }
.pick-sub { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.pick-amt { font-weight: 800; color: var(--text-heading); }

@media (max-width: 820px) {
    .pos-layout { grid-template-columns: 1fr; }
    .pos-check { position: static; }
}

/* =========================================================================
   Terminal PIN fast-switch + manager approval (pkg17): lock overlay, masked
   PIN keypad, operator picker, current-user + role-mode badges, approval
   dialog. Touch-first (64px+ targets) per the QDine UX rules.
   ========================================================================= */

/* Full-screen lock overlay — covers the whole shell; the token is kept behind it. */
.tlock-overlay { position: fixed; inset: 0; z-index: 1300; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(15, 23, 42, 0.82); backdrop-filter: blur(3px); }
.tlock-panel { width: 100%; max-width: 460px; max-height: 94vh; overflow-y: auto; display: grid; gap: 1.1rem; background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 1.6rem; }
.tlock-brand { text-align: center; display: grid; gap: 0.25rem; }
.tlock-brand .oi { font-size: 1.8rem; color: var(--accent); }
.tlock-brand h1 { margin: 0.2rem 0 0; font-size: 1.35rem; font-weight: 800; color: var(--text-heading); }
.tlock-sub { margin: 0; color: var(--text-secondary); font-size: 0.9rem; }
.tlock-empty { text-align: center; color: var(--text-secondary); padding: 1rem; }
.tlock-error { text-align: center; }
.tlock-footer { display: flex; justify-content: center; border-top: 1px solid var(--border); padding-top: 0.9rem; }
.tlock-footer .rx-btn { display: inline-flex; align-items: center; gap: 0.4rem; }

/* Operator picker grid (lock screen + approval dialog). */
.tlock-operators { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.tlock-operator { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; min-height: 96px; padding: 0.8rem 0.5rem; border: 2px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-panel); color: var(--text-primary); cursor: pointer; }
.tlock-operator:hover:not(:disabled) { border-color: var(--accent); }
.tlock-operator:disabled { opacity: 0.5; cursor: default; }
.tlock-operator-nopin { opacity: 0.6; }
.tlock-operator-name { font-weight: 700; font-size: 0.9rem; text-align: center; overflow-wrap: anywhere; }
.tlock-operator-hint { font-size: 0.72rem; color: var(--text-secondary); }
.tlock-avatar { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.tlock-selected { display: flex; align-items: center; gap: 0.6rem; }
.tlock-selected .tlock-operator-name { flex: 1; }
.tlock-back { min-height: 40px; }

/* Masked PIN keypad. */
.pinpad { display: grid; gap: 0.9rem; justify-items: center; }
.pinpad-display { display: flex; gap: 0.55rem; justify-content: center; min-height: 26px; }
.pinpad-dot { width: 16px; height: 16px; border-radius: 999px; border: 2px solid var(--border-strong); background: transparent; }
.pinpad-dot-filled { background: var(--accent); border-color: var(--accent); }
.pinpad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.55rem; width: 100%; max-width: 300px; }
.pinpad-key { min-height: 64px; border: 2px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-panel); color: var(--text-primary); font-size: 1.5rem; font-weight: 800; cursor: pointer; }
.pinpad-key:hover:not(:disabled) { border-color: var(--accent); }
.pinpad-key:disabled { opacity: 0.5; cursor: default; }
.pinpad-key-muted { color: var(--text-secondary); font-size: 1.1rem; }
.pinpad-submit { width: 100%; max-width: 300px; }
.pinpad-disabled { opacity: 0.7; }

/* Manager-approval dialog (reuses settle-panel; adds its own fields). */
.appr-panel { max-width: 460px; }
.appr-sub { margin: 0; color: var(--text-secondary); font-size: 0.9rem; }
.appr-label { display: grid; gap: 0.3rem; color: var(--text-secondary); font-size: 0.8rem; font-weight: 700; }
.appr-select, .appr-reason { width: 100%; min-height: 48px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-panel); color: var(--text-primary); font-size: 1rem; padding: 0 0.7rem; }
.appr-select:focus, .appr-reason:focus { outline: none; border-color: var(--accent); }
.appr-foot { display: flex; justify-content: flex-end; }

/* Current-operator badge + role-mode chip in the sidebar. */
.qd-user-badge { display: flex; align-items: center; gap: 0.55rem; padding: 0.5rem 0.9rem; }
.qd-user-badge-avatar { width: 36px; height: 36px; font-size: 0.85rem; }
.qd-user-badge-text { display: grid; gap: 0.2rem; }
.qd-user-badge-name { font-weight: 700; font-size: 0.9rem; color: var(--text-primary); overflow-wrap: anywhere; }
.qd-mode-badge { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; background: var(--accent-soft); color: var(--accent); }
.qd-mode-manager { background: var(--accent-soft); color: var(--accent); }
.qd-mode-cashier { background: var(--badge-done-bg, var(--accent-soft)); color: var(--badge-done-text, var(--accent)); }
.qd-mode-server { background: var(--surface-alt); color: var(--text-secondary); }
.qd-mode-kitchen { background: var(--badge-pending-bg, var(--surface-alt)); color: var(--badge-pending-text, var(--text-secondary)); }

/* Lock icon on approval-required action buttons. */
.cl-void-lock, .pos-act-lock { font-size: 0.7rem; margin-inline-end: 0.2rem; opacity: 0.8; }

@media (max-width: 480px) {
    .tlock-operators { grid-template-columns: 1fr; }
}

/* Cashier X/Z session page (pkg19). */
.cashier-shell { max-width: 520px; margin: 0 auto; display: grid; gap: 1rem; padding: 1.5rem 1rem; }
.cashier-card { display: grid; gap: 0.7rem; background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 1.1rem; }
.cashier-card h2 { margin: 0; font-size: 1.05rem; font-weight: 800; color: var(--text-heading); }
.cashier-sub { margin: 0; color: var(--text-secondary); font-size: 0.88rem; }
.cashier-session-head { display: flex; align-items: center; justify-content: space-between; }
.cashier-session-id { color: var(--text-secondary); font-weight: 700; font-size: 0.85rem; }
.cashier-label { display: grid; gap: 0.3rem; color: var(--text-secondary); font-size: 0.8rem; font-weight: 700; }
.cashier-input { width: 100%; min-height: 48px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-panel); color: var(--text-primary); font-size: 1.1rem; font-weight: 700; padding: 0 0.8rem; text-align: right; }
.cashier-input:focus { outline: none; border-color: var(--accent); }
.cashier-figures { display: grid; gap: 0.3rem; }
.cashier-row { display: flex; align-items: baseline; justify-content: space-between; }
.cashier-row > span:first-child { color: var(--text-secondary); }
.cashier-row > span:last-child { font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.cashier-row-strong { border-top: 1px solid var(--border); padding-top: 0.5rem; }
.cashier-row-strong > span:last-child { font-size: 1.15rem; font-weight: 800; color: var(--text-heading); }
.cashier-variance { border-top: 1px solid var(--border); padding-top: 0.5rem; }
.cashier-variance > span:last-child { font-size: 1.25rem; font-weight: 800; }
.cashier-variance.is-ok > span:last-child { color: var(--success); }
.cashier-variance.is-over > span:last-child { color: var(--badge-done-text, var(--accent)); }
.cashier-variance.is-short > span:last-child { color: var(--danger); }

/* PIN enrollment page (pkg18). */
.pinset-shell { max-width: 460px; margin: 0 auto; display: grid; gap: 1rem; padding: 1.5rem 1rem; }
.pinset-sub { color: var(--text-secondary); font-size: 0.9rem; margin: 0; }
.pinset-label { display: grid; gap: 0.3rem; color: var(--text-secondary); font-size: 0.8rem; font-weight: 700; }
.pinset-select { width: 100%; min-height: 48px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-panel); color: var(--text-primary); font-size: 1rem; padding: 0 0.7rem; }
.pinset-select:focus { outline: none; border-color: var(--accent); }
.pinset-stage { display: grid; gap: 0.8rem; justify-items: center; }
.pinset-stage-label { color: var(--text-primary); font-weight: 700; margin: 0; }
.pinset-ok { border-color: var(--success); background: var(--badge-done-bg); color: var(--badge-done-text); }

/* ==========================================================================
   Shared interaction and resilience rules apply the visual system to existing
   controls without requiring page-level class or markup changes.
   ========================================================================= */

/* All native action and form controls meet the base keyboard/touch target. */
button:not([hidden]),
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea,
[role="button"] { min-height: var(--touch-target); }

/* Disabled controls stay recognizable while clearly preventing interaction. */
button:not([hidden]):disabled,
input:disabled,
select:disabled,
textarea:disabled,
[aria-disabled="true"] { opacity: var(--disabled-opacity); cursor: not-allowed; filter: saturate(0.72); }

/* Focus visibility is never removed by older component-specific :focus rules. */
:where(a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])):focus-visible {
    outline: 3px solid var(--focus-ring) !important;
    outline-offset: 2px;
}

/* Invalid focused fields retain the focus ring and add a distinct error inset. */
:where(input, select, textarea)[aria-invalid="true"]:focus-visible {
    box-shadow: inset 0 0 0 1px var(--danger-strong), 0 0 0 1px var(--focus-ring);
}

/* Long names, translated labels, identifiers, and server messages wrap safely. */
.rx-card-head,
.check-meta,
.check-foot,
.cashier-session-head,
.settle-total-row,
.settle-change-row { min-width: 0; flex-wrap: wrap; }

.menu-name,
.table-name,
.check-table,
.check-no,
.check-total,
.cashier-session-id,
.settle-total,
.pos-info,
.hardware-recovery-actions,
.tlock-operator-name { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }

/* Selected controls use a border plus fill so selection is not color-only. */
.room-tab.is-active,
.cat-tab.is-active,
.settle-tender.is-active,
.pick-row.is-picked,
.check-line.is-selected,
[aria-pressed="true"],
[aria-selected="true"] { box-shadow: inset 0 0 0 1px var(--accent); }

/* Busy regions and controls consistently advertise the wait cursor. */
[aria-busy="true"],
.is-loading { cursor: wait; }

/* Coarse-pointer terminals receive a slightly larger target without inflating desktop density. */
@media (pointer: coarse) {
    button:not([hidden]),
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea,
    [role="button"] { min-height: 48px; }
}

/* Compact viewports tighten whitespace while retaining readable touch targets. */
@media (max-width: 640px) {
    :root { --page-gap: var(--space-4); --grid-gap: var(--space-3); }
    .rx-shell { padding-bottom: var(--space-6); }
    .rx-header { align-items: stretch; }
    .rx-header-actions { width: 100%; }
    .rx-header-actions > .rx-btn { flex: 1 1 auto; }
    .rx-state { padding: var(--space-8) var(--space-3); }
    .rx-modal,
    .settle-panel,
    .tlock-panel { padding: var(--space-4); }
    .settle-discount-grid { grid-template-columns: 1fr; }
    .settle-discount-foot { align-items: stretch; flex-direction: column; }
    .settle-discount-foot .rx-btn { width: 100%; }
    .hardware-recovery-actions > .rx-btn { width: 100%; }
}

/* Wide terminals use denser grids so operational data remains scan-friendly. */
@media (min-width: 1440px) {
    :root { --page-gap: var(--space-4); --grid-gap: var(--space-3); }
    .rx-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .menu-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .floor-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
}

/* Reduced-motion users keep state changes without lift, zoom, pulse, or spin animation. */
@media (prefers-reduced-motion: reduce) {
    .rx-btn,
    .rx-card,
    .table-tile,
    .menu-item,
    .menu-img,
    .nav-item a,
    .nav-section-chevron { transition-duration: 0.01ms !important; }

    .rx-card:hover,
    .table-tile:hover:not(:disabled),
    .menu-item:hover:not(:disabled) { transform: none; }

    .rx-btn.is-loading::before,
    .rx-btn[aria-busy="true"]::before,
    .kds-conn.is-live .kds-dot { animation: none; }
}

/* ===========================================================================
   Offline / sync status indicator (phase-3 offline order capture).
   Floating badge; hidden entirely when online with an empty queue.
   =========================================================================== */
.sync-status {
    position: fixed;
    bottom: 16px;
    inset-inline-end: 16px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.sync-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
    cursor: pointer;
}

.sync-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.sync-count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--text-inverse);
    text-align: center;
    font-size: 0.75rem;
}

.sync-offline .sync-dot { background: var(--warning); }
.sync-syncing .sync-dot { background: var(--info); animation: sync-pulse 1.1s ease-in-out infinite; }
.sync-attention .sync-dot { background: var(--danger); }
.sync-offline .sync-chip { border-color: var(--warning); }
.sync-attention .sync-chip { border-color: var(--danger); }

@keyframes sync-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.sync-panel {
    width: min(320px, 80vw);
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface-card);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
}

.sync-panel-head {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 8px;
}

.sync-op {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sync-op-needsattention { color: var(--danger-strong); }

.sync-op-actions button {
    margin-inline-start: 6px;
    padding: 3px 8px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface-alt);
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
}

/* Receipt recovery is stacked above order sync so both terminal alerts remain independently actionable. */
.print-recovery-status {
    position: fixed;
    bottom: 62px;
    inset-inline-end: 16px;
    z-index: 1201;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

/* Amber styling distinguishes printer decisions from network synchronization state. */
.print-recovery-chip {
    border-color: var(--warning);
}

.print-recovery-chip .sync-dot {
    background: var(--warning);
}

/* Recovery rows keep the status explanation below the bill/copy label on narrow terminals. */
.print-recovery-op .sync-op-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.print-recovery-op .sync-op-label small {
    color: var(--text-secondary);
}
