/**
 * app.css — componentele aplicației CMI, stilate pe tokenii din tokens.css
 * (sistemul "Asistent Personal": butoane, carduri, formulare, tabele, badge-uri).
 * Nicio culoare fixă aici — doar var(--...). Layout standard: 80% din ecran, centrat.
 */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: var(--lh);
    color: var(--text);
    background: var(--bg);
}

/* Lățimea standard: 80% din ecran, centrată */
.topbar,
main { width: 80%; margin-left: auto; margin-right: auto; }

/* ====================== Pagini de autentificare (card centrat) ============== */
body.auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
}

/* ====================== Topbar ============================================== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin-top: 0;
    margin-bottom: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    font-size: var(--fs-base);
}
.topbar a { color: var(--accent); text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.topbar .nav { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.brand-name { font-size: 16px; font-weight: var(--fw-bold); color: var(--accent-strong); }
.menu { display: flex; gap: 16px; }
.menu a { color: var(--accent); text-decoration: none; font-size: var(--fs-base); }
.menu a:hover { text-decoration: underline; }
.userbox { display: flex; align-items: center; gap: 14px; font-size: var(--fs-sm); }
.userbox .uname { color: var(--muted); }
.userbox a { color: var(--accent); text-decoration: none; }
.userbox a:hover { text-decoration: underline; }

/* ====================== Layout principal ==================================== */
main { margin-top: 24px; margin-bottom: 32px; }
main h1 { font-size: 22px; margin: 0 0 6px; }
.muted { color: var(--muted); margin-top: 0; font-size: var(--fs-sm); }

/* ====================== Card ================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 0 0 16px;
    box-shadow: var(--shadow);
}
.card h1 { margin: 0 0 10px; font-size: 20px; }

/* ====================== Login ============================================== */
.login {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    background: var(--surface);
    padding: 32px 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.login h1 { margin: 0 0 18px; font-size: 20px; }
.login .brand { text-align: center; margin-bottom: 24px; }
.login .brand-title { font-size: 18px; font-weight: var(--fw-bold); color: var(--accent-strong); }
.login .brand-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.login label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: var(--fw-medium); color: var(--text-soft); }
.login input {
    width: 100%;
    margin-top: 5px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: var(--fs-base);
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}
.login input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.login button {
    width: 100%;
    padding: 10px 16px;
    border: 0;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--on-accent);
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    cursor: pointer;
}
.login button:hover { background: var(--accent-hover); }

/* Erori / alerte */
.err {
    background: var(--danger-050);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 35%, #fff);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin: 0 0 14px;
}

/* Toggle parolă */
.pw-wrap { position: relative; margin-top: 5px; }
.pw-wrap input { width: 100%; margin-top: 0; padding-right: 42px; }
.login .pw-toggle {
    position: absolute;
    right: 6px; top: 0; bottom: 0; margin: auto;
    height: 30px; width: 36px; padding: 0;
    background: none; border: 0; cursor: pointer;
    font-size: 16px; color: var(--muted);
}
.login .pw-toggle:hover { background: none; color: var(--text); }

/* Checkbox "ține-mă minte" + link resetare */
.login .checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.login .checkbox input { width: auto; margin: 0; }
.muted-link { margin: 12px 0 0; font-size: 13px; text-align: center; }
.muted-link a { color: var(--accent); text-decoration: none; }
.muted-link a:hover { text-decoration: underline; }

/* ====================== Dashboard cards ===================================== */
.cards { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 20px; }
.dash-card {
    flex: 1 1 220px; min-width: 200px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; text-decoration: none; color: var(--text);
    box-shadow: var(--shadow);
    transition: box-shadow .15s, transform .15s, border-color .15s;
}
a.dash-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, .07); transform: translateY(-1px); border-color: var(--accent-border); }
.dash-card h3 { margin: 0 0 6px; font-size: 15px; font-weight: var(--fw-medium); }
.dash-card p { margin: 0; font-size: 13px; color: var(--muted); }
.muted-card { opacity: .6; }

