/* ============================================================================
   GRAVON ERP — Enterprise design system v2
   Layered graphite surfaces + Performance Lime. Hand-authored, no build step.
   Logical properties throughout so Arabic (RTL) and English (LTR) mirror
   automatically without a second stylesheet.

   Lime is reserved for primary actions, active state, positive metrics and
   selected navigation. It is never decoration.
   ========================================================================= */

/* ---------------------------------------------------------------- tokens */
:root {
  /* Layered surfaces — depth comes from elevation, not from pure black */
  --background:  #070B08;
  --sidebar:     #0B100D;
  --surface-1:   #101611;
  --surface-2:   #151D17;
  --surface-3:   #1B241D;
  --surface-4:   #222D24;

  --border:        rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-hover:  rgba(183, 245, 42, 0.25);

  --primary:       #B7F52A;
  --primary-hover: #C6FF3D;
  --primary-dim:   #9BD422;
  --primary-muted: rgba(183, 245, 42, 0.12);
  --primary-faint: rgba(183, 245, 42, 0.06);
  --primary-ink:   #0A1206;

  --text-primary:   #F7F9F7;
  --text-secondary: #B7BDB8;
  --text-muted:     #7F8982;

  --danger:  #EF5350; --danger-bg:  rgba(239,83,80,.13);  --danger-border:  rgba(239,83,80,.30);
  --warning: #F4B740; --warning-bg: rgba(244,183,64,.13); --warning-border: rgba(244,183,64,.30);
  --success: #35C76F; --success-bg: rgba(53,199,111,.13); --success-border: rgba(53,199,111,.30);
  --info:    #4AA8FF; --info-bg:    rgba(74,168,255,.13); --info-border:    rgba(74,168,255,.30);
  --neutral-bg: rgba(255,255,255,.06);

  --font-ar: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-en: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Roboto Mono', monospace;

  --fs-page:    clamp(1.5rem, 1.15rem + 1.1vw, 2.125rem);
  --fs-section: clamp(1.125rem, 1rem + .45vw, 1.375rem);
  --fs-kpi:     clamp(1.625rem, 1.35rem + 1vw, 2.25rem);
  --fs-card:    .9375rem;
  --fs-body:    .9375rem;
  --fs-sm:      .875rem;
  --fs-xs:      .8125rem;
  --fs-2xs:     .75rem;

  --lh-tight: 1.28;
  --lh-body: 1.75;

  --sp-1: .25rem;  --sp-2: .5rem;  --sp-3: .75rem;  --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-7: 1.75rem; --sp-8: 2rem;
  --sp-10: 2.5rem; --sp-12: 3rem;  --sp-16: 4rem;

  --radius-xs: 6px;  --radius-sm: 8px;  --radius: 12px;
  --radius-lg: 16px; --radius-xl: 20px; --radius-pill: 999px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.30), 0 1px 1px rgba(0,0,0,.20);
  --shadow-2: 0 2px 6px rgba(0,0,0,.32), 0 6px 16px rgba(0,0,0,.22);
  --shadow-3: 0 12px 32px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.30);
  --shadow-4: 0 24px 64px rgba(0,0,0,.55);

  --sidebar-w: 272px;
  --sidebar-rail: 72px;
  --header-h: 64px;

  --dur: 160ms;
  --dur-slow: 240ms;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ----------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-ar);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-secondary);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  overflow-x: hidden;
}
body[dir="ltr"] { font-family: var(--font-en); }

img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4, h5 { line-height: var(--lh-tight); color: var(--text-primary); font-weight: 600; letter-spacing: -.01em; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--radius-pill); border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-4); background-clip: content-box; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(183,245,42,.26); color: var(--text-primary); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; inset-inline-start: -9999px; top: 0; z-index: 999; background: var(--primary); color: var(--primary-ink); padding: .65rem 1.1rem; border-radius: 0 0 var(--radius) 0; font-weight: 600; }
.skip-link:focus { inset-inline-start: 0; }

/* ================================================================== SHELL */
.shell { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--sidebar); border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh; z-index: 60;
  transition: width var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}

.sidebar-brand {
  height: var(--header-h); display: flex; align-items: center; gap: var(--sp-3);
  padding-inline: var(--sp-5); border-bottom: 1px solid var(--border);
  flex-shrink: 0; overflow: hidden;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dim) 100%);
  display: grid; place-items: center;
  color: var(--primary-ink); font-weight: 800; font-size: 16px; letter-spacing: -.04em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; white-space: nowrap; }
.brand-text strong { font-size: .9375rem; color: var(--text-primary); font-weight: 700; letter-spacing: .02em; }
.brand-text span { font-size: var(--fs-2xs); color: var(--text-muted); }

.sidebar-search { padding: var(--sp-4) var(--sp-4) var(--sp-2); flex-shrink: 0; }
.sidebar-search button {
  width: 100%; display: flex; align-items: center; gap: var(--sp-2);
  height: 38px; padding-inline: var(--sp-3);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: var(--fs-xs); cursor: pointer; text-align: start;
  transition: all var(--dur) var(--ease);
}
.sidebar-search button:hover { border-color: var(--border-strong); color: var(--text-secondary); background: var(--surface-2); }
.sidebar-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-search .kbd { margin-inline-start: auto; font-family: var(--font-mono); font-size: 10px; border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; background: var(--background); white-space: nowrap; }

.sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--sp-2) var(--sp-3) var(--sp-8); scrollbar-width: thin; }

.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .12em;
  color: var(--text-muted); text-transform: uppercase;
  padding: var(--sp-5) var(--sp-3) var(--sp-2); white-space: nowrap;
}

.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: .55rem var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: var(--fs-sm);
  background: none; border: 0; cursor: pointer; text-align: start;
  position: relative; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item > svg:first-child { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.75; opacity: .85; }
