/* ==========================================================================
   Electro Dan Service — Panou admin
   Temă preluată din site-ul principal (styles/globals.css + tailwind.config):
   navy stratificat, glassmorphism, accent mint pe CTA, Plus Jakarta + Inter.
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */
:root {
    /* Culori de bază */
    --navy:          #0D1B2A; /* fundal pagină */
    --navy-band:     #0A1526;
    --navy-deep:     #060C16; /* header / footer */
    --surface-raised:#0F2035; /* carduri / suprafețe ridicate */
    --offwhite:      #F0F4F8;
    --grey-cool:     #94A3B8;
    --cta:           #B9FFF0; /* accent mint — buton principal */
    --cta-hover:     #97EFDB;

    /* Linii / contururi */
    --line:          rgba(255, 255, 255, 0.10);
    --line-soft:     rgba(255, 255, 255, 0.06);
    --line-strong:   rgba(255, 255, 255, 0.14);

    /* Suprafețe subtile (hover, chip-uri, input-uri) */
    --wash-1:        rgba(255, 255, 255, 0.02);
    --wash-2:        rgba(255, 255, 255, 0.04);
    --wash-3:        rgba(255, 255, 255, 0.07);

    /* Semantice */
    --success:       #34D399;
    --success-bg:    rgba(16, 185, 129, 0.10);
    --success-line:  rgba(16, 185, 129, 0.35);
    --success-fg:    #A7F3D0;
    --danger:        #F87171;
    --danger-bg:     rgba(239, 68, 68, 0.10);
    --danger-line:   rgba(239, 68, 68, 0.35);
    --danger-fg:     #FECACA;
    --danger-soft:   #FCA5A5;

    /* Accent translucid (focus, glow) */
    --cta-glow:      rgba(185, 255, 240, 0.12);
    --ring:          0 0 0 3px rgba(185, 255, 240, 0.16);

    /* Tipografie */
    --font-body:     'Inter', system-ui, -apple-system, sans-serif;
    --font-display:  'Plus Jakarta Sans', 'Inter', sans-serif;

    /* Spațiere */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-7: 32px;

    /* Raze */
    --radius-sm:     8px;
    --radius-md:     10px;
    --radius:        14px;
    --radius-lg:     16px;

    /* Mișcare — scurte (<300ms), dezactivate la prefers-reduced-motion */
    --dur-fast:      120ms;
    --dur:           180ms;
    --dur-slow:      260ms;
    --ease:          cubic-bezier(0.2, 0, 0, 1);
    --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);

    color-scheme: dark; /* controale native (date picker, scrollbar) pe temă închisă */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* Bara de scroll verticală e mereu vizibilă. Altfel paginile scurte
   (liste cu puține rânduri) sunt cu ~15px mai late decât cele lungi (Panou),
   iar `.container` fiind centrat cu `margin: 0 auto`, conținutul „sare"
   lateral la schimbarea tab-urilor. (Nu folosim `scrollbar-gutter: stable`:
   pe paginile scurte lasă o bandă goală în dreapta, fără scrollbar în ea.) */
html { overflow-y: scroll; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(1100px 560px at 82% -12%, rgba(185, 255, 240, 0.06), transparent 60%),
        var(--navy);
    color: var(--offwhite);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main { display: flex; flex-direction: column; flex: 1 0 auto; }

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.01em;
}

a { color: inherit; text-decoration: none; }

::selection { background: rgba(185, 255, 240, 0.25); }

/* --- Accesibilitate -------------------------------------------------------- */
/* Inel de focus vizibil doar la navigarea cu tastatura. */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--cta);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Link „sari la conținut" — vizibil doar când primește focus. */
.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 200;
    padding: 10px 16px;
    background: var(--cta);
    color: var(--navy);
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-md);
    transform: translateY(-64px);
    opacity: 0;
    transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.skip-link:focus-visible { transform: none; opacity: 1; outline-offset: 0; }

/* Oprim complet mișcarea pentru cine a cerut asta din sistem. */
@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;
    }
}

/* --- Animații comune ------------------------------------------------------- */
@keyframes rise-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
@keyframes pop-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.99); }
    to   { opacity: 1; transform: none; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Bară de progres la navigare ------------------------------------------ */
.nav-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 300;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, var(--cta), var(--cta-hover));
    box-shadow: 0 0 8px rgba(185, 255, 240, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
}
.nav-progress.active {
    opacity: 1;
    /* Indeterminată: urcă repede spre ~80% și așteaptă pagina nouă. */
    animation: nav-progress 1.4s var(--ease) forwards;
}
@keyframes nav-progress {
    0%   { width: 0; }
    60%  { width: 62%; }
    100% { width: 82%; }
}