/* ====================== Tabel (grid) ======================================== */
.grid {
    width: 100%; border-collapse: collapse;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow);
}
.grid th, .grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.grid th { background: var(--surface-2); font-weight: var(--fw-medium); color: var(--text-soft); }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: var(--surface-2); }
.actions { display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.inline { display: inline-flex; margin: 0; }

/* Butoane-icon (acțiuni per rând) — neutre, se aprind la hover */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; padding: 0;
    border: 0; background: none; color: var(--muted);
    border-radius: var(--radius); cursor: pointer; text-decoration: none;
    transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--accent-050); color: var(--accent); }
.icon-btn.danger:hover { background: var(--danger-050); color: var(--danger); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn svg { width: 17px; height: 17px; }

/* Expirare aviz aproape/expirată */
.expira { color: var(--danger); font-weight: var(--fw-medium); }

/* Coloane înguste: selecție + acțiuni (în stânga) */
.grid .col-check { width: 1%; text-align: center; padding-left: 14px; padding-right: 6px; }
.grid .col-actions { width: 1%; white-space: nowrap; }
.grid input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; margin: 0; }

/* Layout listă: sidebar filtre + conținut */
.list-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: stretch; }
.filters { align-self: start; }
.filters-rail { display: none; }
.list-layout.filters-collapsed { grid-template-columns: 42px 1fr; }
.list-layout.filters-collapsed .filters { display: none; }
.list-layout.filters-collapsed .filters-rail {
    display: flex; align-items: center; justify-content: center;
    width: 42px; min-height: 200px; padding: 16px 0;
    background: var(--surface); color: var(--text-soft);
    border: 1px solid var(--accent-100); border-top: 3px solid var(--accent); border-radius: var(--radius);
    font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer;
    writing-mode: vertical-rl; letter-spacing: .4px; white-space: nowrap;
}
.list-layout.filters-collapsed .filters-rail:hover { background: var(--accent-050); }

/* Panel filtre (secțiuni colapsabile) */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.filters-title { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-weight: var(--fw-bold); font-size: var(--fs-sm); color: var(--accent-strong); border-bottom: 1px solid var(--line); }
.filters-collapse { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 7px; border-radius: var(--radius); }
.filters-collapse:hover { background: var(--surface-2); color: var(--accent); }
.filter-total { padding: 10px 14px; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--muted); }
.filter-total strong { color: var(--text); }
#listResults.is-loading { opacity: .5; }

/* Bară de căutare sus (sub header): câmp + dropdown câmp */
.top-search { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; }
.top-search .qf-select { padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-base); }
.top-search .search { flex: 0 1 360px; width: auto; }
.top-search .qf-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* Toolbar listă (dreapta-sus): per-pagină + coloane + print */
.list-tools { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-bottom: 12px; }
.pp-field { font-size: var(--fs-sm); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.pp-field select { padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); }
.tool-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text-soft); font-size: var(--fs-sm); cursor: pointer; }
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.tool-btn svg { width: 15px; height: 15px; }
.tool-cols { position: relative; }
.cols-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 8px; min-width: 180px; display: flex; flex-direction: column; gap: 6px; }
.cols-menu[hidden] { display: none; }
.cols-menu label { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); cursor: pointer; }
.cols-menu input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }

/* Tabelul poate depăși lățimea → scroll orizontal (index dens) */
#listResults { overflow-x: auto; }

/* Ascundere coloane */
#listResults.hide-email .col-email,
#listResults.hide-cuim .col-cuim,
#listResults.hide-telefon .col-telefon,
#listResults.hide-nrcert .col-nrcert,
#listResults.hide-statuscert .col-statuscert,
#listResults.hide-expira .col-expira,
#listResults.hide-rezident .col-rezident,
#listResults.hide-status .col-status { display: none; }

