/*
 * Dezayn UI: Apple-style design layer for the admin app (loaded after styles.css).
 * System font (SF Pro on Apple devices), grouped grey canvas, white rounded cards, hairline separators,
 * translucent sidebar / bars, one interactive accent (--accent). Brand colours stay on documents and the logo.
 */
:root {
  --accent: #0071e3;            /* Apple system blue. Dezayn beige alternative: #a2805f */
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, .1);
  --ui-bg: #f5f5f7;
  --ui-surface: #ffffff;
  --ui-text: #1d1d1f;
  --ui-text-2: #6e6e73;
  --ui-text-3: #86868b;
  --ui-sep: rgba(0, 0, 0, .08);
  --ui-sep-strong: rgba(0, 0, 0, .12);
  --ui-fill: rgba(118, 118, 128, .12);
  --ui-fill-2: rgba(118, 118, 128, .08);
  --ui-green: #248a3d; --ui-green-bg: rgba(52, 199, 89, .14);
  --ui-orange: #c45f00; --ui-orange-bg: rgba(255, 149, 0, .15);
  --ui-red: #d70015; --ui-red-bg: rgba(255, 59, 48, .12);
  --ui-blue-bg: rgba(0, 122, 255, .12);
  --ui-radius: 12px; --ui-radius-sm: 8px; --ui-radius-lg: 16px;
  --ui-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 0 0 .5px rgba(0, 0, 0, .04);
  --ui-shadow-pop: 0 10px 40px rgba(0, 0, 0, .16), 0 0 0 .5px rgba(0, 0, 0, .06);
  --ui-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  /* re-point the legacy tokens so older rules follow the new system */
  --ink: var(--ui-text); --navy: #1d1d1f; --muted: var(--ui-text-2); --line: var(--ui-sep-strong); --surface: #fff; --canvas: var(--ui-bg);
  --radius: var(--ui-radius); --radius-md: 10px; --radius-sm: 8px; --radius-lg: 14px;
  --shadow-sm: none; --shadow-md: var(--ui-shadow);
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--ui-font); background: var(--ui-bg); color: var(--ui-text); letter-spacing: -.01em; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; letter-spacing: inherit; }
::selection { background: rgba(0, 113, 227, .2); }

/* ---------- Sidebar (translucent, grouped) ---------- */
.sidebar { width: 248px; padding: 18px 12px 12px; background: rgba(246, 246, 248, .86); backdrop-filter: saturate(1.8) blur(24px); -webkit-backdrop-filter: saturate(1.8) blur(24px); color: var(--ui-text); border-right: .5px solid var(--ui-sep-strong); box-shadow: none; }
.sidebar .brand { padding: 4px 10px 14px; color: var(--ui-text); gap: 10px; }
.sidebar .brand-mark { width: 30px; height: 30px; border-radius: 8px; border: .5px solid var(--ui-sep-strong); background: #fff; }
.sidebar .brand strong { color: var(--ui-text); font-size: 14px; letter-spacing: .12em; font-weight: 700; }
.sidebar .brand small { color: var(--ui-text-3); font-size: 11px; letter-spacing: .02em; text-transform: none; }
.command-trigger { display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; margin: 0 0 10px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--ui-fill-2); color: var(--ui-text-3); font-size: 13px; }
.command-trigger .nav-icon { width: 15px; height: 15px; }
.command-trigger kbd { margin-left: auto; padding: 1px 6px; border: 0; border-radius: 5px; background: rgba(0,0,0,.06); color: var(--ui-text-2); font: 600 11px var(--ui-font); }
.sidebar .nav { gap: 1px; }
.nav-label { margin: 14px 10px 4px; font-size: 11px; font-weight: 600; color: var(--ui-text-3); letter-spacing: 0; }
.nav-label[hidden] { display: none; }
.sidebar .nav a { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 10px; border-radius: 8px; color: var(--ui-text); font-size: 13.5px; font-weight: 500; text-decoration: none; transition: background .15s; }
.sidebar .nav a > span { color: inherit; width: auto; height: auto; font-size: inherit; background: none; display: inline; }
.sidebar .nav a:hover { background: rgba(0, 0, 0, .045); }
.sidebar .nav a.active { background: rgba(0, 0, 0, .075); color: var(--ui-text); font-weight: 600; box-shadow: none; }
.sidebar .nav a.active .nav-icon { color: var(--accent); }
.sidebar .nav a.active::before, .sidebar .nav a.active::after { display: none !important; }
.nav-icon { width: 18px; height: 18px; flex: none; color: var(--ui-text-2); }
.sidebar-foot { margin: 8px 0 0; padding: 10px 6px 2px; border-top: .5px solid var(--ui-sep-strong); background: transparent; color: var(--ui-text); }
.sidebar-foot strong { color: var(--ui-text); font-size: 13px; }
.sidebar-foot small { color: var(--ui-text-3); }
.company-avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(180deg, #a1a1a6, #8e8e93); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; border: 0; }
.logout-button { width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent; color: var(--ui-text-2); display: grid; place-items: center; }
.logout-button:hover { background: rgba(0,0,0,.05); }
.logout-button .nav-icon { width: 17px; height: 17px; }

/* ---------- Page layout & header ---------- */
.shell { margin-left: 248px; padding: 28px 40px 64px; max-width: 1440px; }
.topbar { align-items: flex-end; margin-bottom: 20px; gap: 16px; min-height: 0; }
.topbar .eyebrow { display: none; }
.topbar h1 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; color: var(--ui-text); }
.topbar-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* Marketing-style banners removed: their figures are in the summary cards below */
.intro-panel { display: none !important; }
h2 { letter-spacing: -.015em; }
.eyebrow { color: var(--ui-text-3); letter-spacing: .02em; font-weight: 600; }