.nav-item:hover { background: var(--surface-1); color: var(--text-primary); }
.nav-item:hover > svg:first-child { opacity: 1; }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.nav-item.is-active { background: var(--primary-muted); color: var(--primary); font-weight: 600; }
.nav-item.is-active > svg:first-child { opacity: 1; }
.nav-item.is-active::before { content: ''; position: absolute; inset-inline-start: 0; top: 50%; translate: 0 -50%; width: 3px; height: 18px; border-radius: var(--radius-pill); background: var(--primary); }

.nav-item .chevron { width: 15px; height: 15px; flex-shrink: 0; opacity: .6; transition: transform var(--dur) var(--ease); }
body[dir="rtl"] .nav-item .chevron { transform: rotate(180deg); }
.nav-group.is-open > .nav-item .chevron { transform: rotate(90deg); }
body[dir="rtl"] .nav-group.is-open > .nav-item .chevron { transform: rotate(90deg); }

.nav-badge { font-size: 10px; font-weight: 700; line-height: 1.6; padding: 0 6px; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--text-secondary); flex-shrink: 0; }
.nav-badge.is-danger { background: var(--danger-bg); color: var(--danger); }
.nav-badge.is-warning { background: var(--warning-bg); color: var(--warning); }
.nav-badge.is-primary { background: var(--primary-muted); color: var(--primary); }

.nav-children { display: none; margin: var(--sp-1) 0 var(--sp-2); padding-inline-start: var(--sp-4); position: relative; }
.nav-children::before { content: ''; position: absolute; inset-inline-start: 21px; top: 2px; bottom: 2px; width: 1px; background: var(--border); }
.nav-group.is-open > .nav-children { display: block; }
.nav-children .nav-item { font-size: var(--fs-xs); padding-block: .4rem; padding-inline-start: var(--sp-5); color: var(--text-muted); }
.nav-children .nav-item:hover { color: var(--text-primary); }
.nav-children .nav-item.is-active { color: var(--primary); background: transparent; font-weight: 600; }
.nav-children .nav-item.is-active::before { inset-inline-start: 20px; width: 2px; height: 14px; }
.nav-children .nav-item .wip { font-size: 9px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--text-muted); flex-shrink: 0; }

.sidebar-footer { padding: var(--sp-3); border-top: 1px solid var(--border); flex-shrink: 0; background: var(--sidebar); }
.sidebar-user { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); width: 100%; background: none; border: 0; cursor: pointer; text-align: start; transition: background var(--dur) var(--ease); }
.sidebar-user:hover { background: var(--surface-1); }
.sidebar-user .who { min-width: 0; flex: 1; overflow: hidden; }
.sidebar-user .who strong { display: block; font-size: var(--fs-xs); color: var(--text-primary); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who span { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------- collapsed (rail) */
body.sidebar-collapsed .sidebar { width: var(--sidebar-rail); }
body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .nav-item .label,
body.sidebar-collapsed .sidebar .nav-item .chevron,
body.sidebar-collapsed .sidebar .nav-section-label,
body.sidebar-collapsed .sidebar .sidebar-user .who,
body.sidebar-collapsed .sidebar .nav-badge,
body.sidebar-collapsed .sidebar .sidebar-search .kbd,
body.sidebar-collapsed .sidebar .sidebar-search span { display: none; }
body.sidebar-collapsed .sidebar .nav-children { display: none !important; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .sidebar-search { padding-inline: var(--sp-3); }
body.sidebar-collapsed .sidebar-search button { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .sidebar-scroll { padding-inline: var(--sp-3); }
body.sidebar-collapsed .nav-item { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .sidebar-user { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .sidebar .nav-item[data-tip]::after {
  content: attr(data-tip);
  position: absolute; inset-inline-start: calc(100% + 10px); top: 50%; translate: 0 -50%;
  background: var(--surface-3); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
  padding: .35rem .65rem; font-size: var(--fs-xs); white-space: nowrap;
  box-shadow: var(--shadow-3); opacity: 0; visibility: hidden; z-index: 200;
  transition: opacity var(--dur) var(--ease);
}
body.sidebar-collapsed .sidebar .nav-item:hover::after { opacity: 1; visibility: visible; }

/* ------------------------------------------------------------- main col */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.header {
  height: var(--header-h); flex-shrink: 0;
  display: flex; align-items: center; gap: var(--sp-3);
  padding-inline: var(--sp-6);
  background: rgba(7,11,8,.85); backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-crumbs { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.header-actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-2); }
.header-title { font-size: var(--fs-sm); color: var(--text-primary); font-weight: 600; }

.breadcrumb { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-2xs); color: var(--text-muted); flex-wrap: wrap; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { opacity: .45; }

.icon-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-secondary);
  display: grid; place-items: center; cursor: pointer; position: relative;
  transition: all var(--dur) var(--ease); flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); border-color: var(--border); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot { position: absolute; top: 5px; inset-inline-end: 5px; min-width: 17px; height: 17px; padding-inline: 4px; background: var(--danger); color: #fff; border-radius: var(--radius-pill); font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--background); }

.content { flex: 1; padding: var(--sp-6) var(--sp-8) var(--sp-16); width: 100%; }
.content-narrow { max-width: 960px; }

/* =============================================================== BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 38px; padding-inline: var(--sp-4);
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-primary);
  font-size: var(--fs-sm); font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 700; box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); border-color: var(--border-strong); }
.btn-subtle { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-subtle:hover { background: var(--surface-2); color: var(--text-primary); }
.btn-danger { background: var(--danger-bg); border-color: var(--danger-border); color: #FF8A87; }
.btn-danger:hover { background: rgba(239,83,80,.22); }
.btn-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.btn-sm { height: 32px; padding-inline: var(--sp-3); font-size: var(--fs-xs); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: 46px; padding-inline: var(--sp-6); font-size: var(--fs-body); }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }

.btn-group { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.btn-group button, .btn-group a { padding: .3rem .7rem; border-radius: var(--radius-xs); border: 0; background: transparent; color: var(--text-muted); font-size: var(--fs-xs); cursor: pointer; white-space: nowrap; transition: all var(--dur) var(--ease); }
.btn-group button:hover, .btn-group a:hover { color: var(--text-primary); }
.btn-group .is-active { background: var(--surface-3); color: var(--text-primary); font-weight: 600; }

/* ================================================================== CARDS */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); overflow: hidden; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.card-hover:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.card-raised { background: var(--surface-2); box-shadow: var(--shadow-2); }
.card-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: var(--fs-card); font-weight: 600; }
.card-head .sub { font-size: var(--fs-2xs); color: var(--text-muted); margin-top: 2px; font-weight: 400; }
.card-head-actions { margin-inline-start: auto; display: flex; gap: var(--sp-2); align-items: center; }
.card-head-icon { width: 32px; height: 32px; border-radius: var(--radius-xs); flex-shrink: 0; display: grid; place-items: center; background: var(--surface-3); color: var(--text-secondary); }
.card-head-icon svg { width: 16px; height: 16px; }
.card-body { padding: var(--sp-6); }
.card-body-tight { padding: var(--sp-4); }
.card-body-flush { padding: 0; }
.card-foot { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); background: var(--background); }

/* ============================================================ KPI WIDGETS */
.kpi-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.kpi-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1600px) { .kpi-grid-6 { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 900px)  { .kpi-grid-6 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px)  { .kpi-grid-6 { grid-template-columns: 1fr; } }

.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); box-shadow: var(--shadow-1); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); position: relative; min-width: 0; }
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
a.kpi:hover { border-color: var(--border-hover); }
.kpi-top { display: flex; align-items: flex-start; gap: var(--sp-3); }
.kpi-icon { width: 34px; height: 34px; border-radius: var(--radius-sm); flex-shrink: 0; display: grid; place-items: center; background: var(--surface-3); color: var(--text-secondary); }
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-icon.is-primary { background: var(--primary-muted); color: var(--primary); }
.kpi-icon.is-danger { background: var(--danger-bg); color: var(--danger); }
.kpi-icon.is-warning { background: var(--warning-bg); color: var(--warning); }
.kpi-icon.is-success { background: var(--success-bg); color: var(--success); }
.kpi-icon.is-info { background: var(--info-bg); color: var(--info); }
.kpi-label { font-size: var(--fs-xs); color: var(--text-secondary); font-weight: 500; line-height: 1.45; }
.kpi-value { font-size: var(--fs-kpi); font-weight: 700; color: var(--text-primary); line-height: 1.1; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.kpi-value.is-primary { color: var(--primary); }
.kpi-foot { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-top: auto; }
.kpi-delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-2xs); font-weight: 700; padding: .1rem .45rem; border-radius: var(--radius-pill); font-variant-numeric: tabular-nums; }
.kpi-delta.is-up { background: var(--success-bg); color: var(--success); }
.kpi-delta.is-down { background: var(--danger-bg); color: var(--danger); }
.kpi-delta.is-flat { background: var(--neutral-bg); color: var(--text-muted); }
.kpi-delta svg { width: 12px; height: 12px; }
.kpi-note { font-size: var(--fs-2xs); color: var(--text-muted); }
.kpi-spark { height: 34px; margin-top: var(--sp-1); }

