*, *::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: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #334155;
  --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; }
.sidebar-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 1.25rem 1rem; border-bottom: 1px solid #334155; color: white; 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: #334155; color: #cbd5e1; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 500; }
.sidebar-footer { padding: 1rem; border-top: 1px solid #334155; 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: #e2e8f0; 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 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: #f3f4f6; color: #4b5563; }
.badge-final { background: #dcfce7; color: #15803d; }
.badge-arhivat { background: #e5e7eb; color: #6b7280; }
.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; }

/* 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: flex-end; }
.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); }
