﻿:root {
  --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  --surface: rgba(255, 255, 255, 0.45);
  --glass-border: rgba(255, 255, 255, 0.8);
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(226, 232, 240, 0.5);
  --accent: #2563eb;
  --accent-hover: #3b82f6;
  --danger: #ef4444;
  --radius: 20px;
  --shadow: 0 10px 40px -10px rgba(31, 38, 135, 0.15), inset 0 1px 0 0 rgba(255, 255, 255, 0.9);
  --glow: 0 0 20px rgba(59, 130, 246, 0.4);
  --pad-panel: clamp(1rem, 1.2vw + 0.5rem, 1.5rem);
  --gap-layout: clamp(1rem, 1.4vw + 0.5rem, 1.5rem);
  --touch-target: clamp(2.6rem, 1.6rem + 1.4vw, 3.4rem);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --debug-dock-height: clamp(150px, 28vh + 0.5rem, 280px);
  --blur: 24px;
}

html.dark {
  --bg-gradient: radial-gradient(circle at top left, #1e293b 0%, #090e17 100%);
  --surface: rgba(15, 23, 42, 0.5);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(51, 65, 85, 0.5);
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --danger: #f87171;
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.6), inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
  --glow: 0 0 20px rgba(59, 130, 246, 0.6);
  --blur: 28px;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  /* Fundalul HTML egal cu body (gradient-ul e pe body, dar prevenim flash alb la scroll extrem) */
  background: var(--bg-gradient);
  background-attachment: fixed;
  /* Major font size increase for mobile readability */
  font-size: clamp(17px, 15px + 0.6vw, 19.5px);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  font-family: system-ui, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.52;
  font-size: 1rem;
}

/* Coloană pe înălțimea viewport-ului (desktop / mobil) */
.app-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
}

body.alm-debug-open .app-root {
  padding-bottom: var(--debug-dock-height);
}

/* Toasts */
.toast-wrap {
  position: fixed;
  top: calc(var(--touch-target) + 1.25rem);
  right: clamp(0.75rem, 2vw, 1.25rem);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(28rem, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: clamp(0.75rem, 1vw + 0.5rem, 1.1rem) clamp(0.9rem, 1.2vw + 0.5rem, 1.25rem);
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: clamp(0.78rem, 0.75rem + 0.12vw, 0.88rem);
}

.toast-success {
  border-color: rgba(134, 239, 172, 0.5);
  background: rgba(240, 253, 244, 0.7);
}
html.dark .toast-success {
  background: rgba(22, 101, 52, 0.25);
  border-color: #166534;
}

.toast-error {
  border-color: #fca5a5;
  background: #fef2f2;
}
html.dark .toast-error {
  background: rgba(127, 29, 29, 0.35);
  border-color: #991b1b;
}

.toast-info {
  border-color: #93c5fd;
  background: #eff6ff;
}
html.dark .toast-info {
  background: rgba(30, 58, 138, 0.35);
  border-color: #1e40af;
}

.toast-warning {
  border-color: #fcd34d;
  background: #fffbeb;
}
html.dark .toast-warning {
  background: rgba(180, 83, 9, 0.25);
  border-color: #b45309;
}

.toast-close {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 0.25rem;
}

/* Top bar */
.topbar {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  z-index: 150; /* Increased to stay above all layout elements */
  background: var(--surface);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--glass-border);
  /* Safari fix: creates a clean stacking context */
  isolation: isolate; 
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

html.dark .topbar {
  background: var(--surface);
}

.topbar-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  padding-top: calc(0.5rem + var(--safe-top));
  padding-left: clamp(0.65rem, 2.2vw, 1.75rem);
  padding-right: clamp(0.65rem, 2.2vw, 1.75rem);
  padding-bottom: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 1rem;
}

