/* ============================================================
   rema — stiluri aplicatie
   Variabile setate din Setari > Tema: --accent, --radius (max 4px)
   ============================================================ */

:root {
  --accent: #2563eb;
  --accent-text: #ffffff;
  --radius: 4px;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-hover: color-mix(in srgb, var(--accent) 85%, #000);

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --text: #1c2024;
  --text-2: #5b636d;
  --text-3: #8a929b;
  --sidebar-bg: #ffffff;
  --sidebar-text: #3d444c;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .14);

  --ok: #15803d; --ok-bg: #e8f5ec;
  --warn: #b45309; --warn-bg: #fdf3e2;
  --err: #b91c1c; --err-bg: #fdecec;
  --info: #1d4ed8; --info-bg: #e9effd;

  --sidebar-w: 240px;
  --sidebar-w-min: 60px;
  --topbar-h: 56px;
  --pad: 16px;
  --gap: 16px;
  --ctl-h: 38px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

:root[data-density="compact"] { --pad: 12px; --gap: 12px; --ctl-h: 34px; }

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #111315; --surface: #1a1d20; --surface-2: #202428; --border: #2b3035; --border-strong: #3a4046;
    --text: #e7e9eb; --text-2: #a5adb5; --text-3: #7a838c; --sidebar-bg: #16191c; --sidebar-text: #c9ced3;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
    --ok-bg: #12301d; --ok: #6fd28f; --warn-bg: #36270f; --warn: #f0b45a; --err-bg: #3a1515; --err: #f28b8b; --info-bg: #142545; --info: #8fb2f7;
    --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111315; --surface: #1a1d20; --surface-2: #202428; --border: #2b3035; --border-strong: #3a4046;
  --text: #e7e9eb; --text-2: #a5adb5; --text-3: #7a838c; --sidebar-bg: #16191c; --sidebar-text: #c9ced3;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
  --ok-bg: #12301d; --ok: #6fd28f; --warn-bg: #36270f; --warn: #f0b45a; --err-bg: #3a1515; --err: #f28b8b; --info-bg: #142545; --info: #8fb2f7;
  --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
p { margin: 0 0 8px; }
code { font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 0 4px; border-radius: var(--radius); }
.icon { flex: none; vertical-align: middle; }
.muted { color: var(--text-2); } .small { font-size: 12.5px; } .nowrap { white-space: nowrap; }
.right { text-align: right; } .mt { margin-top: var(--gap); } .mb { margin-bottom: var(--gap); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar-w);
  background: var(--sidebar-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transition: width .18s ease, transform .2s ease;
}
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); transition: margin-left .18s ease; display: flex; flex-direction: column; }

.brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); flex: none; }
.brand-mark { width: 32px; height: 32px; border-radius: var(--radius); background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.brand-name { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { flex: 1; overflow-y: auto; padding: 8px; }
.nav-group { margin-top: 12px; padding: 6px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); white-space: nowrap; overflow: hidden; }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 10px; margin-bottom: 2px;
  border-radius: var(--radius); color: var(--sidebar-text); white-space: nowrap; overflow: hidden;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a .label { overflow: hidden; text-overflow: ellipsis; }

.sidebar-foot { border-top: 1px solid var(--border); padding: 8px; flex: none; }
.sidebar-foot button, .sidebar-foot a { width: 100%; }
.collapse-btn .icon { transition: transform .18s; }

/* sidebar minimizat (desktop) */
html.sb-collapsed .sidebar { width: var(--sidebar-w-min); }
html.sb-collapsed .main { margin-left: var(--sidebar-w-min); }
html.sb-collapsed .sidebar .label, html.sb-collapsed .brand-name, html.sb-collapsed .nav-group { display: none; }
html.sb-collapsed .nav a, html.sb-collapsed .sidebar-foot .btn { justify-content: center; padding: 0; }
html.sb-collapsed .collapse-btn .icon { transform: rotate(180deg); }
html.sb-collapsed .brand { padding: 0; justify-content: center; }

.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 var(--pad); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .menu-btn { display: none; }
.content { padding: var(--pad); width: 100%; max-width: 1400px; }

.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); }
.avatar { width: 30px; height: 30px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }

