/* Marian Cargo Admin — Design System v2 */

/* ═══════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════ */
:root {
  /* Culori de bază */
  --brand-50:  #EEF2FF;
  --brand-100: #E0E7FF;
  --brand-500: #1E40AF;
  --brand-600: #1D3A9E;
  --brand-700: #1E3280;
  --brand-900: #0F172A;

  --accent-400: #FB923C;
  --accent-500: #F97316;
  --accent-600: #EA6C0A;

  /* Suprafețe */
  --bg:        #F8FAFC;
  --surface:   #FFFFFF;
  --surface-2: #F1F5F9;
  --surface-3: #E2E8F0;

  /* Text */
  --text-primary:   #0F172A;
  --text-secondary: #475569;
  /* Vechea valoare (#94A3B8) dadea contrast 2.56:1 pe --surface, mult sub
     minimul WCAG AA de 4.5:1 pentru text normal — .muted/.text-muted e
     folosit masiv (timestamp-uri, th din tabele, placeholder-uri), deci
     afecta o parte mare din text. Noua valoare trece 4.5:1 atat pe
     --surface (5.43:1) cat si pe --surface-2 (4.95:1). */
  --text-muted:     #5B6B82;
  --text-inverse:   #FFFFFF;

  /* Granițe */
  --border:       #E2E8F0;
  --border-md:    #CBD5E1;
  --border-focus: #3B82F6;

  /* Status */
  --green-50:  #F0FDF4;
  --green-500: #22C55E;
  --green-600: #16A34A;
  --green-700: #15803D;

  --red-50:    #FFF1F2;
  --red-400:   #F87171;
  --red-500:   #EF4444;
  --red-700:   #B91C1C;

  --amber-50:  #FFFBEB;
  --amber-400: #FBBF24;
  --amber-500: #F59E0B;
  --amber-700: #B45309;

  --blue-50:   #EFF6FF;
  --blue-500:  #3B82F6;
  --blue-700:  #1D4ED8;

  --orange-50:  #FFF7ED;
  --orange-700: #9A3412;

  --purple-50:  #F3E8FF;
  --purple-700: #7C3AED;

  --green-border: #BBF7D0;
  --red-border:   #FECACA;
  --amber-border: #FDE68A;

  /* Shadowing */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.06);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);

  /* Raze */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Sidebar — light mode */
  --sidebar-w:           240px;
  --sidebar-w-collapsed: 64px;
  --sidebar-bg:          #1e293b;
  --sidebar-text:        #94a3b8;
  --sidebar-text-hover:  #f1f5f9;
  --sidebar-active-bg:   rgba(255,255,255,0.10);
  --sidebar-active-text: #ffffff;
  --sidebar-border:      rgba(255,255,255,0.08);

  /* Tranziții */
  --transition:      150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 250ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Alias legacy — compatibilitate cu view-uri existente */
  --card:   var(--surface);
  --line:   var(--border);
  --bg2:    var(--surface-2);
  --brand:  var(--brand-500);
  --accent: var(--accent-500);
  --ok:     var(--green-600);
  --err:    var(--red-700);
  --muted:  var(--text-secondary);
  --text:   var(--text-primary);
  --ink:    var(--text-primary);
}

/* ═══════════════════════════════════════
   DARK MODE
═══════════════════════════════════════ */
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