.progress { height: 6px; background: var(--surface-3); border-radius: var(--radius-pill); overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: var(--radius-pill); transition: width .6s var(--ease); }
.progress-bar.is-success { background: var(--success); }
.progress-bar.is-warning { background: var(--warning); }
.progress-bar.is-danger { background: var(--danger); }
.progress-bar.is-info { background: var(--info); }
.progress-sm { height: 4px; }
.progress-stack { display: flex; height: 8px; border-radius: var(--radius-pill); overflow: hidden; background: var(--surface-3); }
.progress-stack span { height: 100%; }

/* ================================================================= BADGES */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: .2rem .6rem; border-radius: var(--radius-pill); font-size: var(--fs-2xs); font-weight: 600; white-space: nowrap; border: 1px solid transparent; line-height: 1.7; }
.badge .dot-mark { width: 6px; height: 6px; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.badge-danger { background: var(--danger-bg); color: #FF8A87; border-color: var(--danger-border); }
.badge-info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.badge-primary { background: var(--primary-muted); color: var(--primary); border-color: var(--border-hover); }
.badge-muted { background: var(--neutral-bg); color: var(--text-secondary); border-color: var(--border); }

/* ================================================================= TABLES */
.table-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.table-toolbar { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.table-toolbar .spacer { margin-inline-start: auto; }
.table-search { position: relative; min-width: 200px; flex: 0 1 300px; }
.table-search input { width: 100%; height: 34px; background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-sm); padding-inline: 2.1rem .75rem; font-size: var(--fs-xs); color: var(--text-primary); }
.table-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-faint); }
.table-search svg { position: absolute; inset-inline-start: .6rem; top: 50%; translate: 0 -50%; width: 15px; height: 15px; color: var(--text-muted); pointer-events: none; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; font-size: var(--fs-sm); min-width: 720px; }
.table thead th { text-align: start; font-weight: 600; font-size: var(--fs-2xs); color: var(--text-muted); padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 2; }
.table thead th a { display: inline-flex; align-items: center; gap: 4px; }
.table thead th a:hover { color: var(--primary); }
.table thead th svg { width: 12px; height: 12px; opacity: .5; }
.table tbody td { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-secondary); }
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .cell-strong { color: var(--text-primary); font-weight: 600; }
.table .cell-link:hover { color: var(--primary); }
.table .cell-actions { width: 1%; white-space: nowrap; }
.table-compact tbody td { padding: var(--sp-3) var(--sp-4); }
.table-compact thead th { padding: var(--sp-2) var(--sp-4); }
.bulk-bar { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); background: var(--primary-muted); border-bottom: 1px solid var(--border-hover); font-size: var(--fs-xs); }