.overlay { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: min(280px, 84vw); box-shadow: var(--shadow-lg); }
  .main, html.sb-collapsed .main { margin-left: 0; }
  html.sb-collapsed .sidebar { width: min(280px, 84vw); }
  html.sb-collapsed .sidebar .label, html.sb-collapsed .brand-name, html.sb-collapsed .nav-group { display: initial; }
  html.sb-collapsed .nav a { justify-content: flex-start; padding: 0 10px; }
  html.sb-collapsed .brand { padding: 0 14px; justify-content: flex-start; }
  html.sb-open .sidebar { transform: none; }
  html.sb-open .overlay { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.35); }
  .topbar .menu-btn { display: inline-flex; }
  .collapse-btn { display: none !important; }
  .user-chip .who { display: none; }
}

/* impersonare */
.impersonate-bar { background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); padding: 8px var(--pad); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; }
.impersonate-bar form { margin-left: auto; }

/* ---------- elemente ---------- */
.page-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-bottom: var(--gap); }
.page-head h1 { flex: 1; min-width: 200px; }
.page-head .sub { display: block; font-size: 13px; color: var(--text-2); font-weight: 400; margin-top: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.breadcrumb { font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.breadcrumb a { color: var(--text-2); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: var(--gap); }
.grid > .card + .card, .split > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px var(--pad); border-bottom: 1px solid var(--border); }
.card-head h2 { flex: 1; display: flex; align-items: center; gap: 8px; }
.card-body { padding: var(--pad); }
.card-foot { padding: 10px var(--pad); border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.card.flush .card-body { padding: 0; }

.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.split { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

.stat { padding: 14px var(--pad); display: flex; gap: 12px; align-items: center; }
.stat .ico { width: 40px; height: 40px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.stat .val { font-size: 22px; font-weight: 650; line-height: 1.1; }
.stat .lbl { font-size: 12.5px; color: var(--text-2); }

/* butoane */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--ctl-h); padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--border)); }
.btn-danger:hover { background: var(--err-bg); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: var(--ctl-h); padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
form.inline { display: inline; }

/* formulare */
.form-grid { display: grid; gap: 14px var(--gap); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.form-grid > * { grid-column: span 12; }
@media (min-width: 700px) {
  .form-grid .c3 { grid-column: span 3; } .form-grid .c4 { grid-column: span 4; } .form-grid .c6 { grid-column: span 6; }
  .form-grid .c8 { grid-column: span 8; } .form-grid .c2 { grid-column: span 2; }
}
.form-section { grid-column: 1 / -1; font-weight: 600; font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.form-section:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.field label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }
.field .req { color: var(--err); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=tel], input[type=search], select, textarea {
  width: 100%; height: var(--ctl-h); padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
@media (min-width: 700px) { input, select, textarea { font-size: 14px !important; } }
textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; }
input[type=color] { width: 48px; height: var(--ctl-h); padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--err); }
.field-error { color: var(--err); font-size: 12.5px; margin-top: 4px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: var(--gap); }

/* filtre */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--gap); }
.filters > * { flex: 1 1 160px; max-width: 260px; }
.filters .search { flex: 2 1 220px; max-width: 360px; }
.filters .btn { flex: 0 0 auto; }