[data-theme="dark"] {
  --bg:        #0B0F19;
  --surface:   #111827;
  --surface-2: #1A2234;
  --surface-3: #1E2D45;
  --border:    #1E293B;
  --border-md: #334155;
  --text-primary:   #F1F5F9;
  --text-secondary: #94A3B8;
  /* Vechea valoare (#475569) dadea contrast 2.34:1 pe --surface si 2.10:1 pe
     --surface-2, sub minimul AA. Noua valoare trece pe amandoua (5.25:1,
     respectiv 4.70:1) — vezi acelasi comentariu din blocul :root de mai sus. */
  --text-muted:     #7C8DA6;

  --brand-50:  #1E2D45;
  --brand-100: #1E3A5F;

  --green-50:  #052e16;
  --green-600: #4ade80;
  --green-700: #4ade80;
  --red-50:    #450a0a;
  --red-700:   #f87171;
  --amber-50:  #451a03;
  --amber-700: #fbbf24;
  --blue-50:   #0c1a35;
  --blue-700:  #60a5fa;
  --brand-700: #93c5fd;
  --brand-600: #60a5fa;

  --orange-50:  #431407;
  --orange-700: #fdba74;

  --purple-50:  #2e1065;
  --purple-700: #c4b5fd;

  --green-border: #166534;
  --red-border:   #7f1d1d;
  --amber-border: #92400e;

  --sidebar-bg:    #070D1A;
  --sidebar-border: rgba(255,255,255,0.06);

  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);

  --card:   var(--surface);
  --line:   var(--border);
  --brand:  var(--brand-500);
  --accent: var(--accent-500);
  --ok:     var(--green-500);
  --err:    var(--red-400);
  --muted:  var(--text-secondary);
  --text:   var(--text-primary);
  --ink:    var(--text-primary);
}

[data-theme="dark"] body { background: var(--bg); color: var(--text-primary); }
[data-theme="dark"] a { color: #93b4e8; }

/* ═══════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand-500); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--brand-600); }

/* Skip link — invizibil normal, apare doar la focus (primul Tab de pe
   pagina). Fara el, un utilizator de tastatura trebuie sa treaca prin tot
   meniul lateral (15+ linkuri) la fiecare pagina inainte sa ajunga la
   continutul principal. */
.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 2000;
  background: var(--brand-600);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13.5px;
  transition: top var(--transition);
}
.skip-link:focus {
  top: 12px;
  text-decoration: none;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Lucide inline icons */
i[data-lucide].icon    { width:14px; height:14px; display:inline-block; vertical-align:-2px; flex-shrink:0; }
i[data-lucide].icon-sm { width:12px; height:12px; display:inline-block; vertical-align:-1px; flex-shrink:0; }
i[data-lucide].icon-lg { width:16px; height:16px; display:inline-block; vertical-align:-3px; flex-shrink:0; }

/* ═══════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width var(--transition-slow);
  border-right: 1px solid var(--sidebar-border);
  overflow: hidden;
  will-change: transform;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar.collapsed .nav-label,
.sidebar.collapsed .sb-user-info,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .sb-brand-text,
.sidebar.collapsed .sb-search-kbd,
.sidebar.collapsed #theme-toggle,
.sidebar.collapsed .sb-logo { display: none; }

.sidebar.collapsed .nav-icon { margin-right: 0; }
.sidebar.collapsed .sb-toggle svg { transform: rotate(180deg); }
.sidebar.collapsed .sb-top { justify-content: center; }
.sidebar.collapsed .sb-top-actions { margin-left: 0; }

/* Brand */
.sb-top {
  padding: 14px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.brand:hover { text-decoration: none; color: white; }

.sb-logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--brand-500), var(--blue-500));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.05em;
  flex-shrink: 0;
}

.sb-brand-text {
  min-width: 0;
  overflow: hidden;
}

.sb-brand-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.sb-brand-role {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sb-top-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.sb-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  padding: 5px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
}

.sb-icon-btn:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

/* Search */
.sb-search {
  padding: 10px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sb-search-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius);
  padding: 7px 10px;
  color: rgba(255,255,255,0.5);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  font-family: inherit;
}

.sb-search-btn:hover {
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.75);
}

.sb-search-kbd {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: monospace;
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar.collapsed .sb-search-btn { padding: 7px; justify-content: center; }

/* Nav */
.mainnav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.25);
  padding: 10px 10px 4px;
  white-space: nowrap;
  overflow: hidden;
}

.mainnav a,
.sb-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  position: relative;
  transition: all var(--transition);
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  line-height: 1.4;
}

.mainnav a:hover,
.sb-logout:hover {
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}

.mainnav a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.mainnav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent-500);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar.collapsed .mainnav a,
.sidebar.collapsed .sb-logout { justify-content: center; padding: 10px; }

.sidebar.collapsed .mainnav a .nav-label,
.sidebar.collapsed .sb-logout .nav-label { display: none; }