/* ---------- Buttons ---------- */
.primary-button, .secondary-button, .ghost-button { min-height: 34px; padding: 0 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; box-shadow: none; transition: background .15s, opacity .15s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.primary-button { background: var(--accent); color: #fff; border: 0; }
.primary-button:hover { background: var(--accent-hover); }
.primary-button:disabled { opacity: .45; }
.secondary-button { background: var(--ui-fill); color: var(--ui-text); border: 0; }
.secondary-button:hover { background: rgba(118,118,128,.18); }
.ghost-button { background: transparent; color: var(--accent); border: 0; }
.ghost-button:hover { background: var(--accent-soft); }
.view-button { min-height: 28px; padding: 0 10px; border: 0; border-radius: 7px; background: var(--ui-fill-2); color: var(--ui-text); font-size: 12.5px; font-weight: 600; box-shadow: none; }
.view-button:hover { background: var(--ui-fill); }
.danger-button, .view-button.danger-button { color: var(--ui-red); background: var(--ui-red-bg); border: 0; }
.icon-button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--ui-fill); color: var(--ui-text-2); font-size: 18px; line-height: 1; display: grid; place-items: center; }
.row-actions { gap: 6px; }

/* ---------- Summary cards ---------- */
.metrics { gap: 12px; margin: 0 0 20px; }
.metrics article { min-height: 0; padding: 16px 18px; border: 0; border-radius: var(--ui-radius); background: var(--ui-surface); box-shadow: var(--ui-shadow); }
.metrics article::before, .metrics article::after { display: none !important; }
.metrics article.accent { background: var(--ui-surface); }
.metrics article span { font-size: 12.5px; font-weight: 500; color: var(--ui-text-2); }
.metrics article strong { display: block; margin: 6px 0 2px; font-size: 24px; font-weight: 700; letter-spacing: -.02em; color: var(--ui-text); font-variant-numeric: tabular-nums; }
.metrics article.accent strong { color: var(--ui-text); }
.metrics article small { font-size: 12px; color: var(--ui-text-3); }