@media (max-width: 860px) {
  .table-responsive .table { min-width: 0; }
  .table-responsive thead { display: none; }
  .table-responsive tbody tr { display: block; border: 1px solid var(--border); border-radius: var(--radius); margin: var(--sp-3); background: var(--surface-2); overflow: hidden; }
  .table-responsive tbody td { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); border-bottom: 1px solid var(--border); padding: var(--sp-3) var(--sp-4); text-align: end; }
  .table-responsive tbody td:last-child { border-bottom: 0; }
  .table-responsive tbody td::before { content: attr(data-label); color: var(--text-muted); font-size: var(--fs-2xs); font-weight: 600; text-align: start; flex-shrink: 0; }
  .table-responsive tbody tr:hover td { background: transparent; }
}

/* ============================================================ PAGINATION */
.pagination { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); }
.pagination .page-info { font-size: var(--fs-2xs); color: var(--text-muted); margin-inline-end: auto; }
.page-link { min-width: 32px; height: 32px; padding-inline: var(--sp-2); display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-xs); font-size: var(--fs-xs); color: var(--text-secondary); background: transparent; font-variant-numeric: tabular-nums; }
.page-link:hover { background: var(--surface-2); color: var(--text-primary); }
.page-link.is-active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 700; }
.page-link.is-disabled { opacity: .35; pointer-events: none; }
.page-link svg { width: 14px; height: 14px; }
body[dir="rtl"] .page-link svg { transform: scaleX(-1); }

/* ================================================================== FORMS */
.form-section { margin-block-end: var(--sp-8); }
.form-section-head { display: flex; align-items: center; gap: var(--sp-3); margin-block-end: var(--sp-5); padding-block-end: var(--sp-3); border-bottom: 1px solid var(--border); }
.form-section-head .step { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: var(--primary-muted); color: var(--primary); font-size: var(--fs-2xs); font-weight: 700; }
.form-section-head h3 { font-size: var(--fs-card); }
.form-section-head p { font-size: var(--fs-2xs); color: var(--text-muted); margin-top: 2px; }

.form-grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.form-grid-2 { display: grid; gap: var(--sp-5); grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-grid-3 { display: grid; gap: var(--sp-5); grid-template-columns: repeat(3, minmax(0,1fr)); }
.col-span-2 { grid-column: span 2; }
.col-span-full { grid-column: 1 / -1; }
@media (max-width: 1000px) { .form-grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 680px) { .form-grid, .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; } .col-span-2 { grid-column: span 1; } }

.field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.field > label { font-size: var(--fs-xs); color: var(--text-secondary); font-weight: 500; }
.field > label .req { color: var(--danger); margin-inline-start: 3px; }
.field .hint { font-size: var(--fs-2xs); color: var(--text-muted); line-height: 1.5; }
.field .error { font-size: var(--fs-2xs); color: #FF8A87; }

.input, .select, .textarea { width: 100%; min-height: 40px; background: var(--background); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .5rem .85rem; color: var(--text-primary); font-size: var(--fs-sm); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease); }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); background: var(--surface-1); box-shadow: 0 0 0 3px var(--primary-faint); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: .5; cursor: not-allowed; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.textarea { min-height: 108px; resize: vertical; line-height: 1.75; }
.select {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237F8982' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left .85rem center;
  padding-inline-start: 2.3rem; padding-inline-end: .85rem;
}
body[dir="ltr"] .select { background-position: right .85rem center; padding-inline-start: .85rem; padding-inline-end: 2.3rem; }
.select option { background: var(--surface-2); color: var(--text-primary); }

.input-group { display: flex; align-items: stretch; }
.input-group .input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group .addon { display: grid; place-items: center; padding-inline: var(--sp-4); background: var(--surface-2); border: 1px solid var(--border-strong); border-inline-start: 0; border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); color: var(--text-muted); font-size: var(--fs-xs); white-space: nowrap; }

.check-row { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-sm); cursor: pointer; }
.check-row input[type="checkbox"], .check-row input[type="radio"] { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 22px; border-radius: var(--radius-pill); background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: all var(--dur) var(--ease); flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-secondary); transition: all var(--dur) var(--ease); }
.switch input:checked + .track { background: var(--primary-muted); border-color: var(--border-hover); }
.switch input:checked + .track::after { background: var(--primary); transform: translateX(18px); }
body[dir="rtl"] .switch input:checked + .track::after { transform: translateX(-18px); }

.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: var(--sp-8) var(--sp-5); text-align: center; cursor: pointer; background: var(--background); transition: all var(--dur) var(--ease); }
.dropzone:hover, .dropzone.is-dragging { border-color: var(--primary); background: var(--primary-faint); }
.dropzone svg { width: 30px; height: 30px; color: var(--text-muted); margin: 0 auto var(--sp-3); }
.dropzone p { font-size: var(--fs-sm); color: var(--text-secondary); }
.dropzone small { font-size: var(--fs-2xs); color: var(--text-muted); }

.form-actions { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; padding-block-start: var(--sp-5); margin-block-start: var(--sp-6); border-top: 1px solid var(--border); }
.form-actions .spacer { margin-inline-start: auto; }

/* =============================================================== FILTERS */
.filter-bar { display: flex; gap: var(--sp-4); flex-wrap: wrap; align-items: flex-end; padding: var(--sp-5); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-block-end: var(--sp-6); box-shadow: var(--shadow-1); }
.filter-bar .field { min-width: 160px; flex: 1 1 160px; }
.filter-bar .filter-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }
.chip { display: inline-flex; align-items: center; gap: var(--sp-2); padding: .22rem .65rem; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--border-strong); font-size: var(--fs-2xs); color: var(--text-secondary); }
.chip a:hover, .chip button:hover { color: var(--danger); }

