/* ============================================================
   MEYLER — Design System CSS
   tokens + components + Bootstrap overrides
   ============================================================ */

/* ── 1. DESIGN TOKENS ──────────────────────────────────────── */
:root {
  --brand-magenta: #C026D3;
  --brand-violet:  #7C2AED;
  --brand-indigo:  #5B21B6;
  --brand-deep:    #3B1359;
  --grad-brand: linear-gradient(135deg, #D026D3 0%, #8B2BE2 50%, #5B21B6 100%);
  --grad-brand-soft: linear-gradient(135deg, rgba(208,38,211,0.16) 0%, rgba(91,33,182,0.16) 100%);
  --grad-brand-glow: radial-gradient(60% 60% at 30% 30%, rgba(208,38,211,0.45) 0%, rgba(91,33,182,0.0) 70%);

  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   22px;
  --r-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  --font-ui:   'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --t-fast: 140ms cubic-bezier(.2,.7,.3,1);
  --t-med:  240ms cubic-bezier(.2,.7,.3,1);

  --sidebar-w:           248px;
  --sidebar-w-collapsed: 72px;
  --topbar-h:            64px;
}

/* ── LIGHT THEME ───────────────────────────────────────────── */
[data-theme="light"] {
  --bg:            oklch(99% 0.004 300);
  --bg-subtle:     oklch(97% 0.008 300);
  --surface:       #ffffff;
  --surface-2:     oklch(98% 0.006 300);
  --elevated:      #ffffff;
  --border:        oklch(92% 0.012 300);
  --border-strong: oklch(86% 0.02  300);
  --hover:         oklch(96% 0.012 300);

  --text:          oklch(20% 0.04 295);
  --text-muted:    oklch(48% 0.025 295);
  --text-subtle:   oklch(62% 0.02  295);
  --text-invert:   #ffffff;

  --accent:        #7C2AED;
  --accent-soft:   rgba(124,42,237,0.10);
  --accent-text:   #5B21B6;

  --positive:      oklch(55% 0.16 150);
  --positive-soft: oklch(94% 0.05 150);
  --negative:      oklch(58% 0.22  28);
  --negative-soft: oklch(95% 0.04  28);
  --warning:       oklch(70% 0.15  75);

  --shadow-sm:   0 1px 2px rgba(40,14,70,.04);
  --shadow-md:   0 4px 14px rgba(40,14,70,.06), 0 1px 2px rgba(40,14,70,.04);
  --shadow-lg:   0 16px 40px rgba(40,14,70,.10), 0 2px 6px rgba(40,14,70,.05);
  --shadow-glow: 0 8px 32px rgba(124,42,237,.18);

  --sidebar-bg:   oklch(98% 0.006 300);
  --sidebar-text: oklch(30% 0.04  295);
  --grid-line:    rgba(60,20,95,.06);
}

/* ── DARK THEME ────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:            oklch(13% 0.025 295);
  --bg-subtle:     oklch(15% 0.03  295);
  --surface:       oklch(17% 0.035 295);
  --surface-2:     oklch(20% 0.04  295);
  --elevated:      oklch(22% 0.045 295);
  --border:        oklch(26% 0.035 295);
  --border-strong: oklch(34% 0.045 295);
  --hover:         oklch(22% 0.045 295);

  --text:          oklch(96% 0.008 300);
  --text-muted:    oklch(70% 0.02  300);
  --text-subtle:   oklch(55% 0.025 295);
  --text-invert:   oklch(15% 0.03  295);

  --accent:        #B450FF;
  --accent-soft:   rgba(180,80,255,.14);
  --accent-text:   #D8A8FF;

  --positive:      oklch(72% 0.18 150);
  --positive-soft: oklch(28% 0.08 150);
  --negative:      oklch(70% 0.22  28);
  --negative-soft: oklch(28% 0.08  28);
  --warning:       oklch(78% 0.16  75);

  --shadow-sm:   0 1px 2px rgba(0,0,0,.30);
  --shadow-md:   0 4px 14px rgba(0,0,0,.32), 0 1px 2px rgba(0,0,0,.20);
  --shadow-lg:   0 20px 50px rgba(0,0,0,.45), 0 4px 8px rgba(0,0,0,.25);
  --shadow-glow: 0 8px 36px rgba(180,80,255,.32);

  --sidebar-bg:   oklch(11% 0.025 295);
  --sidebar-text: oklch(78% 0.02  300);
  --grid-line:    rgba(255,255,255,.05);
}

/* ── 2. BASE / RESET ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0; padding: 0;
}

body {
  font-family: var(--font-ui) !important;
  font-size: 14px;
  color: var(--text) !important;
  background: var(--bg) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01","cv11";
  /* NO transition here — added via JS after load to avoid black flash on navigation */
}
/* Theme transitions enabled only after page has fully loaded */
body.theme-ready,
body.theme-ready * {
  transition: background-color var(--t-med), color var(--t-med), border-color var(--t-med) !important;
}