/* ---------- Cards, headings, tables ---------- */
.content-card { border: 0; border-radius: var(--ui-radius); background: var(--ui-surface); box-shadow: var(--ui-shadow); }
.section-gap { margin-top: 20px; }
.card-heading { padding: 16px 20px; border-bottom: .5px solid var(--ui-sep); gap: 14px; }
.card-heading h2, .content-card h2 { font-size: 17px; font-weight: 600; color: var(--ui-text); }
.card-heading p { color: var(--ui-text-2); font-size: 13px; }
table { font-variant-numeric: tabular-nums; }
th { background: transparent !important; color: var(--ui-text-3) !important; font-size: 12px !important; font-weight: 500 !important; text-transform: none !important; letter-spacing: 0 !important; border-bottom: .5px solid var(--ui-sep) !important; padding-top: 10px !important; padding-bottom: 10px !important; }
td { border-bottom: .5px solid var(--ui-sep) !important; color: var(--ui-text); font-size: 13.5px; }
tbody tr:last-child td { border-bottom: 0 !important; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: rgba(0, 0, 0, .018); }
.source-reference, .customer-cell { color: var(--ui-text-3) !important; font-size: 12px; }
.expense-group-row td, .exp-table .expense-group-row td { background: var(--ui-bg) !important; color: var(--ui-text-2); font-size: 12.5px; border-left: 0 !important; box-shadow: none !important; }
.expense-group-row { box-shadow: none !important; }

/* ---------- Status pills (Apple tinted badges) ---------- */
.status-pill { padding: 3px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--ui-fill); color: var(--ui-text-2); border: 0; }
.status-pill::before { display: none; }
.status-accepted, .status-paid, .status-approved, .status-completed { background: var(--ui-green-bg); color: var(--ui-green); }
.status-sent, .status-pending, .status-partial, .status-in_progress { background: var(--ui-orange-bg); color: var(--ui-orange); }
.status-cancelled, .status-rejected, .status-overdue, .status-void { background: var(--ui-red-bg); color: var(--ui-red); }
.status-draft { background: var(--ui-fill); color: var(--ui-text-2); }
.sub-pill { border-radius: 6px; padding: 3px 8px; font-size: 11.5px; }
.sub-pill.ok { background: var(--ui-green-bg); color: var(--ui-green); }
.sub-pill.warn { background: var(--ui-orange-bg); color: var(--ui-orange); }
.sub-pill.danger { background: var(--ui-red-bg); color: var(--ui-red); }
.sub-pill.none { background: var(--ui-fill); color: var(--ui-text-2); }

/* ---------- Inputs ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]), select, textarea { border: .5px solid var(--ui-sep-strong); border-radius: 8px; background-color: #fff; color: var(--ui-text); font-size: 14px; box-shadow: 0 .5px 1px rgba(0,0,0,.04); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent) !important; box-shadow: 0 0 0 3px rgba(0, 113, 227, .22) !important; }
label > span { color: var(--ui-text-2); font-weight: 500; }
.search { height: 34px; border: 0; border-radius: 8px; background: var(--ui-fill-2); box-shadow: none; }
.search input { border: 0 !important; background: transparent !important; box-shadow: none !important; height: 32px; }
.search span { color: var(--ui-text-3); }

/* ---------- Dialogs & sheets ---------- */
dialog { border: 0; border-radius: var(--ui-radius-lg); box-shadow: var(--ui-shadow-pop); color: var(--ui-text); }
dialog::backdrop { background: rgba(0, 0, 0, .28); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.dialog-head { padding: 18px 22px; border-bottom: .5px solid var(--ui-sep); }
.dialog-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0; }
.dialog-head p { color: var(--ui-text-2); font-size: 13px; }
.dialog-actions { min-height: 60px; padding: 12px 22px; border-top: .5px solid var(--ui-sep); background: rgba(250,250,252,.9); }
.form-section { border-color: var(--ui-sep) !important; }
.section-title > span { background: var(--ui-fill) !important; color: var(--ui-text-2) !important; border-radius: 6px !important; }