/* --- Topbar -------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    height: 64px;
    padding: 0 var(--sp-6);
    background: rgba(6, 12, 22, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; border-radius: var(--radius-md); }

.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--wash-2);
    border: 1px solid var(--line-strong);
    color: #fff;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.brand-mark svg { width: 16px; height: 16px; }
.brand:hover .brand-mark { background: var(--cta-glow); border-color: rgba(185, 255, 240, 0.4); color: var(--cta); }

.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.14em;
    color: #fff;
}
.brand-sub {
    font-weight: 500;
    font-size: 9px;
    letter-spacing: 0.32em;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 3px;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { font-size: 13px; color: var(--grey-cool); }

/* --- Layout -------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: var(--sp-7) var(--sp-6) 64px;
    flex: 1 0 auto;
    animation: rise-in var(--dur-slow) var(--ease-out) both;
}

/* --- Taburi -------------------------------------------------------------- */
.tabs {
    display: inline-flex;
    gap: var(--sp-1);
    margin-bottom: 28px;
    padding: 5px;
    max-width: 100%;
    overflow-x: auto;
    background: var(--surface-raised);
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--grey-cool);
    transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.tab svg { width: 15px; height: 15px; flex: none; opacity: 0.8; }
.tab:hover { color: #fff; background: var(--wash-2); }
.tab:focus-visible { outline-offset: -2px; }
.tab.active {
    color: var(--navy);
    background: var(--cta);
    box-shadow: 0 4px 12px -4px rgba(185, 255, 240, 0.5);
}
.tab.active svg { opacity: 1; }

/* --- Antet secțiune ------------------------------------------------------ */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-4);
    margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 26px; line-height: 1.25; }
.page-head .count {
    display: inline-block;
    margin-top: 4px;
    color: var(--grey-cool);
    font-size: 13px;
    font-weight: 500;
}

/* --- Card + tabel -------------------------------------------------------- */
.card {
    background: var(--surface-raised);
    border: 1px solid var(--wash-3);
    border-radius: var(--radius);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 18px 40px -24px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

/* Pe ecrane înguste, tabelele derulează orizontal în interiorul cardului
   în loc să spargă layoutul. (Nu se aplică tabelului de piese din formular —
   dropdown-urile lui ar fi tăiate de overflow.) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card .table-scroll table { min-width: 640px; }
.view-card .table-scroll table { min-width: 480px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    text-align: left;
    padding: 14px 18px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--grey-cool);
    background: var(--wash-1);
    border-bottom: 1px solid var(--line-soft);
}
tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-soft);
    transition: background var(--dur-fast) var(--ease);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--wash-1); }

.empty td {
    padding: 52px 18px;
    text-align: center;
    color: var(--grey-cool);
}
.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 12px;
    border-radius: 12px;
    background: var(--wash-2);
    border: 1px solid var(--line-soft);
    color: var(--grey-cool);
}
.empty-icon svg { width: 20px; height: 20px; }
.empty .empty-title { display: block; font-weight: 600; color: var(--offwhite); margin-bottom: 4px; }

/* --- Butoane ------------------------------------------------------------- */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background var(--dur-fast) var(--ease),
        border-color var(--dur-fast) var(--ease),
        color var(--dur-fast) var(--ease),
        box-shadow var(--dur) var(--ease),
        transform var(--dur-fast) var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); transition-duration: 60ms; }
.btn-primary { background: var(--cta); color: var(--navy); }
.btn-primary:hover { background: var(--cta-hover); box-shadow: 0 6px 18px -8px rgba(185, 255, 240, 0.55); }
.btn-ghost { background: transparent; color: var(--offwhite); border-color: var(--line); }
.btn-ghost:hover { background: var(--wash-2); border-color: var(--line-strong); }
.btn-block { width: 100%; justify-content: center; }

/* Stare de încărcare — pusă din JS la trimiterea formularelor. */
.btn.is-loading { pointer-events: none; opacity: 0.85; }
.btn.is-loading::after {
    content: "";
    flex: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin 0.6s linear infinite;
}

/* --- Login --------------------------------------------------------------- */
/* Fără min-height pe viewport: pagina de login trebuie să încapă cu tot cu
   footer, fără scroll — centrarea o face flex-ul întins din <main>. */