button  { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
a       { color: inherit; text-decoration: none; }

/* ── 3. APP SHELL ──────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  transition: grid-template-columns var(--t-med);
}
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ── 4. SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: relative;
  overflow: hidden;
}
.sidebar::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--grad-brand-glow);
  opacity: .45;
  pointer-events: none;
}
[data-theme="dark"] .sidebar::before { opacity: .55; }
.sidebar > * { position: relative; }

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.brand-mark {
  width: 36px; height: 36px;
  background: var(--grad-brand);
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
  overflow: hidden;
}
.brand-mark img {
  width: 28px; height: 28px; object-fit: contain;
  filter: brightness(0) invert(1); /* always white on gradient background */
}
.brand-name {
  font-weight: 700; font-size: 18px; letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
}
.collapsed .brand-name { display: none; }
.collapsed .brand { justify-content: center; padding: 14px 0; }

.nav {
  padding: 12px;
  display: flex; flex-direction: column; flex-wrap: nowrap;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Ripristina il comportamento orizzontale dei nav Bootstrap (es. nav-tabs, nav-pills) */
.nav.nav-tabs,
.nav.nav-pills {
  flex-direction: row;
  flex-wrap: wrap;
  padding: 0;
  gap: 0;
  flex: unset;
  min-height: unset;
  overflow: visible;
}

.nav-section-label {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 14px 12px 6px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--r-sm);
  transition: color var(--t-fast);
}
.nav-section-label:hover { color: var(--text-muted); }
.nav-section-label .section-chevron {
  font-size: 12px;
  transition: transform var(--t-fast);
  flex-shrink: 0;
}
.nav-section-label.collapsed-section .section-chevron { transform: rotate(-90deg); }
.nav-section-items.hidden { display: none; }
.collapsed .nav-section-label { display: none; }
.collapsed .section-chevron { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 14px;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
  white-space: nowrap;
  text-decoration: none;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--grad-brand);
  border-radius: 0 4px 4px 0;
}
.nav-item .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; }
.collapsed .nav-item { justify-content: center; padding: 10px; }
.collapsed .nav-label { display: none; }
.collapsed .nav-item.active::before { left: -12px; }

.nav-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
}
.user-card:hover { background: var(--hover); }
.user-avatar-wrap {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--grad-brand);
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.collapsed .user-meta { display: none; }
.collapsed .user-card { justify-content: center; }
.collapsed .nav-foot { padding: 12px 0; display: flex; justify-content: center; }

/* ── 5. TOPBAR ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: grid; place-items: center;
  transition: all var(--t-fast);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--text); border-color: var(--border); }
.crumbs {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 13px;
}
.crumbs .crumb-current { color: var(--text); font-weight: 600; }
.crumbs .crumb-sep { opacity: 0.5; }

.topbar-search {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 12px;
  height: 36px;
  width: 260px;
  color: var(--text-muted);
  transition: border-color var(--t-fast);
}
.topbar-search:focus-within { border-color: var(--accent); }
.topbar-search input {
  border: none; background: transparent;
  outline: none; flex: 1;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-ui);
}
.topbar-search input::placeholder { color: var(--text-subtle); }

/* ── 6. MAIN / SCROLL ──────────────────────────────────────── */
.main {
  display: flex; flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.page-scroll {
  flex: 1; overflow-y: auto;
  padding: 28px 32px 60px;
}
.page-scroll::-webkit-scrollbar { width: 10px; }
.page-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
  border: 2px solid var(--bg);
}
.page-scroll::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px; margin-bottom: 28px; flex-wrap: wrap;
}
.page-title {
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.02em; color: var(--text);
  margin: 0 0 4px;
}
.page-subtitle {
  font-size: 14px; color: var(--text-muted); margin: 0;
}