/* Căutarea universală din header + selector de temă */
.usearch { display: flex; align-items: center; }
.usearch select { padding: 7px 8px; border: 1px solid var(--line); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; }
.usearch input { width: 200px; max-width: 30vw; padding: 7px 10px; border: 1px solid var(--line); border-radius: 0; font: inherit; font-size: var(--fs-sm); background: var(--surface); color: var(--text); min-width: 0; }
.usearch input:focus { outline: none; border-color: var(--accent); }
.usearch button { display: inline-flex; align-items: center; justify-content: center; padding: 7px 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; }
.usearch button svg { width: 15px; height: 15px; }
.theme-select { padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }

/* ====================== Admin ============================================== */
.admin-nav { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 0 0 18px; flex-wrap: wrap; }
.admin-nav .eyebrow { display: flex; align-items: center; color: var(--muted); font-weight: 700; font-size: 13px; padding: 9px 12px 9px 0; text-decoration: none; }
.admin-nav a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.admin-nav a:hover { color: var(--accent); }
.admin-nav a.on { color: var(--accent-strong); border-bottom-color: var(--accent); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.page-head h1 { margin: 0; }

.flash { background: var(--accent-050); border: 1px solid var(--accent-border); color: var(--accent-strong); padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px; font-size: var(--fs-sm); }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--accent-050); color: var(--accent-strong); font-size: 12px; font-weight: 600; margin: 1px 1px; white-space: nowrap; }
.tag.pill-off { background: var(--surface-2); color: var(--muted); }

.grp-box { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.grp-box label { display: flex; align-items: center; justify-content: flex-start; gap: 8px; margin: 0; font-size: var(--fs-base); font-weight: 400; color: var(--text); cursor: pointer; }
.grp-box label input[type="checkbox"] { width: 16px; height: 16px; max-width: 16px; accent-color: var(--accent); margin: 0; flex: 0 0 auto; }
.chk-inline { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-soft); cursor: pointer; }
.chk-inline input[type="checkbox"] { width: 16px; height: 16px; max-width: 16px; accent-color: var(--accent); margin: 0; flex: 0 0 auto; }
.modal-foot { display: flex; gap: 8px; align-items: center; margin-top: 6px; }

#listResults.hide-grupuri .col-grupuri,
#listResults.hide-last .col-last,
#listResults.hide-code .col-code,
#listResults.hide-sistem .col-sistem,
#listResults.hide-useri .col-useri,
#listResults.hide-drepturi .col-drepturi { display: none; }