/* =================================================================== TABS */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-block-end: var(--sp-6); }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; background: none; border-inline: 0; border-top: 0; transition: all var(--dur) var(--ease); }
.tab:hover { color: var(--text-primary); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab .count { font-size: 10px; color: var(--text-muted); margin-inline-start: 5px; background: var(--surface-3); padding: 0 5px; border-radius: var(--radius-pill); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* =============================================================== TIMELINE */
.timeline { position: relative; padding-inline-start: var(--sp-6); }
.timeline::before { content: ''; position: absolute; inset-inline-start: 7px; top: 8px; bottom: 8px; width: 1px; background: var(--border); }
.timeline-item { position: relative; padding-block-end: var(--sp-5); }
.timeline-item:last-child { padding-block-end: 0; }
.timeline-item::before { content: ''; position: absolute; inset-inline-start: calc(-1 * var(--sp-6) + 3px); top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface-3); border: 2px solid var(--background); box-shadow: 0 0 0 1px var(--border-strong); }
.timeline-item.is-primary::before { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-muted); }
.timeline-item .t-title { font-size: var(--fs-sm); color: var(--text-primary); font-weight: 500; }
.timeline-item .t-desc { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 2px; }
.timeline-item .t-meta { font-size: var(--fs-2xs); color: var(--text-muted); margin-top: var(--sp-1); display: flex; gap: var(--sp-3); flex-wrap: wrap; }

/* ================================================================= KANBAN */
.kanban { display: flex; gap: var(--sp-4); overflow-x: auto; padding-block-end: var(--sp-4); align-items: flex-start; }
.kanban-col { flex: 0 0 300px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: 74vh; }
.kanban-col-head { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: var(--sp-2); }
.kanban-col-head strong { font-size: var(--fs-sm); }
.kanban-col-head .count { font-size: 10px; color: var(--text-muted); background: var(--surface-3); padding: 1px 7px; border-radius: var(--radius-pill); }
.kanban-col-head .sum { margin-inline-start: auto; font-size: var(--fs-2xs); color: var(--primary); font-variant-numeric: tabular-nums; }
.kanban-col-body { padding: var(--sp-3); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: var(--sp-3); min-height: 90px; }
.kanban-col-body.is-drop-target { background: var(--primary-faint); }
.kanban-card { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: var(--sp-4); cursor: grab; transition: border-color var(--dur) var(--ease); }
.kanban-card:hover { border-color: var(--border-hover); }
.kanban-card.is-dragging { opacity: .4; }
.kanban-card .k-title { font-size: var(--fs-sm); color: var(--text-primary); font-weight: 500; }
.kanban-card .k-meta { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); font-size: var(--fs-2xs); color: var(--text-muted); flex-wrap: wrap; }
.kanban-card .k-value { color: var(--primary); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================================================== DROPDOWNS */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; min-width: 240px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-3); padding: var(--sp-2); opacity: 0; visibility: hidden; transform: translateY(-6px); transition: all var(--dur) var(--ease); z-index: 90; }
.dropdown.is-open > .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-menu.is-start { inset-inline-end: auto; inset-inline-start: 0; }
.dropdown-menu.up { top: auto; bottom: calc(100% + 8px); }
.dropdown-item { display: flex; align-items: center; gap: var(--sp-3); padding: .55rem var(--sp-3); border-radius: var(--radius-xs); font-size: var(--fs-sm); color: var(--text-secondary); width: 100%; background: none; border: 0; cursor: pointer; text-align: start; transition: all var(--dur) var(--ease); }
.dropdown-item:hover { background: var(--surface-3); color: var(--text-primary); }
.dropdown-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.dropdown-item.is-danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: var(--sp-2) 0; }
.dropdown-header { padding: var(--sp-2) var(--sp-3); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }

.avatar { width: 34px; height: 34px; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--primary); display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700; border: 1px solid var(--border-strong); flex-shrink: 0; overflow: hidden; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.35rem; border-radius: var(--radius); }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }

/* ========================================================== NOTIFICATIONS */
.notif-panel { width: min(400px, calc(100vw - 2rem)); max-height: 480px; overflow-y: auto; padding: 0; }
.notif-item { display: flex; gap: var(--sp-3); padding: var(--sp-4); border-bottom: 1px solid var(--border); transition: background var(--dur) var(--ease); }
.notif-item:hover { background: var(--surface-3); }
.notif-item.is-unread { background: var(--primary-faint); }
.notif-item .notif-icon { width: 30px; height: 30px; border-radius: var(--radius-xs); flex-shrink: 0; display: grid; place-items: center; background: var(--surface-3); color: var(--text-secondary); }
.notif-item .notif-icon svg { width: 15px; height: 15px; }
.notif-item .notif-body { min-width: 0; flex: 1; }
.notif-item strong { display: block; font-size: var(--fs-sm); color: var(--text-primary); font-weight: 500; }
.notif-item p { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 2px; }
.notif-item time { font-size: var(--fs-2xs); color: var(--text-muted); }