/* ── 7. CARD ───────────────────────────────────────────────── */
.card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: none !important;
}
.card-body  { color: var(--text) !important; }
.card-header {
  background: var(--surface-2) !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text) !important;
}
.card-footer {
  background: var(--surface-2) !important;
  border-top: 1px solid var(--border) !important;
  color: var(--text) !important;
}

/* ── 8. BUTTONS ────────────────────────────────────────────── */
/* Base layout — works with OR without Bootstrap */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  height: 40px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  /* Visual */
  font-family: var(--font-ui) !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  border-radius: var(--r-md) !important;
  transition: all var(--t-fast) !important;
  line-height: 1;
}
.btn-primary, .btn-primary:focus {
  background: var(--grad-brand) !important;
  border-color: transparent !important;
  color: #fff !important;
  box-shadow: 0 4px 16px rgba(124,42,237,.32) !important;
}
.btn-primary:hover { filter: brightness(1.07) !important; transform: translateY(-1px) !important; }
.btn-secondary {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}
.btn-secondary:hover { background: var(--hover) !important; border-color: var(--border-strong) !important; }
.btn-outline-secondary {
  background: transparent !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}
.btn-outline-secondary:hover { background: var(--hover) !important; color: var(--text) !important; border-color: var(--border-strong) !important; }
.btn-outline-primary {
  background: transparent !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}
.btn-outline-primary:hover { background: var(--accent-soft) !important; }
.btn-danger {
  background: var(--negative-soft) !important;
  border-color: var(--negative) !important;
  color: var(--negative) !important;
}
.btn-outline-danger {
  background: transparent !important;
  border-color: var(--negative) !important;
  color: var(--negative) !important;
}
.btn-outline-danger:hover { background: var(--negative-soft) !important; }
.btn-outline-warning {
  background: transparent !important;
  border-color: var(--warning) !important;
  color: var(--warning) !important;
}
.btn-outline-warning:hover { background: color-mix(in oklch, var(--warning) 12%, transparent) !important; }
.btn-outline-info {
  background: transparent !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}
.btn-link { color: var(--accent) !important; text-decoration: none !important; }
.btn-link:hover { color: var(--accent-text) !important; }
.btn-sm { height: 32px !important; padding: 0 12px !important; font-size: 12px !important; }
.btn-close { filter: invert(1) !important; opacity: 0.6 !important; }
.btn-close:hover { opacity: 1 !important; }

/* ── 9. FORMS ──────────────────────────────────────────────── */

/* Base layout — works with OR without Bootstrap */
.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 10px 14px;
  height: 44px;
  line-height: 1.5;
  appearance: none;
  -webkit-appearance: none;
}
textarea.form-control { height: auto; resize: vertical; }

