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

:root {
  --sidebar-w: 220px;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning-bg: #fef3c7;
  --warning-border: #f59e0b;
  --warning-text: #92400e;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --sidebar-bg: #f8fafc;
  --sidebar-text: #64748b;
  --sidebar-active: #2563eb;
  --sidebar-active-bg: #eff6ff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

.screen { width: 100%; min-height: 100vh; }
.hidden { display: none !important; }

/* LOGIN */
#login-screen { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); }
.login-box { background: var(--surface); border-radius: var(--radius-lg); padding: 2.5rem; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 2rem; }
.logo-icon { width: 56px; height: 56px; background: var(--accent); color: white; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; margin: 0 auto 1rem; }
.logo-icon.sm { width: 32px; height: 32px; font-size: 14px; border-radius: 6px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.login-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* MAIN LAYOUT */
#main-screen { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; height: 100vh; z-index: 10; border-right: 1px solid #e2e8f0; }
.sidebar-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 1.25rem 1rem; border-bottom: 1px solid #e2e8f0; color: #1e293b; font-weight: 600; font-size: 15px; text-align: center; }
.sidebar-logo-img { max-width: 140px; max-height: 80px; width: auto; height: auto; object-fit: contain; display: block; }
.login-logo-img { max-width: 200px; max-height: 100px; width: auto; height: auto; object-fit: contain; display: block; margin: 0 auto 1rem; }
.sidebar-nav { flex: 1; padding: 1rem 0.5rem; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 0.6rem 0.75rem; color: var(--sidebar-text); text-decoration: none; border-radius: var(--radius); font-size: 14px; transition: all 0.15s; }
.nav-item:hover { background: #f1f5f9; color: #374151; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 500; }
.sidebar-footer { padding: 1rem; border-top: 1px solid #e2e8f0; display: flex; align-items: center; gap: 8px; }
.user-info { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.avatar { width: 32px; height: 32px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.user-text { flex: 1; min-width: 0; overflow: hidden; }
.user-name { font-size: 13px; color: #1e293b; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .btn-icon { flex-shrink: 0; }
.content { margin-left: var(--sidebar-w); flex: 1; padding: 2rem; min-height: 100vh; }

/* PAGES */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h2 { font-size: 20px; font-weight: 600; }
.badge-count { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: block; }

/* EXPIRING BANNER */
.expiring-banner { background: var(--warning-bg); border: 1px solid var(--warning-border); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1.25rem; color: var(--warning-text); font-size: 13px; }
.expiring-banner strong { font-weight: 600; }
.expiring-banner ul { margin: 6px 0 0 1rem; }
.expiring-banner li { margin-bottom: 2px; }

/* FILTERS */
.filters { display: flex; gap: 8px; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filters input, .filters select { padding: 0.45rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: var(--surface); color: var(--text); outline: none; transition: border 0.15s; }
.filters input { width: 200px; }
.filters input:focus, .filters select:focus { border-color: var(--accent); }

/* TABLE */
.table-wrapper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { background: #f9fafb; padding: 0.75rem 1rem; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th[data-sort] { cursor: pointer; user-select: none; }
.data-table th[data-sort]:hover { color: var(--text-primary); }
.sort-icon { display: inline-block; width: 10px; font-style: normal; text-transform: none; }
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f0f4ff; cursor: pointer; }
.empty-state { text-align: center; color: var(--text-light); padding: 3rem 1rem !important; }

/* STATUS BADGES */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.badge-draft { background: #dbeafe; color: #1d4ed8; }
.badge-final { background: #dcfce7; color: #15803d; }
.badge-arhivat { background: #f1f5f9; color: #475569; }
.badge-expira { background: #fef3c7; color: #92400e; }
.badge-operator { background: #dbeafe; color: #1d4ed8; }
.badge-utilizator { background: #f3f4f6; color: #374151; }
.badge-admin { background: #dcfce7; color: #15803d; }
.badge-default { background: #ede9fe; color: #5b21b6; }

/* EXPIRY CELL */
.expiry-warning { color: #b45309; font-weight: 600; }
.expiry-ok { color: var(--text-muted); }
.expiry-expired { color: var(--danger); font-weight: 600; }
.expiry-special { color: var(--text-muted); font-style: italic; }
.badge-unsigned { display: inline-block; font-size: 11px; font-weight: 500; color: #b45309; white-space: nowrap; margin-left: 5px; }

/* ROW ACTIONS */
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity 0.15s; }
tr:hover .row-actions { opacity: 1; }

/* BUTTONS */
.btn { padding: 0.5rem 1rem; border-radius: var(--radius); border: 1px solid transparent; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-notify { background: #0891b2; color: white; border-color: #0891b2; }
.btn-notify:hover { background: #0e7490; }
.btn-full { width: 100%; justify-content: center; padding: 0.65rem 1rem; }
.btn-icon { background: transparent; border: none; cursor: pointer; padding: 6px; border-radius: 6px; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s; }
.btn-icon:hover { background: rgba(255,255,255,0.1); color: #cbd5e1; }
.btn-icon.dark:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 12px; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; color: var(--text); background: var(--surface); outline: none; transition: border 0.15s; font-family: inherit; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-section-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 1.25rem 0 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.required { color: var(--danger); }

/* ALERTS */
.alert { padding: 0.6rem 0.75rem; border-radius: var(--radius); font-size: 13px; margin-top: 0.5rem; }
.alert-danger { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }

/* MODALS */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 600px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); max-height: 90vh; display: flex; flex-direction: column; }
.modal-lg { max-width: 760px; }
.modal-sm { max-width: 420px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-header .btn-icon { color: var(--text-muted); }
.modal-header .btn-icon:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }

/* DETAIL DRAWER */
.detail-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 200; display: flex; justify-content: flex-end; }
.detail-drawer { width: 640px; max-width: 100vw; height: 100vh; background: var(--surface); display: flex; flex-direction: column; box-shadow: -4px 0 32px rgba(0,0,0,0.15); overflow: hidden; }
.detail-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-shrink: 0; background: #f9fafb; }
.detail-title-block { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-nr-badge { font-size: 12px; color: var(--text-muted); background: var(--border); padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.detail-client-name { font-size: 17px; font-weight: 700; color: var(--text); }
.detail-header-btns { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.detail-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface); }
.dtab-btn { padding: 0.75rem 1.25rem; border: none; background: transparent; font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s; display: flex; align-items: center; gap: 6px; }
.dtab-btn:hover { color: var(--text); }
.dtab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count { background: var(--border); color: var(--text-muted); border-radius: 99px; padding: 0px 6px; font-size: 11px; font-weight: 600; }
.detail-body { flex: 1; overflow-y: auto; }
.dtab-content { padding: 1.5rem; }

/* DETAIL INFO GRID */
.info-grid { display: grid; grid-template-columns: 140px 1fr; gap: 0; }
.info-row { display: contents; }
.info-label { padding: 8px 12px 8px 0; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid #f3f4f6; display: flex; align-items: center; }
.info-value { padding: 8px 0; font-size: 14px; color: var(--text); border-bottom: 1px solid #f3f4f6; word-break: break-word; }
.info-section { grid-column: 1/-1; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 16px 0 8px; border-bottom: 2px solid var(--border); margin-bottom: 4px; }

/* ATTACHMENTS */
.att-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 1rem; }
.att-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.att-icon { color: var(--accent); flex-shrink: 0; }
.att-info { flex: 1; min-width: 0; }
.att-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-meta { font-size: 11px; color: var(--text-muted); }
.att-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* UPLOAD AREA */
.upload-area { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; cursor: pointer; transition: all 0.15s; margin-bottom: 1rem; }
.upload-area:hover { border-color: var(--accent); background: #eff6ff; }
.upload-area input { display: none; }
.upload-area-label { cursor: pointer; color: var(--text-muted); font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ADDENDA */
.addendum-card { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.addendum-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #f9fafb; cursor: pointer; }
.addendum-title { font-weight: 600; font-size: 13px; }
.addendum-meta { font-size: 12px; color: var(--text-muted); }
.addendum-body { padding: 12px 14px; border-top: 1px solid var(--border); }

/* SETTINGS PAGE */
.settings-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.stab-btn { padding: 0.65rem 1.25rem; border: none; background: transparent; font-size: 14px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s; }
.stab-btn:hover { color: var(--text); }
.stab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow); }
.settings-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 1.25rem; }
.settings-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.settings-item-value { flex: 1; font-size: 14px; }
.settings-item-order { font-size: 12px; color: var(--text-muted); width: 60px; }
.settings-add-form { display: flex; gap: 8px; align-items: center; }
.settings-add-form .form-group { margin-bottom: 0; flex: 1; }

/* PERSON TAG SELECTOR */
.person-tags-wrap { display: flex; flex-direction: column; gap: 6px; }
.person-tags { display: flex; flex-wrap: wrap; gap: 5px; min-height: 36px; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.person-tags:empty::before { content: 'Niciun selectat'; color: var(--text-light); font-size: 13px; display: flex; align-items: center; }
.person-tag { display: inline-flex; align-items: center; gap: 5px; background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; border-radius: 99px; padding: 2px 6px 2px 10px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.person-tag-email { font-weight: 400; opacity: 0.75; font-size: 11px; }
.person-tag-remove { background: none; border: none; cursor: pointer; color: #93c5fd; font-size: 15px; line-height: 1; padding: 0 1px; display: flex; align-items: center; }
.person-tag-remove:hover { color: #1d4ed8; }
.person-tags-add select { width: 100%; padding: 0.4rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; color: var(--text); background: var(--surface); outline: none; }
.person-tags-add select:focus { border-color: var(--accent); }

/* STAGED FILES IN MODAL */
.staged-files { display: flex; flex-direction: column; gap: 6px; margin-bottom: 0.75rem; }
.staged-file { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.staged-file-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.staged-file-type { flex-shrink: 0; width: 180px; }
.staged-file-type select { width: 100%; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; background: white; color: var(--text); }

/* PERSOANE SETTINGS */
.persoana-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.persoana-item-info { flex: 1; min-width: 0; }
.persoana-item-name { font-size: 14px; font-weight: 500; }

/* SETTINGS DRAG AND DROP */
.settings-item { cursor: default; transition: opacity 0.15s, background 0.15s, border-color 0.15s; }
.settings-item.dragging { opacity: 0.35; }
.settings-item.drag-over { background: #eff6ff !important; border-color: #2563eb !important; }
.drag-handle { cursor: grab; color: var(--text-muted); font-size: 15px; padding: 0 4px; user-select: none; flex-shrink: 0; }
.drag-handle:active { cursor: grabbing; }

/* SISTEM MULTI-CHECK */
.sistem-checks-wrap { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--bg); min-height: 38px; }
.sistem-check-item { display: flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.sistem-check-item input[type=checkbox] { width: auto; margin: 0; cursor: pointer; }
.persoana-item-email { font-size: 12px; color: var(--text-muted); }

/* ─── MOBILE TOPBAR ────────────────────────────────────────────────────────── */
.mobile-topbar { display: none; position: fixed; top: 0; left: 0; right: 0; height: 56px; background: var(--sidebar-bg); z-index: 50; align-items: center; padding: 0 1rem; gap: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.mobile-menu-btn { background: transparent; border: none; color: #64748b; padding: 8px; cursor: pointer; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.mobile-menu-btn:hover, .mobile-menu-btn:active { background: #e2e8f0; color: #1e293b; }
.mobile-topbar-title { color: #1e293b; font-weight: 600; font-size: 16px; flex: 1; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 390; }
.sidebar-overlay.open { display: block; }

/* ─── RESPONSIVE (≤ 1024px) ─────────────────────────────────────────────────── */
@media (max-width: 1024px) {

  /* Topbar vizibil */
  .mobile-topbar { display: flex; }

  /* Sidebar: ascuns implicit, slide-in la deschidere */
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; z-index: 400; }
  .sidebar.open { transform: translateX(0); }

  /* Content: full width, spatiu pentru topbar */
  .content { margin-left: 0; padding: 1rem; padding-top: calc(56px + 1rem); }

  /* Tabel: scroll orizontal, nu se mai rupe layout-ul */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 520px; }

  /* Row actions: mereu vizibile pe touch (nu exista hover) */
  .row-actions { opacity: 1; }

  /* Page header: se impacheteaza pe 2 randuri */
  .page-header { flex-wrap: wrap; gap: 0.75rem; }

  /* Filtre: input full width, select-urile se impacheteaza */
  .filters { gap: 6px; }
  .filters input { width: 100%; }
  .filters select { flex: 1; min-width: 130px; }

  /* Formulare: o singura coloana */
  .form-row { grid-template-columns: 1fr; gap: 0; }

  /* Modal: bottom-sheet (apare de jos in sus) */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-lg, .modal-sm { max-width: 100%; }
  .modal-body { padding: 1rem; }
  .modal-header { padding: 1rem 1rem 1rem 1.25rem; }
  .modal-footer { padding: 0.75rem 1rem; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; justify-content: center; min-width: 80px; }

  /* Drawer detalii: full width */
  .detail-drawer { width: 100vw; }
  .detail-header { padding: 0.875rem 1rem; flex-wrap: wrap; }
  .detail-header-btns .btn-sm { padding: 0.25rem 0.5rem; font-size: 11px; }
  .dtab-content { padding: 1rem; }

  /* Tab-uri detalii: se rupe pe mai multe randuri */
  .detail-tabs { overflow-x: unset; flex-wrap: wrap; }
  .dtab-btn { white-space: normal; flex-shrink: 1; font-size: 12px; padding: 0.6rem 0.75rem; }

  /* Info grid: label mai ingusta */
  .info-grid { grid-template-columns: 100px 1fr; }

  /* Settings tabs: se rupe pe mai multe randuri, fara scroll orizontal */
  .settings-tabs { flex-wrap: wrap; overflow-x: unset; gap: 2px; }
  .stab-btn { white-space: normal; flex-shrink: 1; padding: 0.55rem 0.9rem; font-size: 13px; }
  .settings-content { padding: 1rem; overflow-x: hidden; }

  /* Fisiere staged in modal: select pe rand separat */
  .staged-file { flex-wrap: wrap; }
  .staged-file-type { width: 100%; margin-top: 4px; }

  /* Login: padding redus pe ecrane mici */
  .login-box { padding: 1.75rem 1.25rem; border-radius: var(--radius); }

  /* Addendum header: wrap */
  .addendum-header { flex-wrap: wrap; gap: 4px; }

  /* Butoane actiuni drawer */
  .detail-header-btns { flex-wrap: wrap; gap: 4px; }

  /* ── Cards 2 randuri — Contracte ──────────────────────────────────────── */
  #page-contracts .data-table { display: block; min-width: unset; }
  #page-contracts .data-table thead { display: none; }
  #page-contracts .data-table tbody { display: block; }
  #page-contracts .data-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    align-items: start;
    column-gap: 8px;
    row-gap: 2px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }
  #page-contracts .data-table td { display: none; padding: 0; border: none; }
  #page-contracts .data-table td:nth-child(2) {
    display: block; grid-column: 1; grid-row: 1;
    font-weight: 600; font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #page-contracts .data-table td:nth-child(8) {
    display: block; grid-column: 2; grid-row: 1; text-align: right;
  }
  #page-contracts .data-table td:nth-child(8) .badge-unsigned {
    display: block; text-align: right; font-size: 10px; margin-left: 0;
  }
  #page-contracts .data-table td:nth-child(3) {
    display: block; grid-column: 1; grid-row: 2;
    font-size: 12px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #page-contracts .data-table td:nth-child(5) {
    display: block; grid-column: 2; grid-row: 2;
    font-size: 12px; color: var(--text-muted); text-align: right; white-space: nowrap;
  }
  #page-contracts .data-table td:nth-child(9) {
    display: block; grid-column: 1 / -1; grid-row: 3; text-align: right;
  }

  /* Utilizatori: raman Nume | Rol | Actiuni */
  #page-users .data-table th:nth-child(2), #page-users .data-table td:nth-child(2),
  #page-users .data-table th:nth-child(4), #page-users .data-table td:nth-child(4)
  { display: none; }
  #page-users .data-table { min-width: unset; }

  /* ── Cards 2 randuri — Drafturi ────────────────────────────────────────── */
  #page-drafts .data-table { display: block; min-width: unset; }
  #page-drafts .data-table thead { display: none; }
  #page-drafts .data-table tbody { display: block; }
  #page-drafts .data-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: start;
    column-gap: 8px;
    row-gap: 3px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }
  #page-drafts .data-table td { display: none; padding: 0; border: none; }
  #page-drafts .data-table td:nth-child(2) {
    display: block; grid-column: 1; grid-row: 1;
    font-weight: 600; font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #page-drafts .data-table td:nth-child(6) {
    display: block; grid-column: 2; grid-row: 1 / 3; align-self: center;
  }
  #page-drafts .data-table td:nth-child(1) {
    display: block; grid-column: 1; grid-row: 2;
    font-size: 12px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #page-drafts .data-table td:nth-child(5) {
    display: none;
  }

  /* ── Touch targets mai mari ───────────────────────────────────────────── */
  .nav-item { padding: 0.75rem; }
  .btn { padding: 0.6rem 1rem; }
  .btn-sm { padding: 0.45rem 0.75rem; font-size: 13px; }
  .btn-icon { padding: 10px; }
  .dtab-btn { padding: 0.6rem 0.75rem; }
  .stab-btn { padding: 0.75rem 1rem; }

  /* Butoane tabel: doar icona, fara text */
  .data-table .btn-label { display: none; }
  .data-table td:last-child .btn { padding: 6px 8px; }

  /* ── Filtru: buton Reseteaza full-width ───────────────────────────────── */
  .filters .btn { width: 100%; justify-content: center; }
}

/* ─── AUDIT / ISTORIC MODIFICARI ────────────────────────────────────────────── */
.audit-list { display: flex; flex-direction: column; padding: 0.5rem 1rem; }
.audit-item { display: flex; gap: 12px; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.audit-item:last-child { border-bottom: none; }
.audit-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.audit-body { flex: 1; min-width: 0; }
.audit-header { display: flex; flex-direction: column; gap: 2px; }
.audit-action { font-size: 13px; font-weight: 600; color: var(--text); }
.audit-meta { font-size: 11px; color: var(--text-muted); }
.audit-details { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.65; }

/* ─── DARK MODE ─────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {

  /* Indica browser-ului sa foloseasca dark pentru scrollbars si form controls */
  html { color-scheme: dark; }

  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-light: #475569;
    --sidebar-bg: #0b1120;
    --sidebar-text: #64748b;
    --sidebar-active: #f1f5f9;
    --sidebar-active-bg: #1d4ed8;
    --shadow: 0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
    --warning-bg: #451a03;
    --warning-border: #92400e;
    --warning-text: #fde68a;
  }

  /* Select dark mode */
  select { color-scheme: dark; background: var(--surface); color: var(--text); border-color: var(--border); }
  option { background: #1e293b; color: #e2e8f0; }

  /* Tabel */
  .data-table th { background: #111e2e; }
  .data-table th[data-sort]:hover { color: #e2e8f0; }
  .data-table tbody tr:hover { background: #172133; }
  .data-table td { border-bottom-color: #1e2d42; }

  /* Drawer detalii */
  .detail-header { background: #111e2e; }
  .info-label, .info-value { border-bottom-color: #1e2d42; }
  .info-section { border-bottom-color: var(--border); }

  /* Carduri acte aditionale */
  .addendum-header { background: #111e2e; }

  /* Person tags */
  .person-tag { background: #1e3a5f; border-color: #2563eb; color: #93c5fd; }
  .upload-area:hover { background: #162032; border-color: var(--accent); }

  /* Badges */
  .badge-unsigned { color: #fbbf24; }
  .badge-draft     { background: #1e3a5f; color: #93c5fd; }
  .badge-final     { background: #14532d; color: #86efac; }
  .badge-arhivat   { background: #1e293b; color: #94a3b8; }
  .badge-expira    { background: #78350f; color: #fde68a; }
  .badge-operator  { background: #1e3a5f; color: #93c5fd; }
  .badge-utilizator{ background: #374151; color: #d1d5db; }
  .badge-admin     { background: #14532d; color: #86efac; }
  .badge-default   { background: #3b0764; color: #c084fc; }

  /* Alerts */
  .alert-danger  { background: #450a0a; border-color: #991b1b; color: #fca5a5; }
  .alert-success { background: #052e16; border-color: #166534; color: #86efac; }

  /* Expirare */
  .expiry-warning { color: #f59e0b; }
  .expiry-expired { color: #f87171; }
  .expiry-ok      { color: var(--text-muted); }

  /* Overlays */
  .modal-overlay   { background: rgba(0,0,0,0.7); }
  .detail-overlay  { background: rgba(0,0,0,0.55); }
  .sidebar-overlay { background: rgba(0,0,0,0.75); }

  /* Elemente diverse */
  .detail-nr-badge { background: var(--border); color: var(--text-muted); }
  .tab-count       { background: var(--border); color: var(--text-muted); }
  .drag-handle     { color: var(--text-light); }
  .settings-item.drag-over { background: #1e3a5f !important; border-color: var(--accent) !important; }

  /* Butoane */
  .btn-ghost { color: var(--text-muted); border-color: var(--border); }
  .btn-ghost:hover { background: var(--border); color: var(--text); }
  .btn-icon:hover  { background: rgba(255,255,255,0.08); }
  .btn-icon.dark:hover { background: var(--border); color: var(--text); }

  /* Inputuri: focus ring mai vizibil pe dark */
  .form-group input:focus,
  .form-group select:focus,
  .form-group textarea:focus { box-shadow: 0 0 0 3px rgba(37,99,235,0.3); }

  /* Filters */
  .filters input:focus,
  .filters select:focus { border-color: var(--accent); }

  /* Sidebar - dark mode */
  .sidebar { border-right-color: transparent; }
  .sidebar-logo { border-bottom-color: #1e293b; color: #f1f5f9; }
  .nav-item:hover { background: #334155; color: #cbd5e1; }
  .sidebar-footer { border-top-color: #1e293b; }
  .user-name { color: #e2e8f0; }
  .mobile-topbar-title { color: white; }
  .mobile-menu-btn { color: #94a3b8; }
  .mobile-menu-btn:hover, .mobile-menu-btn:active { background: #334155; color: white; }
}

/* ─── MOBILE: ELIMINARE SCROLL ORIZONTAL ───────────────────────────────────── */
@media (max-width: 1024px) {
  /* Radacina: zero scroll orizontal la nivel de pagina */
  html, body { overflow-x: hidden; max-width: 100%; }
  .content { overflow-x: hidden; max-width: 100%; }
  .page { overflow-x: hidden; }

  /* Forteaza toate div-urile directe din settings-content la max 100% */
  .settings-content > div { max-width: 100% !important; width: 100% !important; box-sizing: border-box; }

  /* Celule tabel: text lung → ellipsis (...) in loc de word-break */
  .data-table { table-layout: fixed; }
  .data-table th { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .data-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: normal; }
  /* Coloana actiuni (ultima): nu se trunchiaza, latime fixa */
  .data-table th:last-child,
  .data-table td:last-child { width: 88px; overflow: visible; white-space: nowrap; }

  /* Table wrapper: nu mai are nevoie de scroll orizontal dupa column hiding */
  #page-contracts .table-wrapper,
  #page-users    .table-wrapper,
  #page-drafts   .table-wrapper { overflow-x: hidden; }

  /* Elemente cu latime fixa din JS: reset pe mobil */
  .staged-file-type { width: 100%; min-width: 0; }
  .filters input { min-width: 0; }
  .filters select { min-width: 0; }

  /* Form rows din settings (SMTP etc.): fara min-width inline */
  .form-group [style*="min-width"] { min-width: 0 !important; }
}