/* ======================================================== COMMAND PALETTE */
.cmdk-backdrop { position: fixed; inset: 0; background: rgba(4,7,5,.74); backdrop-filter: blur(6px); z-index: 300; display: none; align-items: flex-start; justify-content: center; padding: clamp(1rem, 10vh, 8rem) var(--sp-4) var(--sp-4); }
.cmdk-backdrop.is-open { display: flex; }
.cmdk { width: min(640px, 100%); background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-4); overflow: hidden; animation: pop-in .18s var(--ease); display: flex; flex-direction: column; max-height: 70vh; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-10px) scale(.985); } to { opacity: 1; transform: none; } }
.cmdk-input-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.cmdk-input-row > svg { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.cmdk-input-row input { flex: 1; background: none; border: 0; outline: none; font-size: 1rem; color: var(--text-primary); min-width: 0; }
.cmdk-input-row input::placeholder { color: var(--text-muted); }
.cmdk-input-row .esc { font-family: var(--font-mono); font-size: 10px; border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; color: var(--text-muted); }
.cmdk-results { overflow-y: auto; padding: var(--sp-2); flex: 1; }
.cmdk-group { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); padding: var(--sp-3) var(--sp-3) var(--sp-1); }
.cmdk-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); border-radius: var(--radius-xs); cursor: pointer; color: var(--text-secondary); }
.cmdk-item:hover, .cmdk-item.is-active { background: var(--surface-3); color: var(--text-primary); }
.cmdk-item.is-active { box-shadow: inset 2px 0 0 var(--primary); }
.cmdk-item .ic { width: 30px; height: 30px; border-radius: var(--radius-xs); background: var(--surface-3); display: grid; place-items: center; flex-shrink: 0; }
.cmdk-item.is-active .ic { background: var(--primary-muted); color: var(--primary); }
.cmdk-item .ic svg { width: 15px; height: 15px; }
.cmdk-item .txt { min-width: 0; flex: 1; }
.cmdk-item .txt strong { display: block; font-size: var(--fs-sm); font-weight: 500; }
.cmdk-item .txt span { display: block; font-size: var(--fs-2xs); color: var(--text-muted); }
.cmdk-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); display: flex; gap: var(--sp-4); font-size: var(--fs-2xs); color: var(--text-muted); flex-wrap: wrap; }
.cmdk-foot kbd { font-family: var(--font-mono); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; }
.cmdk-empty { padding: var(--sp-10) var(--sp-5); text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }

/* ================================================================= MODALS */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4,7,5,.72); backdrop-filter: blur(4px); z-index: 200; display: none; align-items: center; justify-content: center; padding: var(--sp-4); }
.modal-backdrop.is-open { display: flex; }
.modal { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-4); width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column; animation: pop-in .2s var(--ease); }
.modal-lg { width: min(900px, 100%); }
.modal-head { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: var(--sp-3); }
.modal-head h3 { font-size: var(--fs-section); }
.modal-head .icon-btn { margin-inline-start: auto; }
.modal-body { padding: var(--sp-6); overflow-y: auto; }
.modal-foot { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); display: flex; gap: var(--sp-3); justify-content: flex-end; }

/* ================================================================= TOASTS */
.toast-stack { position: fixed; inset-block-end: var(--sp-6); inset-inline-end: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); z-index: 400; max-width: min(400px, calc(100vw - 2rem)); pointer-events: none; }
.toast { background: var(--surface-2); border: 1px solid var(--border-strong); border-inline-start: 3px solid var(--primary); border-radius: var(--radius-sm); box-shadow: var(--shadow-3); padding: var(--sp-4); display: flex; gap: var(--sp-3); align-items: flex-start; animation: toast-in .22s var(--ease); pointer-events: auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.toast.is-success { border-inline-start-color: var(--success); }
.toast.is-error { border-inline-start-color: var(--danger); }
.toast.is-warning { border-inline-start-color: var(--warning); }
.toast strong { font-size: var(--fs-sm); color: var(--text-primary); display: block; }
.toast p { font-size: var(--fs-xs); color: var(--text-secondary); }
.toast .icon-btn { margin-inline-start: auto; width: 26px; height: 26px; }

/* ================================================================ ALERTS */
.alert { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-4) var(--sp-5); border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface-2); font-size: var(--fs-sm); color: var(--text-secondary); }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 3px; }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-border); color: #FFB4B2; }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: #A5E9C4; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: #FFDFA8; }
.alert-info { background: var(--info-bg); border-color: var(--info-border); color: #B8DBFF; }
.alert ul { margin: 0; padding-inline-start: var(--sp-5); }

/* =========================================================== EMPTY STATES */
.empty-state { text-align: center; padding: var(--sp-12) var(--sp-5); }
.empty-state.is-compact { padding: var(--sp-8) var(--sp-4); }
.empty-icon { width: 56px; height: 56px; border-radius: var(--radius); margin: 0 auto var(--sp-4); background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-muted); }
.empty-icon svg { width: 24px; height: 24px; }
.empty-state h3 { font-size: var(--fs-card); margin-block-end: var(--sp-2); }
.empty-state p { color: var(--text-muted); font-size: var(--fs-xs); max-width: 40ch; margin: 0 auto var(--sp-5); line-height: 1.7; }

/* ============================================================== SKELETONS */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-xs); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-line { height: 12px; margin-block-end: var(--sp-3); }
.sk-line.w-30 { width: 30%; } .sk-line.w-50 { width: 50%; } .sk-line.w-70 { width: 70%; } .sk-line.w-90 { width: 90%; }
.sk-kpi { height: 132px; border-radius: var(--radius-lg); }
.sk-chart { height: 280px; border-radius: var(--radius-lg); }
.sk-row { height: 44px; border-radius: var(--radius-xs); margin-block-end: var(--sp-2); }

/* ================================================================ CHARTS */
.chart-box { position: relative; width: 100%; }
.chart-h-xs { height: 120px; }
.chart-h-sm { height: 200px; }
.chart-h { height: 300px; }
.chart-h-lg { height: 360px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin-block-start: var(--sp-4); }
.chart-legend .li { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-2xs); color: var(--text-secondary); }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.funnel { display: flex; flex-direction: column; gap: var(--sp-2); }
.funnel-step { display: flex; align-items: center; gap: var(--sp-4); }
.funnel-step .fname { width: 92px; flex-shrink: 0; font-size: var(--fs-xs); color: var(--text-secondary); }
.funnel-step .fbar { flex: 1; height: 34px; background: var(--surface-2); border-radius: var(--radius-xs); overflow: hidden; }
.funnel-step .fbar span { display: block; height: 100%; border-radius: var(--radius-xs); background: linear-gradient(90deg, var(--primary-dim), var(--primary)); transition: width .6s var(--ease); min-width: 3px; }
.funnel-step .fval { width: 118px; flex-shrink: 0; text-align: end; font-size: var(--fs-xs); color: var(--text-primary); font-variant-numeric: tabular-nums; }
.funnel-step .fcount { font-size: var(--fs-2xs); color: var(--text-muted); }