/* Visual overrides (with !important to beat Bootstrap) */
.form-control,
.form-select {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important;
  color: var(--text) !important;
  font-size: 14px !important;
  font-family: var(--font-ui) !important;
  transition: border-color var(--t-fast), box-shadow var(--t-fast) !important;
}
.form-control:focus,
.form-select:focus {
  outline: none !important;
  background: var(--surface) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
  color: var(--text) !important;
}
.form-control::placeholder { color: var(--text-subtle) !important; }
.form-label {
  display: block;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--text-muted) !important;
  margin-bottom: 6px !important;
}
.form-text { color: var(--text-subtle) !important; font-size: 11px !important; }
.form-control-color { width: 56px !important; height: 40px !important; padding: 3px 5px !important; cursor: pointer; }
.input-group-text {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

/* btn-block (no Bootstrap) */
.btn-block { display: block; width: 100%; }

/* ── 10. TABLES ────────────────────────────────────────────── */
.table { color: var(--text) !important; }
.table > :not(caption) > * > * { background-color: transparent !important; box-shadow: none !important; }
.table thead th,
.table th {
  font-size: 11px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  font-weight: 600 !important;
  color: var(--text-subtle) !important;
  padding: 12px 16px !important;
  border-bottom: 1px solid var(--border) !important;
  background: var(--surface-2) !important;
  border-top: none !important;
}
.table td {
  padding: 13px 16px !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-size: 13.5px !important;
  border-top: none !important;
}
.table tr:last-child td { border-bottom: none !important; }
.table-sm th { padding: 8px 12px !important; font-size: 10px !important; }
.table-sm td { padding: 8px 12px !important; font-size: 12px !important; }
.table-hover tbody tr:hover td,
.table-hover > tbody > tr:hover > * { background: var(--hover) !important; cursor: pointer; }
.table-responsive { border-radius: var(--r-md); overflow: hidden; }

/* ── 11. MODALS ────────────────────────────────────────────── */
.modal-backdrop { background: rgba(20,8,35,.55) !important; backdrop-filter: blur(6px); }
.modal-content {
  background: var(--elevated) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-xl) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-lg) !important;
}
.modal-header {
  border-bottom: 1px solid var(--border) !important;
  padding: 20px 24px 12px !important;
}
.modal-title {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: var(--text) !important;
  letter-spacing: -0.01em;
}
.modal-body { padding: 16px 24px !important; }
.modal-footer {
  border-top: 1px solid var(--border) !important;
  padding: 16px 24px 20px !important;
}

/* ── 12. BADGES ────────────────────────────────────────────── */
.badge {
  border-radius: var(--r-pill) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em;
}
.bg-primary  { background: var(--accent)        !important; color: #fff !important; }
.bg-success  { background: var(--positive)      !important; color: #fff !important; }
.bg-danger   { background: var(--negative)      !important; color: #fff !important; }
.bg-warning  { background: var(--warning)       !important; color: #111 !important; }
.bg-secondary {
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border);
}
.bg-opacity-10 { opacity: 1 !important; }
.bg-warning.bg-opacity-10 {
  background: color-mix(in oklch, var(--warning) 15%, transparent) !important;
  color: var(--warning) !important;
}

/* ── 13. NAV TABS ──────────────────────────────────────────── */
.nav-tabs {
  border-bottom: 1px solid var(--border) !important;
  gap: 4px;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  padding: 0 !important;
  overflow: visible !important;
}
/* .nav-item sidebar override non deve valere dentro nav-tabs/nav-pills */
.nav-tabs .nav-item,
.nav-pills .nav-item {
  width: auto !important;
  padding: 0 !important;
  background: transparent !important;
  border-radius: 0 !important;
}
.nav-tabs .nav-link {
  color: var(--text-muted) !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  background: transparent !important;
  border-radius: 0 !important;
  padding: 10px 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  transition: all var(--t-fast) !important;
}
.nav-tabs .nav-link:hover { color: var(--text) !important; }
.nav-tabs .nav-link.active {
  color: var(--accent-text) !important;
  border-bottom-color: var(--accent) !important;
  background: transparent !important;
}

/* ── 14. DROPDOWNS ─────────────────────────────────────────── */
.dropdown-menu {
  background: var(--elevated) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 6px !important;
}
.dropdown-item {
  color: var(--text) !important;
  border-radius: var(--r-md) !important;
  font-size: 13px !important;
  padding: 8px 12px !important;
  transition: background var(--t-fast) !important;
}
.dropdown-item:hover, .dropdown-item:focus { background: var(--hover) !important; }
.dropdown-divider { border-color: var(--border) !important; }

/* ── 15. PROGRESS ──────────────────────────────────────────── */
.progress {
  background: var(--surface-2) !important;
  border-radius: var(--r-pill) !important;
  border: 1px solid var(--border) !important;
  height: 6px !important;
}
.progress-bar { background: var(--grad-brand) !important; border-radius: var(--r-pill) !important; }

/* ── 16. TEXT UTILITIES ────────────────────────────────────── */
.text-muted    { color: var(--text-muted)   !important; }
.text-dark     { color: var(--text)         !important; }
.text-light    { color: var(--text)         !important; }
.text-primary  { color: var(--accent)       !important; }
.text-success  { color: var(--positive)     !important; }
.text-danger   { color: var(--negative)     !important; }
.text-warning  { color: var(--warning)      !important; }
.text-info     { color: var(--accent)       !important; }
.text-reset    { color: var(--text)         !important; }

/* ── 17. BORDER UTILITIES ──────────────────────────────────── */
.border-bottom, .border-top, .border-end, .border-start, .border {
  border-color: var(--border) !important;
}

/* ── 18. PAGE-LEVEL LAYOUT HELPERS ────────────────────────── */
.container-fluid { padding-left: 0 !important; padding-right: 0 !important; }

/* ── 19. MISC COMPONENT STYLES ─────────────────────────────── */

/* Status badges for projects */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.status-planning    { background: var(--surface-2); color: var(--text-subtle); border: 1px solid var(--border); }
.status-in_progress { background: var(--accent-soft); color: var(--accent-text); }
.status-completed   { background: var(--positive-soft); color: var(--positive); }
.status-on_hold     { background: color-mix(in oklch, var(--warning) 15%, transparent); color: var(--warning); }
.act-status-todo        { background: var(--surface-2);   color: var(--text-subtle); border: 1px solid var(--border); border-radius: var(--r-pill); font-size: 11px; font-weight: 600; padding: 3px 8px; }
.act-status-in_progress { background: var(--accent-soft); color: var(--accent-text); border-radius: var(--r-pill); font-size: 11px; font-weight: 600; padding: 3px 8px; }
.act-status-done        { background: var(--positive-soft); color: var(--positive); border-radius: var(--r-pill); font-size: 11px; font-weight: 600; padding: 3px 8px; }

/* Progress thin bar (projects) */
.progress-thin {
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-thin .bar {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--grad-brand);
  transition: width .4s;
}

/* Stat pill */
.stat-pill { font-size: .75rem; color: var(--text-muted); }

/* No projects empty state */
.no-projects { opacity: .7; text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* Finance stat blocks */
.finance-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}

/* Progress bar custom (detail page) */
.progress-bar-custom {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-bar-custom .fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--grad-brand);
  transition: width .5s;
}

/* Document item */
.doc-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--t-fast);
}
.doc-item:hover { border-color: var(--border-strong); }
.doc-icon { font-size: 1.4rem; min-width: 28px; text-align: center; color: var(--text-muted); }