.login-wrap {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-6);
}
.login-card {
    width: 100%;
    max-width: 380px;
    padding: var(--sp-7);
    background: var(--surface-raised);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.8);
    animation: rise-in var(--dur-slow) var(--ease-out) both;
}
/* Logo complet (marcă + text), la fel ca în header. */
.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { margin: 0 0 24px; color: var(--grey-cool); font-size: 13px; }

.field { margin-bottom: var(--sp-4); }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--grey-cool); }
.field input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: var(--wash-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    color: var(--offwhite);
    font-family: var(--font-body);
    font-size: 15px;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.field input:focus {
    outline: none;
    border-color: var(--cta);
    box-shadow: var(--ring);
}

.alert {
    margin-bottom: 18px;
    padding: 11px 14px;
    background: var(--danger-bg);
    border: 1px solid var(--danger-line);
    border-radius: var(--radius-md);
    color: var(--danger-fg);
    font-size: 13px;
    animation: rise-in var(--dur) var(--ease-out) both;
}

/* --- Footer -------------------------------------------------------------- */
.footer {
    flex-shrink: 0;
    padding: var(--sp-6);
    text-align: center;
    color: var(--grey-cool);
    font-size: 12px;
    border-top: 1px solid var(--line-soft);
}
.footer p { margin: 0; }

/* --- Butoane mici / variante --------------------------------------------- */
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-danger { background: transparent; color: var(--danger-soft); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-bg); border-color: rgba(239, 68, 68, 0.55); }

.col-actions { width: 1%; white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-end; }
.inline-form { display: inline; margin: 0; }

/* --- Mesaje (flash) ------------------------------------------------------- */
.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: var(--sp-5);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    border: 1px solid transparent;
    animation: rise-in var(--dur-slow) var(--ease-out) both;
}
.notice-icon { flex: none; display: flex; margin-top: 3px; }
.notice-icon svg { width: 15px; height: 15px; }
.notice-text { flex: 1; }
.notice-close {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin: 1px -4px 0 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.notice-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.notice.is-leaving { opacity: 0; transform: translateY(-4px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.notice-success { background: var(--success-bg); border-color: var(--success-line); color: var(--success-fg); }
.notice-error   { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-fg); }

/* --- Formulare ----------------------------------------------------------- */
.form-card {
    background: var(--surface-raised);
    border: 1px solid var(--wash-3);
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 40px -24px rgba(0, 0, 0, 0.7);
    padding: var(--sp-6);
    margin-bottom: var(--sp-5);
}
.form-card h2 {
    margin: 0 0 4px;
    font-size: 16px;
    font-family: var(--font-display);
    font-weight: 700;
}
.form-card .form-hint { margin: 0 0 20px; color: var(--grey-cool); font-size: 13px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.form-grid .full { grid-column: 1 / -1; }
/* Rând secundar în cardul de piese (manoperă), sub tabel. */
.form-grid.labor-row { margin-top: var(--sp-6); }

label.lbl { display: block; margin-bottom: 6px; font-size: 13px; color: var(--grey-cool); }
label.lbl .opt { color: rgba(148, 163, 184, 0.7); font-weight: 400; }

.inp {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: var(--wash-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    color: var(--offwhite);
    font-family: var(--font-body);
    font-size: 15px;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.inp:hover { border-color: var(--line-strong); }
.inp:focus {
    outline: none;
    border-color: var(--cta);
    box-shadow: var(--ring);
}
select.inp {
    cursor: pointer;
    color-scheme: dark;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}
.field-error { border-color: rgba(239, 68, 68, 0.6) !important; }
.err-text { margin-top: 6px; color: var(--danger-soft); font-size: 12px; animation: rise-in var(--dur) var(--ease-out) both; }

.form-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-2); }

/* --- Combobox căutare (client / mașină) ---------------------------------- */
.combo { position: relative; }
.combo-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 240px;
    overflow-y: auto;
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.8);
    padding: var(--sp-1);
    transform-origin: top center;
}
.combo-list:not([hidden]) { animation: pop-in var(--dur-fast) var(--ease-out); }
.combo-list[hidden] { display: none; }
.combo-opt {
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 14px;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease);
}
.combo-opt:hover, .combo-opt.active { background: var(--wash-3); }
.combo-opt .muted { color: var(--grey-cool); font-size: 12px; }
.combo-empty { padding: 10px 12px; color: var(--grey-cool); font-size: 13px; }