@media (max-width: 1023px) {
  .topbar-inner {
    position: relative !important;
    display: block !important; /* Allow absolute children */
    padding-top: calc(0.35rem + var(--safe-top)) !important;
    padding-bottom: 0 !important;
  }
  .brand {
    display: block !important; /* Vertical stack on mobile header */
    width: 100% !important;
  }
  .brand-copy {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.55rem;
    width: 100%;
  }
  .brand-title {
    line-height: 1.08;
    margin-top: 0.05rem;
  }
  .brand-title-line {
    display: block;
  }
  .brand-meta {
    padding-right: 0;
    display: block !important;
    margin-top: 0;
    text-align: right;
    align-items: flex-end;
  }
  .brand-meta-row {
    justify-content: flex-end;
  }
  .brand-info-ai {
    justify-content: flex-end;
  }
  .topbar-actions {
    position: static !important;
    margin: 0.35rem 0 0 !important;
    justify-content: flex-end;
    width: 100%;
    z-index: 200;
  }
  .topbar-news {
    margin-top: 0.45rem !important;
    border-top: 1px solid var(--border) !important;
    width: 100% !important;
    padding: 0.45rem 0.15rem 0.2rem;
    gap: 0.4rem;
  }
  .news-label-left {
    display: inline-flex;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    padding-top: 0.05rem;
    min-width: 7.2rem;
  }
  .news-ticker-wrap {
    gap: 0.22rem;
  }
  .news-pill {
    padding: 0.4rem 0.25rem;
  }
  .news-link {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.28;
    font-size: clamp(0.8rem, 0.74rem + 0.55vw, 0.96rem);
  }
}

