/* =====================================================================
   ERP Design System — RTL/LTR · Light/Dark · Responsive
   Brand tokens are injected per install from the white-label settings.
   ===================================================================== */

@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/plex-arabic-400.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(../fonts/plex-arabic-500.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/plex-arabic-600.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(../fonts/plex-arabic-700.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/plex-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(../fonts/plex-latin-500.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/plex-latin-600.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(../fonts/plex-latin-700.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --brand: #442159; --brand-rgb: 68,33,89;
  --brand-900: #1f0f29; --brand-800: #2d1740; --brand-700: #371b4a; --brand-600: #3d1e50;
  --brand-400: #6a4a80; --brand-300: #8f76a1; --brand-200: #c7bad0; --brand-100: #e6e0ea; --brand-50: #f4f1f6;
  --brand-fg: #442159;
  --accent: #C9A24D; --accent-rgb: 201,162,77; --accent-50: #faf5ea;

  --bg: #F6F4F9; --surface: #ffffff; --surface-2: #FAF8FC; --surface-3: #F2EFF6;
  --border: #E8E3EF; --border-2: #DCD5E5;
  --text: #1D1526; --text-2: #564D63; --muted: #8C8397;
  --shadow-sm: 0 1px 2px rgba(29,21,38,.06);
  --shadow: 0 1px 3px rgba(29,21,38,.06), 0 4px 16px rgba(29,21,38,.05);
  --shadow-lg: 0 12px 40px rgba(29,21,38,.14);
  --ring: 0 0 0 3px rgba(var(--brand-rgb), .18);

  --success: #0E8A5F; --success-bg: #E6F6EF;
  --warning: #B26A00; --warning-bg: #FDF4E1;
  --danger: #C62828; --danger-bg: #FDECEC;
  --info: #1D5FD1; --info-bg: #E9F0FD;
  --neutral: #625A6E; --neutral-bg: #F0EDF4;

  --radius: 14px; --radius-sm: 10px; --radius-xs: 7px;
  --sb-w: 272px; --sb-w-collapsed: 76px; --top-h: 64px;
  --font: "Plex Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E0B13; --surface: #16121C; --surface-2: #1B1623; --surface-3: #221C2B;
  --border: #2A2334; --border-2: #362D42;
  --text: #EFEAF5; --text-2: #BDB3CA; --muted: #8A8098;
  --brand-50: rgba(var(--brand-rgb), .16); --brand-100: rgba(var(--brand-rgb), .28);
  --brand-fg: #C8A8E6;
  --accent-50: rgba(var(--accent-rgb), .12);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 1px 3px rgba(0,0,0,.35), 0 6px 20px rgba(0,0,0,.25); --shadow-lg: 0 16px 50px rgba(0,0,0,.5);
  --success: #3DD19A; --success-bg: rgba(61,209,154,.12);
  --warning: #F2B64C; --warning-bg: rgba(242,182,76,.12);
  --danger: #F47171; --danger-bg: rgba(244,113,113,.12);
  --info: #7AA7FF; --info-bg: rgba(122,167,255,.12);
  --neutral: #B1A8BE; --neutral-bg: rgba(177,168,190,.1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.6; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-variant-numeric: lining-nums; }
a { color: var(--brand-fg); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 .75em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.num, .ltr { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.cur { font-size: .8em; color: var(--muted); font-weight: 500; margin-inline-start: 2px; }
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.i.sm { width: 15px; height: 15px; } .i.lg { width: 22px; height: 22px; } .i.xl { width: 28px; height: 28px; }
[dir="rtl"] .flip { transform: scaleX(-1); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
::selection { background: rgba(var(--brand-rgb), .2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.scroll-thin { scrollbar-width: thin; }

/* ------------------------------ App shell ------------------------------ */
.app { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--sb-w); z-index: 60; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--brand-900) 0%, var(--brand-800) 55%, var(--brand-700) 100%); color: rgba(255,255,255,.82);
  transition: width .22s ease, transform .25s ease; }
.sidebar::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(600px 300px at 110% -10%, rgba(var(--accent-rgb), .12), transparent 60%); }
.sb-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; height: 72px; position: relative; z-index: 1; }
.sb-brand { display: flex; align-items: center; gap: 12px; color: #fff; min-width: 0; flex: 1; }
.sb-brand:hover { text-decoration: none; }
.sb-logo { width: 42px; height: 42px; border-radius: 12px; background: #fff; display: grid; place-items: center; flex: none; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.sb-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.sb-brand-text { min-width: 0; line-height: 1.25; }
.sb-brand-text b { display: block; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-brand-text small { color: rgba(255,255,255,.55); font-size: 11.5px; white-space: nowrap; }
.sb-collapse { background: rgba(255,255,255,.08); border: 0; color: #fff; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; flex: none; }
.sb-collapse:hover { background: rgba(255,255,255,.16); }
.sb-nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; position: relative; z-index: 1; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.sb-label { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: rgba(255,255,255,.4); padding: 14px 12px 6px; text-transform: uppercase; }
.sb-link, .sb-group-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border-radius: 10px; color: rgba(255,255,255,.78); font: inherit; font-size: 13.5px; font-weight: 500; background: none; border: 0; cursor: pointer; text-align: start; position: relative; transition: background .15s, color .15s; }
.sb-link:hover, .sb-group-btn:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.sb-link.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.sb-link.active::before { content: ""; position: absolute; inset-inline-start: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
[dir="rtl"] .sb-link.active::before { border-radius: 3px 0 0 3px; }
.sb-link .i, .sb-group-btn .i { opacity: .9; }
.sb-link span, .sb-group-btn span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-count { background: var(--accent); color: #1d1526; font-size: 11px; font-weight: 700; border-radius: 20px; padding: 0 7px; line-height: 18px; min-width: 20px; text-align: center; }
.sb-group-btn .chev { transition: transform .2s; opacity: .6; width: 16px; height: 16px; }
.sb-group.open > .sb-group-btn .chev { transform: rotate(180deg); }
.sb-sub { display: none; padding: 2px 0 6px; margin-inline-start: 21px; border-inline-start: 1px solid rgba(255,255,255,.1); padding-inline-start: 8px; }
.sb-group.open > .sb-sub { display: block; }
.sb-sub .sb-link { padding: 7px 12px; font-size: 13px; color: rgba(255,255,255,.66); }
.sb-sub .sb-link.active::before { inset-inline-start: -9px; }
.sb-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); position: relative; z-index: 1; }
.sb-portals { display: flex; gap: 6px; }
.sb-portals a { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; color: rgba(255,255,255,.75); background: rgba(255,255,255,.06); border-radius: 9px; padding: 8px 6px; white-space: nowrap; }
.sb-portals a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.sb-backdrop { display: none; }

.main { flex: 1; min-width: 0; margin-inline-start: var(--sb-w); display: flex; flex-direction: column; min-height: 100vh; transition: margin .22s ease; }
body.sb-collapsed .sidebar { width: var(--sb-w-collapsed); }
body.sb-collapsed .main { margin-inline-start: var(--sb-w-collapsed); }
body.sb-collapsed .sb-brand-text, body.sb-collapsed .sb-link span, body.sb-collapsed .sb-group-btn span, body.sb-collapsed .sb-label, body.sb-collapsed .sb-group-btn .chev, body.sb-collapsed .sb-count, body.sb-collapsed .sb-portals span { display: none; }
body.sb-collapsed .sb-sub { margin: 0; padding: 0; border: 0; }
body.sb-collapsed .sb-link, body.sb-collapsed .sb-group-btn { justify-content: center; padding: 10px; }
body.sb-collapsed .sb-head { flex-direction: column; height: auto; }
body.sb-collapsed .sb-portals { flex-direction: column; }

.topbar { position: sticky; top: 0; z-index: 40; height: var(--top-h); display: flex; align-items: center; gap: 10px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--border); }
.tb-burger { display: none; }
.tb-search { display: flex; align-items: center; gap: 10px; height: 40px; min-width: 300px; max-width: 460px; flex: 0 1 420px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; cursor: pointer; box-shadow: var(--shadow-sm); }
.tb-search:hover { border-color: var(--border-2); }
.tb-search > span:not(.kbd) { flex: 1; min-width: 0; text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-search .kbd { flex: none; white-space: nowrap; }
.kbd { font-size: 11px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; color: var(--muted); background: var(--surface-2); direction: ltr; }
.tb-spacer { flex: 1; }
.tb-date { color: var(--text-2); font-size: 12.5px; text-align: end; line-height: 1.35; white-space: nowrap; }
.tb-date small { display: block; color: var(--muted); }
.tb-btn { position: relative; width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-sm); font: inherit; font-weight: 700; font-size: 12px; }
.tb-btn:hover { color: var(--brand-fg); border-color: var(--border-2); text-decoration: none; }
.tb-dot { position: absolute; top: 6px; inset-inline-end: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); line-height: 1; }
.tb-user { display: flex; align-items: center; gap: 10px; padding: 4px; padding-inline-end: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; color: var(--text); box-shadow: var(--shadow-sm); }
.tb-user-meta { text-align: start; line-height: 1.25; }
.tb-user-meta b { display: block; font-size: 13px; font-weight: 600; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-user-meta small { color: var(--muted); font-size: 11.5px; }

.content { flex: 1; padding: 22px 24px 40px; width: 100%; max-width: 1640px; margin: 0 auto; }
.footer { padding: 16px 24px; color: var(--muted); font-size: 12px; display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; border-top: 1px solid var(--border); }
.footer a { color: var(--text-2); }

/* Progress bar (no spinners) */
#topProgress { position: fixed; top: 0; inset-inline: 0; height: 3px; z-index: 999; pointer-events: none; opacity: 0; transition: opacity .2s; overflow: hidden; }
#topProgress.on { opacity: 1; }
#topProgress::before { content: ""; position: absolute; top: 0; height: 100%; width: 40%; background: linear-gradient(90deg, transparent, var(--accent), var(--brand-300), transparent); animation: slidebar 1.1s ease-in-out infinite; }
@keyframes slidebar { 0% { inset-inline-start: -40%; } 100% { inset-inline-start: 100%; } }

/* ------------------------------ Page header ---------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; }
.ph-sub { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12.5px; margin-bottom: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand-fg); }
.crumbs .i { width: 13px; height: 13px; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.head-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-fg); flex: none; }

/* ------------------------------ Buttons -------------------------------- */
.btn { --bh: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--bh); padding: 0 16px; border-radius: 11px; border: 1px solid transparent;
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s; user-select: none; text-decoration: none !important; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(var(--brand-rgb), .3), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--brand-600); }
:root[data-theme="dark"] .btn-primary { background: color-mix(in srgb, var(--brand) 70%, #fff 12%); }
.btn-accent { background: var(--accent); color: #1d1526; }
.btn-accent:hover { filter: brightness(.95); }
.btn-outline { background: var(--surface); border-color: var(--border-2); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-outline:hover { border-color: var(--brand-300); color: var(--brand-fg); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-soft { background: var(--brand-50); color: var(--brand-fg); }
.btn-soft:hover { background: var(--brand-100); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-soft-danger { background: var(--danger-bg); color: var(--danger); }
.btn-success { background: var(--success); color: #fff; }
.btn-soft-success { background: var(--success-bg); color: var(--success); }
.btn-sm { --bh: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; gap: 6px; }
.btn-xs { --bh: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 4px; }
.btn-lg { --bh: 48px; padding: 0 22px; font-size: 15px; border-radius: 13px; }
.btn-icon { width: var(--bh); padding: 0; }
.btn-block { width: 100%; }
.btn[disabled], .btn.loading { opacity: .65; pointer-events: none; }
.btn.loading::after { content: ""; width: 18px; height: 4px; border-radius: 4px; background: currentColor; animation: pulsebar .8s ease-in-out infinite alternate; }
@keyframes pulsebar { from { opacity: .25; transform: scaleX(.4); } to { opacity: 1; transform: scaleX(1); } }
.btn-group { display: inline-flex; border: 1px solid var(--border-2); border-radius: 11px; overflow: hidden; background: var(--surface); }
.btn-group .btn { border-radius: 0; border: 0; border-inline-end: 1px solid var(--border); height: 38px; }
.btn-group .btn:last-child { border-inline-end: 0; }
.btn-group .btn.active { background: var(--brand-50); color: var(--brand-fg); }

/* ------------------------------ Cards & grid --------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head.flat { border-bottom: 0; padding-bottom: 4px; }
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.card-title .i { color: var(--brand-fg); }
.card-sub { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mb-2 { margin-bottom: 16px; } .mb-1 { margin-bottom: 8px; }

/* KPI tiles */
.kpi { position: relative; padding: 18px; display: flex; gap: 14px; align-items: flex-start; overflow: hidden; }
.kpi-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex: none; background: var(--brand-50); color: var(--brand-fg); }
.kpi-icon.t-success { background: var(--success-bg); color: var(--success); }
.kpi-icon.t-warning { background: var(--warning-bg); color: var(--warning); }
.kpi-icon.t-danger { background: var(--danger-bg); color: var(--danger); }
.kpi-icon.t-info { background: var(--info-bg); color: var(--info); }
.kpi-icon.t-accent { background: var(--accent-50); color: #9b7524; }
:root[data-theme="dark"] .kpi-icon.t-accent { color: var(--accent); }
.kpi-label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.kpi-value { font-size: 23px; font-weight: 700; line-height: 1.25; margin-top: 2px; direction: ltr; unicode-bidi: isolate; display: inline-block; font-variant-numeric: tabular-nums; }
.kpi-value .cur { font-size: 12px; }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 3px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; direction: ltr; }
.delta.up { color: var(--success); } .delta.down { color: var(--danger); }
a.kpi:hover { text-decoration: none; border-color: var(--brand-200); }

/* Hero / welcome band */
.hero { position: relative; overflow: hidden; border-radius: var(--radius); padding: 22px 24px; color: #fff; margin-bottom: 18px;
  background: radial-gradient(900px 300px at 100% 0%, rgba(var(--accent-rgb), .28), transparent 55%), linear-gradient(120deg, var(--brand-900), var(--brand) 70%, var(--brand-400)); }
.hero::after { content: ""; position: absolute; inset-inline-end: -30px; bottom: -40px; width: 220px; height: 220px; border-radius: 50%; border: 36px solid rgba(255,255,255,.05); }
.hero h2 { font-size: 21px; }
.hero p { color: rgba(255,255,255,.75); margin: 6px 0 0; }
.hero .hero-meta { display: flex; gap: 18px; margin-top: 14px; flex-wrap: wrap; font-size: 13px; color: rgba(255,255,255,.85); }
.hero .hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hero .btn-outline { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); box-shadow: none; }
.hero .btn-outline:hover { background: rgba(255,255,255,.18); color: #fff; }

/* ------------------------------ Badges, chips -------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; line-height: 20px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.tone-success { background: var(--success-bg); color: var(--success); }
.tone-warning { background: var(--warning-bg); color: var(--warning); }
.tone-danger { background: var(--danger-bg); color: var(--danger); }
.tone-info { background: var(--info-bg); color: var(--info); }
.tone-neutral { background: var(--neutral-bg); color: var(--neutral); }
.tone-brand { background: var(--brand-50); color: var(--brand-fg); }
.tone-accent { background: var(--accent-50); color: #8a661c; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 8px; font-size: 12px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.pill-count { background: var(--surface-3); color: var(--text-2); border-radius: 20px; padding: 0 8px; font-size: 11.5px; font-weight: 600; }

/* Avatars */
.avatar { --h: 270; width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; flex: none; font-size: 12.5px; font-weight: 700; overflow: hidden;
  background: hsl(var(--h) 45% 92%); color: hsl(var(--h) 45% 32%); }
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 30% 22%); color: hsl(var(--h) 60% 82%); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; border-radius: 8px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; border-radius: 16px; }
.avatar.xl { width: 88px; height: 88px; font-size: 28px; border-radius: 24px; }
.who { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.who b { font-weight: 600; display: block; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); display: block; line-height: 1.3; }
.avatars { display: inline-flex; }
.avatars .avatar { border: 2px solid var(--surface); margin-inline-start: -8px; }
.avatars .avatar:first-child { margin-inline-start: 0; }

/* ------------------------------ Forms ---------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 18px; }
.fg { grid-column: span 6; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fg.c-12 { grid-column: span 12; } .fg.c-8 { grid-column: span 8; } .fg.c-4 { grid-column: span 4; } .fg.c-3 { grid-column: span 3; } .fg.c-9 { grid-column: span 9; }
.label { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 4px; }
.label .req { color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); }
.err { font-size: 12px; color: var(--danger); font-weight: 500; }
.input, .select, .textarea { width: 100%; height: 42px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 96px; padding: 11px 13px; resize: vertical; line-height: 1.7; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--brand-200); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-400); box-shadow: var(--ring); }
.input[readonly], .input:disabled, .select:disabled { background: var(--surface-3); color: var(--text-2); }
.has-err .input, .has-err .select, .has-err .textarea, .has-err .combo-btn { border-color: var(--danger); }
.select { appearance: none; -webkit-appearance: none; padding-inline-end: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238C8397' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; }
[dir="ltr"] .select { background-position: right 12px center; }
.input[type="date"], .input[type="datetime-local"], .input[type="time"], .input[type="month"] { direction: ltr; text-align: end; }
[dir="ltr"] .input[type="date"], [dir="ltr"] .input[type="datetime-local"], [dir="ltr"] .input[type="time"], [dir="ltr"] .input[type="month"] { text-align: start; }
.input[type="color"] { padding: 4px; width: 64px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0; flex: 1; min-width: 0; }
.input-group .input:first-child { border-start-start-radius: 11px; border-end-start-radius: 11px; }
.input-group .input:last-child { border-start-end-radius: 11px; border-end-end-radius: 11px; }
.input-addon { display: grid; place-items: center; padding: 0 12px; background: var(--surface-3); border: 1px solid var(--border-2); color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.input-addon:first-child { border-start-start-radius: 11px; border-end-start-radius: 11px; border-inline-end: 0; }
.input-addon:last-child { border-start-end-radius: 11px; border-end-end-radius: 11px; border-inline-start: 0; }
.input-icon { position: relative; }
.input-icon .i { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 13px; color: var(--muted); pointer-events: none; }
.input-icon .input { padding-inline-start: 40px; }
.form-section { margin-bottom: 18px; }
.form-section-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.form-section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.form-actions { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }

.check, .radio { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; user-select: none; }
.check input, .radio input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; flex: none; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 8px 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 42px; height: 24px; border-radius: 20px; background: var(--border-2); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: inset-inline-start .2s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { inset-inline-start: 21px; }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.rating-input { display: inline-flex; gap: 4px; direction: ltr; }
.rating-input label { cursor: pointer; color: var(--border-2); }
.rating-input input { display: none; }
.rating-input label.on { color: var(--accent); }
.rating-input .i { width: 24px; height: 24px; fill: currentColor; }
.file-drop { border: 1.5px dashed var(--border-2); border-radius: 12px; padding: 14px; display: flex; align-items: center; gap: 12px; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; position: relative; }
.file-drop:hover, .file-drop.drag { border-color: var(--brand-300); background: var(--brand-50); }
.file-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop .fd-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--surface); display: grid; place-items: center; color: var(--brand-fg); border: 1px solid var(--border); flex: none; }
.file-drop .fd-text { font-size: 13px; color: var(--text-2); min-width: 0; }
.file-drop .fd-text b { color: var(--text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-current { display: flex; align-items: center; gap: 10px; font-size: 12.5px; margin-top: 6px; flex-wrap: wrap; }
.img-preview { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; border: 1px solid var(--border); }

/* Combobox (enhanced select) */
.combo { position: relative; }
.combo-btn { width: 100%; height: 42px; border: 1px solid var(--border-2); border-radius: 11px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; display: flex; align-items: center; gap: 8px; padding: 0 13px; cursor: pointer; text-align: start; }
.combo-btn:hover { border-color: var(--brand-200); }
.combo.open .combo-btn, .combo-btn:focus { border-color: var(--brand-400); box-shadow: var(--ring); outline: none; }
.combo-btn .combo-val { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-btn .combo-val.ph { color: var(--muted); }
.combo-btn .i { color: var(--muted); width: 16px; height: 16px; }
.combo-clear { border: 0; background: none; padding: 2px; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 6px; }
.combo-clear:hover { background: var(--surface-3); color: var(--danger); }
.combo-pop { position: absolute; z-index: 80; top: calc(100% + 6px); inset-inline: 0; min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); display: none; overflow: hidden; }
.combo.open .combo-pop { display: block; }
.combo.up .combo-pop { top: auto; bottom: calc(100% + 6px); }
.combo-search { padding: 8px; border-bottom: 1px solid var(--border); }
.combo-search input { width: 100%; height: 36px; border: 1px solid var(--border); border-radius: 9px; padding: 0 10px; font: inherit; background: var(--surface-2); color: var(--text); }
.combo-search input:focus { outline: none; border-color: var(--brand-300); }
.combo-list { max-height: 260px; overflow-y: auto; padding: 6px; scrollbar-width: thin; }
.combo-opt { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.combo-opt:hover, .combo-opt.hl { background: var(--brand-50); color: var(--brand-fg); }
.combo-opt.sel { font-weight: 600; color: var(--brand-fg); }
.combo-opt.sel::after { content: "✓"; margin-inline-start: auto; }
.combo-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.combo-add { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 600; }

/* ------------------------------ Tables --------------------------------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .search-box { flex: 1 1 260px; max-width: 380px; }
.toolbar .select, .toolbar .input { height: 38px; font-size: 13px; }
.toolbar .select { width: auto; min-width: 150px; max-width: 220px; }
.filters-panel { display: none; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filters-panel.open { display: block; }
.filters-panel .form-grid { gap: 12px; }
.filters-panel .fg { grid-column: span 3; }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.table-wrap { width: 100%; overflow-x: auto; scrollbar-width: thin; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { text-align: start; font-weight: 600; font-size: 12px; color: var(--muted); padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover { color: var(--brand-fg); text-decoration: none; }
.table th.sorted { color: var(--brand-fg); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.row-link { cursor: pointer; }
.table .t-num { text-align: end; direction: ltr; font-variant-numeric: tabular-nums; white-space: nowrap; }
[dir="rtl"] .table .t-num { text-align: left; }
.table .t-check { width: 42px; }
.table .t-actions { width: 1%; white-space: nowrap; text-align: end; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.table.compact td, .table.compact th { padding: 8px 12px; }
.table .title-cell { font-weight: 600; color: var(--text); }
.table .title-cell:hover { color: var(--brand-fg); }
.table .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.row-actions { display: inline-flex; gap: 2px; opacity: .55; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pager-links { display: flex; gap: 4px; }
.pager-links a, .pager-links span { min-width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; padding: 0 8px; color: var(--text-2); border: 1px solid var(--border); background: var(--surface); font-weight: 600; }
.pager-links a:hover { border-color: var(--brand-300); color: var(--brand-fg); text-decoration: none; }
.pager-links .cur-page { background: var(--brand); color: #fff; border-color: var(--brand); }
.bulk-bar { display: none; align-items: center; gap: 10px; padding: 10px 16px; background: var(--brand-50); border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--brand-fg); }
.bulk-bar.show { display: flex; }

/* Definition list */
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.dl > div { padding: 12px 18px; border-bottom: 1px solid var(--border); min-width: 0; }
.dl > div:nth-child(odd) { border-inline-end: 1px solid var(--border); }
.dl dt { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.dl > .full { grid-column: span 2; border-inline-end: 0 !important; }
.dl.one { grid-template-columns: 1fr; } .dl.one > div { border-inline-end: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--text-2); }
.kv b { font-weight: 600; }
.kv.total { border-top: 2px solid var(--text); border-bottom: 0; font-size: 16px; padding-top: 12px; margin-top: 4px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 12px 12px; font-weight: 600; font-size: 13.5px; color: var(--muted); border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; font-family: inherit; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand-fg); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 11px; padding: 3px; gap: 2px; }
.seg a, .seg button { padding: 6px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-2); border: 0; background: none; cursor: pointer; font-family: inherit; white-space: nowrap; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg .active { background: var(--surface); color: var(--brand-fg); box-shadow: var(--shadow-sm); }

/* Dropdown */
.dd { position: relative; display: inline-flex; }
.dd-menu { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 90; display: none; }
.dd.open .dd-menu { display: block; animation: pop .14s ease-out; }
.dd-menu.start { inset-inline-end: auto; inset-inline-start: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.dd-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; border-radius: 9px; color: var(--text); font: inherit; font-size: 13.5px; background: none; border: 0; cursor: pointer; text-align: start; white-space: nowrap; }
.dd-item:hover { background: var(--surface-3); text-decoration: none; }
.dd-item .i { color: var(--text-2); }
.dd-item.danger, .dd-item.danger .i { color: var(--danger); }
.dd-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.dd-head { padding: 10px 11px 8px; }
.dd-head b { display: block; }
.dd-head small { color: var(--muted); }
.qa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: 330px; }
.qa-grid a { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 6px; border-radius: 11px; font-size: 12px; color: var(--text-2); text-align: center; font-weight: 500; }
.qa-grid a:hover { background: var(--brand-50); color: var(--brand-fg); text-decoration: none; }
.qa-grid a span.ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3); color: var(--brand-fg); }

/* Notifications panel */
.notif-menu { width: 380px; padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); position: relative; }
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.unread { background: var(--brand-50); }
.notif.unread::after { content: ""; position: absolute; top: 18px; inset-inline-end: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.notif-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--brand-fg); flex: none; }
.notif-body { min-width: 0; flex: 1; font-size: 13px; }
.notif-body b { display: block; font-weight: 600; padding-inline-end: 14px; }
.notif-body p { margin: 2px 0 0; color: var(--text-2); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-body small { color: var(--muted); }
.notif-foot { padding: 10px; text-align: center; font-size: 13px; font-weight: 600; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,10,20,.5); backdrop-filter: blur(3px); animation: fade .15s; }
.modal-box { position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; border: 1px solid var(--border); }
.modal-box.lg { max-width: 820px; } .modal-box.sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 18px 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.confirm-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--danger-bg); color: var(--danger); margin-bottom: 14px; }

/* Command palette */
.cmdk .modal-box { max-width: 640px; align-self: flex-start; margin-top: 8vh; }
.cmdk-input { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.cmdk-input input { flex: 1; border: 0; background: none; font: inherit; font-size: 16px; color: var(--text); outline: none; }
.cmdk-results { max-height: 60vh; overflow-y: auto; padding: 8px; }
.cmdk-group { font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 10px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; color: var(--text); }
.cmdk-item:hover, .cmdk-item.hl { background: var(--brand-50); text-decoration: none; }
.cmdk-item .ic { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-3); display: grid; place-items: center; color: var(--brand-fg); flex: none; }
.cmdk-item small { display: block; color: var(--muted); }

/* Toasts */
#toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 40px); }
.toast { display: flex; align-items: flex-start; gap: 12px; min-width: 280px; max-width: 420px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); animation: rise .2s ease-out; font-size: 13.5px; }
.toast .t-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.toast.success .t-ic { background: var(--success-bg); color: var(--success); }
.toast.error .t-ic { background: var(--danger-bg); color: var(--danger); }
.toast.warning .t-ic { background: var(--warning-bg); color: var(--warning); }
.toast.info .t-ic { background: var(--info-bg); color: var(--info); }
.toast .t-close { margin-inline-start: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .25s; }

