/* TAIF design system: layout, tables, tree, modals. MudBlazor styles the input controls.
   Every colour is a variable so the dark theme only redefines the variables. */

:root, .taif-root[data-theme="light"] {
    --taif-primary: #1B5E3F;
    --taif-primary-dark: #143F2E;
    --taif-primary-soft: #E7F2EB;
    --taif-accent: #B39660;
    --taif-accent-soft: #F8EEDC;
    --taif-accent-text: #8A6116;
    --taif-bg: #F4F6F8;
    --taif-surface: #FFFFFF;
    --taif-surface-2: #F8FAFB;
    --taif-hover: #F2F6F7;
    --taif-text: #1E293B;
    --taif-muted: #5B6B7C;
    --taif-line: #E3E8EE;
    --taif-debit: #1B5E3F;
    --taif-credit: #8C6D35;
    --taif-danger: #C62828;
    --taif-danger-soft: #FDECEC;
    --taif-ok: #2E7D32;
    --taif-ok-soft: #E6F4EA;
    --taif-info: #1565C0;
    --taif-chip: #EEF2F5;
    --taif-sidebar: linear-gradient(180deg, #143F2E, #0E2E21);
    --taif-sidebar-text: #E6F1F3;
    --taif-auth-bg: radial-gradient(circle at 20% 10%, #DDEFE4, transparent 45%), radial-gradient(circle at 85% 90%, #F4EAD5, transparent 40%), #F4F6F8;
    --taif-radius: 10px;
    --taif-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
    --taif-shadow-lg: 0 24px 64px rgba(15, 23, 42, .18);
    color-scheme: light;
}

.taif-root[data-theme="dark"] {
    --taif-primary: #5CC08E;
    --taif-primary-dark: #0B241A;
    --taif-primary-soft: rgba(92, 192, 142, .14);
    --taif-accent: #D2B47A;
    --taif-accent-soft: rgba(210, 180, 122, .14);
    --taif-accent-text: #E2C690;
    --taif-bg: #0F1417;
    --taif-surface: #171E22;
    --taif-surface-2: #1C2429;
    --taif-hover: #1F292E;
    --taif-text: #E3E9ED;
    --taif-muted: #93A3AF;
    --taif-line: #2A353B;
    --taif-debit: #6FD19F;
    --taif-credit: #D9B97C;
    --taif-danger: #EF6B6B;
    --taif-danger-soft: rgba(239, 107, 107, .14);
    --taif-ok: #6FD19F;
    --taif-ok-soft: rgba(111, 209, 159, .13);
    --taif-info: #74A9F0;
    --taif-chip: #232D33;
    --taif-sidebar: linear-gradient(180deg, #0D2219, #081710);
    --taif-sidebar-text: #DCE8E2;
    --taif-auth-bg: radial-gradient(circle at 20% 10%, #12301F, transparent 45%), radial-gradient(circle at 85% 90%, #2C2617, transparent 40%), #0F1417;
    --taif-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
    --taif-shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
    color-scheme: dark;
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--taif-bg);
    color: var(--taif-text);
    font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}

.taif-root { min-height: 100vh; background: var(--taif-bg); color: var(--taif-text); }
.taif-empty { padding: 48px; text-align: center; color: var(--taif-muted); }
.taif-empty.small { padding: 28px 16px; display: grid; gap: 6px; justify-items: center; }
.taif-center { text-align: center; }

/* ---------- splash (also drawn by index.html before the app loads) ---------- */
.taif-splash { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 22px; background: var(--taif-bg); }
.taif-splash img { width: 220px; }
.taif-splash-bar { width: 160px; height: 3px; border-radius: 3px; background: var(--taif-line); overflow: hidden; }
.taif-splash-bar span { display: block; width: 40%; height: 100%; border-radius: 3px; background: var(--taif-accent); animation: taif-slide 1.1s ease-in-out infinite; }
@keyframes taif-slide { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }
[dir="rtl"] .taif-splash-bar span { animation-direction: reverse; }

/* ---------- shell ---------- */
.taif-shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; transition: grid-template-columns .18s ease; }
.taif-shell.compact { grid-template-columns: 72px 1fr; }

.taif-sidebar {
    background: var(--taif-sidebar);
    color: var(--taif-sidebar-text);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    display: flex; flex-direction: column;
}

.taif-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; }
.taif-logo {
    width: 46px; height: 46px; border-radius: 12px; flex: none;
    display: grid; place-items: center;
    background: #FBF8F1; box-shadow: 0 0 0 1px rgba(179, 150, 96, .45);
}
.taif-logo img { width: 38px; height: 38px; object-fit: contain; }
.taif-brand-name { font-weight: 600; font-size: 1rem; white-space: nowrap; }
.taif-brand-sub { font-size: .78rem; opacity: .7; }

/* the company name stays on top; only the menu below it scrolls */
.taif-brand { flex: none; border-bottom: 1px solid rgba(255, 255, 255, .1); margin-bottom: 8px; }
.taif-nav {
    display: flex; flex-direction: column; gap: 2px;
    flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
    margin-inline: -6px; padding-inline: 6px;
    scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .22) transparent;
}
/* group headings: one open at a time, its screens slide open beneath it */
.taif-nav-head {
    display: flex; align-items: center; gap: 10px; width: 100%;
    margin-top: 4px; padding: 10px 12px; border: 0; border-radius: 8px;
    background: transparent; color: inherit; font: inherit; font-size: .93rem; font-weight: 600;
    text-align: start; white-space: nowrap; cursor: pointer;
    transition: background .2s, color .2s;
}
.taif-nav-head:hover { background: rgba(255, 255, 255, .08); }
.taif-nav-head.open { background: rgba(255, 255, 255, .06); }
.taif-nav-head.current { color: var(--taif-accent); }
.taif-nav-head .taif-nav-text:not(.taif-nav-chevron) { flex: 1; }
.taif-nav-chevron { opacity: .6; transition: transform .3s cubic-bezier(.4, 0, .2, 1); }
.taif-nav-head.open .taif-nav-chevron { transform: rotate(180deg); }

.taif-nav-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s cubic-bezier(.4, 0, .2, 1); }
.taif-nav-sub.open { grid-template-rows: 1fr; }
.taif-nav-sub-inner {
    min-height: 0; overflow: hidden;
    display: flex; flex-direction: column; gap: 2px;
    margin-inline-start: 21px; padding-inline-start: 8px;
    border-inline-start: 1px solid rgba(255, 255, 255, .12);
}
.taif-nav-sub .taif-nav-link {
    font-size: .89rem; padding: 8px 10px;
    opacity: 0; transform: translateY(-6px);
    transition: background .15s, opacity .2s, transform .2s;
}
.taif-nav-sub.open .taif-nav-link {
    opacity: 1; transform: none;
    transition: background .15s, opacity .25s ease calc(var(--i, 0) * 25ms + 60ms), transform .25s ease calc(var(--i, 0) * 25ms + 60ms);
}
.taif-nav-sub.open .taif-nav-sub-inner { padding-bottom: 4px; }
@media (prefers-reduced-motion: reduce) {
    .taif-nav-sub, .taif-nav-sub .taif-nav-link, .taif-nav-chevron { transition: none !important; }
}
.taif-nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    color: inherit; text-decoration: none; font-size: .92rem; white-space: nowrap;
    transition: background .15s;
}
.taif-nav-link:hover { background: rgba(255, 255, 255, .08); }
.taif-nav-link.active { background: rgba(255, 255, 255, .16); font-weight: 600; box-shadow: inset 3px 0 0 var(--taif-accent); }
[dir="rtl"] .taif-nav-link.active { box-shadow: inset -3px 0 0 var(--taif-accent); }

