@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,500;0,9..144,700;1,9..144,400&display=swap');

:root {
  --bg-primary: #0B0F1A;
  --bg-secondary: #111827;
  --bg-card: #1A2035;
  --bg-card-hover: #1F2847;
  --bg-input: #0F1629;
  --border: #1E293B;
  --border-light: #2A3654;
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --accent: #22D3EE;
  --accent-dim: rgba(34, 211, 238, 0.1);
  --accent-glow: rgba(34, 211, 238, 0.15);
  --success: #34D399;
  --success-dim: rgba(52, 211, 153, 0.1);
  --warning: #FBBF24;
  --warning-dim: rgba(251, 191, 36, 0.1);
  --danger: #F87171;
  --danger-dim: rgba(248, 113, 113, 0.1);
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.25);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* ── MOBILE TOPBAR (hidden on desktop) ── */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--topbar-h);
  padding: 0 16px;
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 12px;
}

.mobile-topbar .hamburger {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.mobile-topbar .hamburger:hover { background: var(--bg-card); }
.mobile-topbar .hamburger svg { width: 22px; height: 22px; }

.mobile-topbar .topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 700;
}

.mobile-topbar .topbar-logo-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent), #6366F1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.mobile-topbar .topbar-logo span { color: var(--accent); }

.mobile-topbar .topbar-spacer { flex: 1; }

/* Sidebar overlay for mobile/tablet */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.open { display: block; }

/* ── LOGIN ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(34, 211, 238, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
    var(--bg-primary);
}

.login-box {
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.login-box .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-box .logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent), #6366F1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.login-box .logo-text {
  font-family: 'Fraunces', serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.login-box .logo-text span { color: var(--accent); }

.login-box p.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 36px;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}
/* Note: .form-group select este stilizat de regula globală `select` de mai jos */

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group input::placeholder { color: var(--text-muted); }

/* ─────────────────── Dropdown / select global styling ─────────────────── */
/* Aplicat pe toate <select>-urile + clasa explicită .ui-select.
   !important pe săgeată/appearance ca să batem inline style="padding:..." din pagini. */
select,
.ui-select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  /* Săgeată custom (SVG inline, color-aware). Forțăm să nu fie suprascrisă de inline-style: */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1l5 5 5-5' stroke='%23a8b3c4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 12px 8px !important;
  padding-right: 38px !important;
  text-overflow: ellipsis;
}
/* Default padding când nu vine alt inline style */
select:not([style*="padding"]),
.ui-select:not([style*="padding"]) {
  padding: 12px 38px 12px 16px;
  width: 100%;
}
select:hover,
.ui-select:hover {
  border-color: var(--accent);
  background-color: var(--bg-card-hover, var(--bg-input));
}
select:focus,
.ui-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
select:disabled,
.ui-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background-image: none;
  padding-right: 16px;
}
/* Variantă compactă pentru toolbars / row actions */
select.btn-sm,
select[size="sm"],
.ui-select-sm {
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  background-position: right 10px center;
}
/* Dropdown menu items — în Chrome/Edge respectă bg-ul, în Firefox/Safari mai puțin */
select option,
.ui-select option {
  background-color: var(--bg-card);
  color: var(--text-primary);
  padding: 8px;
}
select optgroup,
.ui-select optgroup {
  background-color: var(--bg-input);
  color: var(--text-muted);
  font-style: normal;
  font-weight: 600;
}
/* Multiple-select reset */
select[multiple] {
  background-image: none;
  padding-right: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  letter-spacing: 0.2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366F1);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(34, 211, 238, 0.25);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
}

.btn-ghost:hover { color: var(--text-primary); }

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.2);
}

.btn-accent:hover {
  background: rgba(34, 211, 238, 0.2);
}

.btn-success {
  background: var(--success);
  color: #0B0F1A;
}

.btn-success:hover {
  box-shadow: 0 8px 24px rgba(52, 211, 153, 0.25);
}