/* ---------- Toast ---------- */
.toast { border-radius: 12px; background: rgba(29, 29, 31, .92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: var(--ui-shadow-pop); font-size: 13.5px; }
.toast-action { color: #64b5ff; }

/* ---------- Segmented controls (Apple style) for tab rows ---------- */
.exp-tabs, .payroll-tabs, .staff-app-tabs, [role=tablist] { background: var(--ui-fill) !important; border: 0 !important; border-radius: 9px !important; padding: 2px !important; gap: 0 !important; }
.exp-tabs button, .payroll-tabs button, [data-payroll-tab] { min-height: 30px !important; padding: 0 14px !important; border: 0 !important; border-radius: 7px !important; background: transparent !important; color: var(--ui-text) !important; font-size: 13px !important; font-weight: 500 !important; box-shadow: none !important; }
.exp-tabs button.active, .payroll-tabs button.active, [data-payroll-tab].active { background: #fff !important; font-weight: 600 !important; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04) !important; }
.exp-tab-badge { background: var(--ui-red); }
.exp-chip { border: 0; background: var(--ui-fill-2); }
.exp-chip.active { background: var(--ui-text); }
.exp-chip.warn.active { background: var(--ui-red); }
.exp-receipt.ok { background: var(--ui-green-bg); color: var(--ui-green); }
.exp-receipt.need { background: var(--ui-red-bg); color: var(--ui-red); border: 0; }
.exp-receipt.muted, .exp-cat { background: var(--ui-fill-2); border: 0; color: var(--ui-text-2); }
.exp-metrics .exp-metric-missing strong { color: var(--ui-red); }

/* ---------- Document viewer ---------- */
.doc-viewer, .doc-viewer-bar { background: #1d1d1f; }
.doc-viewer-action.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Auth screen ---------- */
.auth-gate { background: var(--ui-bg); }
.auth-card { border: 0; border-radius: 18px; box-shadow: var(--ui-shadow-pop); }
.auth-card .eyebrow { display: none; }
.auth-card h1 { letter-spacing: -.025em; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .shell { margin-left: 0; padding: 12px 16px 48px; }
  .sidebar { background: rgba(246, 246, 248, .96); }
  .topbar { flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
  .topbar h1 { font-size: 30px; font-weight: 700; }
  .menu-button { font-size: 0; width: 34px; height: 34px; border-radius: 8px; background: var(--ui-fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d1d1f' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h16'/%3E%3C/svg%3E") center / 18px no-repeat; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .metrics article { padding: 14px; }
  .metrics article strong { font-size: 20px; }
  .card-heading { padding: 14px 16px; }
  dialog { border-radius: 14px; }
}

/* ---------- Icons ---------- */
.btn-icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
button .btn-icon:only-child { margin: 0; }
.primary-button .btn-icon, .secondary-button .btn-icon, .ghost-button .btn-icon, .view-button .btn-icon { margin-right: 2px; }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 14px; background: var(--ui-fill-2); color: var(--ui-text-3); font-size: 0; }
.empty-svg { width: 26px; height: 26px; color: var(--ui-text-3); }
.receipt-scan-preview .empty-svg { width: 30px; height: 30px; }
.search-icon { display: inline-flex; color: var(--ui-text-3); }
.search-icon .btn-icon { width: 15px; height: 15px; }
.glyph-icon { width: 16px; height: 16px; }
.today-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--ui-fill-2); color: var(--ui-text-2); font-size: 0; }
.command-icon { display: inline-grid; place-items: center; color: var(--ui-text-2); font-size: 0; }
.exp-more > summary .btn-icon { margin: 0 0 0 4px; }
.push-badge { position: relative; padding-left: 12px; font-weight: 500 !important; }
.push-badge::before { content: ''; position: absolute; left: 0; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: currentColor; }
.push-badge.push-on { color: var(--ui-green) !important; }
.push-badge.push-off { color: var(--ui-red) !important; }

/* ---------- Today panel (widgets) ---------- */
.today-panel { padding: 20px; }
.today-head .eyebrow, .today-head p:first-child { color: var(--ui-text-3); font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.today-head h2 { font-size: 22px !important; font-weight: 700 !important; letter-spacing: -.02em; }
.today-groups { gap: 12px !important; }
.today-groups > * { border: 0 !important; border-radius: 12px !important; background: var(--ui-bg) !important; box-shadow: none !important; }
.today-group-head, .today-group-head * { text-transform: none !important; letter-spacing: -.01em !important; }
.today-group-head strong, .today-group-head h3 { color: var(--ui-text) !important; font-size: 14px !important; font-weight: 600 !important; }
.today-group-head small, .today-group-head p { color: var(--ui-text-3) !important; font-size: 12px !important; }
.today-count { background: var(--ui-fill) !important; color: var(--ui-text-2) !important; border-radius: 6px !important; font-weight: 600 !important; }
.today-item { border-radius: 8px !important; }
.today-item:hover { background: rgba(0,0,0,.04) !important; }
.today-icon { background: #fff; box-shadow: 0 0 0 .5px var(--ui-sep-strong); }
.today-approve, .today-reject { border: 0 !important; border-radius: 7px !important; background: #fff !important; box-shadow: 0 0 0 .5px var(--ui-sep-strong) !important; }
.today-approve { color: var(--ui-green) !important; }
.today-reject { color: var(--ui-red) !important; }
.today-more { color: var(--accent) !important; }

/* ---------- HR & Payroll ---------- */
.payroll-steps { margin: 0 0 12px !important; }
.payroll-steps > * { border: 0 !important; border-radius: var(--ui-radius) !important; background: #fff !important; box-shadow: var(--ui-shadow) !important; }
.payroll-steps > .active, .payroll-steps > [aria-current] { box-shadow: 0 0 0 1.5px var(--accent), var(--ui-shadow) !important; }

/* ---------- Selects & filter rows (calmer weight) ---------- */
select { font-weight: 400 !important; min-height: 34px; }
.table-tools select, .document-table-tools select, .expense-group-control select { height: 34px; font-size: 13.5px; }

/* ---------- Reports ---------- */
.report-category-row .bar { height: 6px; border-radius: 3px; background: var(--ui-fill); }
.report-category-row .bar i { background: var(--accent); border-radius: 3px; }

/* ---------- Login pages ---------- */
body.auth-locked, .auth-gate { background: var(--ui-bg) !important; }
.auth-gate::before, .auth-gate::after { display: none !important; }
.auth-card { padding: 36px 34px !important; max-width: 400px; }
.auth-card .primary-button { width: 100%; min-height: 44px; border-radius: 10px; font-size: 15px; }
.auth-card input { min-height: 44px; border-radius: 10px !important; font-size: 16px !important; }
.auth-copy { color: var(--ui-text-2) !important; }
body.clock-page { background: var(--ui-bg) !important; }
body.clock-page::before, body.clock-page::after { display: none !important; }
.clock-card { border: 0 !important; border-radius: 20px !important; box-shadow: var(--ui-shadow-pop) !important; }
.clock-card .eyebrow { display: none; }
.clock-card .primary-button { min-height: 46px; border-radius: 12px; font-size: 15px; }
.clock-card input { min-height: 46px; border-radius: 12px !important; font-size: 16px !important; }
.clock-card a { color: var(--accent); }
.staff-app-tabs button.active, .staff-app-tabs .active { background: #fff !important; box-shadow: 0 1px 3px rgba(0,0,0,.12) !important; }

/* ---------- AI agents & quick actions ---------- */
#dashboardAgentGrid { gap: 0 !important; padding: 0 !important; }
.dashboard-agent-card { border: 0 !important; border-radius: 0 !important; border-bottom: .5px solid var(--ui-sep) !important; box-shadow: none !important; background: transparent !important; margin: 0 !important; }
.dashboard-agent-card:hover { background: rgba(0,0,0,.018) !important; }
.agent-card { border: 0 !important; box-shadow: var(--ui-shadow) !important; border-radius: var(--ui-radius) !important; }
.agent-avatar { border-radius: 10px !important; background: var(--ui-fill-2) !important; color: var(--ui-text-2) !important; }
.agent-role { color: var(--ui-text-3) !important; letter-spacing: 0 !important; text-transform: none !important; }
.agent-online { background: transparent !important; }
.dashboard-quick-actions { gap: 0 !important; padding: 0 !important; }
.dashboard-quick-actions button { border: 0 !important; border-radius: 0 !important; border-top: .5px solid var(--ui-sep) !important; background: transparent !important; justify-content: flex-start !important; gap: 10px !important; min-height: 48px !important; color: var(--ui-text) !important; font-weight: 500 !important; box-shadow: none !important; }
.dashboard-quick-actions button:hover { background: rgba(0,0,0,.025) !important; }
.dashboard-quick-actions .btn-icon { color: var(--accent); }

/* ---------- Phone: tables become cards (labels from responsive-tables.js) ---------- */
@media (max-width: 760px) {
  .table-wrap:has(> table.stack-table) { overflow: visible; }
  table.stack-table { min-width: 0 !important; width: 100% !important; display: block; }
  table.stack-table thead { display: none; }
  table.stack-table tbody { display: block; }
  table.stack-table tr { display: block; padding: 12px 16px; border-bottom: .5px solid var(--ui-sep); }
  table.stack-table tr:last-child { border-bottom: 0; }
  table.stack-table tbody tr:hover td { background: transparent; }
  table.stack-table td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 3px 0 !important; border: 0 !important; text-align: right !important; font-size: 14px; min-width: 0; white-space: normal !important; }
  table.stack-table td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--ui-text-3); font-size: 12.5px; font-weight: 500; text-align: left; }
  table.stack-table td[data-label=""]::before { display: none; }
  table.stack-table td > * { min-width: 0; }
  table.stack-table td strong, table.stack-table td span, table.stack-table td a { overflow-wrap: anywhere; }
  /* first cell = record title, full width, no label */
  table.stack-table td:first-child { display: block; text-align: left !important; padding-bottom: 6px !important; font-size: 15px; }
  table.stack-table td:first-child::before { display: none; }
  table.stack-table td:first-child strong { font-size: 15px; font-weight: 600; }
  /* actions column (empty header) = button row */
  table.stack-table td[data-label=""]:last-child { justify-content: flex-start; padding-top: 8px !important; }
  table.stack-table td[data-label=""]:last-child .row-actions { flex-wrap: wrap; justify-content: flex-start; }
  table.stack-table td:empty { display: none; }
  table.stack-table tr.stack-full td, table.stack-table tr.expense-group-row td { display: block; text-align: left !important; }
  table.stack-table tr.stack-full td::before { display: none; }
  table.stack-table td.right { text-align: right !important; }
  table.stack-table .source-reference, table.stack-table .customer-cell { display: block; }

  /* header: menu button + title aligned, actions full width */
  .topbar { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 12px; align-items: center; }
  .topbar > div:not(.topbar-actions) { min-width: 0; }
  .topbar h1 { font-size: 26px; overflow-wrap: anywhere; }
  .topbar-actions { grid-column: 1 / -1; justify-content: flex-start; width: 100%; }
  .topbar-actions > * { flex: 1 1 auto; }

  /* summary cards: long amounts shrink instead of overflowing */
  .metrics article { min-width: 0; overflow: hidden; }
  .metrics article strong { font-size: clamp(16px, 5.2vw, 20px); overflow-wrap: anywhere; }

  /* filter / date rows stack */
  .report-controls, .accounting-controls, .filter-row, .content-card form.form-grid { grid-template-columns: 1fr !important; }
  input[type=date], input[type=month] { min-width: 0; max-width: 100%; }

  /* menus anchored on the left button stay on screen */
  .exp-more-menu { left: 0; right: auto; }

  /* horizontally scrolling strips: hide scrollbar, fade the edge */
  .workflow-strip, .ai-tabs { scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .workflow-strip::-webkit-scrollbar, .ai-tabs::-webkit-scrollbar { display: none; }
}
.report-filters { border: 0 !important; border-radius: var(--ui-radius) !important; box-shadow: var(--ui-shadow) !important; background: #fff !important; }
@media (max-width: 760px) {
  .report-filters { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 10px !important; padding: 14px !important; }
  .report-filters label { min-width: 0; }
  .report-filters input { width: 100%; }
  .report-filters button { grid-column: 1 / -1; width: 100%; min-height: 40px; }
}
@media (max-width: 760px) {
  .topbar > div:not(.topbar-actions) { text-align: left !important; justify-self: stretch; }
  .topbar h1 { text-align: left !important; }
  .row-actions { flex-direction: row !important; flex-wrap: wrap !important; align-items: center !important; gap: 6px !important; width: auto !important; }
  .row-actions > * { width: auto !important; flex: 0 0 auto !important; }
  table.stack-table td { flex-wrap: wrap; justify-content: flex-end; column-gap: 8px; row-gap: 1px; }
  table.stack-table td::before { margin-right: auto; padding-right: 12px; }
  table.stack-table td > .source-reference, table.stack-table td > .customer-cell, table.stack-table td > small, table.stack-table td > br + span { flex-basis: 100%; text-align: right; }
  table.stack-table td:first-child > .source-reference, table.stack-table td:first-child > .customer-cell, table.stack-table td:first-child > small { text-align: left; }
  table.stack-table td > strong:only-of-type { text-align: right; }
  .metrics article strong { font-size: clamp(15px, 4.4vw, 20px) !important; white-space: nowrap; overflow-wrap: normal !important; text-overflow: ellipsis; overflow: hidden; }
  .payroll-tabs, [role=tablist] { display: flex !important; flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
  .payroll-tabs::-webkit-scrollbar { display: none; }
  .payroll-tabs button, [data-payroll-tab] { flex: 0 0 auto !important; white-space: nowrap; }
  .card-heading select, .table-tools select { width: 100%; max-width: 100%; }
}

/* ---------- Form sections in dialogs: one left edge, no number badges ---------- */
.section-title { margin-bottom: 14px; }
.section-title > span { display: none !important; }
.section-title h3 { font-size: 17px; font-weight: 600; letter-spacing: -.015em; }
.section-title p { color: var(--ui-text-2); font-size: 13px; }
.form-grid { padding-left: 0 !important; }
.form-grid select, .form-grid input:not([type=checkbox]):not([type=radio]), .form-grid textarea { width: 100%; max-width: 100%; }
.form-section { padding: 20px 22px; }

/* ---------- Staff profile: stats + iOS grouped list ---------- */
#staffProfileDialog { width: min(900px, calc(100vw - 32px)); }
#staffProfileDialog .dialog-head .eyebrow { display: none; }
.profile-stats { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 10px !important; margin-bottom: 16px !important; }
.profile-stats > div { border: 0 !important; border-radius: 12px !important; background: var(--ui-bg); padding: 12px 14px !important; min-width: 0; }
.profile-stats span { color: var(--ui-text-3) !important; font-size: 12px !important; }
.profile-stats strong { margin-top: 3px !important; font-size: 15px; font-weight: 600; line-height: 1.3; }
.profile-grid { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 0 28px !important; padding: 0 16px; border-radius: 12px; background: var(--ui-bg); }
.profile-grid > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; min-height: 44px; padding: 11px 0; border-bottom: .5px solid var(--ui-sep-strong); min-width: 0; }
.profile-grid dt { flex: none; max-width: 42%; font-size: 13.5px !important; color: var(--ui-text-2) !important; }
.profile-grid dd { margin: 0; text-align: right; font-size: 14px; font-weight: 500; color: var(--ui-text); min-width: 0; overflow-wrap: anywhere; }
.profile-grid .profile-wide { grid-column: 1 / -1; display: block; border-bottom: 0; }
.profile-grid .profile-wide dt { max-width: none; margin-bottom: 6px; }
.profile-grid .profile-wide dd { text-align: left; font-weight: 400; }
.profile-grid .profile-wide ol { padding-left: 20px; }
#staffLetterForm.form-grid { padding-left: 0 !important; }
#staffLetterForm .dialog-inline-actions { padding-top: 4px; }
@media (max-width: 760px) {
  .profile-stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .profile-grid { grid-template-columns: 1fr !important; padding: 0 14px; }
  .profile-grid > div:last-of-type:not(.profile-wide) { border-bottom: .5px solid var(--ui-sep-strong); }
  #staffLetterForm.form-grid { grid-template-columns: 1fr !important; }
  .form-section { padding: 16px; }
  #staffProfileDialog .dialog-head h2 { font-size: 18px; }
}
/* Forms nested inside a dialog's scroll area are not height-limited like the dialog's own form */
.quotation-dialog .form-scroll form, .customer-dialog .form-scroll form, #staffLetterForm { max-height: none !important; height: auto !important; overflow: visible !important; }
/* Staff profile: body sections share the header's left edge */
#staffProfileDialog .form-scroll { padding: 0 !important; }
#staffProfileDialog .form-section { padding: 18px 22px; border-bottom: .5px solid var(--ui-sep); }
#staffProfileDialog .form-section:last-child { border-bottom: 0; }
@media (max-width: 760px) { #staffProfileDialog .form-section { padding: 16px 18px; } #staffProfileDialog .dialog-head { padding: 16px 18px; } }
/* All dialogs: body content shares the header's left edge; controls share one height */
dialog .form-scroll { padding-left: 0 !important; padding-right: 0 !important; }
dialog .form-section { padding-left: 22px !important; padding-right: 22px !important; }
dialog .customer-form-body { padding-left: 22px !important; padding-right: 22px !important; }
dialog .dialog-head .eyebrow { display: none; }
.form-grid select, .form-grid input:not([type=checkbox]):not([type=radio]):not([type=file]), dialog select, dialog input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]) { min-height: 42px; }
@media (max-width: 760px) {
  dialog .form-section, dialog .customer-form-body { padding-left: 18px !important; padding-right: 18px !important; }
  dialog .dialog-head { padding-left: 18px !important; padding-right: 18px !important; }
  dialog .dialog-actions { padding-left: 18px !important; padding-right: 18px !important; }
}

/* ---------- Supplier payment slip ---------- */
.pay-slip-panel { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding: 12px 14px; border-radius: 12px; background: var(--ui-bg); }
.pay-slip-text strong { display: block; font-size: 14px; }
.pay-slip-text small { display: block; margin-top: 2px; color: var(--ui-text-2); font-size: 12.5px; line-height: 1.4; }
.pay-slip-actions { display: flex; gap: 6px; flex: none; }
.pay-slip-actions .receipt-file-button { position: relative; overflow: hidden; }
.pay-slip-result { display: grid; gap: 6px; margin-bottom: 14px; }
.pay-slip-result > div { padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.4; }
.pay-slip-result .ok { background: var(--ui-green-bg); color: var(--ui-green); }
.pay-slip-result .warn { background: var(--ui-orange-bg); color: var(--ui-orange); }
.pay-slip-result .info { background: var(--ui-fill-2); color: var(--ui-text-2); }
@media (max-width: 760px) { .pay-slip-panel { flex-direction: column; align-items: stretch; } .pay-slip-actions > * { flex: 1; } }

/* ---------- New release available ---------- */
.app-update-bar { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 3000; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 24px); padding: 10px 10px 10px 16px; border-radius: 14px; background: rgba(29, 29, 31, .94); color: #fff; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.app-update-bar button { flex: none; min-height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: var(--accent, #0071e3); color: #fff; font-weight: 600; font-size: 14px; }
.sp-app .app-update-bar { bottom: calc(80px + env(safe-area-inset-bottom)); }

/* ---------- Salary payments ---------- */
.salary-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.salary-summary > div { padding: 10px 12px; border-radius: 12px; background: var(--ui-bg); min-width: 0; }
.salary-summary span { display: block; font-size: 12px; color: var(--ui-text-3); }
.salary-summary strong { display: block; margin-top: 2px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.salary-form { margin-top: 18px; padding-top: 16px; border-top: .5px solid var(--ui-sep); }
.salary-form h3 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.salary-note { margin: 10px 0 0; color: var(--ui-text-3); font-size: 12.5px; }
.salary-paid-full { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--ui-green-bg); color: var(--ui-green); font-size: 13.5px; }
@media (max-width: 760px) { .salary-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.customer-dialog .table-wrap table:not(.stack-table), .customer-dialog table { min-width: 0 !important; }
#salaryPaymentDialog td:last-child { white-space: nowrap; }