/* compact: icons only, the name is the tooltip */
.taif-shell.compact .taif-sidebar { padding: 20px 10px; }
.taif-shell.compact .taif-brand { padding: 4px 3px 18px; }
.taif-shell.compact .taif-nav-text { display: none; }
.taif-shell.compact .taif-nav-head { justify-content: center; padding: 11px 0; }
.taif-shell.compact .taif-nav-sub-inner { margin: 0; padding: 0; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .06); }
.taif-shell.compact .taif-nav-sub.open .taif-nav-sub-inner { margin: 2px 0 4px; }
.taif-shell.compact .taif-nav-sub .taif-nav-link { padding: 9px 0; }
.taif-shell.compact .taif-nav { scrollbar-width: none; }
.taif-shell.compact .taif-nav-link { justify-content: center; padding: 11px 0; }

.taif-main { display: flex; flex-direction: column; min-width: 0; }
.taif-topbar {
    height: 58px; padding: 0 18px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--taif-surface); border-bottom: 1px solid var(--taif-line);
    position: sticky; top: 0; z-index: 20;
}
.taif-topbar-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.taif-topbar-branch { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--taif-primary); padding: 5px 8px; border-radius: 8px; }
.taif-topbar-branch.clickable { cursor: pointer; }
.taif-topbar-branch.clickable:hover { background: var(--taif-hover); }
.taif-topbar-actions { display: flex; align-items: center; gap: 4px; }
.taif-icon-btn {
    position: relative; width: 36px; height: 36px; border-radius: 9px; border: 0; cursor: pointer;
    display: inline-grid; place-items: center; background: transparent; color: var(--taif-muted);
}
.taif-icon-btn:hover { background: var(--taif-hover); color: var(--taif-text); }
.taif-user {
    display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; margin-inline: 4px;
    border-radius: 999px; color: var(--taif-text); text-decoration: none; font-size: .9rem; font-weight: 500;
}
[dir="rtl"] .taif-user { padding: 4px 4px 4px 10px; }
.taif-user:hover { background: var(--taif-hover); }
.taif-avatar {
    width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    background: var(--taif-primary-soft); color: var(--taif-primary); font-weight: 700; font-size: .85rem;
}
.taif-content { padding: 24px 28px 48px; }
.taif-subscription { display: flex; gap: 8px; align-items: center; margin: 12px 28px 0; padding: 10px 14px; border-radius: 10px;
    background: color-mix(in srgb, var(--taif-gold, #B39660) 16%, transparent); color: var(--taif-text); font-size: .9rem; }
.taif-subscription.urgent { background: color-mix(in srgb, #B42318 14%, transparent); }

/* ---------- popovers (notifications) ---------- */
.taif-bell { position: relative; }
.taif-bell-count {
    position: absolute; top: 3px; inset-inline-end: 2px; min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px; background: var(--taif-danger); color: #fff; font-size: .68rem; font-weight: 700;
    display: grid; place-items: center; line-height: 1;
}
.taif-popover-backdrop { position: fixed; inset: 0; z-index: 40; }
.taif-popover {
    position: absolute; top: 44px; inset-inline-end: 0; z-index: 41;
    background: var(--taif-surface); border: 1px solid var(--taif-line); border-radius: 12px;
    box-shadow: var(--taif-shadow-lg);
}
.taif-popover-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--taif-line); }
.taif-bell-panel { width: 360px; max-height: 70vh; display: flex; flex-direction: column; }
.taif-bell-list { list-style: none; margin: 0; padding: 4px; overflow-y: auto; }
.taif-bell-list li { display: flex; gap: 10px; padding: 10px; border-radius: 8px; cursor: pointer; }
.taif-bell-list li:hover { background: var(--taif-hover); }
.taif-bell-list li:not(.unread) { opacity: .65; }
.taif-bell-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 8px; flex: none; background: var(--taif-info); }
.taif-bell-dot.action { background: var(--taif-accent); }
.taif-bell-dot.warning { background: var(--taif-danger); }
.taif-bell-title { font-weight: 600; font-size: .9rem; }
.taif-bell-body { color: var(--taif-muted); font-size: .84rem; }
.taif-bell-time { color: var(--taif-muted); font-size: .75rem; margin-top: 2px; }

/* ---------- page ---------- */
.taif-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.taif-page-header h1 { margin: 0; font-size: 1.45rem; font-weight: 700; }
.taif-page-header p { margin: 4px 0 0; color: var(--taif-muted); font-size: .92rem; }
.taif-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.taif-card {
    background: var(--taif-surface); border: 1px solid var(--taif-line);
    border-radius: var(--taif-radius); box-shadow: var(--taif-shadow);
    padding: 18px 20px;
}
.taif-card + .taif-card { margin-top: 16px; }
.taif-grid > .taif-card + .taif-card { margin-top: 0; }
.taif-card h3 { margin: 0 0 12px; font-size: 1.02rem; font-weight: 600; }
.taif-card.muted { opacity: .7; }
.taif-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.taif-card-title { display: flex; align-items: center; gap: 12px; }
.taif-card-title h3 { margin: 0; }

.taif-grid { display: grid; gap: 16px; }
.taif-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.taif-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.taif-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.taif-split { display: grid; grid-template-columns: minmax(380px, 3fr) 2fr; gap: 16px; align-items: start; }

.taif-stat { display: flex; flex-direction: column; gap: 4px; }
.taif-stat-label { color: var(--taif-muted); font-size: .85rem; }
.taif-stat-value { font-size: 1.6rem; font-weight: 700; color: var(--taif-primary); }

.taif-toolbar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.taif-toolbar > * { min-width: 160px; }
/* toggle groups (view switches): readable size and weight, same height as dense fields */
.mud-toggle-group .mud-toggle-item.mud-toggle-item { font-weight: 600; padding: 4px 18px; letter-spacing: 0; }
.mud-toggle-group .mud-toggle-item-size-small { min-height: 38px; font-size: .875rem; }
.mud-toggle-group .mud-toggle-item:not(.mud-toggle-item-selected) { color: var(--taif-text); }
.taif-toolbar > .mud-toggle-group { min-width: 0; align-self: center; }

.taif-denied { max-width: 520px; margin: 60px auto; text-align: center; color: var(--taif-muted); }
.taif-denied h2 { color: var(--taif-text); font-size: 1.25rem; margin: 12px 0 6px; }
.taif-denied p { margin: 4px 0; }

.taif-section-title { font-size: .8rem; font-weight: 600; color: var(--taif-muted); margin: 6px 0; text-transform: uppercase; letter-spacing: .03em; }
.taif-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 12px; }

/* ---------- tables ---------- */
.taif-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.taif-table th {
    text-align: start; font-weight: 600; color: var(--taif-muted);
    background: var(--taif-surface-2); padding: 10px 12px; border-bottom: 1px solid var(--taif-line);
    position: sticky; top: 0;
}
.taif-table td { padding: 9px 12px; border-bottom: 1px solid var(--taif-line); vertical-align: middle; }
.taif-table tbody tr:hover { background: var(--taif-hover); }
.taif-table tr.clickable { cursor: pointer; }
.taif-table tr.selected { background: var(--taif-primary-soft); }
.taif-table tr.inactive td { opacity: .55; }
.taif-table tfoot td { font-weight: 700; background: var(--taif-surface-2); border-top: 2px solid var(--taif-line); }
.taif-table .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; }
.taif-table .code { font-family: Consolas, 'Courier New', monospace; color: var(--taif-muted); direction: ltr; text-align: start; }
.taif-table .debit { color: var(--taif-debit); }
.taif-table .credit { color: var(--taif-credit); }
.taif-table .actions { text-align: end; white-space: nowrap; width: 1%; }
.taif-table tr.level-1 td { font-weight: 700; background: var(--taif-surface-2); }
.taif-table tr.level-2 td { font-weight: 600; }
.taif-table tr.group td { color: var(--taif-text); }
.taif-table input, .taif-table select { width: 100%; }