/* ── LAYOUT ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  padding-bottom: var(--safe-bottom);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar .sidebar-close {
  display: none !important;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  z-index: 2;
  padding: 0;
  line-height: 1;
  align-items: center;
  justify-content: center;
}

.sidebar .sidebar-close:hover { background: var(--bg-card); color: var(--text-primary); }

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #6366F1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.sidebar-header .logo-text {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 700;
}

.sidebar-header .logo-text span { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.user-card:hover { background: var(--bg-card); }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366F1, #A78BFA);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.user-info .name {
  font-size: 13px;
  font-weight: 600;
}

.user-info .role {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 40px;
  padding-left: calc(40px + var(--safe-left));
  padding-right: calc(40px + var(--safe-right));
  padding-bottom: calc(32px + var(--safe-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.page-header > div:first-child {
  flex: 1 1 280px;
  min-width: 0;
}

.page-header > div:last-child {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.page-header h1 {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin: 0;
}

.page-header .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ── STAT CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 16px;
}

.stat-card .stat-icon.blue { background: var(--accent-dim); }
.stat-card .stat-icon.green { background: var(--success-dim); }
.stat-card .stat-icon.yellow { background: var(--warning-dim); }
.stat-card .stat-icon.red { background: var(--danger-dim); }

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  font-family: 'Fraunces', serif;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.stat-card .stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 6px;
}

.stat-change.up { color: var(--success); background: var(--success-dim); }
.stat-change.down { color: var(--danger); background: var(--danger-dim); }

/* ── CARDS / PANELS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

/* ── TABLE ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

table tr:last-child td { border-bottom: none; }

table tr:hover td { background: rgba(255,255,255,0.02); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.completed { background: var(--success-dim); color: var(--success); }
.status-badge.pending { background: var(--warning-dim); color: var(--warning); }
.status-badge.draft { background: var(--accent-dim); color: var(--accent); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.upload-zone .upload-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.upload-zone h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 14px;
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ── ACT TYPE SELECTOR ── */
.act-types {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.act-type-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.act-type-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.act-type-card.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.act-type-card .act-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.act-type-card h4 {
  font-size: 15px;
  margin-bottom: 4px;
}

.act-type-card p {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── DOCUMENT CHIPS ── */
.doc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.doc-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.doc-chip .chip-icon { font-size: 16px; }
.doc-chip .chip-remove {
  cursor: pointer;
  color: var(--text-muted);
  margin-left: 4px;
  transition: var(--transition);
}
.doc-chip .chip-remove:hover { color: var(--danger); }

/* ── EXTRACTION PREVIEW ── */
.extraction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.extracted-fields {
  display: grid;
  gap: 12px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.field-row .field-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.field-row .field-value {
  font-size: 14px;
  font-weight: 500;
}

.field-row .field-confidence {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
}

.field-confidence.high { background: var(--success-dim); color: var(--success); }
.field-confidence.medium { background: var(--warning-dim); color: var(--warning); }

/* ── ACT PREVIEW ── */
.act-preview {
  background: #fff;
  color: #1a1a1a;
  padding: 60px 80px;
  border-radius: var(--radius);
  font-family: 'Times New Roman', serif;
  font-size: 15px;
  line-height: 1.8;
  max-height: 600px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.act-preview h2 {
  text-align: center;
  font-size: 20px;
  margin-bottom: 24px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.act-preview .act-number {
  text-align: center;
  font-size: 13px;
  color: #666;
  margin-bottom: 32px;
}

.act-preview .section-title {
  font-weight: 700;
  margin-top: 20px;
  margin-bottom: 8px;
}

.act-preview .highlight {
  background: rgba(34, 211, 238, 0.15);
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
}

/* ── PROCESSING ANIMATION ── */
.processing-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 26, 0.9);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
}

.processing-overlay.active { display: flex; }

.processing-spinner {
  width: 64px;
  height: 64px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.processing-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 300px;
}

.processing-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
  transition: var(--transition);
}

.processing-step.active { color: var(--accent); }
.processing-step.done { color: var(--success); }

.processing-step .step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.processing-step.done .step-icon {
  background: var(--success);
  border-color: var(--success);
  color: var(--bg-primary);
}

/* ── STEPPER ── */
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 40px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text-muted);
}

.step.active .step-number {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-primary);
}

.step.completed .step-number {
  background: var(--success);
  border-color: var(--success);
  color: var(--bg-primary);
}

.step-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.step.active .step-label { color: var(--text-primary); }
.step.completed .step-label { color: var(--success); }

.step-line {
  flex: 0;
  width: 40px;
  height: 2px;
  background: var(--border);
}

.step-line.completed { background: var(--success); }

/* ── TWO COLUMNS LAYOUT ── */
.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ── TEMPLATE SELECTOR ── */
.template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  flex-wrap: wrap;
}

.template-item:hover { border-color: var(--border-light); }

.template-item .template-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 0;
  min-width: 0;
}

.template-item .template-info > div { min-width: 0; }

.template-item .template-icon { font-size: 20px; flex-shrink: 0; }
.template-item .template-name {
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
}
.template-item .template-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.template-item .btn { flex-shrink: 0; white-space: nowrap; }

/* ── ACTIONS BAR ── */
.actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 24px;
}