/* ======================================================= ATTENTION ITEMS */
.attention-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.attention-item { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4); border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); transition: all var(--dur) var(--ease); }
.attention-item:hover { border-color: var(--border-strong); background: var(--surface-3); }
.attention-count { width: 44px; height: 44px; border-radius: var(--radius-sm); flex-shrink: 0; display: grid; place-items: center; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.attention-count.is-danger { background: var(--danger-bg); color: var(--danger); }
.attention-count.is-warning { background: var(--warning-bg); color: var(--warning); }
.attention-count.is-info { background: var(--info-bg); color: var(--info); }
.attention-item .at-body { min-width: 0; flex: 1; }
.attention-item .at-body strong { display: block; font-size: var(--fs-sm); color: var(--text-primary); font-weight: 500; }
.attention-item .at-body span { font-size: var(--fs-2xs); color: var(--text-muted); }
.attention-item > svg:last-child { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

/* ============================================================ PAGE HEADER */
.page-head { display: flex; align-items: flex-start; gap: var(--sp-5); flex-wrap: wrap; margin-block-end: var(--sp-6); }
.page-head-text { min-width: 0; flex: 1; }
.page-title { font-size: var(--fs-page); font-weight: 700; color: var(--text-primary); letter-spacing: -.02em; line-height: 1.2; }
.page-subtitle { color: var(--text-muted); font-size: var(--fs-sm); margin-block-start: var(--sp-2); }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.section-head { display: flex; align-items: center; gap: var(--sp-3); margin-block-end: var(--sp-4); }
.section-head h2 { font-size: var(--fs-section); font-weight: 600; }
.section-head .sub { font-size: var(--fs-2xs); color: var(--text-muted); }
.section-head .spacer { margin-inline-start: auto; }

.meta-list { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.meta-item .meta-label { font-size: var(--fs-2xs); color: var(--text-muted); }
.meta-item .meta-value { font-size: var(--fs-sm); color: var(--text-primary); margin-block-start: 4px; word-break: break-word; }
.stat-row { display: flex; gap: var(--sp-8); flex-wrap: wrap; }
.stat-row .stat .v { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-row .stat .l { font-size: var(--fs-2xs); color: var(--text-muted); margin-top: 3px; }

/* ============================================================== UTILITIES */
.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-8-4 { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.grid-7-5 { grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); }
@media (max-width: 1280px) { .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid-8-4, .grid-7-5 { grid-template-columns: 1fr; } }
@media (max-width: 1000px) { .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid-2, .grid-4 { grid-template-columns: 1fr; } }

.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .items-start { align-items: flex-start; } .items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; } .justify-center { justify-content: center; } .justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; } .flex-1 { flex: 1; min-width: 0; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }
.mt-1 { margin-block-start: var(--sp-1); } .mt-2 { margin-block-start: var(--sp-2); }
.mt-3 { margin-block-start: var(--sp-3); } .mt-4 { margin-block-start: var(--sp-4); }
.mt-5 { margin-block-start: var(--sp-5); } .mt-6 { margin-block-start: var(--sp-6); }
.mt-8 { margin-block-start: var(--sp-8); } .mt-10 { margin-block-start: var(--sp-10); }
.mb-1 { margin-block-end: var(--sp-1); } .mb-2 { margin-block-end: var(--sp-2); }
.mb-3 { margin-block-end: var(--sp-3); } .mb-4 { margin-block-end: var(--sp-4); }
.mb-5 { margin-block-end: var(--sp-5); } .mb-6 { margin-block-end: var(--sp-6); }
.mb-8 { margin-block-end: var(--sp-8); }
.text-sm { font-size: var(--fs-sm); } .text-xs { font-size: var(--fs-xs); } .text-2xs { font-size: var(--fs-2xs); }
.text-muted { color: var(--text-muted); } .text-secondary { color: var(--text-secondary); }
.text-primary-c { color: var(--text-primary); }
.text-lime { color: var(--primary); } .text-success { color: var(--success); }
.text-danger { color: var(--danger); } .text-warning { color: var(--warning); } .text-info { color: var(--info); }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.text-center { text-align: center; } .text-end { text-align: end; } .text-start { text-align: start; }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; } .hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin-block: var(--sp-5); }
.link-lime { color: var(--primary); } .link-lime:hover { text-decoration: underline; }
.hover-lime:hover { color: var(--primary); }
.mono { font-family: var(--font-mono); font-size: var(--fs-xs); }
.dot-mark { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: currentColor; }
.dot-success { background: var(--success); } .dot-warning { background: var(--warning); }
.dot-danger { background: var(--danger); } .dot-info { background: var(--info); } .dot-muted { background: var(--text-muted); }

/* ============================================================ AUTH SCREEN */
.auth-shell { min-height: 100dvh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--background); }
.auth-visual { position: relative; overflow: hidden; padding: var(--sp-12); display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(circle at 76% 16%, rgba(183,245,42,.13) 0%, transparent 46%), radial-gradient(circle at 14% 86%, rgba(183,245,42,.06) 0%, transparent 40%), linear-gradient(155deg, var(--sidebar) 0%, var(--background) 100%); border-inline-end: 1px solid var(--border); }
.auth-visual::after { content: ''; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px); background-size: 58px 58px; opacity: .4; mask-image: radial-gradient(circle at 50% 42%, #000 0%, transparent 76%); }
.auth-visual > * { position: relative; z-index: 1; }
.auth-headline { font-size: clamp(1.75rem, 1.3rem + 1.7vw, 2.6rem); font-weight: 700; line-height: 1.35; max-width: 19ch; }
.auth-headline em { color: var(--primary); font-style: normal; }
.auth-points { display: flex; flex-direction: column; gap: var(--sp-4); margin-block-start: var(--sp-8); }
.auth-point { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: var(--fs-sm); color: var(--text-secondary); }
.auth-point svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; margin-top: 4px; }
.auth-form-side { display: grid; place-items: center; padding: var(--sp-8) var(--sp-5); }
.auth-card { width: min(410px, 100%); }
.auth-card h1 { font-size: var(--fs-page); margin-block-end: var(--sp-2); }
.auth-card > p { color: var(--text-muted); font-size: var(--fs-sm); margin-block-end: var(--sp-8); }
@media (max-width: 960px) { .auth-shell { grid-template-columns: 1fr; } .auth-visual { display: none; } }