.sidebar.collapsed .mainnav a .nav-icon { width: auto; }

/* Tooltip colapsat */
.sidebar.collapsed .mainnav a::after,
.sidebar.collapsed .sb-notif-btn::after,
.sidebar.collapsed .sb-logout::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-w-collapsed) + 4px);
  background: #1a2744;
  color: #fff;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 300;
}

.sidebar.collapsed .mainnav a:hover::after,
.sidebar.collapsed .sb-notif-btn:hover::after,
.sidebar.collapsed .sb-logout:hover::after { opacity: 1; }

/* Badges */
.sb-badge {
  background: var(--accent-500);
  color: white;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  line-height: 1.4;
  margin-left: auto;
}

.sidebar.collapsed .sb-badge {
  position: absolute;
  top: 4px; right: 4px;
  margin-left: 0;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Bottom user block */
.sb-bottom {
  padding: 8px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.sb-notif-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  transition: all var(--transition);
}

.sb-notif-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}

.sidebar.collapsed .sb-notif-btn { justify-content: center; padding: 10px; }
.sidebar.collapsed .sb-notif-btn .nav-label { display: none; }
.sidebar.collapsed .sb-notif-btn .nav-icon { width: auto; }

.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition);
}
.sb-user:hover { background: rgba(255,255,255,0.07); }
.sb-user-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.35;
  margin-left: auto;
  transition: opacity var(--transition);
}
.sb-user:hover .sb-user-chevron { opacity: 0.7; }
.sidebar.collapsed .sb-user-chevron { display: none; }

.sb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-600);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.sb-user-info {
  min-width: 0;
  overflow: hidden;
}

.sb-user-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-user:hover .sb-user-name { color: white; }

.sb-user-role {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-transform: lowercase;
}

/* ═══════════════════════════════════════
   MAIN WRAP & TOPBAR
═══════════════════════════════════════ */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed ~ .main-wrap {
  margin-left: var(--sidebar-w-collapsed);
}

.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-xs);
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-search,
.topbar-theme {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.topbar-search:hover,
.topbar-theme:hover {
  background: var(--surface-3);
  border-color: var(--border-md);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════
   CONTAINER & LAYOUT
═══════════════════════════════════════ */
main.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px;
  width: 100%;
  flex: 1;
}

.footer {
  max-width: 1280px;
  margin: auto auto 0;
  padding: 14px 28px;
  font-size: 12px;
  color: var(--text-muted);
}

h1 { font-size: 22px; font-weight: 700; margin: 6px 0 20px; letter-spacing: -0.02em; color: var(--text-primary); }
h2 { font-size: 14px; font-weight: 600; margin: 0; letter-spacing: -0.01em; color: var(--text-primary); }
/* Titlul de pagina din fiecare view (ex. "Colete (42)") era un al doilea
   <h1> pe langa cel generic din partials/header.ejs (deja h1, dinamic din
   `title`) — doua h1 pe aceeasi pagina, ierarhie incorecta pentru screen
   reader. Coborate la h2 in toate view-urile, dar pastrate vizual identice
   cu vechiul h1 prin aceasta clasa, ca nicio pagina sa nu-si piarda
   dimensiunea titlului. */
.h2-title { font-size: 22px; font-weight: 700; margin: 6px 0 20px; letter-spacing: -0.02em; color: var(--text-primary); }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 12px; color: var(--text-primary); }

.muted { color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.inline { display: inline; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--red-700); font-weight: 500; }

/* ═══════════════════════════════════════
   PAGE HEADER
═══════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.page-header .page-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* ═══════════════════════════════════════
   CARDS
═══════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition);
  margin-bottom: 20px;
}

.card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-md);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.card-head h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  padding: 18px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.grid-2 .card, .grid-4 .card { margin-bottom: 0; }

/* ═══════════════════════════════════════
   TABLES
═══════════════════════════════════════ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table thead th,
.table th {
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

.table tbody td,
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr:last-child td,
.table tr:last-child td { border-bottom: none; }

.table tbody tr:hover td,
.table tr:hover td { background: var(--surface-2); }

.table tbody tr,
.table tr { transition: background var(--transition); }

/* Legacy alias */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { padding: 10px 14px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); background: var(--surface-2); border-bottom: 1px solid var(--border); text-align: left; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-primary); vertical-align: middle; }
.tbl tr:hover td { background: var(--surface-2); }