/* --- Tabel piese deviz --------------------------------------------------- */
.parts-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 14px; margin-bottom: 14px; }
.parts-table col.c-price { width: 148px; }
.parts-table col.c-remove { width: 52px; }
.parts-table th {
    text-align: center; vertical-align: middle; padding: 6px 8px 12px;
    font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--grey-cool); font-weight: 600;
}
.parts-table th.num { text-align: center; }
.parts-table td { padding: 4px 8px; vertical-align: middle; transition: none; }
.parts-table td:first-child, .parts-table th:first-child { padding-left: 0; }
.parts-table td:last-child, .parts-table th:last-child { padding-right: 0; text-align: center; }
.parts-table .inp { height: 40px; font-size: 14px; }
.parts-table .part-pret { text-align: right; }
.parts-table .part-cu-tva {
    text-align: right; white-space: nowrap; color: var(--offwhite);
    font-variant-numeric: tabular-nums;
}
.parts-table tr:hover td { background: transparent; } /* rândurile cu input-uri nu au hover de tabel */
.inp[type="date"] { color-scheme: dark; }

/* Autocomplete text (furnizor) — dropdownul se poziționează pe celulă */
.ac { position: relative; }

/* --- Select personalizat (combustibil) ----------------------------------- */
.select { position: relative; }
.select-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; text-align: left; cursor: pointer;
}
.select-toggle::after {
    content: ""; flex: none; width: 16px; height: 16px; margin-left: 8px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat center;
    transition: transform var(--dur-fast) var(--ease);
}
.select-value.is-placeholder { color: var(--grey-cool); }
.select-list { padding: var(--sp-1); }
.btn-remove {
    width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer;
    background: transparent; border: 1px solid var(--line); color: var(--danger-soft);
    font-size: 18px; line-height: 1;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn-remove:hover { background: var(--danger-bg); border-color: var(--danger-line); }

/* --- Totaluri deviz ------------------------------------------------------ */
.totals-grid {
    margin: 0 0 0 auto; max-width: 340px;
    display: grid; grid-template-columns: 1fr auto; gap: 10px 24px;
    background: var(--wash-1);
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    padding: 18px 20px;
}
.totals-grid dt { color: var(--grey-cool); font-size: 14px; }
.totals-grid dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.totals-grid dt.grand, .totals-grid dd.grand {
    font-size: 18px; font-weight: 700; color: #fff;
    padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line);
}
.totals-grid dd.grand { color: var(--cta); }
/* În formularul de deviz, blocul de totaluri stă sub rândul de manoperă. */
.form-card .totals-grid { margin-top: var(--sp-5); }

/* --- Bara de căutare ----------------------------------------------------- */
.searchbar { display: flex; gap: 10px; margin-bottom: var(--sp-5); }
.searchbar-field { position: relative; flex: 1; display: flex; align-items: center; }
.searchbar-icon {
    position: absolute; left: 14px; display: flex; color: var(--grey-cool); pointer-events: none;
    transition: color var(--dur-fast) var(--ease);
}
.searchbar-icon svg { width: 16px; height: 16px; }
.searchbar-field:focus-within .searchbar-icon { color: var(--cta); }
.searchbar input[type="search"] {
    width: 100%; height: 44px; padding: 0 40px;
    background: var(--wash-2);
    border: 1px solid var(--line); border-radius: var(--radius-md);
    color: var(--offwhite); font-family: var(--font-body); font-size: 15px;
    -webkit-appearance: none; appearance: none;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.searchbar input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.searchbar input:hover { border-color: var(--line-strong); }
.searchbar input:focus { outline: none; border-color: var(--cta); box-shadow: var(--ring); }
.searchbar .btn { height: 44px; }
.searchbar-clear {
    position: absolute; right: 12px;
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.08); color: var(--offwhite); font-size: 15px; line-height: 1;
    transition: background var(--dur-fast) var(--ease);
}
.searchbar-clear:hover { background: rgba(255, 255, 255, 0.16); }
.searchbar-clear[hidden] { display: none; }

/* Căutare live: estompăm rezultatele cât timp așteptăm răspunsul serverului. */
.list-results { transition: opacity var(--dur-fast) var(--ease); }
.list-results.is-searching { opacity: 0.55; pointer-events: none; }

