/* ============================================================
   CTL CRM — Design System
   Fundament: tipografie, culori, reset, utilitare
   Estetică: ERP industrial dens, sobru. Fără gradienți decorativi,
   fără umbre difuze, fără colțuri exagerat rotunjite.
   ============================================================ */

/* ---------- 1. TOKENS ---------- */
:root {
  /* Brand CTL — portocaliu ars, folosit DOAR ca accent (max 5% din suprafață) */
  --brand:            #e14b03;
  --brand-hover:      #c73f00;
  --brand-active:     #a83500;
  --brand-soft:       #fff1e9;
  --brand-soft-brd:   #ffd4bd;
  --brand-ink:        #7a2900;

  /* Neutre — scală rece, ușor albăstruie (citire lungă, ecrane industriale) */
  --n-0:   #ffffff;
  --n-25:  #fbfcfd;
  --n-50:  #f6f8fa;
  --n-100: #eef1f4;
  --n-150: #e6eaef;
  --n-200: #dde2e8;
  --n-300: #c5ccd6;
  --n-400: #9aa4b2;
  --n-500: #6b7684;
  --n-600: #4e5866;
  --n-700: #39424e;
  --n-800: #262d37;
  --n-850: #1c222a;
  --n-900: #141920;
  --n-950: #0d1117;

  /* Semantice */
  --ok:        #0f7b3f;
  --ok-soft:   #e7f6ed;
  --ok-brd:    #b6e3c8;
  --warn:      #a55a00;
  --warn-soft: #fdf3e3;
  --warn-brd:  #f0d4a4;
  --err:       #b42318;
  --err-soft:  #fef3f2;
  --err-brd:   #fbc9c4;
  --info:      #0b5cad;
  --info-soft: #eaf3fc;
  --info-brd:  #b9d6f2;
  --alt:       #5b3fb5;
  --alt-soft:  #f1eefc;
  --alt-brd:   #d3c9f3;

  /* Suprafețe */
  --bg:          var(--n-50);
  --surface:     var(--n-0);
  --surface-2:   var(--n-25);
  --surface-3:   var(--n-100);
  --border:      var(--n-200);
  --border-soft: var(--n-150);
  --border-hard: var(--n-300);

  /* Text */
  --ink:      var(--n-850);
  --ink-2:    var(--n-600);
  --ink-3:    var(--n-500);
  --ink-4:    var(--n-400);
  --ink-inv:  var(--n-0);

  /* Sidebar — întotdeauna închis, indiferent de temă */
  --nav-bg:        #171c24;
  --nav-bg-2:      #11151b;
  --nav-brd:       #262d38;
  --nav-ink:       #aeb8c6;
  --nav-ink-dim:   #6d7888;
  --nav-ink-hi:    #ffffff;
  --nav-active-bg: #212832;

  /* Tipografie */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;

  --fs-2xs: 10.5px;
  --fs-xs:  11.5px;
  --fs-sm:  12.5px;
  --fs-md:  13.5px;
  --fs-lg:  15px;
  --fs-xl:  17px;
  --fs-2xl: 21px;
  --fs-3xl: 27px;
  --fs-4xl: 34px;

  /* Spațiere — grilă de 4px */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  /* Radius — mic și consecvent. Nimic peste 8px în afară de pastile. */
  --r-xs: 3px;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-pill: 999px;

  /* Umbre — doar pentru elemente care plutesc efectiv */
  --sh-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --sh-md: 0 4px 12px -2px rgba(16, 24, 40, .10), 0 2px 4px -2px rgba(16, 24, 40, .06);
  --sh-lg: 0 16px 32px -8px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .08);
  --sh-nav: 0 1px 0 var(--border);

  /* Layout */
  --nav-w:          252px;
  --nav-w-collapsed: 60px;
  --topbar-h:       54px;
  --bottombar-h:    58px;
  --page-max:       1680px;

  --tr: 130ms cubic-bezier(.4, 0, .2, 1);
  --tr-slow: 240ms cubic-bezier(.4, 0, .2, 1);
}

/* ---------- 2. TEMA ÎNTUNECATĂ ---------- */
[data-theme="dark"] {
  --bg:          #0f1319;
  --surface:     #171c24;
  --surface-2:   #1c222b;
  --surface-3:   #222933;
  --border:      #2a323d;
  --border-soft: #232a34;
  --border-hard: #3a4451;

  --ink:     #e6eaf0;
  --ink-2:   #a8b2c1;
  --ink-3:   #8590a1;
  --ink-4:   #66707f;
  --ink-inv: #0f1319;

  --brand:      #ff6a24;
  --brand-hover:#ff7d3f;
  --brand-soft: #2b1810;
  --brand-soft-brd: #4d2a16;
  --brand-ink:  #ffb894;

  --ok-soft:   #10241a; --ok-brd:   #1d4632; --ok:   #4ade80;
  --warn-soft: #241c0f; --warn-brd: #4a3a1c; --warn: #fbbf24;
  --err-soft:  #2a1315; --err-brd:  #532225; --err:  #f87171;
  --info-soft: #101d2c; --info-brd: #1e3a54; --info: #60a5fa;
  --alt-soft:  #1a1530; --alt-brd:  #322a56; --alt:  #a78bfa;

  --nav-bg:   #12161c;
  --nav-bg-2: #0d1116;
  --nav-brd:  #232a34;
  --nav-active-bg: #1e242e;

  --sh-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-md: 0 4px 12px -2px rgba(0, 0, 0, .5);
  --sh-lg: 0 16px 32px -8px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- 3. RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'tnum';
  overscroll-behavior-y: none;
}

img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
ul, ol { list-style: none; }

h1, h2, h3, h4, h5 { font-weight: 600; line-height: 1.25; letter-spacing: -.011em; }
h1 { font-size: var(--fs-2xl); letter-spacing: -.02em; }
h2 { font-size: var(--fs-xl); letter-spacing: -.015em; }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-radius: var(--r-xs);
}

::selection { background: var(--brand); color: #fff; }

/* Scrollbar discret */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--n-300);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--n-400); background-clip: content-box; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #38414e; background-clip: content-box; }

/* ---------- 4. UTILITARE TIPOGRAFICE ---------- */
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.02em; }

.t-xs  { font-size: var(--fs-xs); }
.t-sm  { font-size: var(--fs-sm); }
.t-lg  { font-size: var(--fs-lg); }
.t-xl  { font-size: var(--fs-xl); }

.t-dim  { color: var(--ink-3); }
.t-dim2 { color: var(--ink-4); }
.t-ink  { color: var(--ink); }
.t-ok   { color: var(--ok); }
.t-warn { color: var(--warn); }
.t-err  { color: var(--err); }
.t-brand{ color: var(--brand); }

.t-med  { font-weight: 500; }
.t-semi { font-weight: 600; }
.t-bold { font-weight: 700; }

.t-up {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--ink-3);
}

.t-right  { text-align: right; }
.t-center { text-align: center; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 5. LAYOUT UTILITARE ---------- */
.row  { display: flex; align-items: center; gap: var(--s2); }
.row-b{ display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.col  { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.g1 { gap: var(--s1); } .g2 { gap: var(--s2); } .g3 { gap: var(--s3); }
.g4 { gap: var(--s4); } .g5 { gap: var(--s5); } .g6 { gap: var(--s6); }

.grid { display: grid; gap: var(--s4); }
.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-auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.hidden { display: none !important; }
.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;
}

@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 6. ACCESIBILITATE ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .no-print, .sidebar, .topbar, .bottom-nav, .fab { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
}