[data-theme="dark"] .table thead th,
[data-theme="dark"] .table th,
[data-theme="dark"] .tbl th { background: var(--surface-2); border-bottom-color: var(--border); }
[data-theme="dark"] .table tbody tr:hover td,
[data-theme="dark"] .table tr:hover td,
[data-theme="dark"] .tbl tr:hover td { background: var(--surface-3); }

/* ═══════════════════════════════════════
   BUTTONS
═══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--border-md);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
  letter-spacing: -0.01em;
  font-family: inherit;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-focus);
  color: var(--text-primary);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--brand-500);
  border-color: var(--brand-600);
  color: white;
}
.btn-primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-700);
  color: white;
}

.btn-danger {
  background: var(--red-50);
  border-color: var(--red-400);
  color: var(--red-700);
}
.btn-danger:hover {
  background: var(--red-500);
  color: white;
  border-color: var(--red-500);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.35);
  color: white;
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); color: white; }

.btn-muted {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-muted);
  font-weight: 400;
}
.btn-muted:hover { background: var(--surface-3); color: var(--text-primary); }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

[data-theme="dark"] .btn {
  background: var(--surface-2);
  border-color: var(--border-md);
  color: var(--text-primary);
}
[data-theme="dark"] .btn:hover { background: var(--surface-3); }
[data-theme="dark"] .btn-primary { background: var(--brand-500); border-color: var(--brand-600); color: #fff; }
[data-theme="dark"] .btn-primary:hover { background: var(--brand-600); }

/* ═══════════════════════════════════════
   BADGES STATUS
═══════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 99px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
  flex-shrink: 0;
}

.badge-preluat    { background: var(--blue-50);   color: var(--blue-700); }
.badge-in_tranzit { background: var(--amber-50);  color: var(--amber-700); }
.badge-vama       { background: var(--orange-50); color: var(--orange-700); }
.badge-in_livrare { background: var(--brand-50);  color: var(--brand-600); }
.badge-livrat     { background: var(--green-50);  color: var(--green-700); }
.badge-anulat     { background: var(--red-50);    color: var(--red-700); }
.badge-returnat   { background: var(--purple-50); color: var(--purple-700); }

.table tbody tr.row-preluat    { background: var(--blue-50); }
.table tbody tr.row-in_tranzit { background: var(--amber-50); }
.table tbody tr.row-vama       { background: var(--orange-50); }
.table tbody tr.row-in_livrare { background: var(--brand-50); }
.table tbody tr.row-livrat     { background: var(--green-50); }
.table tbody tr.row-anulat     { background: var(--surface-2); opacity: .7; }
.table tbody tr.row-overdue    { background: var(--red-50); }

.row-actions { display:flex; gap:4px; opacity:0; transition:opacity var(--transition); white-space:nowrap; }
.table tbody tr:hover .row-actions { opacity:1; }
.row-actions .btn-icon { display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:5px; border:1px solid var(--line); background:var(--bg); color:var(--text-muted); cursor:pointer; font-size:12px; text-decoration:none; transition:background var(--transition), color var(--transition), transform var(--transition); }
.row-actions .btn-icon:hover { background:var(--accent); color:#fff; border-color:var(--accent); }
.row-actions .btn-icon:active { transform: scale(0.9); }
.row-actions .btn-icon.danger:hover { background:var(--err); color:#fff; border-color:var(--err); }

.badge-msg-nou,
.badge-msg-in_lucru { background: var(--amber-50);  color: var(--amber-700); }
.badge-msg-citit    { background: var(--surface-2); color: var(--text-muted); }
.badge-msg-raspuns,
.badge-msg-rezolvat { background: var(--green-50);  color: var(--green-700); }
.badge-msg-arhivat  { background: var(--surface-2); color: var(--text-muted); }

/* ═══════════════════════════════════════
   FORMS & INPUTS
═══════════════════════════════════════ */
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.field > span,
.field label > span,
.field > label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field input,
.field select,
.field textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input::placeholder,
textarea::placeholder { color: var(--text-muted); }