/* Alerts */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; font-size: 13.5px; margin-bottom: 16px; border: 1px solid transparent; }
.alert .i { margin-top: 2px; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 20%, transparent); }
.alert-error, .alert-danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 20%, transparent); }
.alert-info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 20%, transparent); }
.alert b { color: inherit; }
.alert p { margin: 2px 0 0; color: var(--text-2); }

/* Empty state */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-ic { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-fg); }
.empty-ic .i { width: 28px; height: 28px; }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty p { max-width: 420px; margin: 0 auto 16px; }
.empty.sm { padding: 26px 16px; } .empty.sm .empty-ic { width: 46px; height: 46px; border-radius: 14px; }

/* Progress */
.progress { height: 8px; border-radius: 10px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--brand), var(--brand-400)); }
.progress.sm { height: 5px; }
.progress.success > span { background: var(--success); } .progress.warning > span { background: var(--warning); } .progress.danger > span { background: var(--danger); } .progress.accent > span { background: var(--accent); }
.ring { --p: 50; --c: var(--brand); width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); position: relative; flex: none; }
.ring::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--surface); }
.ring b { position: relative; font-size: 14px; direction: ltr; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--text); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-main b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-main small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3); color: var(--brand-fg); flex: none; }
.date-tile { width: 46px; text-align: center; border-radius: 11px; overflow: hidden; border: 1px solid var(--border); flex: none; background: var(--surface); }
.date-tile b { display: block; font-size: 17px; line-height: 1.2; padding-top: 3px; }
.date-tile small { display: block; font-size: 10.5px; background: var(--brand); color: #fff; padding: 1px 0; }

/* Timeline */
.timeline { position: relative; padding: 6px 0; }
.tl-item { position: relative; display: flex; gap: 12px; padding: 0 18px 16px; }
.tl-item::before { content: ""; position: absolute; top: 30px; bottom: 0; inset-inline-start: 34px; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 32px; height: 32px; border-radius: 10px; background: var(--surface-3); color: var(--brand-fg); display: grid; place-items: center; flex: none; position: relative; z-index: 1; border: 1px solid var(--border); }
.tl-dot .i { width: 15px; height: 15px; }
.tl-body { flex: 1; min-width: 0; font-size: 13px; padding-top: 5px; }
.tl-body b { font-weight: 600; }
.tl-body .muted { font-size: 12px; }
.tl-body .note-text { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 6px; white-space: pre-wrap; color: var(--text); }

/* Kanban */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; scrollbar-width: thin; min-height: 60vh; }
.kb-col { flex: 0 0 300px; background: var(--surface-3); border-radius: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 220px); border: 1px solid var(--border); }
.kb-head { padding: 12px 14px; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; }
.kb-head .kb-sum { margin-inline-start: auto; font-size: 12px; color: var(--muted); font-weight: 600; direction: ltr; }
.kb-head .kb-bar { height: 3px; }
.kb-list { flex: 1; overflow-y: auto; padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 10px; min-height: 80px; scrollbar-width: thin; }
.kb-list.over { background: var(--brand-50); border-radius: 12px; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: var(--shadow-sm); cursor: grab; transition: box-shadow .15s, transform .15s; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.kb-card:hover { box-shadow: var(--shadow); border-color: var(--border-2); }
.kb-card.dragging { opacity: .5; transform: rotate(0deg) scale(.98); }
.kb-card-title { font-weight: 600; font-size: 13.5px; color: var(--text); display: block; margin-bottom: 6px; line-height: 1.45; }
.kb-card-title:hover { color: var(--brand-fg); text-decoration: none; }
.kb-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.kb-meta .i { width: 13px; height: 13px; }
.kb-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.kb-add { margin: 0 10px 10px; }
.prio { display: inline-block; width: 4px; height: 16px; border-radius: 3px; }
.prio-urgent { background: var(--danger); } .prio-high { background: #E8590C; } .prio-medium { background: var(--warning); } .prio-low { background: var(--muted); }
.kb-ghost { height: 60px; border: 2px dashed var(--brand-300); border-radius: 12px; background: var(--brand-50); }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.cal-dow { padding: 10px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-day { min-height: 118px; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; min-width: 0; }
.cal-day:nth-child(7n) { border-inline-end: 0; }
.cal-day.other { background: var(--surface-2); }
.cal-day.other .cal-num { color: var(--muted); opacity: .6; }
.cal-num { font-size: 12.5px; font-weight: 600; display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 8px; }
.cal-day.today .cal-num { background: var(--brand); color: #fff; }
.cal-ev { display: block; font-size: 11.5px; padding: 3px 7px; border-radius: 6px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--brand-50); color: var(--brand-fg); border-inline-start: 3px solid var(--brand); font-weight: 500; }
.cal-ev:hover { text-decoration: none; filter: brightness(.97); }
.cal-more { font-size: 11px; color: var(--muted); padding: 2px 6px; }

/* Line items editor */
.lines-table { width: 100%; border-collapse: collapse; }
.lines-table th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: start; padding: 8px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.lines-table td { padding: 6px; vertical-align: top; border-bottom: 1px solid var(--border); }
.lines-table .input, .lines-table .select, .lines-table .combo-btn { height: 38px; font-size: 13px; }
.lines-table .l-desc { min-width: 240px; }
.lines-table .l-num { width: 110px; }
.lines-table .l-qty { width: 84px; }
.lines-table .l-total { width: 130px; text-align: end; font-weight: 600; padding-top: 14px; direction: ltr; white-space: nowrap; }
[dir="rtl"] .lines-table .l-total { text-align: left; }
.lines-table .l-del { width: 40px; }
.lines-table .l-item { width: 190px; }
.totals-box { width: 100%; max-width: 380px; margin-inline-start: auto; }

/* Document (print-like) view */
.doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; box-shadow: var(--shadow-sm); }
.doc-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 22px; border-bottom: 2px solid var(--brand); margin-bottom: 22px; flex-wrap: wrap; }
.doc-logo { height: 70px; }
.doc-title { text-align: end; }
.doc-title h2 { font-size: 26px; color: var(--brand-fg); }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 22px; }
.doc-party { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; font-size: 13px; }
.doc-party h4 { font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-table th { background: var(--brand); color: #fff; padding: 10px; text-align: start; font-weight: 600; }
.doc-table th:first-child { border-start-start-radius: 8px; } .doc-table th:last-child { border-start-end-radius: 8px; }
.doc-table td { padding: 10px; border-bottom: 1px solid var(--border); }
.doc-foot { display: flex; justify-content: space-between; gap: 24px; margin-top: 22px; align-items: flex-start; flex-wrap: wrap; }
.qr-box { width: 130px; height: 130px; border: 1px solid var(--border); border-radius: 10px; padding: 6px; background: #fff; }
.qr-box img, .qr-box canvas, .qr-box svg { width: 100%; height: 100%; }

/* Stats / misc */
.stat-row { display: flex; gap: 0; border-top: 1px solid var(--border); }
.stat-row > div { flex: 1; padding: 14px 16px; border-inline-end: 1px solid var(--border); }
.stat-row > div:last-child { border-inline-end: 0; }
.stat-row small { color: var(--muted); display: block; font-size: 12px; }
.stat-row b { font-size: 17px; direction: ltr; display: inline-block; }
.chart-box { position: relative; height: 290px; }
.chart-box.sm { height: 220px; } .chart-box.lg { height: 340px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.bar-list .bl-row { display: grid; grid-template-columns: 130px 1fr 80px; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; }
.bar-list .bl-row b { text-align: end; direction: ltr; font-weight: 600; }
.profile-head { display: flex; align-items: center; gap: 18px; padding: 22px; flex-wrap: wrap; }
.profile-head h2 { font-size: 20px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.color-dot { width: 14px; height: 14px; border-radius: 5px; display: inline-block; vertical-align: middle; border: 1px solid rgba(0,0,0,.08); }
.check-list li { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 22px 0 10px; letter-spacing: .02em; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: start; }
.perm-mod { background: var(--surface-2); font-weight: 700; }
.code-box { background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; direction: ltr; text-align: left; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.placeholder-list code { background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 12px; direction: ltr; display: inline-block; margin: 2px; cursor: pointer; }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Check-in widget */
.clock-card { text-align: center; padding: 26px 20px; }
.clock-time { font-size: 44px; font-weight: 700; letter-spacing: .02em; direction: ltr; line-height: 1.1; font-variant-numeric: tabular-nums; }
.clock-date { color: var(--muted); margin-top: 6px; }
.clock-btn { width: 170px; height: 170px; border-radius: 50%; margin: 22px auto 10px; border: 0; cursor: pointer; display: grid; place-items: center; color: #fff; font: inherit; font-weight: 700; font-size: 17px;
  background: radial-gradient(circle at 30% 25%, var(--brand-400), var(--brand) 60%, var(--brand-900)); box-shadow: 0 16px 40px rgba(var(--brand-rgb), .35), inset 0 2px 0 rgba(255,255,255,.2); transition: transform .15s, box-shadow .15s; position: relative; }
.clock-btn::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid rgba(var(--brand-rgb), .15); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.05); opacity: .5; } }
.clock-btn:hover { transform: translateY(-2px); }
.clock-btn.out { background: radial-gradient(circle at 30% 25%, #f08a6b, #D9480F 60%, #8a2c05); box-shadow: 0 16px 40px rgba(217,72,15,.3); }
.clock-btn.out::before { border-color: rgba(217,72,15,.18); }
.clock-btn.done { background: radial-gradient(circle at 30% 25%, #6fdcb0, var(--success) 60%, #065f41); box-shadow: 0 16px 40px rgba(14,138,95,.28); cursor: default; }
.clock-btn .i { width: 40px; height: 40px; display: block; margin: 0 auto 6px; }
.geo-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 5px 12px; border-radius: 20px; background: var(--surface-3); color: var(--text-2); }

/* ------------------------------ Auth pages ----------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-brand { position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; color: #fff;
  background: radial-gradient(800px 500px at 110% -10%, rgba(var(--accent-rgb), .35), transparent 60%), radial-gradient(700px 500px at -10% 110%, rgba(255,255,255,.08), transparent 60%), linear-gradient(150deg, var(--brand-900), var(--brand) 65%, var(--brand-400)); }
.auth-brand.has-bg { background-size: cover; background-position: center; }
.auth-brand.has-bg::before { content: ""; position: absolute; inset: 0; background: linear-gradient(150deg, rgba(var(--brand-rgb), .92), rgba(var(--brand-rgb), .7)); }
.auth-brand > * { position: relative; z-index: 1; }
.auth-dots { position: absolute; inset: 0; z-index: 0 !important; opacity: .09; background-image: radial-gradient(#fff 1.5px, transparent 1.6px); background-size: 26px 26px; mask-image: linear-gradient(180deg, transparent, #000 40%, #000 70%, transparent); }
.auth-logo { display: flex; align-items: center; gap: 14px; }
.auth-logo .sb-logo { width: 58px; height: 58px; border-radius: 16px; }
.auth-logo b { font-size: 20px; display: block; }
.auth-logo small { color: rgba(255,255,255,.65); }
.auth-hero h1 { font-size: 36px; line-height: 1.3; max-width: 520px; }
.auth-hero p { color: rgba(255,255,255,.75); font-size: 16px; max-width: 480px; margin-top: 14px; }
.auth-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 520px; margin-top: 30px; }
.auth-feats div { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); border-radius: 12px; padding: 11px 13px; font-size: 13.5px; backdrop-filter: blur(4px); }
.auth-feats .i { color: var(--accent); }
.auth-foot { color: rgba(255,255,255,.55); font-size: 12.5px; }
.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; position: relative; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { font-size: 26px; }
.auth-card .sub { color: var(--muted); margin: 8px 0 26px; }
.auth-portal-tag { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 20px; background: var(--brand-50); color: var(--brand-fg); font-weight: 600; font-size: 12.5px; margin-bottom: 18px; }
.auth-card .fg { margin-bottom: 16px; }
.auth-card .input { height: 48px; border-radius: 12px; }
.auth-top { position: absolute; top: 20px; inset-inline-end: 24px; display: flex; gap: 8px; }
.auth-links { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 20px; font-size: 13px; }
.auth-other { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; font-size: 12.5px; }
.auth-other a { color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.auth-other a:hover { color: var(--brand-fg); border-color: var(--brand-200); text-decoration: none; }
.otp-inputs { display: flex; gap: 10px; justify-content: center; direction: ltr; margin: 10px 0 20px; }
.otp-inputs input { width: 52px; height: 60px; text-align: center; font-size: 24px; font-weight: 700; border-radius: 13px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font-family: inherit; }
.otp-inputs input:focus { outline: none; border-color: var(--brand-400); box-shadow: var(--ring); }
.pw-toggle { position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-inline-end: 44px; }

/* Super admin theme: darker, gold-accented */
body.portal-super .sidebar { background: linear-gradient(180deg, #0c0a10 0%, #16121c 60%, #1d1726 100%); }
body.portal-super .sb-link.active { background: rgba(var(--accent-rgb), .14); color: var(--accent); }
body.portal-super .sb-link.active .i { color: var(--accent); }
.super-auth .auth-brand { background: radial-gradient(700px 500px at 110% -10%, rgba(var(--accent-rgb), .3), transparent 60%), linear-gradient(150deg, #09070c, #1a1422 60%, #2a2035); }
.super-auth .auth-portal-tag { background: var(--accent-50); color: #8a661c; }

/* Employee portal: bottom tab bar on mobile */
.tabbar { display: none; }

/* Portal (employee/client) top-nav variant */
.pnav-shell .main { margin-inline-start: 0; }

/* ------------------------------ Responsive ----------------------------- */
/* Line items: popups must not be clipped; stack rows on smaller screens */
[data-lines] .table-wrap { overflow: visible; }
@media (max-width: 1100px) {
  [data-lines] .lines-table thead { display: none; }
  [data-lines] .lines-table, [data-lines] .lines-table tbody { display: block; }
  [data-lines] .lines-table tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; background: var(--surface-2); }
  [data-lines] .lines-table td { display: block; border: 0; padding: 0; width: auto; min-width: 0; }
  [data-lines] .lines-table td::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
  [data-lines] .lines-table td.l-del::before { content: none; }
  [data-lines] .lines-table .l-item, [data-lines] .lines-table .l-desc { grid-column: span 2; }
  [data-lines] .lines-table .l-total { grid-column: span 3; padding-top: 0; text-align: start; font-size: 15px; }
  [data-lines] .lines-table .l-del { grid-column: span 1; justify-self: end; align-self: end; }
}
@media (max-width: 560px) {
  [data-lines] .lines-table tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [data-lines] .lines-table .l-total { grid-column: span 1; }
}

@media (max-width: 1280px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side { grid-template-columns: minmax(0, 1fr) 300px; }
  .tb-date { display: none; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(100%); width: var(--sb-w) !important; box-shadow: var(--shadow-lg); }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  body.sb-open .sidebar { transform: none !important; }
  body.sb-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,6,14,.45); z-index: 55; backdrop-filter: blur(2px); }
  .main, body.sb-collapsed .main { margin-inline-start: 0; }
  body.sb-collapsed .sb-brand-text, body.sb-collapsed .sb-link span, body.sb-collapsed .sb-group-btn span, body.sb-collapsed .sb-label { display: initial; }
  .sb-collapse { display: none; }
  .tb-burger { display: grid; }
  .g-main, .g-side, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .g-side > .side-first { order: -1; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .filters-panel .fg { grid-column: span 6; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .content { padding: 16px 14px 90px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .tb-search { min-width: 0; flex: 1; }
  .tb-search span, .tb-search .kbd { display: none; }
  .tb-search { flex: 0 0 40px; width: 40px; padding: 0; justify-content: center; }
  .tb-user-meta, .tb-hide-sm { display: none; }
  .tb-user { padding: 3px; }
  .g-2, .g-4 { grid-template-columns: minmax(0, 1fr); }
  .g-4.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .span-2 { grid-column: auto; }
  .fg, .fg.c-8, .fg.c-4, .fg.c-3, .fg.c-9, .filters-panel .fg { grid-column: span 12; }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 20px; }
  .ph-actions { width: 100%; }
  .ph-actions .btn { flex: 1; }
  .ph-actions .dd { flex: 1; } .ph-actions .dd .btn { width: 100%; }
  .kpi { padding: 14px; gap: 10px; }
  .kpi-icon { width: 40px; height: 40px; }
  .kpi-value { font-size: 19px; }
  .dl { grid-template-columns: 1fr; }
  .dl > div { border-inline-end: 0 !important; }
  .dl > .full { grid-column: auto; }
  .doc { padding: 18px; }
  .doc-parties { grid-template-columns: 1fr; }
  .notif-menu { width: calc(100vw - 24px); position: fixed; inset-inline: 12px; top: 70px; }
  .dd-menu { max-width: calc(100vw - 24px); }
  .qa-grid { width: calc(100vw - 40px); }
  .toolbar .select { flex: 1; max-width: none; }
  .toolbar .search-box { max-width: none; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { border-radius: 20px 20px 0 0; max-height: 92vh; }
  .cmdk .modal-box { margin-top: 0; align-self: flex-end; }
  .form-actions { border-radius: 0; margin: 0 -1px; }
  .bar-list .bl-row { grid-template-columns: 90px 1fr 70px; }
  #toasts { inset-inline: 12px; bottom: 80px; }
  .toast { min-width: 0; max-width: none; }
  .hero { padding: 18px; }
  .hero h2 { font-size: 18px; }
  .kb-col { flex-basis: 84vw; }
  .cal-day { min-height: 74px; padding: 3px; }
  .cal-ev { font-size: 10px; padding: 1px 4px; }
  .stat-row { flex-wrap: wrap; }
  .stat-row > div { flex: 1 1 50%; border-bottom: 1px solid var(--border); }
  .auth-main { padding: 28px 18px; justify-content: flex-start; padding-top: 80px; }

  /* Responsive tables → cards */
  .table.resp thead { display: none; }
  .table.resp, .table.resp tbody, .table.resp tr, .table.resp td { display: block; width: 100%; }
  .table.resp tr { padding: 12px 14px; border-bottom: 1px solid var(--border); position: relative; }
  .table.resp td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: end; }
  .table.resp td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500; text-align: start; flex: none; }
  .table.resp td.t-primary { display: block; text-align: start; padding-bottom: 6px; font-size: 14.5px; }
  .table.resp td.t-primary::before, .table.resp td.t-check::before, .table.resp td.t-actions::before { display: none; }
  .table.resp td.t-check { position: absolute; top: 12px; inset-inline-end: 10px; width: auto; }
  .table.resp td.t-actions { justify-content: flex-end; padding-top: 8px; }
  .table.resp td.t-num { text-align: end; }
  .table.resp .row-actions { opacity: 1; }
  .table.resp tfoot { display: block; }
  .table.resp tfoot tr { display: flex; justify-content: space-between; padding: 10px 14px; }
  .table.resp tfoot td { display: inline; width: auto; padding: 0; }
  .table.resp tfoot td:empty { display: none; }

  /* Bottom tab bar (employee & client portals) */
  .tabbar { display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--muted); padding: 6px 2px; border-radius: 10px; }
  .tabbar a.active { color: var(--brand-fg); background: var(--brand-50); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .i { width: 21px; height: 21px; }
}
@media (hover: none) { .row-actions { opacity: 1; } }

/* ------------------------------ Print ---------------------------------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; color: #000; font-size: 12px; }
  .sidebar, .topbar, .footer, .no-print, .tabbar, #toasts, .ph-actions, .crumbs { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0; max-width: none; }
  .card, .doc { box-shadow: none; border: 0; padding: 0; }
  .doc-table th { background: #442159 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge, .doc-party, .kv.total { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
}
[dir="ltr"] .flip-ltr { transform: scaleX(-1); }