@media (min-width: 1024px) {
  .topbar-inner {
    flex-wrap: nowrap;
    align-items: center;
    padding: clamp(0.55rem, 0.8vw + 0.35rem, 0.95rem) clamp(0.75rem, 2.2vw, 1.75rem);
    gap: 0 1.25rem;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-copy {
  min-width: 0;
}

.brand-logo-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.brand-icon {
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: calc(var(--radius) - 2px);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1rem, 0.9rem + 0.35vw, 1.25rem);
}

.btn-on-logo {
  width: 1.15rem !important;
  height: 1.15rem !important;
  min-width: 0 !important;
  min-height: 0 !important;
  font-size: 0.55rem !important;
  padding: 0 !important;
  opacity: 0.35;
  color: var(--muted) !important;
}

.btn-on-logo:hover {
  opacity: 1;
  background: var(--border) !important;
}

.brand-title {
  margin: 0;
  font-size: clamp(1.05rem, 0.9rem + 0.3vw, 1.3rem);
  font-weight: 700;
}

.brand-title-line {
  display: block;
}

.brand-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.brand-meta-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.badge {
  font-size: clamp(0.58rem, 0.55rem + 0.1vw, 0.7rem);
  font-weight: 700;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.badge-accent {
  color: var(--accent);
  border-color: #93c5fd;
}

.badge-title {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.7rem, 0.65rem + 0.1vw, 0.78rem);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  border-color: rgba(37, 99, 235, 0.25);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

html.dark .badge-title {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
}

html.dark .badge-accent {
  border-color: #475569;
}

.brand-info-ai {
  font-size: clamp(0.58rem, 0.55rem + 0.1vw, 0.72rem);
  font-weight: 600;
  color: #f59e0b;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

html.dark .brand-info-ai {
  color: #fbbf24;
}

.ai-icon {
  font-size: 0.95em;
  filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.4));
}

.topbar-news {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  padding: 0.25rem 0.2rem;
  overflow: hidden;
  gap: 0.6rem;
}

@media (min-width: 1024px) {
  .topbar-news {
    grid-column: auto;
    width: auto;
    flex: 1;
    max-width: 1400px; /* Enhanced wide view for desktop */
    padding: 0.2rem 1.5rem;
    border-top: none;
    margin-top: 0;
  }
}

/* Eticheta din stânga */
.news-label-left {
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  opacity: 0.9;
  padding-top: 0.28rem;
  white-space: nowrap;
}

@media (max-width: 1023px) {
  .news-label-left {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  /* Doar eticheta "JURIDICE NEWS" coboară spre rândul 2 din ticker */
  .news-label-left {
    padding-top: 2.42rem;
  }
}

/* Wrapperul ticker-ului — afișează 3 rânduri */
.news-ticker-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow: hidden;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

/* Pastila news — container principal */
.news-pill {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  width: 100%;
  /* compact pe mobil */
  padding: 0.28rem 0.6rem;
  background: transparent;
  border-radius: 6px;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: background 0.18s;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(245, 158, 11, 0.1);
}

@media (max-width: 1023px) {
  .news-pill:nth-child(n+2) {
    display: none;
  }
}

.news-pill:not(:last-child) {
  border-bottom: 1px solid rgba(245, 158, 11, 0.15);
}

.news-pill:hover {
  background: rgba(37, 99, 235, 0.07);
  border-color: transparent;
  box-shadow: none;
}

html.dark .news-pill {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

html.dark .news-pill:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: transparent;
  box-shadow: none;
}

/* .news-label (dot-pulse vechi) — ascuns, înlocuit de .news-label-left */
.news-label {
  display: none;
}

/* Punctulețe animate în fața fiecărei știri */
.news-bullet {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-right: 0.45rem;
  flex-shrink: 0;
  padding-top: 1px;
}

.news-bullet-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: news-dot-wave 1.05s ease-in-out infinite;
}

.news-bullet-dot:nth-child(1) {
  animation-delay: 0ms;
}

.news-bullet-dot:nth-child(2) {
  animation-delay: 150ms;
}

.news-bullet-dot:nth-child(3) {
  animation-delay: 300ms;
}

@keyframes news-dot-wave {
  0%,
  100% {
    opacity: 0.28;
    transform: scale(0.82);
  }
  50% {
    opacity: 1;
    transform: scale(1.12);
  }
}

.news-link {
  color: #111827; /* Light mode: text negru */
  text-decoration: none;
  font-size: clamp(0.78rem, 0.75rem + 0.2vw, 0.88rem);
  font-weight: 600;
  line-height: 1.35;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  transition: color 0.2s, opacity 0.2s;
}

html.dark .news-link {
  color: #f59e0b; /* Dark mode: păstrăm accentul amber */
}

.news-pill:hover .news-link {
  color: var(--accent);
}

/* Animatie ticker — ieșire (pe wrapper) */
.news-pill--exit {
  opacity: 0;
  transform: translateX(-15px); /* Slide out to left */
  pointer-events: none;
}

/* Animatie ticker — intrare inițială (pe wrapper) */
.news-pill--enter {
  opacity: 0;
  transform: translateX(15px); /* Slide in from right */
}

/* Starea "normal" = afișare completă */
.news-ticker-wrap:not(.news-pill--exit):not(.news-pill--enter) {
  opacity: 1;
  transform: translateX(0);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  position: relative;
  z-index: 160; /* Above topbar-inner */
  margin-left: auto; /* Force right alignment on mobile/wrapped lines */
}

.btn-icon {
  width: var(--touch-target);
  height: var(--touch-target);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  border: none;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: clamp(1.1rem, 1rem + 0.2vw, 1.35rem);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Safari hit-test optimization */
  position: relative;
  z-index: 1;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.btn-icon:hover {
  background: var(--border);
}

/* iOS tap highlight fix */
.btn-icon, .btn, .link-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-icon.danger:hover {
  color: var(--danger);
}

.notif-wrap {
  position: relative;
  /* Safari hit-test optimization */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.notif-badge {
  position: absolute;
  top: 0.1rem;
  right: 0.1rem;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.2rem;
  font-size: 0.6rem;
  font-weight: 800;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* Prevents blocking clicks on the button below */
}

/* display:flex de mai sus bate uneori atributul [hidden] — fără asta badge-ul rămâne vizibil la 0 necitite */
.notif-badge[hidden] {
  display: none !important;
}

.notif-dropdown {
  position: fixed;
  top: clamp(3.8rem, 4vh + 2.8rem, 5rem);
  right: clamp(0.75rem, 2vw, 1.5rem);
  left: auto;
  z-index: 125;
  width: min(320px, calc(100vw - 1.5rem));
  max-height: min(600px, 80vh);
  background: #f1f5f9; /* Gri opac (Slate 100) */
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

html.dark .notif-dropdown {
  background: #1e293b; /* Gri închis opac */
  border-color: #334155;
}

.notif-dropdown[hidden] {
  display: none !important;
}

.notif-dropdown-head {
  flex-shrink: 0;
  padding: calc(0.75rem + var(--safe-top)) calc(1rem + var(--safe-right)) 0.75rem calc(1rem + var(--safe-left));
  border-bottom: 1px solid #cbd5e1;
  background: #e2e8f0; /* Capăt gri puțin mai închis */
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}

html.dark .notif-dropdown-head {
  background: #0f172a;
  border-bottom-color: #334155;
}

.notif-settings {
  padding: 0.5rem calc(1rem + var(--safe-right)) 0.5rem calc(1rem + var(--safe-left));
  border-bottom: 1px solid #cbd5e1;
  background: #f8fafc;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

html.dark .notif-settings {
  background: #0f172a;
  border-bottom-color: #334155;
}

.notif-head-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.notif-close-x {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 300;
  width: 1.85rem;
  height: 1.85rem;
  position: relative;
  z-index: 3;
  pointer-events: auto;
}

.link-btn {
  border: none;
  background: none;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}

.link-btn:hover {
  color: var(--danger);
}

.notif-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.notif-item {
  padding: 0.65rem calc(1rem + var(--safe-right)) 0.65rem calc(1rem + var(--safe-left));
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.75rem;
  background: #ffffff; /* Notificările rămân albe pt lizibilitate pe fundalul gri al ferestrei */
}

html.dark .notif-item {
  background: transparent;
  border-bottom-color: #334155;
}

.notif-item.unread {
  background: rgba(37, 99, 235, 0.12);
}

html.dark .notif-item.unread {
  background: rgba(59, 130, 246, 0.18);
}

.notif-dropdown-foot {
  flex-shrink: 0;
  padding: 0.65rem calc(1rem + var(--safe-right)) calc(0.65rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
  border-top: 1px solid #cbd5e1;
  background: #e2e8f0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  padding: 0.25rem 0;
  user-select: none;
}

.switch-text {
  font-weight: 600;
  color: var(--text);
}

.notif-warn {
  margin-top: 0.5rem;
  padding: 0.4rem 0.65rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  color: #b91c1c;
  font-size: 0.68rem;
  font-weight: 600;
}

html.dark .notif-warn {
  background: rgba(127, 29, 29, 0.2);
  color: #f87171;
}

.btn-warn-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 0.95rem;
  font-weight: 300;
  cursor: pointer;
  padding: 0 0.25rem;
  margin-left: auto;
  opacity: 0.6;
}

.btn-warn-close:hover {
  opacity: 1;
}

.notif-warn {
  display: flex;
  align-items: center;
}

.full-width {
  width: 100%;
}

html.dark .notif-dropdown-foot {
  background: #0f172a;
  border-top-color: #334155;
}

.backdrop {
  position: fixed;
  inset: 0;
  /* Sub topbar (100) ca dropdown + butonul × să primească clicuri */
  z-index: 90;
  background: transparent;
}

.backdrop[hidden] {
  display: none !important;
}

/* Layout — lățime și înălțime după viewport (fără bandă îngustă 1200px) */
.layout {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--gap-layout) clamp(0.55rem, 1.8vw, 1.5rem) clamp(0.45rem, 1vw, 0.85rem);
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  gap: var(--gap-layout);
  align-items: stretch;
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    grid-template-rows: minmax(0, 1fr);
    gap: var(--gap-layout);
    padding: calc(var(--gap-layout) + 0.15rem) clamp(0.7rem, 1.5vw, 1.65rem);
  }
}

.panel {
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Eliminăm min-height fix pe mobil pentru a evita spațiul gol când nu sunt date */
}

@media (min-width: 1024px) {
  .panel {
    min-height: 0;
    height: 100%;
  }
}

.panel-head {
  padding: var(--pad-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: clamp(0.6rem, 1vw + 0.35rem, 1rem);
}

.panel-head h2 {
  margin: 0;
  font-size: clamp(0.92rem, 0.85rem + 0.15vw, 1.05rem);
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.panel-actions {
  padding: clamp(0.65rem, 0.8vw + 0.45rem, 1rem) var(--pad-panel);
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.45rem, 0.6vw + 0.3rem, 0.75rem);
  border-bottom: 1px solid var(--border);
}

.table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  max-height: none;
}

@media (max-width: 1023px) {
  .table-wrap {
    max-height: min(50vh, 420px);
  }
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.85rem, 0.8rem + 0.15vw, 0.95rem);
}

@media (min-width: 1024px) {
    .data-table {
        font-size: 0.9rem;
    }
}

.data-table th {
  text-align: left;
  padding: clamp(0.45rem, 0.4vw + 0.35rem, 0.75rem) clamp(0.55rem, 0.6vw + 0.35rem, 0.85rem);
  font-size: clamp(0.62rem, 0.58rem + 0.1vw, 0.72rem);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.data-table td {
  padding: clamp(0.45rem, 0.45vw + 0.35rem, 0.75rem) clamp(0.55rem, 0.55vw + 0.35rem, 0.85rem);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

@media (min-width: 1024px) {
  .data-table--cases {
    table-layout: fixed;
  }
  .data-table--cases .col-dosar {
    width: 42%;
  }
  .data-table--cases .col-parti {
    width: 26%;
  }
  .data-table--cases .col-termen {
    width: 8.5rem;
  }
  .data-table--cases .col-actions {
    width: 10.5rem;
  }
  .data-table--cases th:first-child,
  .data-table--cases td:first-child {
    max-width: none;
    padding-right: 0.5rem;
  }
  .data-table--cases th:nth-child(3),
  .data-table--cases td:nth-child(3) {
    padding-left: 0.35rem;
    padding-right: 0.25rem;
    font-size: 0.82rem;
    line-height: 1.3;
    word-break: break-word;
  }
  .data-table--cases th:last-child,
  .data-table--cases td:last-child {
    padding-left: 0.15rem;
    width: 10.5rem;
  }
  .data-table--cases .clamp {
    max-width: none;
  }
  /* Group actions: grid format (2 buttons per row) on desktop */
  .actions {
    display: grid !important;
    grid-template-columns: repeat(2, max-content) !important;
    justify-content: center;
    gap: 0.35rem !important;
    padding: 0.4rem 0 !important;
  }
}

.data-table tr {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.data-table tr:hover td {
  background: var(--surface);
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.data-table tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.02);
}
html.dark .data-table tr:hover td {
  background: rgba(51, 65, 85, 0.3);
  box-shadow: inset 0 0 0 1px var(--accent);
}
html.dark .data-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}

/* Dosare nou adăugate la Import — albastru, italic, ~15s (clasa setată din JS) */
.data-table tr.case-row-import-new td:not(.actions),
.data-table tr.case-row-import-new td:not(.actions) * {
  color: #1d4ed8 !important;
  font-style: italic;
}
.data-table tr.case-row-import-new td:not(.actions) {
  background: rgba(29, 78, 216, 0.07) !important;
}
.data-table tr.case-row-import-new:hover td:not(.actions),
.data-table tr.case-row-import-new:hover td:not(.actions) * {
  color: #1d4ed8 !important;
}
.data-table tr.case-row-import-new:hover td:not(.actions) {
  background: rgba(29, 78, 216, 0.12) !important;
}
html.dark .data-table tr.case-row-import-new td:not(.actions),
html.dark .data-table tr.case-row-import-new td:not(.actions) * {
  color: #93c5fd !important;
  font-style: italic;
}
html.dark .data-table tr.case-row-import-new td:not(.actions) {
  background: rgba(147, 197, 253, 0.1) !important;
}
html.dark .data-table tr.case-row-import-new:hover td:not(.actions) {
  background: rgba(147, 197, 253, 0.16) !important;
}

/* Pastile număr dosar: rejudecare (*), asociat (/a1 …) */
.case-badges-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
}
.case-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  line-height: 1.25;
  font-style: normal !important;
}
.case-badge--rejudecare {
  background: rgba(99, 102, 241, 0.22);
  color: #4338ca;
  border: 1px solid rgba(99, 102, 241, 0.35);
}
.case-badge--asociat {
  background: rgba(14, 165, 233, 0.2);
  color: #0369a1;
  border: 1px solid rgba(14, 165, 233, 0.35);
}
html.dark .case-badge--rejudecare {
  background: rgba(129, 140, 248, 0.18);
  color: #c7d2fe;
  border-color: rgba(129, 140, 248, 0.35);
}
html.dark .case-badge--asociat {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.35);
}
.data-table tr.case-row-import-new td .case-badge {
  font-style: normal !important;
}
.data-table tr.case-row-import-new td .case-badge--rejudecare {
  color: #4338ca !important;
}
.data-table tr.case-row-import-new td .case-badge--asociat {
  color: #0369a1 !important;
}
html.dark .data-table tr.case-row-import-new td .case-badge--rejudecare {
  color: #c7d2fe !important;
}
html.dark .data-table tr.case-row-import-new td .case-badge--asociat {
  color: #7dd3fc !important;
}