.field textarea { min-height: 90px; resize: vertical; }

[data-theme="dark"] .field input,
[data-theme="dark"] .field select,
[data-theme="dark"] .field textarea,
[data-theme="dark"] .toolbar input,
[data-theme="dark"] .toolbar select,
[data-theme="dark"] textarea,
[data-theme="dark"] select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] input[type="password"] {
  background: var(--surface-2);
  border-color: var(--border-md);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════
   FLASH / TOASTS
═══════════════════════════════════════ */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

.flash-ok {
  background: var(--green-50);
  color: var(--green-700);
  border-color: var(--green-border);
}

.flash-err {
  background: var(--red-50);
  color: var(--red-700);
  border-color: var(--red-border);
}

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; }
.alert-warn { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-border); }

[data-theme="dark"] .flash-ok { background: #052e16; color: #86efac; border-color: #166534; }
[data-theme="dark"] .flash-err { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }

/* Toast system */
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid transparent;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: all 0.25s ease;
  max-width: 380px;
  pointer-events: auto;
  position: relative;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-ok  { background: var(--green-50);  color: var(--green-700);  border-color: var(--green-border); }
.toast-err { background: var(--red-50);    color: var(--red-700);    border-color: var(--red-border); }

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

/* ═══════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px 24px 16px;
  position: relative;
}
.login-screen > .login-footer-brand {
  margin-top: 16px;
}

.login-panel {
  display: flex;
  width: 100%;
  max-width: 900px;
  min-height: 540px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  flex: 1;
  background: var(--brand-900);
  padding: 48px;
  display: flex;
  align-items: center;
  color: white;
}

.login-brand-inner { width: 100%; }

.login-brand h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 16px 0 8px;
  color: white;
  letter-spacing: -0.02em;
}

.login-brand p {
  color: rgba(255,255,255,0.55);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 32px;
}

.mc-logo-lg {
  width: 58px;
  height: 58px;
  background: var(--accent-500);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.05em;
}

.mc-logo-sm {
  width: 40px;
  height: 40px;
  background: var(--brand-500);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.05em;
  margin-bottom: 16px;
}

.login-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-feat {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
}

.login-feat span {
  color: var(--accent-400);
  font-weight: 700;
}
.login-feat svg {
  color: var(--accent-400);
  flex-shrink: 0;
}

.login-form-panel {
  flex: 0 0 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}

.login-form-inner { width: 100%; }
.login-form-inner .field { gap: 7px; margin-bottom: 18px; }
.login-form-inner .form-grid { gap: 0; }
.login-form-inner input::placeholder { color: var(--text-muted); opacity: 1; }

.login-header { margin-bottom: 28px; }

.login-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.login-header p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* Legacy login wrap */
.login-wrap { display: grid; place-items: center; min-height: 70vh; }
.login-card { width: 380px; max-width: 92vw; padding: 28px; }
.login-card h1 { margin: 0 0 4px; }

.login-mobile-brand { display: none; }

@media (max-width: 680px) {
  .login-brand { display: none; }
  .login-form-panel { flex: 1; padding: 32px 24px; }
  .login-panel { max-width: 420px; min-height: auto; }
  .login-screen { justify-content: center; padding-bottom: 48px; }
  .login-footer-brand { position: absolute; bottom: 16px; left: 0; right: 0; }
  .login-mobile-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border, #e2e8f0);
  }
}

[data-theme="dark"] .login-brand { background: #050A14; }
[data-theme="dark"] .login-panel { border-color: var(--border); }

.login-footer-brand {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.login-screen-page .footer {
  display: none !important;
}

/* Pagina login — fără sidebar, deci resetăm offset-ul și padding-ul */
.login-screen-page .main-wrap {
  margin-left: 0 !important;
}
.login-screen-page main.container {
  max-width: 100%;
  padding: 0;
}

/* ═══════════════════════════════════════
   TOOLBAR
═══════════════════════════════════════ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.toolbar input[type="search"],
.toolbar input[type="text"],
.toolbar select {
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: 13px;
  width: auto;
}

/* ═══════════════════════════════════════
   CONFIRM MODAL (inlocuieste window.confirm())
═══════════════════════════════════════ */
.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: confirmModalFadeIn 0.15s ease;
}

@keyframes confirmModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.confirm-modal-box {
  width: 420px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.04);
  padding: 24px;
}