.actions-bar .left-actions,
.actions-bar .right-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 80px 40px;
}

.empty-state-row td {
  text-align: center !important;
  padding: 60px 20px !important;
}

.empty-state-row .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state-row h4 {
  font-size: 16px;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.empty-state-row p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── SKELETON LOADER ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-card-hover) 50%, var(--bg-card) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-xs);
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-row td {
  padding: 14px 16px !important;
}

.skeleton-bar {
  display: inline-block;
  height: 14px;
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 4px;
  width: 80%;
}

/* ── TOOLTIP ── */
[data-tip] {
  position: relative;
}

[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

[data-tip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--bg-secondary);
  z-index: 100;
}

@media (hover: none) {
  [data-tip]:hover::after, [data-tip]:hover::before { display: none; }
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto 24px;
}

/* ── SETTINGS GRID ── */
.settings-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-nav a {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
}

.settings-nav a:hover { background: var(--bg-card); color: var(--text-primary); }
.settings-nav a.active { background: var(--accent-dim); color: var(--accent); }

/* ── NOTIFICATION DOT ── */
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  top: -2px;
  right: -2px;
}

/* ── SEARCH BAR ── */
.search-bar {
  position: relative;
  flex: 1 1 200px;
  max-width: 340px;
  min-width: 180px;
  display: flex;
  align-items: center;
}

.search-bar input,
a.search-bar {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  height: 40px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}

.search-bar input:focus { border-color: var(--accent); }

.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.search-bar > span:not(.search-icon) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── RESPONSIVE ──
   Breakpoints:
   - ≥ 1440px: large desktop (default)
   - 1280-1439px: standard desktop (default)
   - 1024-1279px: laptop / tablet landscape
   - 768-1023px: tablet portrait / mobile landscape mare → sidebar offcanvas
   - 480-767px: mobile landscape mic / tablet small portrait
   - < 480px: mobile portrait
*/

