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

:root {
  --bg: #e9edf2;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --text: #1a1d24;
  --text-muted: #5a6270;
  --border: #d8dde4;
  --primary: #1e63d6;
  --primary-hover: #194fa8;
  --warn: #c97a1c;
  --error: #c0392b;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 8px 24px rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #1a1d24;
    --surface-2: #22262f;
    --text: #e8eaee;
    --text-muted: #8a92a0;
    --border: #2a2f3a;
    --primary: #4d8cf5;
    --primary-hover: #6ba2ff;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.4);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;  /* dynamic viewport — fix iOS/Android browser chrome */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

.auth-container {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  animation: fadeUp 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.brand {
  text-align: center;
  margin-bottom: 2rem;
}

.brand h1 {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: clamp(1.65rem, 5vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  color: var(--primary);
  margin-bottom: 0.25rem;
}
.brand h1 .x {
  color: #dc2626;
}

.brand-subtitle {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field input {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  transition: border-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
              background 200ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* Wrapper for password field with toggle button */
.input-wrap {
  position: relative;
}
.input-wrap input {
  padding-right: 2.75rem;
}
.toggle-pw {
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  touch-action: manipulation;
  transition: color 200ms cubic-bezier(0.16, 1, 0.3, 1),
              background 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.toggle-pw:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  color: var(--text);
}
.toggle-pw svg { width: 1.2rem; height: 1.2rem; }

.submit-btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.875rem 1.25rem;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 200ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
  margin-top: 0.5rem;
}

.submit-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.submit-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status {
  text-align: center;
  font-size: 0.875rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-muted);
}

.status.warn { color: var(--warn); }
.status.error { color: var(--error); }

.status.spinning::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: -3px;
  animation: spin 0.8s linear infinite;
}

.status.warn:not(.spinning)::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c97a1c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  margin-right: 0.5rem;
  vertical-align: -3px;
}

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

/* Reduced motion preference — disable animations */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ── Language switcher ── */
.lang-switcher {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 1.9rem 0.4rem 0.7rem;
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6270' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 12px;
  box-shadow: var(--shadow);
  touch-action: manipulation;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  z-index: 10;
  min-width: 7rem;
  min-height: 36px;
}
.lang-switcher:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-color: var(--primary);
}
@media (prefers-color-scheme: dark) {
  .lang-switcher {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a92a0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/polyline%3E%3C/svg%3E");
  }
}
/* ─── Responsive layout — mobile breakpoints ─── */
@media (max-width: 480px) {
  body {
    padding: 0.75rem;
    padding-top: max(0.75rem, env(safe-area-inset-top));
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
  .auth-container { padding: 1.75rem; }
  .lang-switcher {
    top: max(0.5rem, env(safe-area-inset-top));
    right: max(0.5rem, env(safe-area-inset-right));
    font-size: 0.8rem;
    min-width: auto;
  }
}
@media (max-width: 360px) {
  .auth-container { padding: 1.5rem; }
}

/* ─── Hover states — only on devices with hover pointer (mouse), not on touch ─── */
@media (hover: hover) and (pointer: fine) {
  .toggle-pw:hover { color: var(--text); background: var(--bg); }
  .submit-btn:hover:not(:disabled) { background: var(--primary-hover); }
  .lang-switcher:hover { border-color: var(--primary); }
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD (Faza C)
   ═══════════════════════════════════════════════════════════ */

body.dashboard-body {
  display: block;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

/* ── Header ── */
.dashboard-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  padding-top: max(0.75rem, env(safe-area-inset-top));
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand-link {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
}
.brand-mark {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  color: var(--primary);
}
.brand-mark .x { color: #dc2626; }

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-who {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-right: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 30rem;
}
.user-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.3rem 0.6rem;
  background: var(--bg);
  border-radius: 6px;
  display: inline-block;
  max-width: 26rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Smaller lang switcher pentru header (override fixed-position) */
.lang-switcher-inline {
  position: static;
  box-shadow: none;
  min-width: 4rem;
  min-height: 36px;
  font-size: 0.8rem;
  padding: 0.35rem 1.6rem 0.35rem 0.55rem;
}

/* ── Container central ── */
.dashboard-container {
  max-width: 760px;
  margin: 1.5rem auto;
  padding: 0 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Section card ── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  animation: fadeUp 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
.section-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Key-value list (dl) pentru read-only data ── */
.kv-list {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}
.kv-list dt {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}
.kv-list dd {
  font-size: 0.95rem;
  word-break: break-word;
}
.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  letter-spacing: 0.01em;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.count-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
}

/* ── details/summary (accordion) ── */
details {
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  padding-top: 0.75rem;
}
details summary {
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  list-style: none;
  user-select: none;
  touch-action: manipulation;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.5rem;
  color: var(--text-muted);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
details[open] > summary::before {
  transform: rotate(90deg);
}
details summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.summary-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: auto;
}

.editable-block { border-top-color: var(--primary); border-top-width: 2px; }

/* ── Bloc fix necolapsabil (Identitate) — înlocuiește details/summary ── */
.static-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 1rem;
  padding: 0.75rem 1rem 1rem;
}
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.block-head-actions { display: flex; align-items: center; gap: 0.75rem; }
.ud-rank { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 0.75rem; }
.ud-rank .rank-legend { color: var(--text-muted); font-size: 0.78rem; }
/* Rând: butoane status (stânga) + Grad de autoritate (dreapta), lipit deasupra liniei blocului identitate */
.ud-actions-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin: 0.5rem 0 0.75rem; }
.ud-actions-row .ud-rank { margin: 0; }
.ud-actions-row .status-actions { margin-top: 0; }   /* centrare verticală în rând (anulează offset-ul de 16px) */
/* combo grad — același stil ca selectoarele din Search (.search-filters select) */
.ud-rank select { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 0.9rem; font-family: inherit; cursor: pointer; }
/* Edit + Aplică — aceeași dimensiune (lățime egalizată indiferent de text) */
#ud-rank-apply, #ei-edit-btn { min-width: 6rem; }
.block-title {
  margin: 0;
  font-weight: 500;
  font-size: 1rem;
}
.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
/* ── Lățimi câmpuri după conținut + contact pe un rând (formular identitate) ── */
.field-sm { max-width: 12rem; }
.field-md { max-width: 20rem; }
.form-group .contact-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.form-group .contact-row input.field-uid { width: 11rem; flex: 0 0 auto; }
.inline-check { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; white-space: nowrap; cursor: pointer; }
.inline-check input[type="checkbox"] { width: auto; margin: 0; flex: 0 0 auto; }

/* ── Contacte asociate (afișare): aliniere coloane (nume min-width) + nume = link ── */
.ec-row { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.ec-name { min-width: 12rem; }
a.ec-name { color: var(--primary); text-decoration: none; }
a.ec-name:hover { text-decoration: underline; }
.ec-status { color: var(--text-muted); }

/* ── Modalități de autentificare (5 checkbox-uri, auto-save) ── */
.am-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.4rem; cursor: pointer; width: 100%; box-sizing: border-box; user-select: none; border-radius: 6px; }
.am-row:hover { background: var(--surface-2, rgba(127,127,127,.08)); }
.am-row input { width: auto; margin: 0; flex: 0 0 auto; }
.am-num { color: var(--text-muted); min-width: 1.2rem; }
.am-status { font-size: 0.8rem; }
.am-status.success { color: #2e8b3a; }
.am-status.warn { color: var(--error); }
.am-status.spinning { color: var(--text-muted); }
.am-arm-actions { display: flex; gap: 0.5rem; margin: 0.15rem 0 0.5rem 1.7rem; }
.am-arm-actions button { border-radius: 999px; padding: 5px 16px; color: #fff; border: none; font-weight: 600; cursor: pointer; font-size: 0.9rem; }
.am-arm-actions .am-arm   { background: #2563eb; }
.am-arm-actions .am-rearm { background: #e0a800; }
.am-arm-actions button:disabled { opacity: .4; cursor: not-allowed; }

/* ── Antet detaliu user: nume + status badge pe același rând ── */
.ud-header { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.ud-header h2 { margin: 0; }
/* UID — cifre mai mari */
.uid-value { font-size: 1.2rem; letter-spacing: 0.06em; }
.kv-actor { color: var(--text-muted); font-size: 0.85em; }
a.kv-actor-link { color: var(--primary); text-decoration: none; }
a.kv-actor-link:hover { text-decoration: underline; }

/* ── Settings groups (nested details) ── */
.settings-group { border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.875rem; margin-top: 0.75rem; }
.settings-group summary { padding: 0.5rem 0; }

/* ── Form groups ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin: 0.875rem 0;
}
.form-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
}
/* Adaugă user — secțiuni + grid + marcaj obligatoriu */
.au-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 1rem 0.75rem;
  margin: 1rem 0;
}
.au-section > legend {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  padding: 0 0.4rem;
}
.au-section .au-hint { font-weight: 400; color: var(--text-muted); }
.au-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
.au-grid .au-span2 { grid-column: 1 / -1; }
/* Cont: câmpuri scurte (credențiale), nu pe toată lățimea panoului */
.au-section > .form-group input { max-width: 22rem; }
.au-pw-toggle { display: inline-flex; align-items: center; gap: 0.4rem; margin: -0.3rem 0 0.6rem; font-size: 0.85rem; color: var(--text-muted); cursor: pointer; user-select: none; }
.au-pw-toggle input { width: auto; margin: 0; }
.form-group.required > label::after { content: " *"; color: var(--error); }
/* Dashboard — cardul „Identitatea mea" */
.id-summary { margin-bottom: 1rem; }
.id-name { font-size: 1.4rem; font-weight: 600; margin-right: 0.6rem; }
.id-meta { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.edit-actions { margin: 1rem 0; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.badge-ok { background: #1f9d57; color: #fff; }
.badge-warn { background: var(--warn); color: #fff; }
@media (max-width: 560px) {
  .au-grid { grid-template-columns: 1fr; }
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
.form-group textarea { resize: vertical; min-height: 2.5rem; }
.form-group input[type="range"] {
  width: 100%;
  height: 30px;
  accent-color: var(--primary);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text);
  min-height: 24px;
}
.checkbox-row input[type="checkbox"] {
  width: 18px; height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.warn-box {
  font-size: 0.82rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  border-radius: 4px;
  color: var(--text);
  margin-bottom: 0.5rem;
}

/* ── Buttons ── */
.btn-primary, .btn-secondary {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 200ms, border-color 200ms;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-primary:focus-visible, .btn-secondary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Documents list ── */
.documents-list { display: flex; flex-direction: column; gap: 0.5rem; }
.documents-list details {
  border: 1px solid var(--border);
  border-top: 1px solid var(--border);  /* override */
  border-radius: 8px;
  padding: 0.5rem 0.875rem;
  margin-top: 0;
  padding-top: 0.5rem;
}
.documents-list details summary {
  font-weight: 400;
  font-size: 0.92rem;
}
.documents-list dl.kv-list {
  margin-top: 0.5rem;
  font-size: 0.88rem;
}

/* ── Empty state ── */
.empty-state {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px dashed var(--border);
}

/* ── Loading placeholder ── */
.loading {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 0.5rem 0;
}

/* ── Status messages (reused from auth styles) ── */
.status.success {
  color: #2e8b3a;
  background: color-mix(in srgb, #2e8b3a 8%, transparent);
}

/* ── Footer ── */
.dashboard-container .footer {
  margin-top: 0;
  padding: 1rem 0 2rem;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .dashboard-header {
    padding: 0.6rem 0.85rem;
    gap: 0.5rem;
  }
  .brand-mark { font-size: 1.1rem; }
  .user-badge { font-size: 0.78rem; padding: 0.25rem 0.5rem; max-width: 14rem; }
  .admin-who { font-size: 0.9rem; max-width: 12rem; }
  .btn-secondary { font-size: 0.82rem; padding: 0.45rem 0.7rem; }
  .lang-switcher-inline { font-size: 0.75rem; min-width: 3.5rem; padding: 0.3rem 1.4rem 0.3rem 0.45rem; }
  .dashboard-container {
    margin: 1rem auto;
    padding: 0 0.5rem;
    gap: 0.875rem;
  }
  .section-card { padding: 1rem; }
  .kv-list {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  .kv-list dt { margin-top: 0.5rem; }
  .kv-list dt:first-child { margin-top: 0; }
}

@media (hover: hover) and (pointer: fine) {
  details summary:hover { color: var(--primary); }
  .btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
  .btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
}

/* ═══════════════════════════════════════════════════════════
   ADMIN PANEL (Faza D)
   ═══════════════════════════════════════════════════════════ */

.admin-container { max-width: 820px; }

/* ── Admin sidebar layout ── */
.admin-body .brand-mark { font-size: 2.1rem; }
.admin-body .dashboard-header {
  padding-left: max(1.25rem, (100% - 1100px) / 2 + 1rem);
  padding-right: max(1.25rem, (100% - 1100px) / 2 + 1rem);
}
.admin-layout {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}
.admin-sidebar {
  flex: 0 0 200px;
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem;
}
.nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.8rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.nav-btn .nav-icon { font-size: 1.05rem; width: 1.4rem; text-align: center; flex: 0 0 auto; }
@media (hover: hover) and (pointer: fine) { .nav-btn:hover { background: var(--bg); } }
.nav-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-btn.active {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  color: var(--primary);
  font-weight: 600;
}
.nav-btn.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; border-radius: 0 3px 3px 0; background: var(--primary);
}
.search-form .btn-primary {
  background: #4d8cf5;
  border-color: #4d8cf5;
}
.search-form .btn-primary:hover {
  background: #3a7ae8;
  border-color: #3a7ae8;
}
.sidebar-armed {
  margin-top: 0.5rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid #e0a800;
  color: #b58100;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}
.admin-main { flex: 1 1 auto; min-width: 0; }
.admin-panel { display: flex; flex-direction: column; gap: 1.25rem; }
.admin-panel[hidden] { display: none; }
.stats-subhead { margin-top: 1rem; font-size: 0.95rem; font-weight: 600; }
.awaiting-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.6rem; }
.awaiting-item {
  text-align: left; width: 100%;
  background: #fff7e6; border: 1px solid #e0a800; color: #8a6d00;
  border-radius: 8px; padding: 0.5rem 0.75rem; cursor: pointer; font-size: 0.9rem;
}
.awaiting-item:hover { background: #ffefc7; }
.search-filters { display: flex; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.search-filters select {
  padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 0.9rem;
}
.search-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.6rem; max-height: 60vh; overflow-y: auto; }
.search-item {
  text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 0.5rem 0.75rem; cursor: pointer; font-size: 0.9rem;
}
.search-item:hover { border-color: var(--primary); background: #f0f5fd; }
@media (max-width: 760px) {
  .admin-layout { flex-direction: column; gap: 0.875rem; margin: 1rem auto; padding: 0 0.5rem; }
  .admin-sidebar { flex: none; position: static; flex-direction: row; flex-wrap: wrap; }
  .nav-btn { width: auto; flex: 1 1 auto; justify-content: center; text-align: center; }
  .nav-btn.active::before { display: none; }
  .sidebar-armed { width: 100%; }
}

.admin-tag {
  font-size: 0.45em;
  background: #c0392b;
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  vertical-align: middle;
  letter-spacing: 0.05em;
  margin-left: 0.25rem;
}

.search-form {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.search-form input[type="text"] {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  flex: 1;
  min-width: 0;
  max-width: 22rem;
}
.search-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.action-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Destructive (red) buttons */
.destructive-btn {
  border-color: var(--error);
  color: var(--error);
}
@media (hover: hover) and (pointer: fine) {
  .destructive-btn:hover { background: color-mix(in srgb, var(--error) 10%, transparent); }
}

/* Audit log entries */
.audit-list { display: flex; flex-direction: column; gap: 0.35rem; max-height: 320px; overflow-y: auto; }
.audit-entry {
  display: grid;
  grid-template-columns: max-content max-content max-content 1fr max-content;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.82rem;
  align-items: baseline;
}
.audit-entry .audit-action { font-weight: 500; }
.audit-entry .audit-detail {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  word-break: break-all;
}
.audit-entry .audit-time { color: var(--text-muted); white-space: nowrap; }
.audit-entry .audit-ip { color: var(--text-muted); font-family: ui-monospace, monospace; font-size: 0.78rem; }
.audit-entry .audit-who { color: var(--text-muted); white-space: nowrap; }
.audit-action.audit-blue  { color: #2563eb; }
.audit-action.audit-red   { color: var(--error); }
.audit-action.audit-amber { color: #b58100; }
.audit-action.audit-grey  { color: var(--text-muted); }

/* Document/device sub-cards in admin */
.admin-item-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  margin: 0.5rem 0;
}
.admin-item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.admin-item-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* Status badges by value */
.badge.badge-active, .badge.badge-valid { background: color-mix(in srgb, #2e8b3a 15%, transparent); color: #2e8b3a; }
.badge.badge-suspended, .badge.badge-pending_activation { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.badge-deleted, .badge.badge-revoked, .badge.badge-lost, .badge.badge-decommissioned { background: color-mix(in srgb, var(--error) 15%, transparent); color: var(--error); }

/* ── Status unic cont+device: badge + bară de acțiuni (model 2026-05-21) ── */
.status-badge { display:inline-block; border-radius:999px; padding:4px 14px; font-weight:600; font-size:.8em; letter-spacing:.3px; color:#fff; }
.status-badge.status-awaiting  { background:#e0a800; }
.status-badge.status-active    { background:#28a745; }
.status-badge.status-suspended { background:#dc3545; }
.status-badge.status-deleted   { background:#777; }
.status-actions { margin-top:16px; display:flex; flex-wrap:wrap; gap:8px; }
.status-actions button { border-radius:999px; padding:5px 16px; color:#fff; border:none; font-weight:600; cursor:pointer; }
#ud-arm          { background:#2563eb; }
#ud-rearm        { background:#e0a800; }
#ud-suspend      { background:#f59e0b; }
#ud-resume       { background:#28a745; }
#ud-delete       { background:#dc3545; }
#ud-force-logout { background:#6b7280; }
.status-actions button:disabled { opacity:.4; cursor:not-allowed; }

@media (max-width: 600px) {
  .audit-entry { grid-template-columns: 1fr; gap: 0.15rem; }
  .search-form { flex-direction: column; }
}

/* ── Panou Info (text explicativ) ── */
.info-personal { background: color-mix(in srgb, var(--primary) 8%, transparent); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.9rem; margin-bottom: 0.75rem; }
.info-personal p { margin: 0; }
.info-text h3 { margin: 1.2rem 0 0.4rem; font-size: 1rem; }
.info-text p { margin: 0.5rem 0; line-height: 1.55; }
.info-text ul { margin: 0.4rem 0 0.6rem 1.2rem; }
.info-text li { margin: 0.3rem 0; line-height: 1.55; }
/* ── Panou Info: tabele tehnice de referință (câmpurile unui cont) ── */
.info-text .info-table { width: 100%; border-collapse: collapse; margin: 0.3rem 0 1.4rem; font-size: 0.86rem; }
.info-text .info-table caption { caption-side: top; text-align: left; font-weight: 600; padding: 0.3rem 0; color: var(--text); }
.info-text .info-table th, .info-text .info-table td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; vertical-align: top; }
.info-text .info-table thead th { background: var(--bg); font-weight: 600; }
.info-text .info-table td.col-field, .info-text .info-table td.col-type { font-family: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace; color: var(--text-muted); }
.info-text .info-table td.col-field { color: var(--text); white-space: nowrap; }
.info-text .info-table td.col-type { white-space: normal; overflow-wrap: anywhere; }
/* Steag țară — afișat după numele țării (detaliu admin + dashboard) */
.flag { display: inline-block; width: 1.33em; height: 1em; margin-left: 0.45em; vertical-align: -0.15em; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }

/* ── Panou Sistem: bare de utilizare (memorie / disc) ── */
.usage { margin: 0.2rem 0 0.5rem; }
.usage-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.usage-bar { height: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.usage-fill { height: 100%; border-radius: 999px; transition: width 300ms; }
.usage-fill.u-green { background: #28a745; }
.usage-fill.u-amber { background: #e0a800; }
.usage-fill.u-red { background: #dc3545; }
.sys-note { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 0.6rem; }

/* ═══════════════════════════════════════════════════════════════════
   Dashboard user — layout cu meniu lateral (redesign 2026-05-25)
   Toate regulile scoped pe .dash-* (există doar pe pagina dashboard).
   ═══════════════════════════════════════════════════════════════════ */
.dash-layout { display: flex; min-height: 100vh; min-height: 100dvh; }

.dash-sidebar {
  width: 232px; flex: 0 0 232px;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1rem 0.75rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-left: max(0.75rem, env(safe-area-inset-left));
}
.dash-brand { padding: 0.4rem 0.6rem 0.9rem; }
.dash-brand .brand-mark { font-size: 2.1rem; white-space: nowrap; }   /* la fel ca .admin-body .brand-mark */
.dash-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.dash-nav-item {
  position: relative;
  display: flex; align-items: center; gap: 0.7rem;
  width: 100%; box-sizing: border-box; padding: 0.6rem 0.7rem;
  background: transparent; border: none; border-radius: 8px;
  color: var(--text); font-size: 0.95rem; font-family: inherit;
  text-align: left; text-decoration: none; cursor: pointer;
}
.dash-nav-item .nav-icon { font-size: 1.05rem; width: 1.4rem; text-align: center; flex: 0 0 auto; }
@media (hover: hover) and (pointer: fine) { .dash-nav-item:hover { background: var(--bg); } }
.dash-nav-item.active { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); font-weight: 600; }
.dash-nav-item.active::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 60%; border-radius: 0 3px 3px 0; background: var(--primary); }
.dash-nav-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.dash-sidebar-foot { margin-top: auto; padding: 0.6rem; color: var(--text-muted); font-size: 0.78rem; }

.dash-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.dash-topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.8rem 1.25rem;
  padding-top: max(0.8rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.dash-section-title { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.dash-topbar .user-badge { margin-left: auto; }
.dash-hamburger {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 auto; cursor: pointer;
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 1.15rem; line-height: 1;
}

.dash-content {
  flex: 1 1 auto; width: 100%; max-width: 840px;
  margin: 1.5rem auto; padding: 0 1.25rem;
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
}
.dash-section { display: none; flex-direction: column; gap: 1.25rem; }
.dash-section.active { display: flex; }

/* hero identitate (fără avatar) */
.hero-card { display: flex; flex-direction: column; gap: 0.55rem; }
.hero-card .id-name { margin-right: 0; }
.hero-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.profile-content > .section-card:not(:first-child) { margin-top: 1.25rem; }

/* date personale: 2 perechi/rând pe ecrane late */
@media (min-width: 720px) {
  .dash-content .kv-grid { grid-template-columns: minmax(110px, max-content) 1fr minmax(110px, max-content) 1fr; }
}

.dash-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 30; }

/* ── Mobil/îngust: sidebar devine drawer ── */
@media (max-width: 860px) {
  .dash-hamburger { display: inline-flex; }
  .dash-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; width: 248px;
    transform: translateX(-100%); transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow);
  }
  .dash-sidebar.open { transform: translateX(0); }
  .dash-sidebar.open ~ .dash-backdrop { display: block; }
  .dash-content { margin: 1.25rem auto; }
}
@media (prefers-reduced-motion: reduce) { .dash-sidebar { transition: none; } }
@media (min-width: 861px) { .dash-backdrop { display: none !important; } }