.confirm-modal-msg {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
}

.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ═══════════════════════════════════════
   CTRL+K SEARCH PALETTE
═══════════════════════════════════════ */
#ck-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

#ck-overlay.open { display: flex; }

#ck-box {
  width: 580px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.04);
  overflow: hidden;
}

/* Support both old id (ck-input-wrap) and new (ck-input-row) */
#ck-input-wrap,
#ck-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

#ck-icon { font-size: 16px; color: var(--text-muted); flex-shrink: 0; }

#ck-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
}

#ck-esc {
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border-md);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--surface-2);
  font-family: inherit;
}

#ck-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
}

.ck-section { padding: 6px 12px 3px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.ck-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  transition: background var(--transition);
}

.ck-item:hover,
.ck-item.active {
  background: var(--brand-50);
  color: var(--brand-600);
  text-decoration: none;
}

.ck-item-icon { font-size: 15px; flex-shrink: 0; width: 22px; text-align: center; }
.ck-item-main { flex: 1; min-width: 0; }
.ck-item-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ck-item-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.ck-badge { font-size: 11px; padding: 2px 7px; border-radius: 20px; flex-shrink: 0; font-weight: 600; }
.ck-empty { padding: 20px 16px; text-align: center; color: var(--text-muted); font-size: 14px; }

.ck-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 14px;
  align-items: center;
}

.ck-footer kbd,
.ck-shortcut kbd {
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: monospace;
}

[data-theme="dark"] #ck-box {
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.05);
}

[data-theme="dark"] .ck-item:hover,
[data-theme="dark"] .ck-item.active {
  background: var(--surface-3);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════
   KPI CARDS
═══════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .kpi-grid { grid-template-columns: 1fr 1fr; } }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
  display: block;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-md);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Legacy kpi-icon support */
.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.kpi-icon.blue   { background: var(--blue-50); }
.kpi-icon.green  { background: var(--green-50); }
.kpi-icon.red    { background: var(--red-50); }
.kpi-icon.orange { background: var(--amber-50); }
.kpi-icon.gray   { background: var(--surface-2); }

.kpi-body { min-width: 0; }

.kpi-num {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.kpi-num.green  { color: var(--green-700); }
.kpi-num.red    { color: var(--red-700); }
.kpi-num.orange { color: var(--amber-700); }

.kpi-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
}

.kpi-trend.up    { background: var(--green-50);  color: var(--green-700); }
.kpi-trend.warn  { background: var(--amber-50);  color: var(--amber-700); }
.kpi-trend.zero  { background: var(--surface-2); color: var(--text-muted); }
.kpi-trend.down  { background: var(--red-50);    color: var(--red-700); }

/* Legacy kpi-today */
.kpi-today {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 8px;
  line-height: 1.6;
  margin-right: 4px;
}

.kpi-today.pos { color: var(--green-700); border-color: var(--green-border); background: var(--green-50); }
.kpi-today.zero { color: var(--text-muted); }

.kpi-accent-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: var(--radius) 0 0 var(--radius);
}
.kpi-accent-bar.blue   { background: var(--blue-700); }
.kpi-accent-bar.green  { background: var(--green-700); }
.kpi-accent-bar.red    { background: var(--red-700); }
.kpi-accent-bar.orange { background: var(--accent-500); }
.kpi-accent-bar.gray   { background: var(--border-md); }

/* ═══════════════════════════════════════
   QUICK ACTIONS
═══════════════════════════════════════ */
.quick-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.qa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.qa-btn:hover {
  background: var(--surface);
  border-color: var(--brand-500);
  color: var(--brand-600);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
}

.qa-icon { font-size: 14px; display: flex; align-items: center; }

.qa-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--red-500);
  color: white;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  line-height: 1.4;
  min-width: 16px;
}

