/* ==========================================================
   Restaurant Management — theme layer (v4), loaded after style.css.
   Identity: the original navy sidebar + blue accent, sky-blue highlights,
   IBM Plex Sans / IBM Plex Sans Arabic (one family for both scripts).
   1 tokens · 2 shell · 3 cards & forms · 4 tables · 5 status · 6 tips
   7 menus & notifications · 8 permissions · 9 new pages · 10 sign-in
   11 right-to-left · 12 phone · 13 print
   ========================================================== */

/* 1 ---------------------------------------------------------------- tokens */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cfd7e3;
  --text: #1f2937;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #e8f0fe;
  --sky: #0ea5e9;
  --saffron: #0ea5e9;          /* highlight colour: sky blue (kept under the old name for the rules below) */
  --success: #16a34a;
  --success-soft: #e7f7ee;
  --warning: #d97706;
  --warning-soft: #fef5e6;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --info: #0891b2;
  --info-soft: #e6f6fa;
  --purple: #7c3aed;
  --sidebar: #0f172a;
  --sidebar-2: #1e293b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 6px 20px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .28);
  --font: "IBM Plex Sans", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, -apple-system, Arial, sans-serif;
  --control-h: 40px;
}
html[lang=ar] { --font: "IBM Plex Sans Arabic", "IBM Plex Sans", Tahoma, "Segoe UI", system-ui, Arial, sans-serif; }
body { font-size: 14px; line-height: 1.5; letter-spacing: 0; }
html[lang=ar] body { font-size: 14.5px; line-height: 1.65; }
[hidden] { display: none !important; }
::selection { background: #dbeafe; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
a { color: var(--accent-dark); }

/* 2 ---------------------------------------------------------------- shell */
.sidebar { width: 252px; flex-basis: 252px; color: #cbd5e1; }
.brand { padding: 18px 16px 14px; gap: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #38bdf8, #2563eb); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-name { font-size: 15px; font-weight: 600; color: #fff; line-height: 1.25; }
.brand-tag { font-size: 11.5px; color: #94a3b8; }
.nav-group { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; color: #94a3b8; padding: 16px 12px 6px; }
.tab-btn { position: relative; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; color: #cbd5e1; text-align: start; }
.tab-btn i { color: #94a3b8; }
.tab-btn:hover { background: var(--sidebar-2); }
.tab-btn.active { background: var(--sidebar-2); color: #fff; font-weight: 600; }
.tab-btn.active::before { content: ''; position: absolute; inset-inline-start: -8px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--saffron); }
.tab-btn.active i { color: var(--saffron); }
.nav-count { margin-inline-start: auto; min-width: 20px; padding: 0 6px; height: 20px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.sidebar-footer button, .sidebar-footer .file-label { background: transparent; border-color: rgba(255,255,255,.1); color: #cbd5e1; border-radius: 9px; }
.sidebar-footer button:hover, .sidebar-footer .file-label:hover { background: var(--sidebar-2); }
.sidebar-version { color: #64748b; }

.topbar { padding: 12px 28px; background: rgba(255,255,255,.94); }
.topbar h1 { font-size: 19px; font-weight: 600; letter-spacing: -.1px; }
.topbar-right { gap: 8px; }
main { padding: 22px 28px 56px; }
.icon-btn, .account-btn, .ellipsis-btn { height: 38px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; color: var(--text); cursor: pointer; font: inherit; display: inline-flex; align-items: center; gap: 8px; }
.icon-btn { width: 38px; justify-content: center; position: relative; color: var(--text-muted); }
.icon-btn:hover, .account-btn:hover, .ellipsis-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.dot-count { position: absolute; top: -6px; inset-inline-end: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--text-muted); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; }
.dot-count.is-new { background: var(--danger); }
.account-btn { padding: 0 12px 0 5px; max-width: 220px; }
[dir=rtl] .account-btn { padding: 0 5px 0 12px; }
.avatar { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.account-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 3 ---------------------------------------------------------------- cards & forms */
.card { border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: none; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.card-title i { color: var(--accent); width: 18px; text-align: center; }
.grid-2, .grid-3 { gap: 18px; }
.form-grid { gap: 14px 16px; }
.field label, .modal-grid label { font-size: 12.5px; font-weight: 500; color: var(--text-muted); }
input, select, textarea { border-radius: var(--radius-sm); border-color: var(--border-strong); }
input[type=search] { height: var(--control-h); padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font: inherit; color: var(--text); min-width: 220px; -webkit-appearance: none; appearance: none; }
.toolbar input[type=search] { flex: 1 1 240px; max-width: 360px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); outline: none; }
.btn, .mini-btn, .edit-btn, .delete-btn, .danger-btn, .end-month-btn, .btn-icon, .toggle-status-btn, .modal-actions button { border-radius: var(--radius-sm); font-weight: 500; }
.btn-primary, form button[type=submit]:not(.btn) { background: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-icon:hover { background: var(--accent-soft); color: var(--accent-dark); border-color: #bfdbfe; }
.toolbar { gap: 10px; margin-bottom: 16px; }
.subtab { font-weight: 500; padding: 10px 16px; }
.subtab.active { color: var(--accent-dark); border-bottom-color: var(--saffron); font-weight: 600; }
.kpi-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { border-radius: var(--radius); padding: 16px 18px; box-shadow: none; }
.kpi::before { left: 0; width: 4px; top: 14px; bottom: 14px; border-radius: 0 4px 4px 0; }
[dir=rtl] .kpi::before { left: auto; right: 0; }
.kpi-label { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 600; letter-spacing: -.3px; }
.kpi-value-sm { font-size: 15px; }
.kpi.clickable:hover { border-color: #bfdbfe; }
.callout { border-radius: var(--radius-sm); }

/* 4 ---------------------------------------------------------------- tables
   Cells keep their text on one line and get real room; when a table is wider
   than the screen, it scrolls sideways inside its own frame. */
.table-wrap { border-radius: var(--radius-sm); overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.table-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; border: 2px solid var(--surface); }
.data-table, .table-wrap > table { width: 100%; min-width: max-content; border-collapse: separate; border-spacing: 0; }
.data-table th, .data-table td, table th, table td { padding: 12px 16px; text-align: start; white-space: nowrap; }
.data-table thead th, table thead th { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 600; color: var(--text-muted); background: var(--surface-2); padding-top: 11px; padding-bottom: 11px; }
.data-table tbody td { min-width: 72px; max-width: none; overflow: visible; }
.data-table tbody tr:hover { background: #f1f5ff; }
.data-table td.num, .data-table th.num, .num, td.num, th.num { text-align: end; }
.compact-table th, .compact-table td { padding: 9px 14px; }
/* names (employee, item, supplier, product, customer…) always get generous width */
.col-name, .data-table td:has(> strong:only-child), .data-table td:has(> a:first-child) { min-width: 220px; }
.col-wide { min-width: 280px; }
.data-table td.actions, .data-table td:last-child:has(button) { overflow: visible; max-width: none; }
.data-table td input[type=number], .data-table td input[type=text], .data-table td select { min-width: 96px; }
.data-table td input.sale-qty, .data-table td input.sale-price, .data-table td input.recipe-qty { width: 120px; text-align: end; }
.data-table td select.recipe-item { min-width: 260px; }
.row-muted td { color: var(--text-muted); }
.row-saved td:first-child { box-shadow: inset 3px 0 0 var(--success); }
[dir=rtl] .row-saved td:first-child { box-shadow: inset -3px 0 0 var(--success); }
.table-foot td { background: var(--surface-2); font-weight: 600; }
.eval-table thead th.num { text-align: center; }
.item-meta { font-size: 12px; color: var(--text-muted); }
.code { border-radius: 6px; padding: 2px 7px; }

/* 5 ---------------------------------------------------------------- status */
.badge, .status-badge { padding: 3px 10px; font-size: 12px; font-weight: 500; }
.chip { background: var(--accent-soft); color: var(--accent-dark); padding: 3px 10px; font-weight: 500; margin: 1px 0; }

/* 6 ---------------------------------------------------------------- tips
   Explanations live behind an "i" (or on the control itself) and appear when
   the pointer rests there, on keyboard focus, or on tap. */
.tip { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--text-muted); font-size: 11px; font-weight: 600; font-style: normal; cursor: help; flex: none; background: var(--surface); line-height: 1; user-select: none; }
.tip:hover, .tip:focus-visible { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }
.tip-bar { display: flex; justify-content: flex-end; margin: -4px 0 8px; }
.tip-link { font-size: 12px; font-weight: 500; margin-inline-start: 4px; }
.field label[data-tip], th[data-tip] { cursor: help; text-decoration: underline dotted #b6c2d3; text-underline-offset: 4px; }
.tip-pop { position: fixed; z-index: 2000; max-width: min(340px, calc(100vw - 16px)); padding: 9px 12px; border-radius: 9px; background: #0f172a; color: #f1f5f9; font-size: 12.5px; line-height: 1.5; white-space: pre-line; box-shadow: var(--shadow); pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .12s; }
.tip-pop.show { opacity: 1; visibility: visible; }
summary.card-title .tip { margin-inline-start: 2px; }

/* 7 ---------------------------------------------------------------- menus & notifications */
.dropdown-content { right: auto; inset-inline-end: 0; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.dropdown-item { text-align: start; }
.account-menu { width: 250px; }
.lang-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px 10px; }
.lang-switch .dropdown-item { justify-content: center; border: 1px solid var(--border); border-radius: 8px; padding: 7px 8px; }
.lang-switch .dropdown-item.active { background: var(--accent-soft); border-color: #bfdbfe; color: var(--accent-dark); font-weight: 600; }
.notif-panel { width: min(380px, calc(100vw - 24px)); }
.notif-list { max-height: min(60vh, 440px); overflow-y: auto; }
.notif { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-top: 1px solid var(--border); cursor: pointer; }
.notif:hover { background: var(--surface-2); }
.notif.is-new { background: #eff6ff; }
.notif > i { margin-top: 3px; color: var(--info); }
.notif-danger > i { color: var(--danger); } .notif-warning > i { color: var(--warning); }
.notif-text { flex: 1; min-width: 0; } .notif-text strong { font-weight: 600; font-size: 13px; display: block; }
.notif-empty { padding: 26px 16px; text-align: center; }
.ui-modal { border-radius: 14px; }

/* 8 ---------------------------------------------------------------- permissions
   .read-only  = the user may only look at this page  → no entry forms, no row buttons
   .no-manage  = may add but not edit/delete          → no edit / delete buttons      */
.tab-content.read-only form:not(.filter-form), .tab-content.read-only details.card:has(form), .tab-content.read-only .card:has(> form):not(:has(.data-table)),
.tab-content.read-only .edit-btn, .tab-content.read-only .delete-btn, .tab-content.read-only .danger-btn, .tab-content.read-only .end-month-btn, .tab-content.read-only .toggle-status-btn,
.tab-content.read-only td.actions > *, .tab-content.read-only [data-needs], .tab-content.read-only .btn-save,
.tab-content.no-manage .edit-btn, .tab-content.no-manage .delete-btn, .tab-content.no-manage .danger-btn, .tab-content.no-manage .end-month-btn, .tab-content.no-manage [data-needs=manage] { display: none !important; }
.perm-group { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 14px; overflow: hidden; }
.perm-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.perm-quick { display: flex; gap: 4px; flex-wrap: wrap; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--border); border-inline-start: 3px solid transparent; font-size: 13.5px; }
.perm-row select { width: 190px; min-width: 0; height: 34px; font-size: 12.5px; }
.perm-row.lvl-0 { color: var(--text-muted); } .perm-row.lvl-1 { border-inline-start-color: var(--info); } .perm-row.lvl-2 { border-inline-start-color: var(--saffron); } .perm-row.lvl-3 { border-inline-start-color: var(--success); }

/* 9 ---------------------------------------------------------------- new pages */
#recipeTable { min-width: 0; }
.stack-cards { gap: 18px; }
.boot-error { max-width: 520px; margin: 12vh auto; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.boot-error h2 { margin-bottom: 10px; font-weight: 600; }

/* 10 --------------------------------------------------------------- sign-in page */
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-aside { background: linear-gradient(160deg, #0f172a, #1e3a8a); color: #dbe4f0; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-aside::after { content: ''; position: absolute; inset-inline-end: -140px; bottom: -140px; width: 420px; height: 420px; border-radius: 50%; border: 56px solid rgba(56, 189, 248, .18); }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 16px; color: #fff; }
.auth-aside h1 { color: #fff; font-size: clamp(28px, 3.2vw, 40px); font-weight: 600; line-height: 1.2; letter-spacing: -.5px; max-width: 14ch; }
.auth-aside p { color: #94a3b8; max-width: 40ch; margin-top: 14px; font-size: 15px; }
.auth-main { display: flex; flex-direction: column; padding: 28px; }
.auth-top { display: flex; justify-content: flex-end; }
.auth-lang { border: 1px solid var(--border); background: var(--surface); border-radius: 9px; height: 36px; padding: 0 14px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text); }
.auth-card { width: 100%; max-width: 400px; margin: auto; }
.auth-card h2 { font-size: 24px; font-weight: 600; letter-spacing: -.3px; margin-bottom: 6px; }
.auth-card .muted { margin-bottom: 22px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; margin-bottom: 20px; }
.auth-tabs button { border: 0; background: none; height: 38px; border-radius: 8px; font: inherit; font-weight: 500; color: var(--text-muted); cursor: pointer; }
.auth-tabs button.active { background: var(--surface); color: var(--text-dark); box-shadow: var(--shadow-sm); font-weight: 600; }
.auth-card .field { margin-bottom: 14px; }
.auth-card input[type=text], .auth-card input[type=password], .auth-card input[type=tel] { height: 46px; font-size: 15px; width: 100%; }
.auth-card .btn-primary { width: 100%; height: 46px; font-size: 15px; justify-content: center; margin-top: 6px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 14px; font-size: 13px; }
.auth-row label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
.auth-error { display: none; background: var(--danger-soft); color: #8f2a20; border: 1px solid #f0c4be; border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.auth-error.show { display: block; }
.auth-note { background: var(--info-soft); color: #1c566e; border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.otp-input { letter-spacing: .5em; text-align: center; font-size: 22px !important; font-variant-numeric: tabular-nums; }
.link-btn { border: 0; background: none; color: var(--accent-dark); font: inherit; font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:disabled { color: var(--text-muted); text-decoration: none; cursor: default; }
.pw-wrap { position: relative; } .pw-wrap .pw-eye { position: absolute; inset-inline-end: 6px; top: 6px; height: 34px; width: 38px; border: 0; background: none; color: var(--text-muted); cursor: pointer; }
@media (max-width: 860px) { .auth-page { grid-template-columns: 1fr; } .auth-aside { padding: 22px 24px; flex-direction: row; align-items: center; } .auth-aside h1, .auth-aside p, .auth-aside::after { display: none; } .auth-main { padding: 20px; } }

/* 11 --------------------------------------------------------------- right-to-left (Arabic) */
/* each cell reads in the direction of its own content ("185 pcs" stays "185 pcs"; Arabic stays Arabic) */
[dir=rtl] .data-table td, [dir=rtl] .kpi-value, [dir=rtl] .notif-text { unicode-bidi: plaintext; text-align: right; }
[dir=rtl] .data-table td.num, [dir=rtl] .data-table th.num { text-align: left; }
[dir=rtl] .tab-btn.active::before, [dir=rtl] .kpi::before { border-radius: 4px 0 0 4px; }
[dir=rtl] .card-collapsible > summary::after { margin-left: 0; margin-right: auto; }
[dir=rtl] input[type=tel], [dir=rtl] input[type=url], [dir=rtl] input[type=number], [dir=rtl] input[type=date], [dir=rtl] input[type=month], [dir=rtl] .code, [dir=rtl] .otp-input { direction: ltr; }
[dir=rtl] input[type=tel], [dir=rtl] input[type=url] { text-align: right; }
[dir=rtl] .fa-sign-out-alt, [dir=rtl] .fa-chevron-right, [dir=rtl] .fa-arrow-right { transform: scaleX(-1); }
[dir=rtl] .toast-container, [dir=rtl] #toastContainer { right: auto; left: 16px; }
@media (max-width: 960px) {
  [dir=rtl] .sidebar { left: auto; right: 0; transform: translateX(100%); }
  [dir=rtl] body.nav-open .sidebar, body.nav-open .sidebar { transform: none; }
}

/* 12 --------------------------------------------------------------- phone */
@media (max-width: 960px) {
  .topbar { padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  main { padding: 16px 14px calc(48px + env(safe-area-inset-bottom, 0px)); }
  .sidebar { width: min(86vw, 300px); padding-top: env(safe-area-inset-top, 0px); }
  .account-name { display: none; } .account-btn { padding: 0 5px; }
  .card { padding: 16px; }
}
@media (max-width: 560px) {
  input, select, textarea { font-size: 16px; }             /* stops iOS from zooming into fields */
  .btn { min-height: 42px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; } .kpi-value { font-size: 19px; }
  .data-table th, .data-table td, table th, table td { padding: 11px 13px; }
  .col-name, .data-table td:has(> strong:only-child) { min-width: 180px; }
  .perm-grid { grid-template-columns: 1fr; } .perm-row select { width: 160px; }
  .ui-modal-overlay { padding: 0; align-items: flex-end; } .ui-modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  #saveState span, .ellipsis-btn span { display: none; }
}
@media (hover: none) { .data-table tbody tr:hover { background: transparent; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* 13 --------------------------------------------------------------- print */
@media print { .tip, .tip-pop, .icon-btn, .account-btn, .nav-count { display: none !important; } }
@media (max-width: 560px) {
  /* day navigator stays on one line: ‹ [date] › Today */
  .toolbar > button.btn-ghost { flex: 0 0 auto; min-width: 44px; }
  .toolbar > input[type=date], .toolbar > input[type=month] { flex: 1 1 130px; min-width: 0; }
}

/* 14 --------------------------------------------------------------- refinements */
/* The Actions column stays pinned to the edge while a wide table scrolls sideways. */
.data-table td.actions, .data-table tbody td:last-child:has(> button), .data-table tbody td:last-child:has(> .btn) { position: sticky; inset-inline-end: 0; background: var(--surface); box-shadow: -8px 0 8px -8px rgba(15, 23, 42, .18); z-index: 1; }
[dir=rtl] .data-table td.actions, [dir=rtl] .data-table tbody td:last-child:has(> button) { box-shadow: 8px 0 8px -8px rgba(15, 23, 42, .18); }
.data-table:has(tbody td:last-child > button) thead th:last-child, .data-table:has(td.actions) thead th:last-child { position: sticky; inset-inline-end: 0; z-index: 2; box-shadow: -8px 0 8px -8px rgba(15, 23, 42, .18); }
.data-table tbody tr:hover td.actions, .data-table tbody tr:hover td:last-child:has(> button) { background: #f1f5ff; }
.data-table tbody td.num { min-width: 0; }
.data-table td.actions:empty { box-shadow: none; }
@media (max-width: 860px) { .auth-page { grid-template-rows: auto 1fr; } .auth-aside > div:empty { display: none; } }
@media (max-width: 560px) { .data-table td.actions, .data-table tbody td:last-child:has(> button), .data-table thead th:last-child { position: static !important; box-shadow: none !important; } }

/* 15 --------------------------------------------------------------- v4.1 additions */
.avatar img, .avatar-lg img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar { overflow: hidden; }
.avatar-lg { width: 84px; height: 84px; border-radius: 20px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 30px; font-weight: 600; overflow: hidden; }
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.profile-head .muted { font-size: 13px; }
.avatar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.role-badge { background: #e0e7ff; color: #3730a3; }
.perm-matrix { min-width: max-content; }
.perm-matrix th, .perm-matrix td { text-align: center; padding: 8px 10px; }
.perm-matrix th:first-child, .perm-matrix td:first-child { text-align: start; min-width: 200px; position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; }
.perm-matrix thead th:first-child { background: var(--surface-2); z-index: 3; }
.perm-matrix tr.perm-group-row td { background: var(--surface-2); font-weight: 600; text-align: start; }
.perm-matrix .pm { width: 34px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; display: inline-grid; place-items: center; color: var(--text-muted); }
.perm-matrix .pm.on { background: var(--success-soft); color: var(--success); border-color: #b7e4c7; }
.perm-matrix .pm.off { background: var(--danger-soft); color: var(--danger); border-color: #f5c2c0; }
.perm-matrix .pm.inherit-on { background: #f0fdf4; color: #4ade80; border-style: dashed; }
.perm-matrix .pm.na { visibility: hidden; }
.perm-matrix .pm:disabled { cursor: default; opacity: .7; }
.perm-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); margin: 8px 0 12px; }
.perm-legend .pm { pointer-events: none; }
.detail-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.detail-tabs button { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.detail-tabs button.active { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; }
.detail-grid dt { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; } .detail-grid dd { margin: 0 0 8px; font-weight: 500; }
.pos { color: var(--success); } .neg { color: var(--danger); }
.delta-up { color: var(--danger); font-weight: 600; } .delta-down { color: var(--success); font-weight: 600; }
.ui-modal.wide { max-width: 1040px; }
.dash-section-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 6px 0 10px; }
.stat-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.user-cell { display: inline-flex; align-items: center; gap: 10px; }
.tab-content.no-print .print-btn, .tab-content.no-print [data-print] { display: none !important; }
.chip-pref { background: var(--success-soft); color: var(--success); }
.chart-box { min-height: 220px; }
.perm-matrix th, .perm-matrix td { overflow: visible; text-overflow: clip; max-width: none; white-space: nowrap; }
.perm-matrix thead th { font-size: 12px; }
.perm-matrix th, .perm-matrix td { padding: 7px 6px; }
.perm-matrix th:first-child, .perm-matrix td:first-child { min-width: 170px; padding-inline-start: 12px; }
.perm-matrix thead th { font-size: 11.5px; }
.perm-matrix th, .perm-matrix td { padding: 6px 4px; }
.perm-matrix .pm { width: 30px; height: 28px; }
.perm-matrix th:first-child, .perm-matrix td:first-child { min-width: 150px; }
.perm-matrix thead th:not(:first-child) { white-space: normal; max-width: 74px; width: 74px; line-height: 1.2; vertical-align: bottom; text-align: center; }

/* edit lock */
#lockBtn.is-locked { color: var(--danger); background: var(--danger-soft); border-color: #f5c2c0; }
#lockBtn:not(.is-locked) { color: var(--success); background: var(--success-soft); border-color: #b7e4c7; }
body.locked .tab-content form input:not([type=search]):not(.filter), body.locked .tab-content form select, body.locked .tab-content form textarea,
body.locked .tab-content form button[type=submit], body.locked .edit-btn, body.locked .delete-btn, body.locked .tab-content .btn-primary, body.locked .tab-content .btn-danger, body.locked .status-badge { pointer-events: none; opacity: .55; }
body.locked .toolbar input, body.locked .toolbar select, body.locked .subtabs button, body.locked .detail-tabs button { pointer-events: auto; opacity: 1; }
.lock-banner { display: none; align-items: center; gap: 10px; padding: 8px 14px; margin-bottom: 14px; border-radius: var(--radius-sm); background: var(--warning-soft); color: #7c4a03; font-size: 13px; }
body.locked .lock-banner { display: flex; }
.lock-banner a { color: inherit; font-weight: 600; cursor: pointer; }
.status-pending { background: var(--warning-soft); color: var(--warning); } .status-suspended, .status-locked { background: var(--danger-soft); color: var(--danger); } .status-disabled { background: #e2e8f0; color: #475569; }
.progress { width: 90px; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 4px; }
#syncBtn.spinning i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.save-status.is-error { color: var(--danger); }
/* 16 --------------------------------------------------------------- dark theme (same blue identity, dark surfaces) */
html[data-theme="dark"] {
  --bg: #0b1220; --surface: #111a2b; --surface-2: #17223a; --border: #22304a; --border-strong: #2f3f5e;
  --text: #dbe4f0; --text-dark: #f1f5f9; --text-muted: #8fa3bf; --accent: #3b82f6; --accent-dark: #60a5fa; --accent-soft: #172554;
  --success-soft: #0f2e1c; --warning-soft: #33230a; --danger-soft: #3b1212; --info-soft: #0c2a33;
  --sidebar: #070c17; --sidebar-2: #0f172a; --row-alt: #141e33; --row-hover: #1a2640; --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 6px 20px rgba(0,0,0,.45);
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] .data-table tbody tr:hover, html[data-theme="dark"] .data-table tbody tr:hover td.actions { background: var(--row-hover); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
html[data-theme="dark"] .kpi, html[data-theme="dark"] .card, html[data-theme="dark"] .ui-modal, html[data-theme="dark"] .dropdown-content { background: var(--surface); }
html[data-theme="dark"] .badge { filter: brightness(.9); }
html[data-theme="dark"] .tip-pop { background: #e2e8f0; color: #0f172a; }
html[data-theme="dark"] .topbar, html[data-theme="dark"] .topbar h1, html[data-theme="dark"] #pageTitle, html[data-theme="dark"] .topbar .save-status { color: var(--text-dark); }
html[data-theme="dark"] .topbar { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .icon-btn, html[data-theme="dark"] .account-btn, html[data-theme="dark"] .btn-secondary, html[data-theme="dark"] .btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
/* 17 --------------------------------------------------------------- searchable select */
.ss { position: relative; }
.ss .ss-native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.ss .ss-input { width: 100%; }
.ss-list { position: absolute; z-index: 60; inset-inline: 0; top: calc(100% + 4px); max-height: 280px; overflow: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); }
.ss-item { padding: 9px 12px; cursor: pointer; font-size: 13.5px; }
.ss-item:hover, .ss-item.is-active { background: var(--accent-soft); color: var(--accent-dark); }
.ss-item.is-selected { font-weight: 600; }
.ss-empty { padding: 10px 12px; color: var(--text-muted); font-size: 13px; }
.count-grid input[type=number] { width: 120px; }
.count-row.is-done td { background: var(--success-soft); }
.count-row.is-missed td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.count-row.is-focus td { background: var(--accent-soft); }
.inv-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 20px; }
.inv-card .v { font-size: 22px; font-weight: 600; } .inv-card .l { font-size: 12px; color: var(--text-muted); }
/* 18 --------------------------------------------------------------- accent colours, density, text size */
html[data-accent="navy"] { --accent: #1e3a8a; --accent-dark: #172554; --accent-soft: #e0e7ff; --sky: #3b82f6; --saffron: #3b82f6; }
html[data-accent="teal"] { --accent: #0d9488; --accent-dark: #0f766e; --accent-soft: #ccfbf1; --sky: #2dd4bf; --saffron: #2dd4bf; }
html[data-accent="emerald"] { --accent: #059669; --accent-dark: #047857; --accent-soft: #d1fae5; --sky: #34d399; --saffron: #34d399; }
html[data-accent="violet"] { --accent: #7c3aed; --accent-dark: #6d28d9; --accent-soft: #ede9fe; --sky: #a78bfa; --saffron: #a78bfa; }
html[data-accent="amber"] { --accent: #d97706; --accent-dark: #b45309; --accent-soft: #fef3c7; --sky: #fbbf24; --saffron: #fbbf24; }
html[data-accent="graphite"] { --accent: #374151; --accent-dark: #1f2937; --accent-soft: #e5e7eb; --sky: #9ca3af; --saffron: #9ca3af; --sidebar: #111827; --sidebar-2: #1f2937; }
html[data-accent="navy"] .brand-mark { background: linear-gradient(135deg, #3b82f6, #1e3a8a); }
html[data-accent="teal"] .brand-mark { background: linear-gradient(135deg, #2dd4bf, #0d9488); } html[data-accent="emerald"] .brand-mark { background: linear-gradient(135deg, #34d399, #059669); }
html[data-accent="violet"] .brand-mark { background: linear-gradient(135deg, #a78bfa, #7c3aed); } html[data-accent="amber"] .brand-mark { background: linear-gradient(135deg, #fbbf24, #d97706); } html[data-accent="graphite"] .brand-mark { background: linear-gradient(135deg, #9ca3af, #374151); }
html[data-theme="dark"][data-accent="navy"] { --accent: #60a5fa; --accent-dark: #93c5fd; --accent-soft: #1e3a8a; } html[data-theme="dark"][data-accent="teal"] { --accent: #2dd4bf; --accent-dark: #5eead4; --accent-soft: #134e4a; }
html[data-theme="dark"][data-accent="emerald"] { --accent: #34d399; --accent-dark: #6ee7b7; --accent-soft: #064e3b; } html[data-theme="dark"][data-accent="violet"] { --accent: #a78bfa; --accent-dark: #c4b5fd; --accent-soft: #4c1d95; }
html[data-theme="dark"][data-accent="amber"] { --accent: #fbbf24; --accent-dark: #fcd34d; --accent-soft: #78350f; } html[data-theme="dark"][data-accent="graphite"] { --accent: #9ca3af; --accent-dark: #d1d5db; --accent-soft: #374151; }
html[data-density="compact"] { --control-h: 34px; } html[data-density="compact"] .data-table th, html[data-density="compact"] .data-table td { padding: 7px 10px; } html[data-density="compact"] .card { padding: 14px; } html[data-density="compact"] .kpi { padding: 12px; } html[data-density="compact"] .kpi-value { font-size: 20px; }
html[data-font="small"] { font-size: 13px; } html[data-font="normal"] { font-size: 14.5px; } html[data-font="large"] { font-size: 16.5px; }
html[data-font="small"] body, html[data-font="large"] body { font-size: inherit; }
.theme-swatch { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); cursor: pointer; font-size: 12.5px; } .theme-swatch i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; } .theme-swatch.active { border-color: var(--accent); background: var(--accent-soft); }
.feature-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
@media (max-width: 640px) { .hide-sm { display: none; } }
/* 19 --------------------------------------------------------------- phone top bar: one row, essentials only */
@media (max-width: 640px) {
  .topbar { padding: 8px 10px; gap: 6px; flex-wrap: nowrap; }
  .topbar h1 { font-size: 16px; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { gap: 4px; flex-wrap: nowrap; flex: 0 0 auto; }
  .topbar .save-state { display: none; }
  .topbar #navIOMenuBtn { display: none; }                     /* Transfer covers export/import on phones */
  .topbar .icon-btn, .topbar .account-btn { width: 36px; height: 36px; min-width: 36px; padding: 0; }
  .topbar .account-btn .account-name { display: none; }
  .topbar #transferBtn { padding: 0 8px; height: 36px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px; } .kpi-value { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .ui-modal { max-height: calc(100vh - 16px); overflow: auto; border-radius: 14px; }
  .toolbar { gap: 6px; } .toolbar > * { flex: 1 1 140px; min-width: 0; }
  .data-table th, .data-table td { padding: 9px 10px; font-size: 13px; }
}

/* ---- v4.8 stock workflow bar + live count warnings ---- */
.flow-bar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 0 0 14px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.flow-step { display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.flow-step:hover { background: var(--accent-soft); color: var(--accent-dark); }
.flow-step.active { background: var(--accent); color: #fff; cursor: default; }
.flow-no { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-2); color: var(--text-muted); font-size: 11px; }
.flow-step.active .flow-no { background: rgba(255,255,255,.25); color: #fff; }
.flow-sep { color: var(--border-strong); font-size: 16px; }
.flow-badge { min-width: 18px; padding: 0 6px; border-radius: 999px; font-size: 11px; line-height: 18px; text-align: center; color: #fff; background: var(--info); }
.flow-badge.flow-danger { background: var(--danger); } .flow-badge.flow-warn { background: var(--warning); }
[dir="rtl"] .flow-sep { transform: scaleX(-1); }
@media (max-width: 720px) { .flow-bar { flex-wrap: nowrap; overflow-x: auto; } .flow-label { font-size: 12px; } }
#ohTable tr.row-warn td { background: var(--warning-soft); }
#ohTable tr.row-warn .oh-input { border-color: var(--danger); }
/* 20 --------------------------------------------------------------- print / PDF: always the light palette, colours kept */
@media print {
  html, html[data-theme="dark"], html[data-accent] { --bg: #fff; --surface: #fff; --surface-2: #f8fafc; --border: #d7dee8; --border-strong: #c3ccd9; --text: #1f2937; --text-dark: #0f172a; --text-muted: #4b5563;
    --accent: #2563eb; --accent-dark: #1d4ed8; --accent-soft: #e8f0fe; --success: #15803d; --success-soft: #e7f7ee; --warning: #b45309; --warning-soft: #fef5e6; --danger: #b91c1c; --danger-soft: #fdecec; --info: #0e7490; --sidebar: #fff; color-scheme: light; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: #fff !important; color: #1f2937 !important; }
  .payroll-card-arabic, .modal-summary { background: #fff !important; color: #0f172a !important; }
  .payroll-card-arabic span, .payroll-card-arabic strong, .modal-summary span, .payroll-card-name { color: #0f172a !important; }
  .payroll-card-meta, .payroll-sublabel, .payroll-advance-date { color: #4b5563 !important; }
  .modal-summary .net span { color: #15803d !important; }
  .payroll-advance-amount { color: #b91c1c !important; }
  .badge { border: 1px solid #c3ccd9; color: #0f172a !important; }
  #transferBtn, #syncBtn, #lockBtn, .lock-banner, .flow-bar, .ss-list, .toast, .ui-modal-overlay:not(.print-keep) { display: none !important; }
}
/* 21 --------------------------------------------------------------- more accents, surface tones, sidebar tones */
html[data-accent="rose"] { --accent: #e11d48; --accent-dark: #be123c; --accent-soft: #ffe4e6; --sky: #fb7185; --saffron: #fb7185; }
html[data-accent="indigo"] { --accent: #4f46e5; --accent-dark: #4338ca; --accent-soft: #e0e7ff; --sky: #818cf8; --saffron: #818cf8; }
html[data-accent="slate"] { --accent: #475569; --accent-dark: #334155; --accent-soft: #e2e8f0; --sky: #94a3b8; --saffron: #94a3b8; }
html[data-theme="dark"][data-accent="rose"] { --accent: #fb7185; --accent-dark: #fda4af; --accent-soft: #4c0519; } html[data-theme="dark"][data-accent="indigo"] { --accent: #818cf8; --accent-dark: #a5b4fc; --accent-soft: #312e81; } html[data-theme="dark"][data-accent="slate"] { --accent: #94a3b8; --accent-dark: #cbd5e1; --accent-soft: #334155; }
html[data-accent="rose"] .brand-mark { background: linear-gradient(135deg, #fb7185, #e11d48); } html[data-accent="indigo"] .brand-mark { background: linear-gradient(135deg, #818cf8, #4f46e5); } html[data-accent="slate"] .brand-mark { background: linear-gradient(135deg, #94a3b8, #475569); }
html[data-surface="warm"]:not([data-theme="dark"]) { --bg: #f8f5f0; --surface: #fffdfa; --surface-2: #f6f1ea; --border: #e8e0d5; --border-strong: #d6cbbc; }
html[data-surface="neutral"]:not([data-theme="dark"]) { --bg: #f3f4f6; --surface: #fff; --surface-2: #f9fafb; --border: #e5e7eb; --border-strong: #d1d5db; }
html[data-surface="paper"]:not([data-theme="dark"]) { --bg: #fbf9f3; --surface: #fffefb; --surface-2: #f7f3e8; --border: #ebe4d3; --border-strong: #d9cfb6; --text: #2b2a26; --text-dark: #171614; }
html[data-surface="plain"]:not([data-theme="dark"]) { --bg: #fff; --surface: #fff; --surface-2: #f4f4f5; --border: #9ca3af; --border-strong: #6b7280; --text: #000; --text-dark: #000; --text-muted: #374151; }
html[data-surface="plain"] .card { border-width: 1.5px; } html[data-surface="plain"] .data-table th, html[data-surface="plain"] .data-table td { border-bottom: 1px solid #9ca3af; }
html[data-sidebar="light"] { --sidebar: #ffffff; --sidebar-2: #f1f5f9; } html[data-sidebar="light"] .sidebar { color: #1f2937; border-inline-end: 1px solid var(--border); } html[data-sidebar="light"] .tab-btn, html[data-sidebar="light"] .brand-tag, html[data-sidebar="light"] .nav-group, html[data-sidebar="light"] .tab-btn i { color: #334155; } html[data-sidebar="light"] .tab-btn.active { background: var(--accent-soft); color: var(--accent-dark); } html[data-sidebar="light"] .sidebar-footer button, html[data-sidebar="light"] .sidebar-footer .file-label { color: #1f2937; border-color: var(--border); } html[data-sidebar="light"] .sidebar-version { color: #64748b; }
html[data-sidebar="accent"] { --sidebar: var(--accent-dark); --sidebar-2: var(--accent); } html[data-sidebar="accent"] .tab-btn, html[data-sidebar="accent"] .nav-group, html[data-sidebar="accent"] .brand-tag, html[data-sidebar="accent"] .tab-btn i { color: rgba(255,255,255,.85); } html[data-sidebar="accent"] .tab-btn.active { background: rgba(255,255,255,.18); color: #fff; }
html[data-theme="dark"][data-sidebar="light"] { --sidebar: var(--surface); --sidebar-2: var(--surface-2); } html[data-theme="dark"][data-sidebar="light"] .sidebar, html[data-theme="dark"][data-sidebar="light"] .tab-btn, html[data-theme="dark"][data-sidebar="light"] .nav-group { color: #dbe4f0; }
/* 22 --------------------------------------------------------------- navigation folding, sticky table headers, smoother scrolling */
.nav-group.foldable { cursor: pointer; display: flex; align-items: center; justify-content: space-between; user-select: none; }
.nav-group.foldable .nav-fold { font-size: 10px; opacity: .7; transition: transform .15s; } .nav-group.folded .nav-fold { transform: rotate(-90deg); }
.tab-btn.nav-folded { display: none !important; }
.sidebar nav { overscroll-behavior: contain; scrollbar-width: thin; }
.tab-btn.active { box-shadow: inset 3px 0 0 var(--sky); }
html[dir="rtl"] .tab-btn.active { box-shadow: inset -3px 0 0 var(--sky); }
body.sticky-headers .table-wrap { max-height: 70vh; overflow: auto; }
body.sticky-headers .data-table thead th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--border); }
body.sticky-headers .perm-matrix thead th:first-child { z-index: 4; }
main { scroll-behavior: smooth; overscroll-behavior-y: contain; }
.data-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.data-table tbody tr:hover td { background: var(--accent-soft) !important; }
html[data-theme="dark"] .data-table tbody tr:nth-child(even) td { background: var(--row-alt); }
.salary-mask { color: var(--text-muted); letter-spacing: 1px; white-space: nowrap; } .salary-mask i { font-size: 10px; margin-inline-start: 2px; }
.salary-notice { margin-bottom: 12px; } @media print { .salary-notice { display: none !important; } }
.salary-notice { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); font-size: 13.5px; }
.salary-notice a { font-weight: 600; }
.field-attention { outline: 2px solid var(--warning); outline-offset: 1px; }
#custQueueTable input, #custQueueTable select { height: 32px; font-size: 13px; padding: 4px 8px; }
/* 23 --------------------------------------------------------------- searchable pickers: never wider than their box (phones), add-new row */
.ss { min-width: 0; max-width: 100%; }
.toolbar .ss, .search-bar .ss { flex: 1 1 200px; }
.ss .ss-input, .toolbar .ss .ss-input, .search-bar .ss .ss-input { width: 100%; min-width: 0; flex: none; box-sizing: border-box; }
.ss-add { color: var(--accent-dark); font-weight: 600; border-top: 1px solid var(--border); }
.ss-add i { font-size: 11px; margin-inline-end: 4px; }
.ss .ss-native { position: absolute !important; inset-inline-start: 0; top: 0; width: 1px !important; min-width: 0 !important; height: 1px !important; padding: 0 !important; border: 0 !important; overflow: hidden; clip-path: inset(50%); }
/* 24 --------------------------------------------------------------- notifications: read / handled stay visible, dimmed */
.notif.is-read { opacity: .62; } .notif.is-read strong { font-weight: 500; }
.notif.is-handled .notif-text strong { text-decoration: none; } .notif-state { color: var(--success); padding: 0 6px; }
.notif.is-new { box-shadow: inset 3px 0 0 var(--accent); }
.notif-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .notif-head-actions { margin-inline-start: auto; display: flex; gap: 4px; }
#ntTable tr.is-read td { color: var(--text-muted); } #ntTable tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.nt-sev-danger { color: var(--danger); } .nt-sev-warning { color: var(--warning); } .nt-sev-info { color: var(--accent); }
/* notifications are not data editing: their buttons work while the edit lock is closed */
body.locked #notifications .btn, body.locked #notifications button, body.locked #notifPanel button { pointer-events: auto; opacity: 1; }
/* no-delete = may work on the page but not delete → no delete / delete-all buttons (the server refuses anyway) */
.tab-content.no-delete .delete-btn, .tab-content.no-delete .danger-btn, .tab-content.no-delete [id^="deleteAll"] { display: none !important; }

/* ---- Picture viewer (invoice / receipt / product pictures) — always has a visible close button */
.img-viewer { position: fixed; inset: 0; z-index: 2500; background: rgba(8, 13, 26, .94); display: flex; flex-direction: column; animation: fadein .12s; }
.img-viewer-bar { display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) 10px calc(14px + env(safe-area-inset-left, 0px)); color: #e2e8f0; background: #0b1220; border-bottom: 1px solid rgba(255,255,255,.08); flex: 0 0 auto; }
.img-viewer-title { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-viewer-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: #e2e8f0; background: rgba(255,255,255,.1); text-decoration: none; }
.img-viewer-x { width: 46px; height: 46px; border: 0; border-radius: 50%; background: #fff; color: #0f172a; font-size: 30px; line-height: 1; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.35); flex: 0 0 auto; }
.img-viewer-x:focus-visible, .img-viewer-btn:focus-visible { outline: 3px solid var(--accent, #2563eb); outline-offset: 2px; }
.img-viewer-stage { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
.img-viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #fff; cursor: zoom-in; touch-action: pinch-zoom; }
.img-viewer.zoomed .img-viewer-stage { align-items: flex-start; justify-content: flex-start; }
.img-viewer.zoomed .img-viewer-stage img { max-width: none; max-height: none; cursor: zoom-out; }
.img-viewer-msg { color: #e2e8f0; }
/* dialogs: the title bar with its X stays on screen while a tall dialog scrolls (phones scroll the whole dialog) */
.ui-modal-head { position: sticky; top: 0; z-index: 3; background: var(--surface); border-radius: inherit; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.ui-modal-x { min-width: 40px; min-height: 40px; font-size: 26px; border-radius: 10px; }
.ui-modal-x:hover { background: var(--surface-2); color: var(--text); }
@media print { .img-viewer { display: none !important; } }
/* invoice picture in the receipt form */
.receipt-img-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; min-width: 0; }
.receipt-img-row .muted { min-width: 0; overflow-wrap: anywhere; }
.receipt-img-thumb { flex: 0 0 auto; width: 64px; height: 64px; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; }
.receipt-img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.receipt-img-thumb.is-removed { opacity: .35; filter: grayscale(1); }
/* work month: real dates next to a month picker, and the settings card */
.wm-hint { display: inline-block; font-size: 12px; color: var(--text-muted); white-space: nowrap; align-self: center; padding: 0 4px; }
.readonly-field { background: var(--surface-2) !important; color: var(--text-muted); }
/* QR codes for opening the system on a phone */
.qr { display: block; width: 100%; height: auto; max-width: 260px; image-rendering: pixelated; border-radius: 8px; }
.phone-connect { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.phone-connect .qr-box { width: min(260px, 72vw); padding: 8px; background: #fff; border-radius: 12px; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.12)); }
.phone-connect .qr-addr { font-size: 15px; font-weight: 600; word-break: break-all; }
.phone-connect .qr-steps { text-align: start; margin: 4px 0 0; padding-inline-start: 20px; }
.phone-connect .field { width: 100%; }
.qr-grid { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 12px; }
.qr-card { margin: 0; width: 180px; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 10px; text-align: center; }
.qr-card figcaption { font-size: 11px; color: #334155; word-break: break-all; margin-top: 4px; }
/* restore: differences and duplicates */
.restore-conflicts .rc-sec { padding: 10px 14px; margin-bottom: 10px; }
.restore-conflicts .rc-sec > summary { cursor: pointer; }
.restore-conflicts .rc-rec { border-top: 1px solid var(--border); padding: 8px 0; }
.restore-conflicts .rc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.restore-conflicts .rc-head select, .restore-conflicts td select { max-width: 100%; }
.restore-conflicts .rc-custom, .restore-conflicts .rc-key { margin-top: 4px; min-width: 0; max-width: 220px; }
/* sign-in: forgotten password */
#resetChannels { display: flex; flex-direction: column; gap: 6px; }
#resetChannels .label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.radio-line { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm, 8px); cursor: pointer; font-weight: 500; }
.radio-line:has(input:checked) { border-color: var(--accent, #2563eb); background: var(--info-soft, #eff6ff); }
.radio-line[hidden] { display: none; }
.auth-ok { background: #ecfdf5; color: #065f46; }

/* 23 --------------------------------------------------------------- v4.23 more dark themes, more light themes, custom highlight colour */
/* dark themes (Settings → Appearance → Dark theme). "midnight" is the original navy dark (section 16). */
html[data-theme="dark"][data-dark="charcoal"] { --bg: #121214; --surface: #1b1b1f; --surface-2: #232328; --border: #2e2e35; --border-strong: #3d3d46; --text: #e4e4e7; --text-dark: #fafafa; --text-muted: #a1a1aa; --sidebar: #0c0c0e; --sidebar-2: #18181b; --row-alt: #1f1f24; --row-hover: #29292f; }
html[data-theme="dark"][data-dark="black"] { --bg: #000; --surface: #0a0a0a; --surface-2: #141414; --border: #232323; --border-strong: #343434; --text: #e5e5e5; --text-dark: #fff; --text-muted: #9a9a9a; --sidebar: #000; --sidebar-2: #101010; --row-alt: #0f0f0f; --row-hover: #1b1b1b; }
html[data-theme="dark"][data-dark="ocean"] { --bg: #061a20; --surface: #0b252d; --surface-2: #10313b; --border: #17424d; --border-strong: #215663; --text: #d5eef2; --text-dark: #effafc; --text-muted: #84b3bd; --sidebar: #04131a; --sidebar-2: #0a222a; --row-alt: #0d2a33; --row-hover: #12363f; }
html[data-theme="dark"][data-dark="forest"] { --bg: #0a1610; --surface: #0f2018; --surface-2: #152a20; --border: #1f3a2c; --border-strong: #2a4d3a; --text: #d8ece0; --text-dark: #f0faf4; --text-muted: #8db59c; --sidebar: #06100b; --sidebar-2: #0d1c14; --row-alt: #122519; --row-hover: #183022; }
html[data-theme="dark"][data-dark="espresso"] { --bg: #17110d; --surface: #211913; --surface-2: #2b211a; --border: #3a2d23; --border-strong: #4d3c2f; --text: #eee2d6; --text-dark: #fbf5ee; --text-muted: #b6a08b; --sidebar: #100b08; --sidebar-2: #1d1510; --row-alt: #261d16; --row-hover: #31261d; }
html[data-theme="dark"][data-dark="plum"] { --bg: #150f1f; --surface: #1e162b; --surface-2: #281e38; --border: #36294a; --border-strong: #47375f; --text: #e7def3; --text-dark: #f7f2fc; --text-muted: #a99bc0; --sidebar: #0e0915; --sidebar-2: #1a1326; --row-alt: #231a31; --row-hover: #2d223e; }
html[data-theme="dark"][data-dark="dusk"] { --bg: #1f2633; --surface: #283040; --surface-2: #30394b; --border: #3b4559; --border-strong: #4a556b; --text: #dfe5ee; --text-dark: #f3f6fa; --text-muted: #9aa6b8; --sidebar: #171d28; --sidebar-2: #222a38; --row-alt: #2c3445; --row-hover: #343e51; }
html[data-theme="dark"][data-dark="black"] .card, html[data-theme="dark"][data-dark="black"] .kpi { border-color: #262626; }
/* more light themes (Settings → Appearance → Light theme) */
html[data-surface="mint"]:not([data-theme="dark"]) { --bg: #eef7f3; --surface: #fbfefc; --surface-2: #f1f8f4; --border: #d6e9df; --border-strong: #bcd9c9; }
html[data-surface="sky"]:not([data-theme="dark"]) { --bg: #eef5fc; --surface: #fbfdff; --surface-2: #f0f6fd; --border: #d5e4f3; --border-strong: #bad0e8; }
html[data-surface="lavender"]:not([data-theme="dark"]) { --bg: #f3f1fb; --surface: #fdfcff; --surface-2: #f5f3fc; --border: #e1dcf3; --border-strong: #cbc3e8; }
html[data-surface="blush"]:not([data-theme="dark"]) { --bg: #fbf1f3; --surface: #fffcfd; --surface-2: #fbf3f5; --border: #f0dde2; --border-strong: #e3c3cc; }
html[data-surface="sand"]:not([data-theme="dark"]) { --bg: #f4efe4; --surface: #fffcf5; --surface-2: #f6f0e2; --border: #e6dcc6; --border-strong: #d3c4a3; --text: #2e2a22; --text-dark: #1a1712; }
/* custom highlight colour: the shades are worked out in prefs.js and set on <html> */
html[data-accent="custom"] .brand-mark { background: linear-gradient(135deg, var(--sky), var(--accent)); }
/* the row being edited: clearly visible in every theme (stronger than the hover colour) */
.data-table tbody tr.row-highlight td, .data-table tbody tr.row-highlight:hover td { background: color-mix(in srgb, var(--accent) 16%, var(--surface)) !important; }
.data-table tbody tr.row-highlight td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
html[dir="rtl"] .data-table tbody tr.row-highlight td:first-child { box-shadow: inset -4px 0 0 var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
/* Settings → Appearance: colour circles, theme gallery, "what the colour highlights" preview */
.ap-section { margin-top: 18px; }
.ap-section h4 { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; color: var(--text-dark); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ap-section .muted { margin: 0 0 10px; }
.accent-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.accent-dot { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 64px; padding: 6px 2px; border: 0; background: none; font: inherit; font-size: 11.5px; color: var(--text); cursor: pointer; border-radius: 10px; }
.accent-dot:hover { background: var(--surface-2); }
.accent-dot .dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 14px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-strong); transition: transform .12s; }
.accent-dot:hover .dot { transform: scale(1.08); }
.accent-dot.active .dot { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text-dark); }
.accent-dot.active { font-weight: 600; }
.accent-dot .dot.custom { background: conic-gradient(#ef4444, #f59e0b, #eab308, #22c55e, #06b6d4, #3b82f6, #8b5cf6, #ec4899, #ef4444); position: relative; overflow: hidden; }
.accent-dot .dot.custom input[type=color] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.accent-hex { font-family: ui-monospace, monospace; font-size: 11px; color: var(--text-muted); }
.theme-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.theme-tile { border: 2px solid var(--border); border-radius: 12px; padding: 0; background: none; cursor: pointer; overflow: hidden; text-align: start; font: inherit; color: var(--text); transition: border-color .12s, transform .12s; }
.theme-tile:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.theme-tile.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.theme-tile .mini { display: flex; height: 74px; }
.theme-tile .mini .s { width: 24%; display: flex; flex-direction: column; gap: 5px; padding: 8px 5px; }
.theme-tile .mini .s i { display: block; height: 4px; border-radius: 2px; background: rgba(255,255,255,.28); }
.theme-tile .mini .s i.on { background: var(--accent); }
.theme-tile .mini .m { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.theme-tile .mini .c { flex: 1; border-radius: 6px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.theme-tile .mini .c b { display: block; height: 4px; border-radius: 2px; width: 70%; opacity: .55; }
.theme-tile .mini .c u { display: block; height: 10px; width: 38%; border-radius: 3px; background: var(--accent); margin-top: auto; }
.theme-tile .name { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 9px; font-size: 12.5px; font-weight: 600; border-top: 1px solid var(--border); background: var(--surface); }
.theme-tile .name .fa-check { color: var(--accent); visibility: hidden; }
.theme-tile.active .name .fa-check { visibility: visible; }
.hl-preview { display: grid; grid-template-columns: 150px 1fr; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg); }
.hl-preview .hp-side { background: var(--sidebar); padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.hl-preview .hp-nav { padding: 7px 10px; border-radius: 8px; font-size: 12.5px; color: #cbd5e1; position: relative; }
.hl-preview .hp-nav.active { background: var(--sidebar-2); color: #fff; box-shadow: inset 3px 0 0 var(--sky); }
html[dir="rtl"] .hl-preview .hp-nav.active { box-shadow: inset -3px 0 0 var(--sky); }
html[data-sidebar="light"] .hl-preview .hp-nav { color: #334155; } html[data-sidebar="light"] .hl-preview .hp-nav.active { background: var(--accent-soft); color: var(--accent-dark); }
.hl-preview .hp-main { padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hl-preview .hp-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.hl-preview .hp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.hl-preview .hp-input { height: 34px; padding: 0 10px; border: 1px solid var(--accent); border-radius: 8px; background: var(--surface); color: var(--text); outline: 3px solid color-mix(in srgb, var(--accent) 22%, transparent); display: inline-flex; align-items: center; font-size: 13px; min-width: 140px; }
.hl-preview .hp-sugg { border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font-size: 12.5px; overflow: hidden; min-width: 160px; }
.hl-preview .hp-sugg div { padding: 6px 10px; } .hl-preview .hp-sugg div.is-active { background: var(--accent-soft); color: var(--accent-dark); }
.hl-preview table { width: 100%; border-collapse: collapse; font-size: 12.5px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.hl-preview td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.hp-tag { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--text-dark); color: var(--surface); font-size: 10.5px; font-weight: 700; margin-inline-end: 4px; vertical-align: middle; }
.hl-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; margin-top: 10px; font-size: 12.5px; color: var(--text-muted); }
.hl-legend span { display: flex; align-items: center; gap: 4px; }
@media (max-width: 640px) { .hl-preview { grid-template-columns: 1fr; } .hl-preview .hp-side { flex-direction: row; overflow-x: auto; } .theme-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } .accent-dot { width: 58px; } }
.rc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.rc-grid code { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 16px; letter-spacing: 1px; padding: 8px 10px; border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface-2); text-align: center; }
.rc-grid code span { color: var(--text-muted); font-size: 12px; margin-inline-end: 6px; }
.pw-help { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.pw-help-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.temp-pw { font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: 2px; padding: 10px 14px; border: 2px dashed var(--accent); border-radius: 10px; text-align: center; background: var(--accent-soft); color: var(--text-dark); margin: 10px 0; user-select: all; }
/* 24 --------------------------------------------------------------- invoices: priced by quantity or by weight, discount (v4.24) */
.receipt-line { grid-template-columns: minmax(180px, 2.6fr) auto minmax(80px, 1fr) minmax(90px, 1fr) minmax(90px, 1fr) auto; }
.receipt-line.is-weight { grid-template-columns: minmax(180px, 2.6fr) auto minmax(80px, 1fr) minmax(80px, 1fr) minmax(90px, 1fr) minmax(90px, 1fr) auto; }
.receipt-line .line-weight { display: none; } .receipt-line.is-weight .line-weight { display: block; }
.receipt-line .line-info { grid-column: 1 / -1; font-size: 12px; color: var(--text-muted); margin-top: -2px; }
.receipt-line .line-info:empty { display: none; }
.basis-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; height: var(--control-h); background: var(--surface); }
.basis-seg button { border: 0; background: none; padding: 0 12px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.basis-seg button + button { border-inline-start: 1px solid var(--border-strong); }
.basis-seg button.on { background: var(--accent); color: #fff; }
.receipt-line input[readonly] { background: var(--surface-2); color: var(--text-muted); }
.input-with-select { display: flex; gap: 6px; } .input-with-select input { flex: 1; min-width: 0; } .input-with-select select { width: 112px; flex: 0 0 auto; }
.receipt-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin-inline-start: auto; }
.receipt-total .rt-part { color: var(--text-muted); font-size: 13.5px; } .receipt-total .rt-part b { color: var(--text-dark); font-variant-numeric: tabular-nums; }
.receipt-total .rt-minus b { color: var(--success); }
.receipt-total .rt-part strong { font-size: 18px; color: var(--text-dark); }
@media (max-width: 900px) { .receipt-line, .receipt-line.is-weight { grid-template-columns: 1fr 1fr; } .receipt-line .line-item, .receipt-line .line-basis { grid-column: 1 / -1; } .basis-seg { width: 100%; } .basis-seg button { flex: 1; } .receipt-total { margin-inline-start: 0; } }
/* 25 --------------------------------------------------------------- invoices: filter / sort by supplier or product (v4.25) */
.th-sort { border: 0; background: none; padding: 0; font: inherit; font-weight: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.th-sort i { font-size: 10px; opacity: .45; } .th-sort.on { color: var(--accent-dark); } .th-sort.on i { opacity: 1; }
mark.rc-hit { background: var(--accent-soft); color: var(--accent-dark); border-radius: 4px; padding: 0 4px; font-weight: 600; }
.receipt-filter-sum { margin-bottom: 10px; font-size: 13.5px; line-height: 1.7; }
/* 26 --------------------------------------------------------------- Control Center (v4.26) */
.cc-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 14px; }
.cc-state { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.cc-state.is-ok i { color: var(--success); } .cc-state.is-warn i { color: var(--warning); }
.cc-list { display: flex; flex-direction: column; gap: 8px; }
.cc-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13.5px; }
.cc-item > span { flex: 1; min-width: 0; }
.cc-item > i { font-size: 15px; } .cc-danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: var(--danger-soft); } .cc-danger > i { color: var(--danger); }
.cc-warn { border-color: color-mix(in srgb, var(--warning) 40%, var(--border)); background: var(--warning-soft); } .cc-warn > i { color: var(--warning); }
.cc-info > i { color: var(--info); } .cc-ok > i { color: var(--success); }
.cc-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.cc-actions .btn { justify-content: flex-start; }
.cc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.cc-tile { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.cc-tile-head { display: flex; align-items: center; gap: 8px; } .cc-tile-head .badge { margin-inline-start: auto; }
.cc-tile.cc-ok { border-inline-start: 4px solid var(--success); } .cc-tile.cc-bad { border-inline-start: 4px solid var(--danger); } .cc-tile.cc-off { border-inline-start: 4px solid var(--border-strong); }
.cc-tile .btn { align-self: flex-start; }
.cc-features { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 22px; }
.cc-fgroup .dash-section-title { margin: 8px 0 6px; }
.cc-switch { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; font-size: 13.5px; }
.cc-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cc-knob { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); flex: 0 0 auto; transition: background .15s; }
.cc-knob::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: inset-inline-start .15s; }
.cc-switch input:checked + .cc-knob { background: var(--accent); } .cc-switch input:checked + .cc-knob::after { inset-inline-start: 19px; }
.cc-switch input:focus-visible + .cc-knob { outline: 2px solid var(--accent); outline-offset: 2px; }
.cc-switch input:disabled + .cc-knob { opacity: .55; } .cc-switch:has(input:disabled) { cursor: default; }
.cc-sys .stat-line { display: flex; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; } .cc-sys .stat-line > span:first-child { width: 190px; flex: 0 0 auto; color: var(--text-muted); } .cc-sys .stat-line > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.fd-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.fd-h { margin: 16px 0 8px; font-size: 14px; color: var(--text-dark); }
.fd-parts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; }
.fd-errors { margin: 8px 0; padding-inline-start: 20px; color: var(--danger); font-size: 13px; }
@media (max-width: 640px) { .cc-sys .stat-line { flex-direction: column; gap: 2px; } .cc-sys .stat-line > span:first-child { width: auto; } .cc-actions { grid-template-columns: 1fr 1fr; } }
/* 27 --------------------------------------------------------------- Control Center controls (v4.27) */
.cc-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.cc-ctl { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.cc-ctl-on { border-color: var(--warning); background: var(--warning-soft); }
.cc-ctl-head { font-size: 14px; } .cc-ctl .field { margin: 0; } .cc-ctl p { margin: 0; }
.cc-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cc-mini { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important; margin-top: 4px; }
.cc-policy-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.cc-policy td.num, .cc-policy th.num { text-align: center; width: 70px; }
.cc-policy input[type=checkbox] { width: 18px; height: 18px; }
.cc-sess { max-height: 360px; overflow: auto; }
.cc-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); margin-inline-end: 4px; vertical-align: middle; } .cc-dot.on { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent); }
.maint-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 14px; border-radius: 10px; background: var(--warning-soft); border: 1px solid var(--warning); color: var(--text-dark); font-size: 13.5px; }
.maint-banner i { color: var(--warning); font-size: 16px; } .maint-banner a { margin-inline-start: auto; font-weight: 600; }
.nowrap { white-space: nowrap; }
/* 28 --------------------------------------------------------------- Notes, Advance requests, Buttons & details, Database check (v4.28) */
.note-yellow { --note: #eab308; } .note-blue { --note: #3b82f6; } .note-green { --note: #22c55e; } .note-pink { --note: #ec4899; } .note-purple { --note: #8b5cf6; } .note-gray { --note: #94a3b8; }
.note-swatches { display: flex; gap: 8px; flex-wrap: wrap; min-height: var(--control-h); align-items: center; }
.note-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); background: var(--note); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.note-swatch.on { box-shadow: 0 0 0 3px var(--accent); transform: scale(1.08); }
.note-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.notes-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 10px; align-items: start; }
.note-card { border-radius: 12px; padding: 12px 14px 8px; background: color-mix(in srgb, var(--note) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--note) 45%, var(--border)); border-top: 5px solid var(--note); display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm); min-height: 120px; }
.note-card header { display: flex; gap: 8px; align-items: flex-start; } .note-title { flex: 1; font-size: 15px; color: var(--text-dark); word-break: break-word; }
.note-flags { display: flex; gap: 6px; color: var(--text-muted); font-size: 12px; padding-top: 3px; } .note-card.is-pinned .fa-thumbtack { color: var(--note); }
.note-body { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.5; max-height: 260px; overflow: auto; }
.note-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: auto; }
.note-actions { display: flex; gap: 6px; justify-content: flex-end; border-top: 1px dashed color-mix(in srgb, var(--note) 40%, var(--border)); padding-top: 6px; min-height: 8px; }
.note-card.is-done .note-title, .note-card.is-done .note-body { opacity: .6; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text) 40%, transparent); }
.ar-kpis { margin: 10px 0; } .ar-kpis .kpi-value { font-size: 20px; }
#arMine .dash-section-title { margin-top: 14px; }
.ui-bar { margin-bottom: 6px; } .ui-bar select { min-width: 220px; }
.ui-group { margin-top: 10px; } .ui-group .dash-section-title { margin: 8px 0 4px; }
.ui-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 18px; }
.ui-item { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--border); } .ui-item .cc-switch { flex: 1; min-width: 0; } .ui-item .cc-switch span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-item.is-off .cc-switch span:last-child { color: var(--text-muted); text-decoration: line-through; }
.ui-flash { outline: 3px solid var(--saffron) !important; outline-offset: 3px; border-radius: 6px; animation: uiFlash .65s ease-in-out 4; }
@keyframes uiFlash { 50% { outline-color: transparent; } }
.db-checks { margin: 8px 0; } .db-check { padding: 6px 2px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.db-check > summary { cursor: pointer; display: flex; gap: 8px; align-items: center; } .db-check.ok { display: flex; gap: 8px; align-items: center; color: var(--text-muted); }
.db-check ul { margin: 6px 0 4px; padding-inline-start: 30px; font-size: 13px; } .db-check.error > summary { color: var(--danger); font-weight: 600; } .db-check.warn > summary { color: var(--warning); font-weight: 600; }
.db-tables { margin: 8px 0; } .db-tables summary { cursor: pointer; color: var(--text-muted); font-size: 13px; }
.warn { color: var(--warning); }
@media (max-width: 640px) { .notes-board { grid-template-columns: 1fr; } .ui-items { grid-template-columns: 1fr; } .ui-bar select { min-width: 0; width: 100%; } }
.notes-board > .empty-state, .notes-board > p { grid-column: 1 / -1; }
/* 29 --------------------------------------------------------------- Control Center live, tools, handles; notes handled (v4.28.1) */
.cc-nav { position: sticky; top: 0; z-index: 30; display: flex; gap: 6px; overflow-x: auto; padding: 8px 2px; margin: -4px 0 12px; background: var(--bg); scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.cc-chip { flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.cc-chip:hover, .cc-chip:focus-visible { border-color: var(--accent); color: var(--accent); }
.cc-chip .nav-count { position: static; }
.cc-live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-inline-end: 4px; vertical-align: middle; animation: ccPulse 2s infinite; }
@keyframes ccPulse { 50% { opacity: .35; } }
.cc-head { flex-wrap: wrap; row-gap: 8px; }
.cc-item { flex-wrap: wrap; } .cc-item > span:not(.cc-item-acts) { flex: 1 1 180px; min-width: 0; } .cc-item .item-meta { display: block; }
.cc-item > .cc-item-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-inline-start: auto; flex: 0 1 auto; }
.cc-handled { margin-top: 8px; } .cc-handled > summary { cursor: pointer; color: var(--text-muted); font-size: 13px; padding: 4px 0; } .cc-handled .cc-item { opacity: .8; }
.cc-actions .btn { min-width: 0; white-space: normal; text-align: start; line-height: 1.25; }
.cc-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.cc-tool { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2, var(--surface)); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cc-tool.is-clear { opacity: .85; } .cc-tool p { margin: 0; }
.cc-tool-head { display: flex; align-items: center; gap: 8px; } .cc-tool-head .badge { margin-inline-start: auto; }
.cc-tool-state { font-size: 13.5px; font-weight: 600; color: var(--text-dark); }
.cc-tool input[type=number] { width: 84px; }
.cc-tool-result { border-top: 1px dashed var(--border); padding-top: 6px; }
.db-acts { margin: 6px 0 4px 26px; } .db-check.reviewed > summary { color: var(--text-muted); }
.cc-policy th:first-child, .cc-policy td:first-child { position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; }
.note-handled { font-size: 12.5px; color: var(--success); background: color-mix(in srgb, var(--success) 10%, transparent); border-radius: 8px; padding: 6px 8px; }
.note-handled div { color: var(--text); margin-top: 2px; white-space: pre-wrap; }
.note-handle-btn { margin-inline-end: auto; }
@media (max-width: 640px) {
  #control .card { padding: 14px; }
  .cc-head .toolbar-spacer { display: none; } .cc-head #ccRefresh { margin-inline-start: auto; }
  #ccKpis { grid-template-columns: 1fr 1fr; gap: 8px; } #ccKpis .kpi { padding: 10px 12px; } #ccKpis .kpi-value { font-size: 18px; } #ccKpis .kpi-sub { font-size: 11.5px; }
  .cc-actions { grid-template-columns: 1fr 1fr; }
  .cc-tools, .cc-tiles { grid-template-columns: 1fr; }
  .cc-item > .cc-item-acts { flex: 1 1 100%; box-sizing: border-box; justify-content: flex-start; margin-inline-start: 0; padding-inline-start: 26px; min-width: 0; } .cc-item-acts .btn { white-space: normal; }
  .ui-item .cc-switch span:last-child { white-space: normal; }
  .cc-policy-bar .btn { flex: 1 1 45%; }
  .cc-ctl .cc-inline input[type=date] { flex: 1; }
}
/* 30 --------------------------------------------------------------- Lists as cards on phones (v4.30) */
@media (max-width: 640px) {
  .table-wrap:has(> table.stackable) { border: 0; background: transparent; overflow: visible; }
  table.data-table.stackable, table.data-table.stackable > tbody, table.data-table.stackable > tfoot, table.data-table.stackable > tbody > tr, table.data-table.stackable > tfoot > tr { display: block; width: 100%; min-width: 0 !important; }
  table.data-table.stackable > thead { display: none; }
  table.data-table.stackable > tbody > tr { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin: 0 0 10px; padding: 6px 12px; box-shadow: var(--shadow-sm); }
  table.data-table.stackable > tbody > tr.row-muted { opacity: .85; }
  table.data-table.stackable > tbody > tr > td, table.data-table.stackable > tfoot > tr > td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border: 0; border-bottom: 1px dashed var(--border); text-align: end; min-width: 0; white-space: normal; word-break: break-word; }
  table.data-table.stackable > tbody > tr > td:last-child { border-bottom: 0; }
  table.data-table.stackable > tbody > tr > td[data-label]:not([data-label=""])::before, table.data-table.stackable > tfoot > tr > td[data-label]:not([data-label=""])::before { content: attr(data-label); flex: 0 0 42%; max-width: 42%; text-align: start; color: var(--text-muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
  table.data-table.stackable > tbody > tr > td[data-label=""] { justify-content: flex-end; flex-wrap: wrap; }
  table.data-table.stackable > tbody > tr > td.num { text-align: end; }
  table.data-table.stackable > tbody > tr.empty-row { border-style: dashed; box-shadow: none; }
  table.data-table.stackable > tbody > tr.empty-row > td { justify-content: center; border: 0; }
  table.data-table.stackable > tfoot > tr { border-radius: 12px; background: var(--surface-2); padding: 6px 12px; }
  table.data-table.stackable td input:not([type=checkbox]):not([type=radio]), table.data-table.stackable td select { max-width: 58%; }
  table.data-table.stackable > tfoot > tr > td:empty, table.data-table.stackable > tfoot > tr > td[data-label=""]:empty { display: none; }
  table.data-table.stackable > tbody > tr > td.select-cell, table.data-table.stackable > tbody > tr > td:has(> input[type=checkbox]:only-child) { justify-content: flex-start; }
}
.pw-match { font-size: 12px; margin-top: 4px; min-height: 16px; } .pw-match.ok { color: var(--success); } .pw-match.bad { color: var(--danger); }
.pw-wrap input { padding-inline-end: 44px; }
.adv-presets { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.adv-preset-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.adv-preset { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.adv-preset:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.adv-preset.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.adv-preset:disabled { opacity: .55; cursor: default; }
.btn.pulse { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); animation: btnPulse 1.6s infinite; }
@keyframes btnPulse { 70% { box-shadow: 0 0 0 10px transparent; } }
.stack-sort { display: none; }
@media (max-width: 640px) { .stack-sort { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; } .stack-sort .th-sort { border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px; background: var(--surface); font-size: 12.5px; } .stack-sort .th-sort.on { border-color: var(--accent); } }

/* 30 --------------------------------------------------------------- v4.30.1 phone fixes */
@media (max-width: 640px) {
  .lookup-row { grid-template-columns: 24px minmax(0, 1fr); row-gap: 6px; }
  .lookup-row > :nth-child(n+3) { grid-column: 2; }
  .lookup-row > :nth-child(n+4) { justify-self: start; display: inline-flex; gap: 6px; flex-wrap: wrap; }
  td .delete-btn, td .btn-icon, td .edit-btn, .note-actions .btn-icon, .note-actions .delete-btn { min-width: 36px; min-height: 36px; }
}