.cell-empty {
  text-align: center;
  padding: 2rem !important;
  color: var(--muted);
  font-style: italic;
}

.link-dosar {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.15rem);
}

.link-dosar:hover {
  text-decoration: underline;
}

.tiny {
  font-size: clamp(0.65rem, 0.62rem + 0.08vw, 0.75rem);
}

.muted,
.muted2 {
  color: var(--muted);
}

.small {
  font-size: clamp(0.78rem, 0.75rem + 0.1vw, 0.9rem);
  margin: 0.25rem 0;
}

.clamp {
  max-width: 10rem;
}

.sol {
  color: #ea580c;
  font-style: italic;
}

.term {
  color: var(--accent);
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.25rem !important;
}

.btn-saved {
  width: var(--touch-target);
  height: var(--touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #22c55e;
  font-size: 1.25rem;
  font-weight: 800;
}

strong {
  font-weight: 600;
}

.strong {
  font-weight: 700;
}

/* Search */
.search-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0 1rem 0.35rem;
  flex-wrap: wrap;
}

.search-portal-hint {
  margin: 0 1rem 0.65rem;
  padding: 0;
  line-height: 1.4;
}

.search-portal-hint.search-portal-mirror {
  margin-top: -0.35rem;
}

.search-ex {
  font-size: clamp(0.78rem, 0.74rem + 0.1vw, 0.88rem);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.search-ex:hover {
  text-decoration: underline;
}

.search-input-wrap {
  flex: 1;
  min-width: min(100%, 14rem);
}

.panel-search .select.full {
  margin: 0 1rem 0.75rem;
  width: calc(100% - 2rem);
  max-width: none;
}

.search-date-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.25rem;
  margin: 0 1rem 0.5rem;
}