/* ═══════════════════════════════════════
   STATUS MINI
═══════════════════════════════════════ */
.status-mini-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.status-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-secondary);
  transition: all var(--transition);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
}

.status-mini .n {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.status-mini:hover {
  border-color: var(--brand-500);
  background: var(--brand-50);
  color: var(--brand-600);
  text-decoration: none;
}

/* ═══════════════════════════════════════
   CLIENTS WIDGET
═══════════════════════════════════════ */
.clients-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-xs);
}

.clients-widget .cw-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.clients-widget .cw-bar {
  flex: 1;
  min-width: 120px;
  height: 6px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}

.clients-widget .cw-bar-fill {
  height: 100%;
  background: var(--green-600);
  border-radius: 99px;
  transition: width 0.4s ease;
}

.clients-widget .cw-stats {
  display: flex;
  gap: 14px;
  font-size: 13px;
  white-space: nowrap;
}

.clients-widget .cw-stat { display: flex; align-items: center; gap: 5px; }
.clients-widget .cw-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.clients-widget .cw-n { font-weight: 700; color: var(--text-primary); }
.clients-widget .cw-lbl { color: var(--text-muted); }
.clients-widget a { text-decoration: none; color: inherit; }
.clients-widget a:hover .cw-n { text-decoration: underline; }

/* ═══════════════════════════════════════
   TREND BADGES (stats)
═══════════════════════════════════════ */
.trend-badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 99px; margin-left: 6px; vertical-align: middle; }
.trend-up   { background: var(--green-50);  color: var(--green-700); }
.trend-down { background: var(--red-50);    color: var(--red-700); }

/* ═══════════════════════════════════════
   STAT BLOCKS
═══════════════════════════════════════ */
.stat { text-align: center; padding: 20px 12px; margin-bottom: 0; }
.stat-num { font-size: 32px; font-weight: 800; color: var(--brand-500); letter-spacing: -0.03em; }
.stat-label { color: var(--text-muted); margin-top: 4px; font-size: 13px; }
.stat-attn .stat-num { color: var(--accent-500); }

/* ═══════════════════════════════════════
   BAR CHARTS
═══════════════════════════════════════ */
.bar-row { display: grid; grid-template-columns: 130px 1fr 60px; gap: 10px; align-items: center; margin-bottom: 6px; font-size: 14px; }
.bar-track { background: var(--surface-2); border-radius: 6px; height: 16px; overflow: hidden; }
.bar-fill { background: var(--brand-500); height: 100%; border-radius: 6px; min-width: 2px; }

/* ═══════════════════════════════════════
   TIMELINE
═══════════════════════════════════════ */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--border); margin-left: 8px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px; top: 3px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent-500);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline .tl-head { font-weight: 600; }
.timeline .tl-meta { color: var(--text-muted); font-size: 13px; }

/* ═══════════════════════════════════════
   KANBAN
═══════════════════════════════════════ */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
}

.kanban-col {
  flex: 0 0 270px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.kanban-col-header {
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin: 8px;
  cursor: grab;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}

.kanban-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-md);
}

.kanban-card:active { cursor: grabbing; }

.kanban-cards.drag-over { background: var(--brand-50); }

[data-theme="dark"] .kanban-cards.drag-over { background: var(--surface-3); }

/* ═══════════════════════════════════════
   CODE
═══════════════════════════════════════ */
code.code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'Fira Code', 'Cascadia Code', Menlo, monospace;
  color: var(--text-primary);
}

/* ═══════════════════════════════════════
   PAGE LOADER (slim top bar)
═══════════════════════════════════════ */
#page-loader {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-500), var(--blue-500), var(--accent-500));
  background-size: 200% 100%;
  z-index: 9999;
  display: none;
  animation: loader-slide 1.2s linear infinite;
}

#page-loader.active { display: block; }