/* ---------- account tree ---------- */
.taif-tree { list-style: none; margin: 0; padding: 0; }
.taif-tree ul { list-style: none; margin: 0; padding-inline-start: 18px; border-inline-start: 1px dashed var(--taif-line); margin-inline-start: 10px; }
.taif-tree-row {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 8px; border-radius: 6px; cursor: pointer; user-select: none;
}
.taif-tree-row:hover { background: var(--taif-hover); }
.taif-tree-row.selected { background: var(--taif-primary-soft); border-inline-start: 3px solid var(--taif-accent); }
.taif-tree-row.inactive { opacity: .5; }
.taif-tree-code { font-family: Consolas, monospace; font-size: .82rem; color: var(--taif-muted); direction: ltr; unicode-bidi: isolate; margin-inline-end: 6px; }
.taif-tree-toggle { width: 22px; display: inline-grid; place-items: center; color: var(--taif-muted); }

/* ---------- chips / badges ---------- */
.taif-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600;
    background: var(--taif-chip); color: var(--taif-muted); white-space: nowrap;
}
.taif-badge.primary { background: var(--taif-primary-soft); color: var(--taif-primary); }
.taif-badge.accent { background: var(--taif-accent-soft); color: var(--taif-accent-text); }
.taif-badge.ok { background: var(--taif-ok-soft); color: var(--taif-ok); }
.taif-badge.danger { background: var(--taif-danger-soft); color: var(--taif-danger); }

.taif-balance-bar {
    display: flex; gap: 24px; align-items: center; justify-content: flex-end;
    padding: 12px 16px; border-radius: 8px; background: var(--taif-surface-2); margin-top: 12px;
}
.taif-balance-bar.ok { background: var(--taif-ok-soft); }
.taif-balance-bar.bad { background: var(--taif-danger-soft); }

.taif-definition { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: .92rem; }
.taif-definition dt { color: var(--taif-muted); }
.taif-definition dd { margin: 0; font-weight: 500; }

/* ---------- modal ---------- */
.taif-modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1300; }
.taif-modal {
    position: fixed; z-index: 1301; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: min(560px, 94vw); max-height: 90vh; display: flex; flex-direction: column;
    background: var(--taif-surface); color: var(--taif-text); border-radius: 14px; box-shadow: var(--taif-shadow-lg);
    outline: none;
}
.taif-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--taif-line); }
.taif-modal-head h2 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.taif-modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.taif-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--taif-line); }
.taif-modal-foot .start { margin-inline-end: auto; }

/* ---------- auth / setup ---------- */
.taif-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--taif-auth-bg); }
.taif-auth-card {
    width: min(460px, 100%); background: var(--taif-surface); border-radius: 18px;
    box-shadow: var(--taif-shadow-lg); padding: 32px;
    display: flex; flex-direction: column; gap: 14px;
}
.taif-auth-card.wide { width: min(760px, 100%); }
.taif-auth-card h1 { margin: 0; font-size: 1.5rem; }
.taif-auth-card .lead { margin: 0 0 6px; color: var(--taif-muted); }
.taif-auth-head { display: flex; align-items: center; gap: 14px; }
.taif-auth-logo { display: block; width: 200px; max-width: 70%; margin: 0 auto 6px; }
.taif-steps { display: flex; gap: 8px; margin: 4px 0 8px; }
.taif-step { flex: 1; height: 4px; border-radius: 4px; background: var(--taif-line); }
.taif-step.done { background: var(--taif-primary); }
.taif-hint { color: var(--taif-muted); font-size: .85rem; margin: 0; }