/* --- Pagini de vizualizare ----------------------------------------------- */
.view-card {
    background: var(--surface-raised); border: 1px solid var(--wash-3);
    border-radius: var(--radius); padding: var(--sp-6); margin-bottom: var(--sp-5);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 40px -24px rgba(0, 0, 0, 0.7);
}
.view-card h2 {
    margin: 0 0 16px; font-size: 15px; font-family: var(--font-display); font-weight: 700;
    display: flex; align-items: center; gap: 10px;
}
.view-card h2 .count {
    font-family: var(--font-body); font-size: 12px; font-weight: 500; color: var(--grey-cool);
    background: var(--wash-2); padding: 2px 8px; border-radius: 999px;
}
.detail-grid { margin: 0; display: grid; grid-template-columns: 170px 1fr; gap: 12px 20px; }
.detail-grid dt { color: var(--grey-cool); font-size: 14px; }
.detail-grid dd { margin: 0; font-size: 14px; }
.detail-grid dd a, .mini-table a.btn { color: inherit; }
.detail-grid dd > a {
    color: var(--cta);
    border-bottom: 1px solid transparent;
    transition: border-color var(--dur-fast) var(--ease);
}
.detail-grid dd > a:hover { border-bottom-color: rgba(185, 255, 240, 0.5); }

.mini-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mini-table th {
    text-align: left; padding: 8px 12px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--grey-cool); font-weight: 600; border-bottom: 1px solid var(--line-soft);
    background: transparent;
}
.mini-table th.num, .mini-table td.num { text-align: right; }
.mini-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.mini-table tr:last-child td { border-bottom: none; }
.mini-table .muted { color: var(--grey-cool); }
.totals-view { margin-top: var(--sp-5); }

/* Hint mic sub un câmp */
.field-hint { margin-top: 6px; font-size: 12px; color: var(--grey-cool); }

/* --- Panou de control (dashboard) ---------------------------------------- */
.range-filter {
    display: inline-flex; gap: 3px; padding: 4px;
    background: var(--surface-raised); border: 1px solid var(--line-soft); border-radius: var(--radius-md);
}
.range-opt {
    padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 600;
    color: var(--grey-cool); transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.range-opt:hover { color: #fff; background: var(--wash-2); }
.range-opt.active { color: var(--navy); background: var(--cta); }
.range-opt:focus-visible { outline-offset: -2px; }

.stat-grid {
    /* `minmax(0, 1fr)`: sumele lungi („14.172,74 lei") au min-content mare și,
       cu `1fr` simplu, lățeau pista peste ecran. */
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5);
}
.stat-card {
    display: flex; flex-direction: column; gap: 10px;
    background: var(--surface-raised); border: 1px solid var(--wash-3);
    border-radius: var(--radius); padding: var(--sp-5);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
    animation: rise-in var(--dur-slow) var(--ease-out) both;
}
/* Intrare ușor eșalonată a cardurilor de statistici. */
.stat-card:nth-child(2) { animation-delay: 40ms; }
.stat-card:nth-child(3) { animation-delay: 80ms; }
.stat-card:nth-child(4) { animation-delay: 120ms; }
.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(185, 255, 240, 0.22);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 14px 30px -18px rgba(0, 0, 0, 0.8);
}
.stat-top { display: flex; align-items: center; gap: 10px; }
.stat-icon {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; flex: none;
    border-radius: 9px;
    background: var(--cta-glow);
    border: 1px solid rgba(185, 255, 240, 0.25);
    color: var(--cta);
}
.stat-icon svg { width: 15px; height: 15px; }
.stat-label { font-size: 12px; color: var(--grey-cool); font-weight: 500; }
.stat-value {
    font-family: var(--font-display); font-weight: 800; font-size: 26px;
    color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}

.chart-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5);
}
.chart-row .view-card { margin-bottom: var(--sp-5); }

/* Graficul umple întotdeauna lățimea cardului (raport fix 480:170 din viewBox),
   deci nu rămâne spațiu gol la dreapta indiferent de numărul de bare. */
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--cta); transition: fill var(--dur-fast) var(--ease); }
.chart .bar:hover { fill: #fff; }
.chart .chart-grid { stroke: var(--line-soft); }
/* FONT_SIZE din ChartRenderer trebuie ținut în sincron cu `font-size` de aici
   (pe baza lui se calculează rarefierea etichetelor). */
.chart .chart-axis { fill: #CBD5E1; font-size: 13px; font-weight: 700; font-family: var(--font-body); }
.chart .chart-axis-max { font-size: 14px; fill: var(--offwhite); }

@media (max-width: 720px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-row { grid-template-columns: 1fr; }
}

/* Sub ~400px, două carduri de statistici alături înseamnă cifre rupte pe
   trei rânduri. Mai bine unul pe rând. */
@media (max-width: 400px) {
    .stat-grid { grid-template-columns: minmax(0, 1fr); }
    .stat-value { font-size: 24px; }
    .brand-name { white-space: nowrap; }
    /* Pe ecrane atât de înguste contează butonul de ieșire, nu numele contului. */
    .topbar-user { display: none; }
}

/* --- Paginare ------------------------------------------------------------ */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); margin-top: var(--sp-5); }
.page-btn {
    padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line);
    font-size: 14px; font-weight: 600; color: var(--offwhite);
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.page-btn:hover { background: var(--wash-2); border-color: var(--line-strong); }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }
.page-info { font-size: 13px; color: var(--grey-cool); }