@keyframes loader-slide {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════
   LIGHT MODE — sidebar overrides
═══════════════════════════════════════ */
[data-theme="light"] {
  --sidebar-bg:          #f1f5f9;
  --sidebar-text:        #475569;
  --sidebar-text-hover:  #0f172a;
  --sidebar-active-bg:   rgba(59,130,246,0.10);
  --sidebar-active-text: #1d4ed8;
  --sidebar-border:      rgba(0,0,0,0.08);
}
[data-theme="light"] .sidebar { border-right: 1px solid rgba(0,0,0,0.08); }
[data-theme="light"] .sb-top { border-bottom-color: rgba(0,0,0,0.08); }
[data-theme="light"] .brand,
[data-theme="light"] .brand:hover { color: #0f172a; }
[data-theme="light"] .sb-brand-name { color: #0f172a; }
[data-theme="light"] .sb-brand-role { color: #64748b; }
[data-theme="light"] .sidebar-section-label { color: #94a3b8; }
[data-theme="light"] .sb-icon-btn { color: #64748b; }
[data-theme="light"] .sb-icon-btn:hover { background: rgba(0,0,0,0.06); color: #0f172a; }
[data-theme="light"] .sb-search-btn { background: #fff; border-color: rgba(0,0,0,0.12); color: #64748b; }
[data-theme="light"] .sb-search-btn:hover { background: rgba(0,0,0,0.04); color: #0f172a; }
[data-theme="light"] .sb-search-kbd { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.12); color: #64748b; }
[data-theme="light"] .mainnav a:hover,
[data-theme="light"] .sb-logout:hover { background: rgba(0,0,0,0.05); }
[data-theme="light"] .mainnav a.active::before { background: #1d4ed8; }
[data-theme="light"] .sb-bottom { border-top-color: rgba(0,0,0,0.08); }
[data-theme="light"] .sb-user-name { color: #0f172a; }
[data-theme="light"] .sb-user-role { color: #64748b; }

/* ═══════════════════════════════════════
   DARK MODE — component overrides
═══════════════════════════════════════ */
[data-theme="dark"] .sidebar { box-shadow: inset -1px 0 0 var(--sidebar-border); }
[data-theme="dark"] .card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .topbar { background: var(--surface); border-bottom-color: var(--border); }
[data-theme="dark"] .toolbar { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .quick-actions { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .kpi-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .status-mini { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .qa-btn { background: var(--surface-2); border-color: var(--border-md); }
[data-theme="dark"] .clients-widget { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .kpi-today { background: var(--surface-2); border-color: var(--border-md); }
[data-theme="dark"] #ck-input { color: var(--text-primary); }

/* ═══════════════════════════════════════
   RESPONSIVE — MOBILE
═══════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    z-index: 300;
    width: var(--sidebar-w) !important;
    top: 0;
    bottom: auto;
    height: 100dvh;
  }

  .sidebar.mob-open { transform: translateX(0); }

  .sb-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow);
  }

  .sb-backdrop.mob-open {
    opacity: 1;
    pointer-events: all;
  }

  .main-wrap { margin-left: 0 !important; }

  .topbar { padding-left: 56px; }

  .mob-menu-btn {
    display: flex;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 150;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
  }

  .mob-menu-btn:hover { background: var(--surface-2); }

  main.container { padding: 20px; }
  h1 { font-size: 20px; margin-bottom: 14px; }
  .h2-title { font-size: 20px; margin-bottom: 14px; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 14px 16px; }
  .kpi-num { font-size: 24px; }

  .table { min-width: 520px; }
  .table.table-kv { min-width: 0; }
  .card { overflow-x: auto; }
  .table th, .table td { padding: 8px 10px; }
  .table .col-hide-sm { display: none; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input, .toolbar select, .toolbar .btn { width: 100%; }

  #toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { max-width: 100%; }
  .sb-toggle { display: none !important; }
}

@media (min-width: 769px) {
  .mob-menu-btn { display: none; }
  .sb-backdrop { display: none !important; }
}

@media (max-width: 640px) {
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
  }
  .table-wrap .table,
  .card[style*="overflow-x"] .table { min-width: 640px; }

  .grid-2, .grid-4 { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════
   DIALOG CONFIRMARE
═══════════════════════════════════════ */
.mc-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mc-modal-overlay[hidden] { display: none; }
.mc-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-1);
  padding: 24px;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.mc-dialog p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
}
.mc-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