.search-date-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 10rem;
}

.input-date {
  max-width: 12rem;
}

.search-portal-hint {
  margin: 0 1rem 0.65rem;
  line-height: 1.45;
  font-size: 0.85rem;
  color: var(--muted);
}

.search-empty {
  flex-shrink: 0;
  padding: 1rem 1.5rem;
  text-align: center;
}

.search-results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-search {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: clamp(0.9rem, 1vw + 0.55rem, 1.35rem);
  background: var(--surface);
  backdrop-filter: blur(calc(var(--blur) * 0.5));
  -webkit-backdrop-filter: blur(calc(var(--blur) * 0.5));
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.card-search:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow), var(--glow);
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.8);
}

.card-search:nth-of-type(even) {
  background: rgba(248, 250, 252, 0.4);
}

html.dark .card-search {
  background: var(--surface);
}

html.dark .card-search:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: var(--accent);
}

html.dark .card-search:nth-of-type(even) {
  background: rgba(15, 23, 42, 0.3);
}

.card-h {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-add {
  width: var(--touch-target);
  height: var(--touch-target);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent);
  font-size: clamp(0.95rem, 0.9rem + 0.25vw, 1.15rem);
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

html.dark .btn-add {
  background: rgba(59, 130, 246, 0.18);
}

.btn-add:hover {
  background: rgba(37, 99, 235, 0.22);
}

html.dark .btn-add:hover {
  background: rgba(59, 130, 246, 0.28);
}

/* Buttons & inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.45rem, 0.35vw + 0.38rem, 0.65rem) clamp(0.85rem, 0.8vw + 0.55rem, 1.2rem);
  border: 1px solid var(--glass-border);
  border-radius: calc(var(--radius) - 6px);
  font-weight: 700;
  font-size: clamp(0.78rem, 0.74rem + 0.1vw, 0.9rem);
  cursor: pointer;
  min-height: calc(var(--touch-target) * 0.72);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow);
}

.btn-secondary {
  background: rgba(226, 232, 240, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
}

.btn-secondary:hover {
  background: rgba(241, 245, 249, 0.9);
  transform: translateY(-2px);
}

html.dark .btn-secondary {
  background: rgba(30, 41, 59, 0.6);
}
html.dark .btn-secondary:hover {
  background: rgba(51, 65, 85, 0.9);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  border: none;
}

html.dark .btn-danger {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.8) 0%, rgba(185, 28, 28, 0.8) 100%);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

.btn-imminent {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.btn-imminent:hover {
  background: rgba(34, 197, 94, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
}

html.dark .btn-imminent {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.35);
}

.btn-small {
  padding: clamp(0.32rem, 0.25vw + 0.28rem, 0.48rem) clamp(0.55rem, 0.5vw + 0.4rem, 0.8rem);
  font-size: clamp(0.78rem, 0.74rem + 0.1vw, 0.9rem);
  min-height: calc(var(--touch-target) * 0.58);
}

.btn-tiny {
  width: 1.5rem !important;
  height: 1.5rem !important;
  min-width: 1.5rem !important;
  min-height: 1.5rem !important;
  font-size: 0.75rem !important;
}

.file-label {
  cursor: pointer;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: clamp(0.48rem, 0.4vw + 0.38rem, 0.72rem) clamp(0.65rem, 0.55vw + 0.5rem, 0.95rem);
  border: 1px solid var(--glass-border);
  border-radius: calc(var(--radius) - 2px);
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: var(--text);
  font-size: clamp(0.78rem, 0.74rem + 0.1vw, 0.9rem);
}

html.dark .input,
html.dark .select,
html.dark .textarea {
  background: rgba(30, 41, 59, 0.4);
}

.input,
.select {
  min-height: calc(var(--touch-target) * 0.62);
}

.input-sm {
  width: auto;
  min-width: 6rem;
  max-width: 10rem;
}

.textarea {
  resize: vertical;
  min-height: clamp(6.5rem, 14vh, 12rem);
}

html.dark option {
  background-color: #1e293b;
  color: #f8fafc;
}

.hint {
  font-size: clamp(0.68rem, 0.65rem + 0.08vw, 0.78rem);
  color: var(--muted);
  margin: 0.35rem 0 0;
}

/* Modals — fullscreen pe orice ecran */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal {
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  width: min(900px, calc(100vw - 2rem));
  max-width: none;
  flex: 0 1 auto;
  margin: auto;
  min-height: 0;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-wide {
  max-width: none;
}

.modal-head {
  flex-shrink: 0;
  padding: calc(1rem + var(--safe-top)) calc(1rem + var(--safe-right)) 1rem calc(1rem + var(--safe-left));
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h2 {
  margin: 0;
  font-size: 0.9rem;
}

.modal-body {
  flex: 1;
  min-height: 0;
  padding: clamp(0.85rem, 2vw, 1.25rem) calc(clamp(0.85rem, 2vw, 1.25rem) + var(--safe-right)) clamp(0.85rem, 2vw, 1.25rem) calc(clamp(0.85rem, 2vw, 1.25rem) + var(--safe-left));
  overflow: auto;
}

.modal-foot {
  flex-shrink: 0;
  padding: 1rem calc(1rem + var(--safe-right)) calc(1rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.ai-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: clamp(0.78rem, 0.74rem + 0.08vw, 0.9rem);
  line-height: 1.55;
  font-family: inherit;
}

/* Debug — bară discretă jos, lățime completă (nu overlay pe tot ecranul) */
.debug-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  z-index: 140;
  width: 100%;
  max-width: 100vw;
  height: var(--debug-dock-height);
  min-height: 112px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

html.dark .debug-panel {
  background: var(--surface);
  box-shadow: var(--shadow);
}

.debug-panel[hidden] {
  display: none !important;
}

.debug-head {
  flex-shrink: 0;
  padding: 0.4rem calc(0.5rem + var(--safe-right)) 0.4rem calc(0.5rem + var(--safe-left));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.debug-actions {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
}

.debug-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.35rem calc(0.45rem + var(--safe-right)) calc(0.5rem + var(--safe-bottom)) calc(0.45rem + var(--safe-left));
  font-family: ui-monospace, monospace;
  font-size: 0.62rem;
  line-height: 1.35;
  opacity: 0.95;
}

.debug-line {
  border-left: 2px solid var(--border);
  padding-left: 0.35rem;
  margin-bottom: 0.25rem;
}

.debug-xml-block {
  display: block;
  margin: 0.3rem 0 0.35rem;
  padding: 0.45rem 0.5rem;
  max-height: min(45vh, 28rem);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  font-size: 0.58rem;
  line-height: 1.4;
  color: inherit;
}

html.dark .debug-xml-block {
  background: rgba(0, 0, 0, 0.25);
}

.debug-error {
  border-color: #ef4444;
  color: #f87171;
}

.debug-warn {
  border-color: #eab308;
  color: #facc15;
}

.debug-api {
  border-color: var(--accent);
  color: #93c5fd;
}

.debug-ui {
  border-color: #22c55e;
  color: #86efac;
}

/* Mesaje din browser (console / manifest / resurse) — F12 */
.debug-browser-warn {
  border-color: #ea580c;
  color: #fdba74;
}

.debug-browser-error {
  border-color: #dc2626;
  color: #fca5a5;
}

.debug-ts {
  color: var(--muted);
}

.debug-type {
  font-weight: 700;
  opacity: 0.7;
}

.pad {
  padding: 1.5rem;
}

/* Footer */
.footer {
  flex-shrink: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.4rem clamp(0.75rem, 2vw, 1.5rem) calc(0.5rem + var(--safe-bottom));
  font-size: 0.6rem;
  color: var(--muted);
  text-align: center;
}

.footer-sep {
  margin: 0 0.35rem;
}

/* Animatie Cautare */
.loading-pulse {
  animation: searchPulse 1.5s infinite ease-in-out;
  opacity: 0.7;
  pointer-events: auto !important;
}
@keyframes searchPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

/* --- Export Dropdown --- */
.dropdown-wrap {
  position: relative;
  display: inline-block;
}

.dropdown-popover {
  position: absolute;
  top: 110%;
  left: 0;
  min-width: 160px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  z-index: 1000;
  display: none;
  flex-direction: column;
  padding: 0.5rem;
  gap: 0.25rem;
  backdrop-filter: blur(8px);
}

.dropdown-popover:not([hidden]) {
  display: flex;
}

.dropdown-popover button {
  background: transparent;
  border: none;
  padding: 0.65rem 1rem;
  text-align: left;
  border-radius: var(--radius-sm);
  color: var(--text-color);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.dropdown-popover button:hover {
  background: var(--bg-hover);
  color: var(--primary-color);
  padding-left: 1.25rem;
}

.dark .dropdown-popover {
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.btn-active {
  background-color: var(--primary) !important;
  color: white !important;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
  border-color: transparent !important;
}

/* Import Progress */
.import-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border);
  flex: 1;
  max-width: min(100%, 22rem);
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s ease;
}

.progress-fill.is-complete {
  background: #22c55e;
}

/* CloudSync — bară progres: ieșiri ↑ roșu, intrări ↓ verde, total în Cloud */
.cloud-sync-summary {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.35;
}
.cloud-sync-sep {
  color: var(--muted);
  font-weight: 400;
}
.cloud-sync-arrow-red,
.cloud-sync-arrow-green {
  display: inline-block;
  font-size: 1.5em;
  font-weight: 800;
  line-height: 1;
  vertical-align: -0.1em;
  margin-right: 0.08em;
}
.cloud-sync-arrow-red {
  color: #dc2626;
}
.cloud-sync-arrow-green {
  color: #15803d;
}
html.dark .cloud-sync-arrow-red {
  color: #f87171;
}
html.dark .cloud-sync-arrow-green {
  color: #4ade80;
}
.cloud-sync-in-cloud {
  color: #15803d;
  font-weight: 700;
}
html.dark .cloud-sync-in-cloud {
  color: #4ade80;
}
.cloud-sync-wipe,
.cloud-sync-add {
  font-weight: 700;
}

@media (max-width: 768px) {
  .import-progress {
      max-width: none;
      width: 100%;
      margin-top: 0.5rem;
  }
}