/* --- Descriere deviz ----------------------------------------------------- */
.inp-area {
    height: auto;
    min-height: 96px;
    padding: 12px 14px;
    line-height: 1.55;
    resize: vertical;
}
.descriere-text { margin: 0; font-size: 14px; line-height: 1.65; color: var(--offwhite); }

/* --- Poze deviz ---------------------------------------------------------- */
.poza-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--sp-3);
}
/* Grila goală are înălțime 0, deci marginea de sub ea e mereu corectă. */
.poza-grid + .poza-drop { margin-top: var(--sp-3); }

.poza-tile {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--wash-2);
    border: 1px solid var(--line);
    animation: pop-in var(--dur) var(--ease-out);
}
.poza-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Tile-urile alese în browser, încă netrimise la server. */
.poza-tile.is-pending { border-style: dashed; border-color: var(--line-strong); }
.poza-tile.is-pending::after {
    content: "nesalvată";
    position: absolute; left: 6px; bottom: 6px;
    padding: 2px 7px; border-radius: 999px;
    background: rgba(6, 12, 22, 0.78); color: var(--grey-cool);
    font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
}

.poza-remove {
    position: absolute; top: 6px; right: 6px;
    width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: rgba(6, 12, 22, 0.78); border: 1px solid var(--line);
    color: var(--danger-soft); font-size: 16px; line-height: 1;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.poza-remove:hover { background: var(--danger-bg); border-color: var(--danger-line); }

.poza-view { cursor: zoom-in; transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.poza-view:hover { border-color: var(--cta); transform: translateY(-2px); }

.poza-drop {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 92px; padding: var(--sp-4);
    border: 1px dashed var(--line-strong); border-radius: var(--radius-md);
    background: var(--wash-1); color: var(--grey-cool); cursor: pointer;
    font-size: 14px;
    transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.poza-drop:hover, .poza-drop.is-dragover { border-color: var(--cta); background: var(--cta-glow); color: var(--offwhite); }
.poza-drop svg { width: 22px; height: 22px; flex: none; }
.poza-drop .opt { color: rgba(148, 163, 184, 0.7); }

/* --- Lightbox (poze deviz) ----------------------------------------------- */
.lightbox {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: var(--sp-6);
    background: rgba(6, 12, 22, 0.92);
    animation: fade-in var(--dur-fast) var(--ease-out);
}
.lightbox img {
    max-width: 100%; max-height: 100%;
    object-fit: contain; border-radius: var(--radius-md);
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.9);
}
.lightbox-close, .lightbox-nav {
    position: absolute; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: var(--wash-3); border: 1px solid var(--line);
    color: var(--offwhite); border-radius: 50%;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.lightbox-close:hover, .lightbox-nav:hover { background: var(--wash-2); border-color: var(--cta); }
.lightbox-close { top: var(--sp-5); right: var(--sp-5); width: 40px; height: 40px; font-size: 22px; line-height: 1; }
.lightbox-nav { top: 50%; margin-top: -22px; width: 44px; height: 44px; font-size: 24px; line-height: 1; }
.lightbox-prev { left: var(--sp-5); }
.lightbox-next { right: var(--sp-5); }
.lightbox-caption {
    position: absolute; bottom: var(--sp-5); left: 50%; transform: translateX(-50%);
    max-width: 80%; padding: 6px 14px; border-radius: 999px;
    background: rgba(6, 12, 22, 0.8); border: 1px solid var(--line);
    color: var(--grey-cool); font-size: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
body.lightbox-open { overflow: hidden; }

/* --- Print / Export PDF (deviz) ------------------------------------------ */
.print-only { display: none; }
@media print {
    * { animation: none !important; transition: none !important; }
    .topbar, .tabs, .footer, .range-filter, .searchbar, .pagination,
    .row-actions, .btn, .page-head .row-actions, .notice, .skip-link, .nav-progress,
    .no-print, .lightbox { display: none !important; }
    .descriere-text { color: #000; }
    body { background: #fff; color: #000; }
    .container { padding: 0; max-width: none; }
    .view-card { background: #fff; border: 1px solid #ccc; box-shadow: none; color: #000; page-break-inside: avoid; }
    .view-card h2, .page-head h1 { color: #000; }
    .detail-grid dt, .mini-table th { color: #333; }
    .detail-grid dd, .detail-grid dd > a { color: #000; }
    .mini-table th { border-color: #ccc; }
    .mini-table td { border-color: #eee; color: #000; }
    .mini-table .muted { color: #555; }
    .totals-grid { background: #fff; border: 1px solid #ccc; }
    .totals-grid dt { color: #333; }
    .totals-grid dd, .totals-grid dt.grand, .totals-grid dd.grand { color: #000; border-color: #999; }
    .print-only { display: block !important; }
    .print-head { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid #000; }
    .print-head strong { font-size: 18px; }
    .print-head span { display: block; font-size: 12px; color: #444; margin-top: 2px; }

    /* --- Pozele pe devizul printat / PDF --------------------------------
       Merg la final, ca anexă: cine primește devizul vrea întâi lucrările și
       prețurile, pozele sunt dovada care le însoțește. */
    .container { display: flex; flex-direction: column; }
    .poze-card { order: 10; }
    /* Un card cu multe poze trebuie să poată curge pe pagina următoare; doar
       pozele individuale nu au voie să fie tăiate în două. */
    .poze-card { page-break-inside: auto; break-inside: auto; }
    /* Coloane, nu grid: pozele au înălțimi diferite (portret lângă peisaj), iar
       grid-ul lăsa jumătate de pagină goală sub cele late. Fluxul pe coloane le
       împachetează și respectă `break-inside` la schimbarea de pagină. */
    .poza-grid-view { display: block; columns: 2; column-gap: 10px; }
    .poza-tile {
        /* Pe hârtie renunțăm la caseta 4:3 cu decupare: poza se vede întreagă,
           la proporția ei reală — e dovada avariei, nu o ilustrație. */
        display: block;
        width: 100%;
        aspect-ratio: auto;
        margin: 0 0 10px;
        border: 1px solid #ccc;
        background: #fff;
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .poza-tile img { height: auto; object-fit: fill; }
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 560px) {
    .topbar { padding: 0 var(--sp-4); }
    .container { padding: var(--sp-6) var(--sp-4) 48px; }
    .brand-sub { display: none; }
    .page-head { align-items: flex-start; }
    .page-head h1 { font-size: 22px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { justify-content: center; }
    .totals-grid { margin-left: 0; max-width: none; }
    .detail-grid { grid-template-columns: 1fr; gap: 4px 0; }
    .detail-grid dd { margin-bottom: 10px; }
    .searchbar .btn { padding: 0 14px; }
    /* iOS Safari mărește automat pagina la focus pe un input sub 16px, și nu o
       mai dezumflă la blur. Deci pe ecrane mici toate câmpurile trec la 16px. */
    .inp, .searchbar input[type="search"], .parts-table .inp,
    .login-card input, textarea { font-size: 16px; }

    /* Cele patru taburi încap toate dacă renunțăm la padding-ul generos; altfel
       tabul activ („Devize") rămânea în afara ecranului, fără niciun indiciu. */
    .tabs { display: flex; width: 100%; overflow-x: visible; }
    .tab { flex: 1 1 0; min-width: 0; justify-content: center; padding: 10px 6px; font-size: 13px; }
    .tab svg { display: none; }

    /* --- Tabele → carduri --------------------------------------------------
       Scroll-ul orizontal ascundea exact coloanele care contează (prețuri,
       butoanele de acțiune) și nimic nu sugera că mai există conținut la
       dreapta. Fiecare rând devine un card, iar numele coloanei vine din
       `data-label` (capul de tabel e ascuns). */
    .card .table-scroll, .view-card .table-scroll { overflow-x: visible; }
    .card .table-scroll table, .view-card .table-scroll table { min-width: 0; }
    .card table, .card thead, .card tbody, .card tr, .card td,
    .mini-table, .mini-table thead, .mini-table tbody, .mini-table tr, .mini-table td { display: block; }
    .card thead, .mini-table thead { display: none; }

    .card tbody tr, .mini-table tbody tr {
        padding: var(--sp-4) var(--sp-4) var(--sp-3);
        border-bottom: 1px solid var(--line-soft);
    }
    .card tbody tr:last-child, .mini-table tbody tr:last-child { border-bottom: none; }
    .card tbody tr:hover td, .mini-table tbody tr:hover td { background: transparent; }

    .card tbody td, .mini-table tbody td {
        display: grid;
        grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
        gap: var(--sp-3);
        align-items: baseline;
        padding: 5px 0;
        border-bottom: none;
    }
    .card tbody td::before, .mini-table tbody td::before {
        content: attr(data-label);
        color: var(--grey-cool);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        line-height: 1.5;
        /* Valorile numerice rămân aliniate la dreapta (coloană de sume ușor de
           citit), dar eticheta stă mereu la stânga. */
        text-align: left;
    }
    /* Celulele fără etichetă (acțiuni, rândul „niciun rezultat") ocupă tot rândul. */
    .card tbody td:not([data-label]), .mini-table tbody td:not([data-label]) { display: block; }
    .card tbody td:not([data-label])::before, .mini-table tbody td:not([data-label])::before { content: none; }
    /* `.col-actions` are `width: 1%` — trucul de „strânge coloana la conținut"
       din layoutul de tabel. Fără display:table devine literal 1% (3px) și
       butoanele se stivuiau vertical. */
    .card td.col-actions { width: auto; white-space: normal; margin-top: var(--sp-3); }
    .card .row-actions, .mini-table .row-actions { justify-content: flex-start; }
    .card .row-actions .btn, .mini-table .btn { height: 40px; }
    .empty td { padding: 40px var(--sp-4); text-align: center; }

    /* Tabelul de piese nu încape pe telefon: cele trei coloane fixe (preț, preț
       cu TVA, ștergere) lăsau sub 30px pentru „Piesă" și „Furnizor". Îl scoatem
       din layout-ul de tabel și facem din fiecare rând un card. */
    .parts-table, .parts-table tbody { display: block; }
    .parts-table thead { display: none; }
    .parts-table .part-row {
        display: grid;
        /* `minmax(0, 1fr)`, nu `1fr`: altfel pista nu poate coborî sub lățimea
           intrinsecă a unui <input> (~170px) și rândul iese din ecran. */
        grid-template-columns: minmax(0, 1fr) auto 36px;
        grid-template-areas:
            "nume     nume nume"
            "furnizor furnizor furnizor"
            "pret     tva  remove";
        gap: var(--sp-2);
        align-items: center;
        margin-bottom: var(--sp-3);
        padding: var(--sp-3);
        background: var(--wash-1);
        border: 1px solid var(--line-soft);
        border-radius: var(--radius-md);
    }
    .parts-table .part-row td { display: block; padding: 0; }
    .parts-table .part-row td:nth-child(1) { grid-area: nume; }
    .parts-table .part-row td:nth-child(2) { grid-area: furnizor; }
    .parts-table .part-row td:nth-child(3) { grid-area: pret; }
    .parts-table .part-row td:nth-child(4) { grid-area: tva; }
    .parts-table .part-row td:nth-child(5) { grid-area: remove; text-align: right; }
    /* Capul de tabel e ascuns, deci coloana calculată își spune singură numele.
       Fără `nowrap`, ca un total lung să se rupă în loc să lățească rândul. */
    .parts-table .part-cu-tva { white-space: normal; font-size: 13px; }
    .parts-table .part-cu-tva::before { content: "cu TVA "; color: var(--grey-cool); }

    .poza-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
    .lightbox { padding: var(--sp-3); }
    .lightbox-nav { width: 40px; height: 40px; margin-top: -20px; }
    .lightbox-prev { left: var(--sp-2); }
    .lightbox-next { right: var(--sp-2); }
    /* Numele lung de utilizator nu are voie să împingă butonul de ieșire afară. */
    .topbar-user { max-width: 33vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Ținte tactile: „×"-ul de pe poze și butonul de ștergere a piesei erau sub
       pragul uzual de 40px. Legăm asta de lățimea ecranului, nu de `hover: none`
       — ultimul nu e raportat consecvent de toate browserele. */
    .poza-remove { width: 36px; height: 36px; font-size: 20px; }
    .btn-remove { width: 40px; height: 40px; }
    .btn-sm { height: 40px; padding: 0 14px; }
    .brand { min-height: 40px; }
    .range-opt { padding: 10px 14px; }
    /* Legăturile către client/mașină de pe deviz sunt navigație principală pe
       telefon — le dăm înălțime de atins, nu doar înălțimea textului. */
    .detail-grid dd > a { display: inline-block; padding: 6px 0; }
    /* „Trage-le aici" nu înseamnă nimic fără mouse. */
    .poza-drop .opt { display: none; }
}