/* Gantt chart */
.gantt-wrap { overflow-x: auto; }
.gantt-container { min-width: 800px; }
.gantt-row { display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.gantt-row:last-child { border-bottom: none; }
.gantt-label { min-width: 180px; max-width: 180px; padding: 8px 12px; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--border); color: var(--text-muted); }
.gantt-chart { flex: 1; position: relative; height: 34px; }
.gantt-bar { position: absolute; top: 5px; height: 24px; border-radius: 5px; cursor: pointer; transition: opacity .15s; display: flex; align-items: center; padding: 0 8px; font-size: .72rem; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.gantt-bar:hover { opacity: .8; }
.gantt-header { display: flex; align-items: center; border-bottom: 2px solid var(--border); }
.gantt-header-label { min-width: 180px; max-width: 180px; padding: 6px 12px; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-subtle); border-right: 1px solid var(--border); }
.gantt-header-dates { flex: 1; display: flex; }
.gantt-month-tick { font-size: .68rem; color: var(--text-muted); border-left: 1px solid var(--border); padding: 4px 6px; }
.gantt-today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--negative); opacity: .7; z-index: 2; pointer-events: none; }
.gantt-empty { text-align: center; padding: 32px; color: var(--text-muted); font-size: .85rem; }
.gantt-milestone { position: absolute; top: 7px; width: 20px; height: 20px; transform: rotate(45deg); border-radius: 3px; cursor: pointer; z-index: 3; }
.gantt-milestone:hover { opacity: .8; }