.flash--err { background: var(--danger-050, #fdecec); border-color: var(--danger, #c0392b); color: var(--danger, #c0392b); }

/* ── Matricea de drepturi (permisiuni) ─────────────────────────────────────── */
.perm-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.perm-groups { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.perm-groups-title { padding: 10px 14px; font-size: 13px; font-weight: var(--fw-medium); color: var(--text-soft); background: var(--accent-050); border-bottom: 1px solid var(--line); }
.perm-group { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: var(--fs-base); }
.perm-group:last-child { border-bottom: 0; }
.perm-group:hover { background: var(--accent-050); }
.perm-group.on { background: var(--accent-100); border-left: 3px solid var(--accent); font-weight: var(--fw-medium); }
.perm-head, .perm-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.perm-foot { margin-top: 14px; margin-bottom: 0; justify-content: flex-end; }
.perm-head h2 { margin: 0; font-size: 18px; }
.perm-matrix th.perm-op, .perm-matrix td.perm-op { text-align: center; width: 92px; }
.perm-matrix td.perm-res { white-space: nowrap; }
.perm-matrix td.perm-op input[type="checkbox"] { width: 17px; height: 17px; max-width: 17px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.perm-matrix tr.perm-sep td { background: var(--accent-050); font-size: 12px; font-weight: var(--fw-medium); color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; padding: 6px 12px; }
.perm-colbtn, .perm-rowbtn { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; }
.perm-colbtn { font-weight: var(--fw-medium); }
.perm-colbtn:hover { color: var(--accent); text-decoration: underline; }
.perm-rowbtn { margin-left: 8px; font-size: 11px; color: var(--text-soft); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.perm-rowbtn:hover { color: var(--accent); border-color: var(--accent); }
.ord-input { width: 60px; max-width: 60px; text-align: center; padding: 5px 6px; border: 1px solid var(--line); border-radius: 4px; font: inherit; background: var(--surface); color: var(--text); }
.perm-res code.muted { font-size: 11px; color: var(--text-soft); margin-left: 6px; }
@media (max-width: 720px) { .perm-layout { grid-template-columns: 1fr; } }

/* Print: doar tabelul curat */
@media print {
    .topbar, .theme-switcher, .top-search, .filters, .filters-rail, .list-tools, .pager, .col-check, .col-actions, .actions { display: none !important; }
    .list-layout { display: block !important; }
    body { background: #fff; }
    .grid { box-shadow: none; border-color: #999; }
}
.fgroup { border-bottom: 1px solid var(--line); }
.fgroup:last-of-type { border-bottom: 0; }
.fgroup > summary {
    list-style: none; cursor: pointer; padding: 11px 14px;
    font-weight: var(--fw-medium); font-size: var(--fs-sm); color: var(--text-soft);
    display: flex; align-items: center; justify-content: space-between;
}
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary::after { content: '▾'; color: var(--muted); font-size: 11px; transition: transform .15s; }
.fgroup[open] > summary::after { transform: rotate(180deg); }
.fgroup-body { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.fcheck, .fradio { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text); cursor: pointer; }
.fcheck input, .fradio input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; flex: none; }
.fdate { display: flex; flex-direction: column; gap: 3px; font-size: var(--fs-sm); color: var(--muted); }
.fdate input { padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); font-family: inherit; font-size: var(--fs-sm); background: var(--surface); color: var(--text); accent-color: var(--accent); }
.fdate input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.factions { padding: 12px 14px; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); }

/* Câmp de căutare */
.search {
    width: 100%; padding: 9px 11px;
    border: 1px solid var(--line); border-radius: var(--radius);
    font-size: var(--fs-base); font-family: inherit;
    background: var(--surface); color: var(--text);
}
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* Bara de sus a listei + buton colaps filtre */
.list-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.filters-toggle {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 7px 12px; font-size: var(--fs-sm); color: var(--text-soft); cursor: pointer;
}
.filters-toggle:hover { border-color: var(--accent); color: var(--accent); }
.list-count { color: var(--muted); font-size: var(--fs-sm); }
.list-head .list-count { margin-left: auto; }

@media (max-width: 760px) { .list-layout { grid-template-columns: 1fr; } }

/* Headere sortabile */
.grid th a.sort { color: var(--text-soft); text-decoration: none; display: inline-flex; align-items: center; gap: 2px; }
.grid th a.sort:hover { color: var(--accent); }

/* Paginare */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pager-info, .pager-page { color: var(--muted); font-size: var(--fs-sm); }
.pager-ctrl { display: flex; align-items: center; gap: 10px; }

/* Butoane-link în tabel */
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: var(--fs-sm); width: auto; font-weight: var(--fw-medium); }
button.link:hover { background: none; text-decoration: underline; }
button.link.danger { color: var(--danger); }

/* Badge status (suspendat etc.) */
.badge-susp {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    background: var(--warn-050); color: var(--warn); font-size: 11px; font-weight: var(--fw-bold);
}

/* ====================== Detaliu + formular edit ============================= */
.detail { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; margin: 0 0 16px; }
.detail dt { color: var(--muted); font-size: 13px; }
.detail dd { margin: 0; font-size: var(--fs-base); }
.form-row { margin-bottom: 14px; }
.form-row > label { display: block; font-size: 13px; font-weight: var(--fw-medium); color: var(--text-soft); margin-bottom: 4px; }
.form-row label.chk-inline { display: flex; margin-bottom: 0; }
.form-row input:not([type="checkbox"]):not([type="radio"]), .form-row select {
    width: 100%; max-width: 420px; padding: 9px 11px;
    border: 1px solid var(--line); border-radius: var(--radius);
    font-size: var(--fs-base); font-family: inherit;
    background: var(--surface); color: var(--text);
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* Textarea în formular — pe temă, lat și redimensionabil vertical. */
.form-row textarea {
    width: 100%; max-width: 640px; padding: 9px 11px;
    border: 1px solid var(--line); border-radius: var(--radius);
    font-size: var(--fs-base); font-family: inherit; line-height: 1.5;
    background: var(--surface); color: var(--text);
    min-height: 140px; resize: vertical;
}
.form-row textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* Input de fișier — butonul intern stilizat ca buton secundar. */
.form-row input[type="file"] { padding: 6px 8px; cursor: pointer; }
.form-row input[type="file"]::file-selector-button {
    margin-right: 12px; padding: 7px 14px;
    border: 1px solid var(--accent); border-radius: var(--radius);
    background: var(--surface); color: var(--accent);
    font: inherit; font-weight: var(--fw-medium); cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.form-row input[type="file"]::file-selector-button:hover { background: var(--accent-050); }

/* Separator „sau" între două variante alternative dintr-un formular. */
.or-sep { display: flex; align-items: center; gap: 12px; max-width: 640px; margin: 2px 0 14px; color: var(--muted); font-size: 13px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Bibliotecă documente — două casete egale (upload / text), înălțimi armonizate. */
.doc-add { display: flex; gap: 16px; align-items: stretch; flex-wrap: wrap; margin-bottom: 18px; }
.doc-add-card { flex: 1 1 320px; display: flex; flex-direction: column; }
.doc-add-card h3 { margin: 0 0 12px; }
.doc-add-card .doc-add-foot { margin-top: auto; padding-top: 12px; }
.doc-paste-row { flex: 1; display: flex; margin-bottom: 12px; }
.doc-paste-row textarea { flex: 1; width: 100%; max-width: none; min-height: 170px; }

/* ====================== Modal (popup editare) ============================== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: none; align-items: flex-start; justify-content: center;
    background: rgba(17, 24, 39, .45);
    padding: 48px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%; max-width: 460px;
    box-shadow: var(--shadow-pop);
    overflow: hidden;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; border-bottom: 1px solid var(--line);
    font-size: var(--fs-lg);
}
.modal-close {
    background: none; border: 0; cursor: pointer;
    font-size: 24px; line-height: 1; color: var(--muted);
    width: 32px; height: 32px; border-radius: var(--radius);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px; }

/* Buton general */
.btn {
    display: inline-block; padding: 10px 16px; border: 0; border-radius: var(--radius);
    background: var(--accent); color: var(--on-accent);
    font-size: var(--fs-base); font-weight: var(--fw-medium); cursor: pointer;
    text-decoration: none; text-align: center; width: auto;
}
.btn:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.btn--secondary:hover { background: var(--accent-050); }
.btn--danger { background: var(--danger); }
.btn--danger:hover { background: var(--danger-hover, #991b1b); }

/* ====================== Responsive ========================================== */
@media (max-width: 900px) {
    .topbar, main { width: 92%; }
}
@media (max-width: 768px) {
    input, select, textarea { font-size: 16px; }   /* fix zoom iOS */
    .grid { font-size: var(--fs-base); }
    .card { padding: 14px 16px; }
}

/* ── Asistent chat ─────────────────────────────────────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 240px 1fr; gap: 18px; align-items: stretch; min-height: 70vh; }
.chat-sidebar { display: flex; flex-direction: column; gap: 10px; }
.chat-new { text-align: center; }
.chat-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.chat-item { display: block; padding: 8px 10px; border-radius: var(--radius); color: var(--text); text-decoration: none;
    font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item:hover { background: var(--accent-050); }
.chat-item.on { background: var(--accent-100); font-weight: var(--fw-medium); }
.chat-empty { padding: 8px 10px; }
.chat-main { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.chat-welcome { margin: auto; text-align: center; max-width: 440px; }
.chat-welcome h2 { margin-bottom: 6px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: var(--fs-base); line-height: 1.5; white-space: normal; }
.msg-user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.msg-assistant { align-self: flex-start; background: var(--accent-050); color: var(--text); border-bottom-left-radius: 3px; }
.msg-error { align-self: flex-start; background: var(--danger-050, #fdecec); color: var(--danger, #c0392b); border: 1px solid var(--danger, #c0392b); }
.msg-sources { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12px; }
.msg-sources-h { font-weight: var(--fw-medium); color: var(--text-soft); }
.msg-sources ol { margin: 4px 0 0 18px; }
.msg-sources a { color: var(--accent); }
.chat-composer { display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-composer textarea { flex: 1; resize: none; min-height: 40px; max-height: 160px; padding: 9px 12px;
    border: 1px solid var(--line); border-radius: var(--radius); font: inherit; background: var(--surface); color: var(--text); }
.chat-composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.web-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); white-space: nowrap; cursor: pointer; }
.web-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }
.chat-processing { display: flex; align-items: center; gap: 8px; color: var(--text-soft); }
.chat-processing .dots { display: inline-flex; gap: 3px; }
.chat-processing .dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: chatdot 1s infinite ease-in-out; }
.chat-processing .dots span:nth-child(2) { animation-delay: .15s; }
.chat-processing .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes chatdot { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ── Audit LLM — totaluri ──────────────────────────────────────────────────── */
.llm-totals { display: flex; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.llm-totals .stat { flex: 1; min-width: 120px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.llm-totals .stat-n { display: block; font-size: 22px; font-weight: var(--fw-bold, 700); color: var(--accent); }
.llm-totals .stat-l { font-size: 12px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }
.tag.pill-warn { background: var(--warn-050, #fdf6e3); color: var(--warn, #9a6b00); border-color: var(--warn, #e0c56b); }
.col-tin, .col-tout, .col-lat { text-align: right; white-space: nowrap; }

@media (max-width: 720px) { .chat-layout { grid-template-columns: 1fr; } }

/* ── Taburi (Configurare LLM) ──────────────────────────────────────────────── */
.tabs .tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab-btn { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 18px; font: inherit; color: var(--text-soft); cursor: pointer; }
.tab-btn:hover { color: var(--accent); }
.tab-btn.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: var(--fw-medium); }
.tab-panel { display: none; }
.tab-panel.on { display: block; }
.form-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
textarea.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; }
details.adv { margin: 4px 0 12px; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; }
details.adv summary { cursor: pointer; color: var(--text-soft); font-size: 13px; }
details.adv[open] { padding-bottom: 2px; }
#editModal .modal { max-width: 580px; }

/* ── Helpdesk email ────────────────────────────────────────────────────────── */
.row-gap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-link { cursor: pointer; }
.row-link:hover { background: var(--accent-050); }
.thread-head { display: flex; flex-direction: column; gap: 6px; }
.thread-head .status-form { margin-top: 4px; }
.thread-msgs { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.mail-msg { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.mail-msg.mail-out { border-left: 3px solid var(--accent); background: var(--accent-050); }
.mail-msg.mail-in  { border-left: 3px solid var(--line); }
.mail-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 8px; }
.mail-body { white-space: normal; line-height: 1.55; }
.mail-atts { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.mail-atts .att { font-size: 13px; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 10px; text-decoration: none; color: var(--accent); }
.mail-atts .att:hover { background: var(--accent-050); }
.reply-box { display: flex; flex-direction: column; gap: 10px; }
.reply-box > form { display: flex; flex-direction: column; gap: 10px; }
.reply-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.reply-box textarea { resize: vertical; min-height: 120px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; background: var(--surface); color: var(--text); }
.reply-box textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* ── Helpdesk: acțiuni fir/mesaj ──────────────────────────────────────────── */
.thread-head-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mail-meta-right { display: flex; align-items: center; gap: 12px; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; font-size: 12px; color: var(--text-soft); cursor: pointer; text-decoration: underline; }
.linkbtn:hover { color: var(--accent); }
.linkbtn.danger:hover { color: var(--danger, #c0392b); }
.btn.btn-danger { color: var(--danger, #c0392b); border-color: var(--danger, #c0392b); }
.btn.btn-danger:hover { background: var(--danger-050, #fdecec); }