/* tabele -> carduri pe mobil */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.actions-cell { text-align: right; white-space: nowrap; width: 1%; }
.table .num { text-align: right; white-space: nowrap; }
.row-link { color: var(--text); font-weight: 500; }
@media (max-width: 700px) {
  table.table.responsive thead { display: none; }
  table.table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .table.responsive tr:last-child { border-bottom: 0; }
  .table.responsive td { border: 0; padding: 2px 0; display: flex; gap: 12px; justify-content: space-between; text-align: right; }
  .table.responsive td::before { content: attr(data-label); color: var(--text-3); font-size: 12px; text-align: left; flex: none; }
  .table.responsive td.primary { font-size: 15px; text-align: left; justify-content: flex-start; padding-bottom: 4px; }
  .table.responsive td.primary::before, .table.responsive td.actions-cell::before { display: none; }
  .table.responsive td.actions-cell { justify-content: flex-end; width: 100%; padding-top: 6px; }
  .table.responsive td.num { text-align: right; }
}

/* badge */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--radius); font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--err-bg); color: var(--err); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* alerte */
.alerts { display: grid; gap: 8px; margin-bottom: var(--gap); }
.alert { padding: 10px 14px; border-radius: var(--radius); border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start; }
.alert.success { background: var(--ok-bg); color: var(--ok); }
.alert.error { background: var(--err-bg); color: var(--err); }
.alert.warning { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert .close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; padding: 0; opacity: .7; }

/* taburi */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--text-2); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* liste cheie / valoare */
dl.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 16px; margin: 0; }
dl.kv dt { color: var(--text-2); font-size: 13px; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 500px) { dl.kv { grid-template-columns: 1fr; gap: 0; } dl.kv dd { margin-bottom: 8px; } }

.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty .icon { color: var(--text-3); margin-bottom: 8px; }

.pager { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; padding: 12px; }
.pager a, .pager span { min-width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: var(--radius); border: 1px solid var(--border); padding: 0 6px; color: var(--text); }
.pager .current { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* structura corp > etaj > spatiu */
.tree-building { border: 1px solid var(--border); border-radius: var(--radius); }
.tree-building + .tree-building { margin-top: 12px; }
.tree-building > header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tree-building > header h3 { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 160px; }
.tree-floor { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.tree-floor:last-child { border-bottom: 0; }
.tree-floor > .floor-head { display: flex; align-items: center; gap: 8px; font-weight: 500; flex-wrap: wrap; }
.tree-floor > .floor-head .grow { flex: 1; }
.space-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.space-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12.5px; color: var(--text); background: var(--surface); }
.space-chip:hover { border-color: var(--accent); text-decoration: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.disponibil { background: var(--ok); } .dot.inchiriat { background: var(--info); } .dot.rezervat { background: var(--warn); } .dot.indisponibil { background: var(--err); }

/* card proprietate (lista) */
.prop-card { display: flex; flex-direction: column; }
.prop-card .card-body { flex: 1; display: grid; gap: 8px; }
.prop-card h2 a { color: var(--text); }
.prop-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-2); }
.prop-meta span { display: inline-flex; align-items: center; gap: 4px; }
.occupancy { height: 6px; border-radius: var(--radius); background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.occupancy > div { height: 100%; background: var(--accent); }

/* setari tema */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: var(--radius); border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.selected { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--surface); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; flex-wrap: wrap; }
.seg label { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; height: var(--ctl-h); cursor: pointer; border-right: 1px solid var(--border); }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* matrice permisiuni */
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-module td { background: var(--surface-2); font-weight: 600; }

/* login */
.guest { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { border: 0; justify-content: center; height: auto; padding: 8px 0 18px; }

/* dropdown simplu */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; display: none; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: var(--radius); color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.dropdown-menu .head { padding: 6px 10px 8px; font-size: 12.5px; color: var(--text-2); }

/* dialog */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .card-head { border-bottom: 1px solid var(--border); }

/* mobil: statistici pe 2 coloane, header corp pe un rand */
@media (max-width: 700px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat .ico { width: 32px; height: 32px; }
  .stat .val { font-size: 18px; }
  .tree-building > header { flex-wrap: nowrap; }
  .tree-building > header h3 { min-width: 0; }
  .tree-building > header .area-info { display: none; }
}