/* Admin dashboard */
.kpi-card-adm {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
}
.kpi-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1; font-family: var(--font-mono); }
.kpi-sub   { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.positive  { color: var(--positive) !important; }
.negative  { color: var(--negative) !important; }
.neutral   { color: var(--accent) !important; }
.upcoming-badge { font-size: .68rem; padding: .22em .6em; border-radius: var(--r-pill); font-weight: 600; }
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.section-title-small {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-subtle);
  margin-bottom: 12px;
  font-weight: 600;
}

/* Expense category badge */
.cat-badge {
  font-size: .68rem;
  padding: .22em .6em;
  border-radius: var(--r-pill);
  font-weight: 600;
  text-transform: capitalize;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.receipt-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; cursor: pointer; }

/* Mono numbers */
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── 20. LOGIN PAGE ────────────────────────────────────────── */
.login-shell {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.login-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lb-orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: .6;
}
.lb-orb-1 {
  top: -200px; left: -160px; width: 520px; height: 520px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 60%);
}
.lb-orb-2 {
  bottom: -240px; right: -200px; width: 600px; height: 600px;
  background: radial-gradient(circle, var(--brand-magenta) 0%, transparent 60%);
  opacity: .45;
}
.lb-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 50%, black 0%, transparent 70%);
  opacity: .35;
}
.login-topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px;
}
.login-topbar-brand {
  display: flex; align-items: center; gap: 10px;
}
.login-topbar-brand .brand-mark {
  width: 36px; height: 36px;
  background: var(--grad-brand);
  border-radius: 10px;
  display: grid; place-items: center;
  box-shadow: var(--shadow-glow);
  overflow: hidden;
  flex-shrink: 0;
}
.login-topbar-brand .brand-mark img {
  width: 28px; height: 28px; object-fit: contain;
  filter: brightness(0) invert(1);
}
.login-topbar-brand span { font-weight: 700; font-size: 18px; color: var(--text); }

.login-grid {
  position: relative; z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}
@media (max-width: 960px) {
  .login-grid { grid-template-columns: 1fr; }
  .login-hero  { display: none; }
}

.login-hero {
  position: relative;
  padding: 48px 56px 56px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.login-hero::before {
  content: ""; position: absolute; inset: 24px;
  border-radius: 28px;
  background: var(--grad-brand);
  box-shadow: var(--shadow-glow);
  opacity: .92;
}
.login-hero::after {
  content: ""; position: absolute; inset: 24px;
  border-radius: 28px;
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(255,255,255,.18) 0%, transparent 50%),
    radial-gradient(80%  80% at 100% 100%, rgba(0,0,0,.18) 0%, transparent 60%);
}
.login-hero-inner {
  position: relative; z-index: 1;
  padding: 36px;
  color: white;
  flex: 1;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.24);
  color: white; font-size: 12px; font-weight: 500;
  backdrop-filter: blur(8px);
  width: fit-content;
}
.login-headline {
  font-size: clamp(36px, 4.5vw, 56px);
  font-weight: 700; line-height: 1.04;
  letter-spacing: -0.025em;
  margin: 24px 0 0 0;
  color: white;
}
.login-sub {
  font-size: 16px; line-height: 1.6;
  margin-top: 16px; max-width: 400px;
  color: rgba(255,255,255,.82);
}
.login-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 32px;
}
.ls-card {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(10px);
}
.ls-num { font-size: 24px; font-weight: 700; color: white; letter-spacing: -0.02em; font-family: var(--font-mono); }
.ls-lbl { font-size: 12px; color: rgba(255,255,255,.78); margin-top: 4px; }

.login-main {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.login-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 36px;
  position: relative;
}
.lc-step {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent-text);
  margin-bottom: 12px;
}
.lc-title {
  font-size: 28px; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.1;
  margin: 0; color: var(--text);
}
.lc-sub {
  font-size: 14px; color: var(--text-muted);
  margin: 8px 0 28px 0; line-height: 1.5;
}
.btn-block { width: 100%; justify-content: center; }
.login-error {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--r-md);
  background: var(--negative-soft); color: var(--negative);
  font-size: 13px; font-weight: 500;
  margin-top: 12px;
}
.lc-foot {
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── 21. 2FA PAGE ──────────────────────────────────────────── */
.otp-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}
.otp-cell {
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0;
  border: 1.5px solid var(--border-strong) !important;
  border-radius: 12px !important;
  background: var(--surface-2) !important;
  font-family: var(--font-mono) !important;
  font-size: 22px !important;
  font-weight: 600;
  text-align: center;
  color: var(--text) !important;
  transition: all var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
}
.otp-cell:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  background: var(--surface) !important;
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
}