/* Laptop & tablet landscape: 1024-1279 */
@media (max-width: 1279px) {
  :root { --sidebar-w: 220px; }
  .main-content { padding: 28px 28px; padding-left: calc(28px + var(--safe-left)); padding-right: calc(28px + var(--safe-right)); }
  .page-header h1 { font-size: 24px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .stat-card { padding: 18px; }
  .stat-card .stat-value { font-size: 26px; }
  .act-types { grid-template-columns: repeat(3, 1fr); }
  .extraction-grid { grid-template-columns: 1fr; }
  .act-preview { padding: 50px 60px; max-height: 540px; }
}

/* Desktop ≥ 1024: hard-hide mobile-topbar și sidebar-close */
@media (min-width: 1024px) {
  .mobile-topbar { display: none !important; height: 0 !important; visibility: hidden !important; }
  .sidebar-overlay { display: none !important; }
  .sidebar .sidebar-close { display: none !important; visibility: hidden !important; }
  .sidebar { transform: none !important; }
}

/* Tablet portrait & mobile landscape: 768-1023 — sidebar becomes offcanvas */
@media (max-width: 1023px) {
  .mobile-topbar { display: flex !important; visibility: visible !important; }

  .app-layout { display: block; }

  .sidebar {
    transform: translateX(-100%);
    width: min(280px, 85vw);
    box-shadow: 8px 0 32px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .sidebar-close { display: flex !important; visibility: visible !important; align-items: center; justify-content: center; }

  .main-content {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-left: 0 !important;
    padding: 20px 20px;
    padding-left: max(20px, var(--safe-left));
    padding-right: max(20px, var(--safe-right));
  }

  .page-header { margin-bottom: 24px; gap: 12px; flex-direction: column; align-items: stretch; }
  .page-header h1 { font-size: 22px; }
  .page-header > div:first-child { flex: 1 1 100%; width: 100%; min-width: 0; }
  .page-header > div:last-child { width: 100%; flex-wrap: wrap; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 24px; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 24px; }

  .two-cols { grid-template-columns: 1fr; gap: 16px; }
  .act-types { grid-template-columns: repeat(2, 1fr); }
  .extraction-grid { grid-template-columns: 1fr; }

  .act-preview { padding: 40px 36px; font-size: 14px; max-height: 460px; }

  .settings-grid { grid-template-columns: 1fr; gap: 16px; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .settings-nav a { padding: 8px 14px; }

  .stepper { gap: 4px; margin-bottom: 28px; overflow-x: auto; padding-bottom: 6px; }
  .step-line { width: 24px; }

  .card-header { padding: 16px 18px; }
  .card-body { padding: 18px; }
  table th, table td { padding: 12px 14px; }
}

/* Mobile (any orientation): < 768 */
@media (max-width: 767px) {
  :root { --topbar-h: 56px; }
  .app-layout { display: block; }
  .main-content { display: block; width: 100%; max-width: 100%; margin: 0; padding: 16px 14px; padding-left: max(14px, var(--safe-left)); padding-right: max(14px, var(--safe-right)); }
  .page-header { margin-bottom: 18px; }
  .page-header h1 { font-size: 19px; line-height: 1.25; }
  .page-header .subtitle { font-size: 13px; }
  .page-header > div:last-child { gap: 8px; width: 100%; }
  .page-header .btn { flex: 1 1 auto; min-width: 120px; }
  .page-header .search-bar { flex: 1 1 100%; max-width: 100%; }
  .search-bar > span:not(.search-icon) { font-size: 14px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-icon { width: 32px; height: 32px; font-size: 15px; margin-bottom: 10px; }
  .stat-card .stat-value { font-size: 22px; }
  .stat-card .stat-label { font-size: 12px; }
  .stat-card .stat-change { font-size: 11px; }

  .act-types { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .act-type-card { padding: 16px 12px; }
  .act-type-card .act-icon { font-size: 26px; margin-bottom: 8px; }
  .act-type-card h4 { font-size: 13px; }

  .card-header { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .card-body { padding: 16px; }
  .card-header h3 { font-size: 15px; }

  /* Tabel scrollabil + min-width pentru lizibilitate */
  .table-wrap {
    margin: 0 -16px;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .table-wrap table { min-width: 560px; }
  table th { padding: 10px 12px; font-size: 11px; }
  table td { padding: 12px; font-size: 13px; }

  .act-preview { padding: 24px 18px; font-size: 13px; line-height: 1.7; max-height: 380px; border-radius: var(--radius-sm); }
  .act-preview h2 { font-size: 16px; letter-spacing: 1px; }

  .actions-bar { flex-direction: column; gap: 12px; padding: 14px 16px; align-items: stretch; }
  .actions-bar .left-actions, .actions-bar .right-actions { flex-wrap: wrap; gap: 8px; }
  .actions-bar .btn { flex: 1 1 calc(50% - 4px); }

  .upload-zone { padding: 36px 20px; }
  .upload-zone .upload-icon { font-size: 40px; }
  .upload-zone h3 { font-size: 16px; }

  .doc-chips { gap: 6px; }
  .doc-chip { padding: 6px 10px; font-size: 12px; }

  .stepper { margin-bottom: 22px; }
  .step-label { display: none; }
  .step.active .step-label { display: inline; font-size: 12px; }
  .step-line { width: 16px; }
  .step-number { width: 28px; height: 28px; font-size: 12px; }

  .empty-state { padding: 50px 20px; }
  .empty-state .empty-icon { font-size: 40px; }
}

/* Mobile portrait: < 480 */
@media (max-width: 479px) {
  .stats-grid { grid-template-columns: 1fr; }
  .act-types { grid-template-columns: 1fr; }
  .act-type-card { display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px; }
  .act-type-card .act-icon { font-size: 22px; margin-bottom: 0; }
  .act-type-card h4 { font-size: 14px; margin: 0; }
  .page-header h1 { font-size: 17px; line-height: 1.2; }
  .page-header .subtitle { font-size: 12px; }

  .login-box { padding: 32px 22px; border-radius: 16px; }
  .login-box .logo-text { font-size: 22px; }
  .login-box p.subtitle { margin-bottom: 26px; }
}

/* Mobile landscape - prevent over-tall topbar squeeze when keyboard up */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --topbar-h: 48px; }
  .main-content { padding-top: 12px; }
  .page-header { margin-bottom: 14px; }
}

/* Touch device tweaks - bigger tap targets */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 44px; padding: 10px 18px; }
  .btn-sm { min-height: 38px; padding: 8px 14px; }
  .btn-ghost { min-height: 38px; }
  .nav-item { padding: 12px 14px; }
  .form-group input, .form-group select, .form-group textarea { padding: 13px 14px; font-size: 16px; /* prevents iOS zoom */ }
  .search-bar input { padding-top: 12px; padding-bottom: 12px; font-size: 16px; }
  table td .btn-sm, table td button { min-height: 36px; }
}

/* Print-friendly */
@media print {
  .sidebar, .mobile-topbar, .sidebar-overlay, .actions-bar, .btn { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .act-preview { max-height: none; box-shadow: none; padding: 40px; }
}

/* ── ANIMATIONS ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeInUp 0.4s ease-out forwards;
  opacity: 0;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