/* the full logo has dark lettering: give it a light tile on dark backgrounds */
.taif-root[data-theme="dark"] .taif-auth-logo,
.taif-root[data-theme="dark"] .taif-splash img { background: #FBF8F1; border-radius: 14px; padding: 10px 14px; box-sizing: border-box; }

.taif-phone-only, .taif-backdrop { display: none; }
@media (max-width: 960px) {
    .taif-shell, .taif-shell.compact { grid-template-columns: 1fr; }
    /* phones and small tablets: the menu slides over the page from the button in the top bar */
    .taif-sidebar, .taif-shell.compact .taif-sidebar {
        position: fixed; top: 0; bottom: 0; inset-inline-start: 0; z-index: 1300; width: min(300px, 86vw); height: 100vh;
        padding: 20px 14px; transform: translateX(100%); transition: transform .25s cubic-bezier(.4, 0, .2, 1);
    }
    [dir="ltr"] .taif-sidebar, [dir="ltr"] .taif-shell.compact .taif-sidebar { transform: translateX(-100%); }
    .taif-shell.menu-open .taif-sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
    .taif-shell.menu-open .taif-backdrop { display: block; position: fixed; inset: 0; z-index: 1299; background: rgba(0, 0, 0, .4); }
    .taif-phone-only { display: inline-grid; }
    .taif-wide-only { display: none; }
    /* the icon-only menu is for wide screens */
    .taif-shell.compact .taif-nav-text { display: revert; }
    .taif-shell.compact .taif-nav-link, .taif-shell.compact .taif-nav-head { justify-content: flex-start; padding: 10px 12px; }
    .taif-shell.compact .taif-nav-sub-inner { margin-inline-start: 21px; padding-inline-start: 8px; border-inline-start: 1px solid rgba(255, 255, 255, .12); background: none; }
    .taif-topbar { gap: 6px; padding-inline: 10px; }
    .taif-topbar-branch { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* room on a phone's top bar: the device badge and the user's name go */
    .taif-topbar-start .taif-badge, .taif-user > span:not(.taif-avatar) { display: none; }
    .taif-modal { max-height: calc(100vh - 16px); }
    .taif-modal-body { padding: 12px; }
    .taif-split, .taif-grid.cols-2, .taif-grid.cols-3, .taif-grid.cols-4 { grid-template-columns: 1fr; }
}

/* before the app knows the user's choice (start-up splash), follow the system */
@media (prefers-color-scheme: dark) {
    :root { --taif-bg: #0F1417; --taif-line: #2A353B; color-scheme: dark; }
    #app > .taif-splash img { background: #FBF8F1; border-radius: 14px; padding: 10px 14px; box-sizing: border-box; }
}
body:has(.taif-root) > .taif-static-splash { display: none; }
@media (prefers-color-scheme: dark) {
    .taif-static-splash img { background: #FBF8F1; border-radius: 14px; padding: 10px 14px; box-sizing: border-box; }
}

/* ---------- point of sale ---------- */
.pos { display: flex; flex-direction: column; gap: 12px; outline: none; }
.pos-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.pos-tab {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    min-width: 110px; padding: 7px 14px; border-radius: 10px; cursor: pointer;
    border: 1px solid var(--taif-line); background: var(--taif-surface); color: var(--taif-text);
    font: inherit; text-align: start;
}
.pos-tab:hover { border-color: var(--taif-primary); }
.pos-tab.active { background: var(--taif-primary); border-color: var(--taif-primary); color: #fff; box-shadow: var(--taif-shadow); }
.taif-root[data-theme="dark"] .pos-tab.active { color: #0B241A; }
.pos-tab-label { font-weight: 600; font-size: .9rem; }
.pos-tab-meta { font-size: .76rem; opacity: .75; font-variant-numeric: tabular-nums; }
.pos-tab.add { flex-direction: row; align-items: center; border-style: dashed; color: var(--taif-primary); min-width: 0; }

.pos-issued {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
    background: var(--taif-ok-soft); color: var(--taif-ok);
}
.pos-issued > div { display: flex; gap: 18px; flex-wrap: wrap; align-items: baseline; flex: 1; color: var(--taif-text); }
.pos-change { font-weight: 700; color: var(--taif-ok); font-size: 1.05rem; }

.pos-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.pos-main { padding: 14px; min-height: 60vh; }
.pos-scan { position: relative; margin-bottom: 10px; }
.pos-matches {
    position: absolute; z-index: 30; inset-inline: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none;
    background: var(--taif-surface); border: 1px solid var(--taif-line); border-radius: 10px; box-shadow: var(--taif-shadow-lg);
}
.pos-matches li { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.pos-matches li:hover { background: var(--taif-hover); }
.pos-matches .code { font-family: Consolas, monospace; color: var(--taif-muted); direction: ltr; text-align: start; }
.pos-matches .num { font-variant-numeric: tabular-nums; }
.pos-lines td { vertical-align: top; padding-top: 8px; padding-bottom: 8px; }
.pos-lines .mud-input-control { margin: 0; }
/* pay slips: two to an A4 page */
.pay-slip { padding-bottom: 8mm; margin-bottom: 8mm; border-bottom: 1px dashed #999; break-inside: avoid; page-break-inside: avoid; }
.pay-slip:nth-child(2n) { break-after: page; page-break-after: always; border-bottom: 0; }
.taif-table.payroll .mud-input-control { min-width: 78px; }
/* barcode labels: a roll prints one label a page, an A4 sheet a grid */
.labels { background: #fff; color: #000; font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif; display: flex; flex-wrap: wrap; gap: 4mm; padding: 4mm; }
.labels .label { box-sizing: border-box; padding: 1.2mm 2mm; display: flex; flex-direction: column; gap: .4mm; overflow: hidden; text-align: center; outline: 1px dashed #bbb; }
.labels.roll-50x30 .label { width: 50mm; height: 30mm; }
.labels.roll-38x25 .label { width: 38mm; height: 25mm; padding: 1mm 1.5mm; }
.labels.a4-3x8, .labels.a4-4x10 { display: grid; gap: 0; padding: 0; width: 210mm; }
.labels.a4-3x8 { grid-template-columns: repeat(3, 70mm); grid-auto-rows: 34.6mm; }
.labels.a4-4x10 { grid-template-columns: repeat(4, 52.5mm); grid-auto-rows: 27.7mm; }
.label-company { font-size: 6pt; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-name { font-size: 7.5pt; font-weight: 700; line-height: 1.2; max-height: 2.4em; overflow: hidden; }
.labels.roll-38x25 .label-name { font-size: 6.5pt; }
.label-foot { display: flex; justify-content: space-between; align-items: baseline; font-size: 7pt; }
.label-foot b { font-size: 10pt; margin-inline-start: auto; }
@media print {
    .labels { padding: 0; gap: 0; }
    .labels .label { outline: none; }
    .labels.roll-50x30, .labels.roll-38x25 { display: block; }
    .labels.roll-50x30 .label, .labels.roll-38x25 .label { break-after: page; page-break-after: always; }
}
/* a picking list in a side card (price lists) */
.taif-list-row { padding: 8px 10px; border-radius: 8px; margin: 2px 0; }
.taif-list-row:hover { background: var(--taif-surface-2); }
.taif-list-row.selected { background: var(--taif-surface-2); box-shadow: inset 3px 0 0 var(--mud-palette-primary); }
/* asset facts under an expanded register row */
.asset-facts > div { display: flex; flex-direction: column; gap: 2px; }
.asset-facts span { font-size: .8em; opacity: .7; }
/* bank reconciliation summary */
.bank-sum h4 { margin: 0 0 8px; }
.bank-sum > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 0; }
.bank-sum > div.sub { border-top: 1px solid var(--taif-border, rgba(127,127,127,.3)); font-weight: 600; }
.bank-sum > div.good { color: var(--mud-palette-success); font-weight: 700; }
.bank-sum > div.bad { color: var(--mud-palette-error); font-weight: 700; }
.bank-work .taif-table td { font-size: .9em; }
/* wide line tables (purchases) scroll rather than squeeze their number boxes */
.lines-scroll { overflow-x: auto; }
.lines-scroll .pos-lines .mud-input-control { min-width: 78px; }
.pos-line-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 3px; font-size: .78rem; }
.pos-line-meta .code { font-family: Consolas, monospace; color: var(--taif-muted); }
.pos-wh {
    display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 6px; cursor: pointer;
    border: 1px solid var(--taif-line); background: transparent; color: var(--taif-muted); font: inherit; font-size: .76rem;
}
.pos-wh:hover { border-color: var(--taif-primary); color: var(--taif-primary); }
.pos-wh.other { border-color: var(--taif-accent); color: var(--taif-accent-text); background: var(--taif-accent-soft); }

.pos-side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 74px; }
.pos-side .taif-card + .taif-card { margin-top: 0; }
.pos-customer { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.pos-totals { display: flex; flex-direction: column; gap: 6px; }
.pos-totals > div:not(.taif-hint) { display: flex; justify-content: space-between; }
.pos-totals .num { font-variant-numeric: tabular-nums; }
.pos-totals .grand { font-size: 1.6rem; font-weight: 700; color: var(--taif-primary); padding-top: 6px; border-top: 1px dashed var(--taif-line); }
.pos-pay { display: flex; flex-direction: column; gap: 8px; }
.pos-cash { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 8px; background: var(--taif-surface-2); font-weight: 600; }
.pos-cash .num { font-variant-numeric: tabular-nums; }
.pos-cash.change { background: var(--taif-ok-soft); color: var(--taif-ok); }

@media (max-width: 1100px) { .pos-body { grid-template-columns: minmax(0, 1fr); } .pos-side { position: static; } }
/* on a phone the lines scroll inside their card; the page itself never scrolls sideways */
@media (max-width: 700px) { .pos-body > * { min-width: 0; } .pos-main { overflow-x: auto; } .pos-lines .mud-input-control { min-width: 88px; } }

/* ---------- item photos ---------- */
.item-images { display: flex; flex-wrap: wrap; gap: 10px; }
.item-image {
    position: relative; width: 104px; height: 104px; border-radius: 10px; overflow: hidden;
    border: 1px solid var(--taif-line); background: var(--taif-surface-2);
}
.item-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-image.main { border: 2px solid var(--taif-accent); }
.item-image-badge { position: absolute; top: 4px; inset-inline-start: 4px; background: var(--taif-accent); color: #fff; font-size: .68rem; padding: 1px 6px; border-radius: 6px; }
.item-image-actions { position: absolute; bottom: 4px; inset-inline-end: 4px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.item-image:hover .item-image-actions { opacity: 1; }
.item-image-actions button { width: 28px; height: 28px; border: 0; border-radius: 7px; cursor: pointer; display: grid; place-items: center; background: rgba(15, 23, 42, .72); color: #fff; }
.item-image.add { display: grid; place-content: center; justify-items: center; gap: 4px; cursor: pointer; border-style: dashed; color: var(--taif-primary); font-size: .8rem; }
.item-image.add:hover { background: var(--taif-primary-soft); }
.item-image.add.busy { cursor: progress; }
.item-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; display: block; border: 1px solid var(--taif-line); }
.item-thumb.empty { display: grid; place-items: center; color: var(--taif-muted); background: var(--taif-surface-2); }
.pos-matches li img, .pos-matches li .item-thumb { width: 34px; height: 34px; }

/* ---------- printed documents (always black on white) ---------- */
.print-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.print-sheet {
    background: #fff; color: #000; margin: 0 auto; box-shadow: var(--taif-shadow-lg);
    font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif; line-height: 1.45;
}
.print-sheet.receipt { width: 80mm; padding: 4mm 3mm; font-size: 11px; }
.print-sheet.a4 { width: 186mm; min-height: 260mm; padding: 12mm; font-size: 12px; }
.print-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.print-sheet.receipt .print-head { justify-content: center; text-align: center; }
.print-seller h1 { margin: 0; font-size: 1.35em; }
.print-logo { max-height: 70px; max-width: 160px; object-fit: contain; }
.print-sheet.receipt .print-head { flex-direction: column; align-items: center; }
.print-sheet.receipt .print-logo { max-height: 50px; }
.print-foot { white-space: pre-line; }

/* stock counts */
.var-neg { color: var(--taif-danger); }
.var-pos { color: var(--taif-ok); }
.count-badges { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 14px; }
.count-badges .taif-badge { display: inline-flex; align-items: center; gap: 4px; }
.count-scan { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; padding: 12px 14px; }
.count-scan > .mud-input-control:first-child { max-width: 380px; }
.count-table td { vertical-align: middle; }
.count-table .mud-input-control { margin: 0; }
.count-progress { height: 6px; border-radius: 3px; background: var(--taif-line); overflow: hidden; margin: 6px 0 4px; }
.count-progress > span { display: block; height: 100%; background: var(--taif-primary); }

/* import from Excel */
.import-paste textarea { font-family: Consolas, monospace; font-size: .85rem; direction: ltr; }
.import-map { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; }
.import-col { min-width: 150px; max-width: 190px; flex: 0 0 auto; border: 1px solid var(--taif-line); border-radius: 8px; padding: 6px; background: var(--taif-surface); }
.import-col.ignored { opacity: .55; }
.import-sample { font-size: .8rem; padding: 3px 4px; border-top: 1px dashed var(--taif-line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.import-summary { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.import-preview { max-height: 340px; overflow-y: auto; border: 1px solid var(--taif-line); border-radius: 8px; }

/* account ledger */
.ledger-sheet tbody tr.clickable { cursor: pointer; }
.ledger-sheet .print-lines { font-size: .92em; }
.ledger-sheet .ledger-doc { width: 80px; word-break: break-word; font-size: .92em; }
.taif-toolbar .ledger-account { flex: 0 0 360px; max-width: 100%; }
.ledger-sheet tbody tr.clickable:hover td { background: var(--taif-primary-soft); }

/* POS customer credit */
.pos-credit { font-size: .8rem; color: var(--taif-muted, #6b7280); margin-top: 2px; }
.pos-credit.warn { color: var(--taif-accent-text); }
.pos-credit.bad { color: var(--taif-danger); font-weight: 600; }

/* sales reports */
.sales-pay { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; }
.sales-share { height: 8px; border-radius: 4px; background: var(--taif-line); overflow: hidden; }
.sales-share > span { display: block; height: 100%; background: var(--taif-chart-1); }
.print-only { display: none; }
@media print { .print-only { display: block; } .sales-report { font-size: 11px; } }

/* device join requests */
.device-requests { border: 1px solid var(--taif-accent); margin-bottom: 16px; }
.device-requests h3 { display: flex; align-items: center; gap: 6px; }
.device-code { font-family: Consolas, monospace; font-size: 1.25rem; font-weight: 700; letter-spacing: 3px; color: var(--taif-primary); direction: ltr; display: inline-block; }

/* company settings */
.company-form { display: flex; flex-direction: column; gap: 16px; }
.company-form > .taif-card, .company-form > .taif-grid { margin: 0; }
.company-logo { height: 130px; border: 1px dashed var(--taif-line); border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; background: #fff; }
.company-logo img { max-height: 110px; max-width: 90%; object-fit: contain; }
.company-logo .empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #888; }
.print-seller .en { direction: ltr; }
.print-qr-top { width: 110px; height: 110px; }
.print-title { text-align: center; font-weight: 700; font-size: 1.2em; margin: 8px 0; padding: 4px 0; border-top: 1px dashed #000; border-bottom: 1px dashed #000; }
.print-title span { display: block; font-size: .8em; font-weight: 500; }
.print-meta, .print-lines, .print-totals { width: 100%; border-collapse: collapse; margin: 6px 0; }
.print-meta td { padding: 1px 0; vertical-align: top; }
.print-meta td:first-child { color: #333; width: 45%; }
.print-lines th { text-align: start; border-bottom: 1px solid #000; padding: 3px 2px; font-size: .92em; }
.print-lines th span { font-weight: 400; font-size: .85em; }
.print-lines td { padding: 3px 2px; border-bottom: 1px dotted #999; vertical-align: top; }
.print-sheet.a4 .print-lines th, .print-sheet.a4 .print-lines td { border: 1px solid #bbb; padding: 5px 6px; }
.print-sheet .n { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.print-totals td { padding: 2px 0; }
.print-totals tr.grand td { font-weight: 700; font-size: 1.15em; border-top: 1px solid #000; padding-top: 4px; }
.print-payments { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0; }
.print-qr { display: block; width: 34mm; height: 34mm; margin: 8px auto 4px; }
.print-notes { margin: 6px 0; }
.print-foot { text-align: center; margin-top: 8px; font-size: .92em; }

@media print {
    html, body, .taif-root { background: #fff !important; }
    .taif-sidebar, .taif-topbar, .no-print, .mud-snackbar-provider { display: none !important; }
    .taif-shell, .taif-shell.compact { display: block; }
    .taif-content { padding: 0 !important; }
    .print-sheet { box-shadow: none; margin: 0; }
    .print-sheet.a4 { width: auto; min-height: 0; padding: 0; }
}

.pos-shift { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.pos-shift-start { max-width: 520px; margin: 40px auto; text-align: center; display: grid; justify-items: center; gap: 10px; }
.pos-shift-start h2 { margin: 0; }
.pos-matches li { grid-template-columns: 34px 90px 1fr auto; align-items: center; }

.print-sheet.voucher { min-height: 0; }
.print-signatures { display: flex; justify-content: space-between; gap: 24px; margin-top: 36px; }
.print-signatures > div { flex: 1; border-top: 1px solid #000; padding-top: 6px; text-align: center; }
.print-sheet.receipt .print-signatures { margin-top: 24px; }
.print-sheet .nw { white-space: nowrap; }

/* ---------- home: daily sales bars (single series; colour validated for both themes) ---------- */
:root, .taif-root[data-theme="light"] { --taif-chart-1: #1F8A5B; }
.taif-root[data-theme="dark"] { --taif-chart-1: #3FA673; }
.dash-chart { display: flex; gap: 8px; height: 220px; margin-top: 14px; }
.dash-axis { display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 22px; font-size: .72rem; color: var(--taif-muted); font-variant-numeric: tabular-nums; }
.dash-bars {
    flex: 1; display: flex; align-items: stretch; gap: 2px;
    border-bottom: 1px solid var(--taif-line); padding-bottom: 0; position: relative;
}
.dash-col { flex: 1; position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; outline: none; padding-bottom: 22px; margin-bottom: -22px; }
.dash-bar { width: 100%; max-width: 26px; background: var(--taif-chart-1); border-radius: 4px 4px 0 0; transition: opacity .15s; }
.dash-col:hover .dash-bar, .dash-col:focus .dash-bar { opacity: .8; }
.dash-day { position: absolute; bottom: 2px; font-size: .72rem; color: var(--taif-muted); }
.dash-day.today { color: var(--taif-text); font-weight: 700; }
.dash-label { font-size: .74rem; font-weight: 600; color: var(--taif-text); margin-bottom: 2px; }
.dash-tip {
    display: none; position: absolute; bottom: calc(100% - 20px); z-index: 5; white-space: nowrap;
    background: var(--taif-surface); color: var(--taif-text); border: 1px solid var(--taif-line);
    border-radius: 8px; padding: 6px 10px; font-size: .78rem; box-shadow: var(--taif-shadow-lg); text-align: center;
}
.dash-col:hover .dash-tip, .dash-col:focus .dash-tip { display: block; }
.dash-alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dash-alerts li a { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--taif-text); text-decoration: none; background: var(--taif-surface-2); }
.dash-alerts li a:hover { background: var(--taif-hover); }

/* ---------- financial statements ---------- */
.print-sheet .print-lines.fs td { border-left: 0; border-right: 0; border-top: 0; }
.print-lines.fs tr.fs-l1 td { font-weight: 700; padding-top: 10px; }
.print-lines.fs tr.fs-l2 td { font-weight: 600; }
.print-lines.fs tr.fs-total td { font-weight: 700; border-top: 1px solid #000; background: #f4f4f4; }
.dash-pair { display: flex; justify-content: space-between; gap: 8px; color: var(--taif-text); text-decoration: none; font-size: .95rem; }
.dash-pair b { font-size: 1.15rem; color: var(--taif-primary); font-variant-numeric: tabular-nums; }
.dash-pair:hover span { text-decoration: underline; }
.taif-toolbar .mud-select, .taif-toolbar .mud-picker { max-width: 260px; }
.einv-log { white-space: pre-wrap; word-break: break-all; unicode-bidi: plaintext; text-align: start; font-family: Consolas, monospace; font-size: .76rem;
    background: var(--taif-surface-2); border: 1px solid var(--taif-line); border-radius: 8px; padding: 10px; margin: 0; max-height: 260px; overflow: auto; }

/* branch server link to HQ */
.sync-indicator { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

/* item and price requests */
.change-diff tr.changed td { background: var(--taif-accent-soft); font-weight: 600; }
.item-request-note { display: flex; gap: 6px; align-items: center; color: var(--taif-accent-text); margin-top: 8px; }

/* ---------- restaurant till ---------- */
.rpos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 14px; height: calc(100vh - 100px); min-height: 520px; }
.rpos-menu { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.rpos-search { max-width: 360px; }
.rpos-sections { display: flex; gap: 8px; flex-wrap: wrap; }
.rpos-section {
    padding: 10px 18px; border-radius: 999px; border: 2px solid var(--c); background: transparent;
    color: var(--taif-text); font: inherit; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
}
.rpos-section.on { background: var(--c); color: #fff; }
.rpos-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px;
    overflow-y: auto; padding: 2px; align-content: start; flex: 1;
}
.rpos-tile {
    display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-height: 132px;
    padding: 0 0 10px; border: 1px solid var(--taif-line); border-top: 4px solid var(--c); border-radius: var(--taif-radius);
    background: var(--taif-surface); color: var(--taif-text); font: inherit; cursor: pointer; overflow: hidden;
    transition: transform .08s, box-shadow .15s;
}
.rpos-tile:hover { box-shadow: var(--taif-shadow); }
.rpos-tile:active { transform: scale(.97); }
.rpos-tile:disabled { opacity: .5; cursor: default; }
.rpos-tile img { width: 100%; height: 78px; object-fit: cover; }
.rpos-tile-initial {
    height: 78px; display: grid; place-items: center; font-size: 2rem; font-weight: 700;
    color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
}
.rpos-tile-name { padding: 0 8px; font-weight: 600; font-size: .9rem; line-height: 1.3; }
.rpos-tile-price { padding: 0 8px; margin-top: auto; font-size: .85rem; color: var(--taif-muted); font-variant-numeric: tabular-nums; }

.rpos-order { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 12px; }
.rpos-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.rpos-tab {
    display: flex; flex-direction: column; align-items: center; min-width: 64px; padding: 5px 10px;
    border: 1px solid var(--taif-line); border-radius: 8px; background: var(--taif-surface-2);
    color: var(--taif-text); font: inherit; font-size: .82rem; cursor: pointer; white-space: nowrap;
}
.rpos-tab small { opacity: .7; font-variant-numeric: tabular-nums; }
.rpos-tab.on { background: var(--taif-primary); border-color: var(--taif-primary); color: #fff; }
.rpos-tab.add { justify-content: center; min-width: 40px; border-style: dashed; color: var(--taif-primary); }
.rpos-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rpos-type {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px;
    border: 1px solid var(--taif-line); border-radius: 8px; background: transparent;
    color: var(--taif-text); font: inherit; font-size: .8rem; cursor: pointer;
}
.rpos-type.on { border-color: var(--taif-primary); background: var(--taif-primary-soft); color: var(--taif-primary); font-weight: 700; }
.rpos-lines { flex: 1; overflow-y: auto; min-height: 80px; display: flex; flex-direction: column; }
.rpos-line { display: flex; align-items: center; gap: 8px; padding: 9px 2px; border-bottom: 1px solid var(--taif-line); }
.rpos-line-text { flex: 1; min-width: 0; }
.rpos-line-name { font-weight: 600; }
.rpos-line-details { font-size: .8rem; color: var(--taif-accent-text); }
.rpos-line-price { font-size: .78rem; color: var(--taif-muted); font-variant-numeric: tabular-nums; }
.rpos-line-total { width: 72px; text-align: end; font-weight: 700; }
.rpos-qty { display: flex; align-items: center; gap: 6px; }
.rpos-qty button {
    width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
    border: 1px solid var(--taif-line); background: var(--taif-surface-2); color: var(--taif-text); cursor: pointer;
}
.rpos-qty b { min-width: 22px; text-align: center; }
.rpos-qty.big button { width: 42px; height: 42px; }
.rpos-qty.big b { font-size: 1.3rem; min-width: 36px; }
.rpos-foot { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--taif-line); padding-top: 8px; }
.rpos-sum { display: flex; justify-content: space-between; font-size: .9rem; }
.rpos-sum.grand { font-size: 1.35rem; font-weight: 700; }
.rpos-sum.change { color: var(--taif-ok); font-weight: 700; }
.rpos-tender { display: flex; gap: 6px; align-items: center; }
.rpos-tender .mud-input-control { flex: 1; margin: 0; }
.rpos-bill {
    padding: 8px 10px; border-radius: 8px; border: 1px solid var(--taif-line); background: var(--taif-surface-2);
    color: var(--taif-text); font: inherit; font-weight: 600; cursor: pointer;
}
.rpos-pay { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rpos-pay .mud-button-root { min-height: 54px; font-size: 1.05rem; }
.rpos-foot-actions { display: flex; justify-content: space-between; align-items: center; }
.rpos-issued {
    display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--taif-radius);
    background: var(--taif-primary-soft); border: 1px solid var(--taif-primary);
}
.rpos-call { display: grid; justify-items: center; min-width: 70px; }
.rpos-call small { font-size: .72rem; color: var(--taif-muted); }
.rpos-call b { font-size: 2.2rem; line-height: 1; color: var(--taif-primary); }
.rpos-issued-text { flex: 1; font-size: .85rem; }
.rpos-issued-actions { display: flex; align-items: center; gap: 4px; }
.rpos-group { margin-bottom: 12px; }
.rpos-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.rpos-options { display: flex; flex-wrap: wrap; gap: 8px; }
.rpos-option {
    display: flex; flex-direction: column; align-items: center; min-width: 92px; padding: 10px 14px;
    border: 1px solid var(--taif-line); border-radius: 10px; background: var(--taif-surface-2);
    color: var(--taif-text); font: inherit; font-weight: 600; cursor: pointer; transition: background .12s, border-color .12s;
}
.rpos-option small { font-weight: 500; color: var(--taif-muted); }
.rpos-option.on { background: var(--taif-primary); border-color: var(--taif-primary); color: #fff; }
.rpos-option.on small { color: rgba(255, 255, 255, .85); }
.rpos-choice-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.rpos-choice-price { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) {
    .rpos { grid-template-columns: 1fr; height: auto; }
    .rpos-grid { max-height: 55vh; }
}

/* restaurant menu setup */
.rm-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.rm-sections { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.rm-section { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.rm-section:hover { background: var(--taif-surface-2); }
.rm-section.selected { background: var(--taif-primary-soft); }
.rm-section.stopped { opacity: .6; }
.rm-swatch { width: 18px; height: 18px; border-radius: 50%; flex: none; border: 0; padding: 0; }
.rm-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rm-head h3 { margin: 0; }
.rm-color { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--taif-muted); }
.rm-color input { width: 54px; height: 36px; border: 1px solid var(--taif-line); border-radius: 8px; background: none; cursor: pointer; }
.rm-palette { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.rm-palette .rm-swatch { width: 26px; height: 26px; cursor: pointer; }
.rm-palette .rm-swatch.on { box-shadow: 0 0 0 2px var(--taif-surface), 0 0 0 4px var(--taif-text); }
.rm-options td { padding: 4px 6px; }
.rm-pick { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--taif-line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.rm-pick.on { border-color: var(--taif-primary); background: var(--taif-primary-soft); }
.rm-pick-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--taif-line); font-weight: 700; flex: none; }
.rm-pick.on .rm-pick-n { background: var(--taif-primary); border-color: var(--taif-primary); color: #fff; }
@media (max-width: 900px) { .rm-layout { grid-template-columns: 1fr; } }

/* receipt: the call number and the options under a line */
.print-call { text-align: center; margin: 6px 0; padding: 6px 0; border: 2px solid #000; border-radius: 6px; }
.print-call span { display: block; font-size: .85em; }
.print-call b { display: block; font-size: 2.6em; line-height: 1.1; }
.print-options { font-size: .85em; }
.rm-foodcost { margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: var(--taif-primary-soft); }
.rm-foodcost.high { background: var(--taif-accent-soft); }
.rm-total td { font-weight: 700; }

/* kitchen screen */
.kds-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.kds-head h2 { margin: 0; }
.kds-filter { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.kds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; align-items: start; }
.kds-ticket {
    display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: var(--taif-radius);
    background: var(--taif-surface); border: 1px solid var(--taif-line); border-top: 5px solid var(--taif-primary); box-shadow: var(--taif-shadow);
}
.kds-ticket.slow { border-top-color: var(--taif-accent); }
.kds-ticket.late { border-top-color: var(--taif-danger); }
.kds-ticket.ready { border-top-color: var(--taif-ok); background: var(--taif-primary-soft); }
.kds-ticket-head { display: flex; align-items: baseline; gap: 10px; }
.kds-ticket-head b { font-size: 1.5rem; }
.kds-time { margin-inline-start: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.kds-ticket.late .kds-time { color: var(--taif-danger); }
.kds-station { font-size: .78rem; color: var(--taif-muted); }
.kds-ticket ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.kds-ticket li { font-size: 1.05rem; }
.kds-details { font-size: .85rem; color: var(--taif-accent-text); padding-inline-start: 1.6em; }
.kds-actions { display: flex; gap: 6px; align-items: center; margin-top: 4px; }

/* call screen */
.calls { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; min-height: calc(100vh - 110px); }
.calls-col { background: var(--taif-surface); border-radius: var(--taif-radius); padding: 20px; border: 1px solid var(--taif-line); }
.calls-col h2 { margin: 0 0 16px; text-align: center; font-size: 1.8rem; color: var(--taif-muted); }
.calls-col.ready { background: var(--taif-primary-soft); border-color: var(--taif-primary); }
.calls-col.ready h2 { color: var(--taif-primary); }
.calls-numbers { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.calls-numbers span { min-width: 110px; padding: 12px 18px; text-align: center; font-size: 3.4rem; font-weight: 800; border-radius: 14px; background: var(--taif-surface-2); }
.calls-col.ready .calls-numbers span { background: var(--taif-primary); color: #fff; }
.calls-numbers span.new { animation: taif-call 1s ease-in-out 4; }
@keyframes taif-call { 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .calls-numbers span.new { animation: none; } }
.print-lines.kitchen td { font-size: 1.15em; padding: 4px 0; }

/* dining room on the restaurant till */
.rpos-views { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-width: 320px; }
.rpos-views .rpos-type { flex-direction: row; justify-content: center; gap: 6px; }
.rpos-floor { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.rpos-table {
    min-height: 104px; padding: 10px; border-radius: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
    border: 2px dashed var(--taif-line); background: var(--taif-surface); transition: border-color .15s, box-shadow .15s;
}
.rpos-table:hover { box-shadow: var(--taif-shadow); }
.rpos-table.busy { border-style: solid; border-color: var(--taif-primary); background: var(--taif-primary-soft); }
.rpos-table.bill { border-style: solid; border-color: var(--taif-accent); background: var(--taif-accent-soft); }
.rpos-table.on { box-shadow: 0 0 0 3px var(--taif-primary); }
.rpos-table-name { font-size: 1.3rem; font-weight: 800; }
.rpos-table-meta { font-size: .8rem; color: var(--taif-muted); }
.rpos-check {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 8px; border-radius: 8px;
    border: 1px solid var(--taif-line); background: var(--taif-surface); color: var(--taif-text); font: inherit; font-size: .8rem; cursor: pointer;
}
.rpos-check b { font-variant-numeric: tabular-nums; }
.rpos-table-bar { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; }
.rpos-table-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.rpos-delivery { display: flex; gap: 6px; flex-wrap: wrap; }
.rpos-check.on { background: var(--taif-primary); border-color: var(--taif-primary); color: #fff; }
.rpos-address { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px; border: 1px dashed var(--taif-line); background: transparent; color: var(--taif-text); font: inherit; cursor: pointer; text-align: start; }
.rpos-pay.one { grid-template-columns: 1fr; }
/* cash desk queue */
.pos-queue-no { display: inline-block; min-width: 2.2em; padding: 0 8px; border-radius: 8px; background: var(--taif-primary); color: #fff; font-weight: 800; text-align: center; }
.pos-queue-head { font-weight: 600; margin-bottom: 6px; }
.pos-tab.queue b { margin-inline-start: 4px; }
.pos-tab.queue.busy { border-style: solid; background: var(--taif-accent-soft); }
.req-late td { background: color-mix(in srgb, var(--taif-danger) 8%, transparent); }

/* the rep's day (phone first) */
.rep { display: flex; flex-direction: column; gap: 10px; max-width: 720px; margin: 0 auto; }
.rep-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rep-stats > div { background: var(--taif-surface); border: 1px solid var(--taif-line); border-radius: var(--taif-radius); padding: 10px; text-align: center; }
.rep-stats small { display: block; color: var(--taif-muted); font-size: .78rem; }
.rep-stats b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.rep-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.rep-tabs .rpos-type { flex: 1 0 auto; position: relative; }
.rep-dot { position: absolute; top: 2px; inset-inline-start: 4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--taif-accent); color: #fff; font-size: .72rem; display: grid; place-items: center; }
.rep-tabs .rpos-type { flex-direction: row; justify-content: center; gap: 6px; }
.rep-stop {
    display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--taif-radius);
    background: var(--taif-surface); border: 1px solid var(--taif-line); cursor: pointer;
}
.rep-stop.done { opacity: .75; border-color: var(--taif-ok); }
.rep-stop-n { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; background: var(--taif-primary-soft); color: var(--taif-primary); }
.rep-stop.done .rep-stop-n { background: var(--taif-ok); color: #fff; }
.rep-stop-text { flex: 1; min-width: 0; }
.rep-call { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--taif-primary); color: #fff; }
.rep-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rep-action {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px; border-radius: 14px;
    border: 1px solid var(--taif-line); background: var(--taif-surface-2); color: var(--taif-text); font: inherit; font-weight: 600; cursor: pointer;
}
.rep-action.sale { background: var(--taif-primary); border-color: var(--taif-primary); color: #fff; }
.rep-match {
    display: flex; justify-content: space-between; width: 100%; padding: 10px; margin-bottom: 4px; border-radius: 8px;
    border: 1px solid var(--taif-line); background: var(--taif-surface-2); color: var(--taif-text); font: inherit; cursor: pointer;
}
.rep-match small { color: var(--taif-muted); }
.rep-pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
@media (max-width: 600px) {
    .taif-content { padding: 10px; }
    .rep-stats b { font-size: 1.1rem; }
}

/* self-service kiosk: the whole screen, big touch targets */
.kiosk-shell { min-height: 100vh; background: var(--taif-bg); padding: 16px; }
.kiosk { min-height: calc(100vh - 32px); }
.kiosk-welcome { min-height: calc(100vh - 32px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.kiosk-welcome img { width: 260px; max-width: 70vw; background: #FBF8F1; border-radius: 18px; padding: 12px 16px; }
.kiosk-welcome h1 { margin: 0; font-size: 2.4rem; }
.kiosk-welcome p { margin: 0; font-size: 1.2rem; color: var(--taif-muted); }
.kiosk-choices { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.kiosk-choices button {
    width: 220px; height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    border-radius: 24px; border: 0; background: var(--taif-primary); color: #fff; font: inherit; font-size: 1.6rem; font-weight: 700; cursor: pointer;
    box-shadow: var(--taif-shadow-lg);
}
.kiosk-choices button .mud-icon-root { font-size: 64px; }
.kiosk-number { font-size: 7rem; font-weight: 800; line-height: 1; color: var(--taif-primary); }
.kiosk-order { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; height: calc(100vh - 32px); }
.kiosk-catalog { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.kiosk-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kiosk-grid .rpos-tile { min-height: 180px; }
.kiosk-grid .rpos-tile img, .kiosk-grid .rpos-tile-initial { height: 110px; }
.kiosk-grid .rpos-tile-name { font-size: 1.05rem; }
.kiosk-cart { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 16px; }
.kiosk-cart h2 { margin: 0; }
.kiosk-pay { display: flex; flex-direction: column; gap: 10px; }
.kiosk-pay .mud-button-root { min-height: 64px; font-size: 1.15rem; }
@media (max-width: 960px) { .kiosk-order { grid-template-columns: 1fr; height: auto; } }

/* online store */
.store-key-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; background: var(--taif-accent-soft); }
.store-key { font-size: .95rem; word-break: break-all; }
.store-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.store-order { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.store-order-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.store-order-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.store-sync { margin-top: 12px; padding: 8px 12px; border-radius: 10px; font-size: .9rem; }
.store-sync.ok { background: var(--taif-ok-soft); color: var(--taif-ok); }
.store-sync.bad { background: var(--taif-danger-soft); color: var(--taif-danger); }

/* phones: a wide table or grid scrolls inside its card; the page itself never scrolls sideways */
@media (max-width: 700px) {
    html, body { overflow-x: clip; }
    .taif-table { display: block; max-width: 100%; overflow-x: auto; }
    .taif-card { max-width: 100%; overflow-x: auto; }
    .taif-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .taif-toolbar > * { min-width: 0; flex: 1 1 140px; }
    .print-sheet { max-width: 100%; overflow-x: auto; }
    .print-sheet.a4 { width: auto; min-height: 0; padding: 4mm; }
}

/* the rep's own: loads to take in, the van, sales rows */
.rep-load { padding: 12px; display: flex; flex-direction: column; gap: 6px; border-color: var(--taif-accent); }
.rep-load ul { margin: 0; padding-inline-start: 18px; }
.rep-van-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 4px 6px 8px; }
.rep-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--taif-line); color: inherit; text-decoration: none; }
.rep-row:last-child { border-bottom: 0; }
.rep-row > span { display: flex; flex-direction: column; min-width: 0; }
.rep-row small { color: var(--taif-muted); }
.taif-table td.neg { color: var(--taif-danger); }
.rep-van-actions .mud-button-root { white-space: nowrap; font-size: .85rem; padding-inline: 6px; }
.rep-van-actions .mud-button-icon-start { margin-inline-end: 4px; }
.rep-out { color: var(--taif-danger); }
.rep-in { color: var(--taif-ok); }
.rep-tabs::-webkit-scrollbar { display: none; }

/* the reps in the field */
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
.field-rep { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
@media (max-width: 700px) { .field-grid { grid-template-columns: minmax(0, 1fr); } }

/* order loading: the store's day of reps' orders */
.load-section { margin: 18px 0 8px; font-size: 1.05rem; color: var(--taif-muted); }
.load-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; }
.load-gauge { margin: 8px 0 12px; display: grid; gap: 6px; }
.load-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.load-order { display: grid; gap: 6px; margin-top: 8px; }
.taif-table tr.load-short td { background: var(--taif-danger-soft); }
.taif-table tr.load-over td { background: var(--taif-accent-soft); }
.load-labels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.load-label { border: 1px dashed #000; padding: 8px 10px; break-inside: avoid; position: relative; }
.load-label-no { position: absolute; inset-inline-end: 8px; top: 6px; font-size: 1.6rem; font-weight: 700; }

/* a document's signature and photos (from the phones) */
.attachments { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 14px; }
.attachments figure { margin: 0; cursor: zoom-in; border: 1px solid var(--taif-line); border-radius: 10px; padding: 6px; background: #fff; }
.attachments img { display: block; height: 70px; width: auto; }
.attachments figure.open { cursor: zoom-out; }
.attachments figure.open img { height: 360px; }
.attachments figcaption { font-size: .75rem; color: #555; margin-top: 4px; }