/* ── Document drop zone ─────────────────────────────────────────── */
.doc-drop-active {
  background: var(--accent-soft) !important;
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

/* ── Meyler Tabs — componente custom, nessun conflitto col tema ── */
.meyler-tabs {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem 0;
  border-bottom: 1px solid var(--border);
  gap: 2px;
}
.meyler-tabs > li {
  flex: 0 0 auto;
  list-style: none;
}
.meyler-tabs > li > a,
.meyler-tabs > li > button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  margin-bottom: -1px;
  outline: none;
}
.meyler-tabs > li > a:hover,
.meyler-tabs > li > button:hover {
  color: var(--text);
  border-bottom-color: var(--border-strong);
  background: var(--surface-2);
}
.meyler-tabs > li > a.active,
.meyler-tabs > li > button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: none;
  font-weight: 600;
}

/* ── 22. PROFILE PAGE ──────────────────────────────────────── */
.profile-card-header {
  background: var(--grad-brand);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 32px;
  position: relative;
  overflow: hidden;
}
.profile-card-header::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(80% 100% at 100% 0%, rgba(255,255,255,.18) 0%, transparent 60%);
  pointer-events: none;
}

/* ── 23. USERS PAGE ────────────────────────────────────────── */
.user-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
}
.user-list-item:hover { background: var(--hover); }
.user-list-item.selected { background: var(--accent-soft); }
.user-list-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border);
}
.user-list-info { min-width: 0; }
.user-list-name  { font-size: 14px; font-weight: 600; color: var(--text); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-list-email { font-size: 12px; color: var(--text-subtle); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* page-head actions slot */
.page-head-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── 24. SCROLLBAR OVERRIDES ──────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── 25. SWEETALERT2 OVERRIDES ─────────────────────────────── */
.swal2-popup {
  background: var(--elevated) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-xl) !important;
}
.swal2-title  { color: var(--text)       !important; }
.swal2-html-container { color: var(--text-muted) !important; }
.swal2-confirm { background: var(--grad-brand) !important; border: none !important; border-radius: var(--r-md) !important; font-weight: 600 !important; }
.swal2-cancel  { background: var(--surface)    !important; border: 1px solid var(--border) !important; color: var(--text) !important; border-radius: var(--r-md) !important; font-weight: 600 !important; }

/* ── 26. PAGE-WRAPPER RESET (override old Modernize theme) ── */
.page-wrapper { background: var(--bg) !important; min-height: unset !important; }
.body-wrapper { background: var(--bg) !important; }

/* hide old preloader */
.preloader { display: none !important; }

/* ── 27. KEYFRAMES ─────────────────────────────────────────── */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in  { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── 28. TIME TRACKER ─────────────────────────────────────── */
.time-week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
@media (max-width: 768px) {
  .time-week-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) {
  .time-week-grid { grid-template-columns: repeat(2, 1fr); }
}

.time-day-cell {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 8px 8px;
  text-align: center;
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.time-day-cell:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb,.5), .12);
}
.time-day-cell.today {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb, 30,136,229), .06);
}
.time-day-cell.weekend { opacity: .65; }
.time-day-cell.future  { opacity: .55; }

.time-day-name {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.time-day-date {
  font-size: .75rem;
  color: var(--text-subtle);
  margin-bottom: 8px;
}
.time-day-cell.today .time-day-name,
.time-day-cell.today .time-day-date { color: var(--accent); }

.time-hours-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  padding: 6px 4px;
  outline: none;
  transition: border-color .15s;
  -moz-appearance: textfield;
}
.time-hours-input::-webkit-outer-spin-button,
.time-hours-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.time-hours-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 30,136,229), .18);
}

.time-day-saved {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  background: var(--success, #4caf50);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .6rem;
  color: #fff;
}