/* ============================================================ ERROR PAGES */
.error-shell { min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-6); text-align: center; background: radial-gradient(circle at 50% 28%, rgba(183,245,42,.07) 0%, transparent 52%), var(--background); }
.error-code { font-size: clamp(4rem, 12vw, 7.5rem); font-weight: 800; color: var(--primary); line-height: 1; letter-spacing: -.05em; }
.error-shell h1 { font-size: var(--fs-page); margin-block: var(--sp-4) var(--sp-2); }
.error-shell p { color: var(--text-secondary); max-width: 46ch; margin: 0 auto var(--sp-6); font-size: var(--fs-sm); }
.error-reference { display: inline-flex; align-items: center; gap: var(--sp-3); margin-block: var(--sp-5) var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); flex-wrap: wrap; justify-content: center; }
.error-reference-label { font-size: var(--fs-2xs); color: var(--text-muted); }
.error-reference-id { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--primary); letter-spacing: .04em; }
.error-reference-copy { background: transparent; border: 1px solid var(--border-strong); color: var(--text-secondary); border-radius: var(--radius-xs); padding: .2rem .55rem; font-size: var(--fs-2xs); cursor: pointer; transition: all var(--dur) var(--ease); }
.error-reference-copy:hover { border-color: var(--border-hover); color: var(--primary); }
.error-reference-hint { font-size: var(--fs-2xs) !important; color: var(--text-muted) !important; margin-block-end: var(--sp-6) !important; }
.sidebar-brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--primary), var(--primary-dim)); display: grid; place-items: center; color: var(--primary-ink); font-weight: 800; }

/* ==================================================== UNDER DEVELOPMENT */
.wip-hero { text-align: center; padding: var(--sp-16) var(--sp-5); background: var(--surface-1); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.wip-badge { display: inline-flex; align-items: center; gap: var(--sp-2); padding: .3rem .8rem; border-radius: var(--radius-pill); background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); font-size: var(--fs-2xs); font-weight: 600; margin-block-end: var(--sp-5); }
.wip-hero h2 { font-size: var(--fs-section); margin-block-end: var(--sp-3); }
.wip-hero p { color: var(--text-muted); font-size: var(--fs-sm); max-width: 52ch; margin: 0 auto var(--sp-6); }
.wip-features { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; max-width: 760px; margin: 0 auto; }
.wip-features .chip { background: var(--surface-2); }

/* ================================================== RESPONSIVE / MOBILE */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(4,7,5,.66); z-index: 55; display: none; backdrop-filter: blur(2px); }
.sidebar-overlay.is-open { display: block; }
.mobile-only { display: none; }

@media (min-width: 2000px) { .content { max-width: 1920px; margin-inline: auto; } }
@media (max-width: 1440px) { .content { padding-inline: var(--sp-6); } }
@media (max-width: 1180px) { :root { --sidebar-w: 250px; } }

@media (max-width: 1024px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 280px; transform: translateX(-100%); box-shadow: var(--shadow-4); }
  body[dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.is-open { transform: translateX(0); }
  body.sidebar-collapsed .sidebar { width: 280px; }
  body.sidebar-collapsed .sidebar .brand-text,
  body.sidebar-collapsed .sidebar .nav-item .label,
  body.sidebar-collapsed .sidebar .nav-item .chevron,
  body.sidebar-collapsed .sidebar .nav-section-label,
  body.sidebar-collapsed .sidebar .sidebar-user .who,
  body.sidebar-collapsed .sidebar .sidebar-search span { display: revert; }
  body.sidebar-collapsed .nav-item, body.sidebar-collapsed .sidebar-user,
  body.sidebar-collapsed .sidebar-brand, body.sidebar-collapsed .sidebar-search button { justify-content: flex-start; padding-inline: var(--sp-3); }
  body.sidebar-collapsed .sidebar .nav-item[data-tip]::after { display: none; }
  .content { padding: var(--sp-5) var(--sp-5) var(--sp-16); }
}

@media (max-width: 860px) {
  :root { --header-h: 58px; }
  .content { padding: var(--sp-4) var(--sp-4) var(--sp-16); }
  .header { padding-inline: var(--sp-3); gap: var(--sp-2); }
  .header-crumbs .breadcrumb { display: none; }
  .card-body, .card-head, .card-foot { padding: var(--sp-4); }
  .kpi { padding: var(--sp-4); }
  .filter-bar { padding: var(--sp-4); gap: var(--sp-3); }
  .filter-bar .field { flex: 1 1 100%; }
  .filter-bar .filter-actions { width: 100%; }
  .filter-bar .filter-actions .btn { flex: 1; }
  .page-actions { width: 100%; }
  .page-actions > .btn { flex: 1; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .toast-stack { inset-inline: var(--sp-3); inset-block-end: var(--sp-3); max-width: none; }
  .kanban-col { flex-basis: 84vw; }
  .stat-row { gap: var(--sp-5); }
  .funnel-step .fname { width: 74px; }
  .funnel-step .fval { width: 96px; }
  .mobile-only { display: revert; }
  .desktop-only { display: none !important; }
  .btn, .icon-btn, .input, .select { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .nav-item { padding-block: .7rem; }
}

@media (max-width: 480px) {
  .page-title { font-size: 1.375rem; }
  .kpi-value { font-size: 1.5rem; }
  .cmdk-backdrop { padding-top: var(--sp-4); }
}

@media print {
  .sidebar, .header, .page-actions, .table-toolbar, .pagination, .toast-stack, .sidebar-overlay { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .kpi { border-color: #ddd; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
