:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #64748b;
  --line: #dbe2ea;
  --navy: #10243c;        /* culoarea identitatii: antet si actiunea principala */
  --navy-hover: #1d3f66;
  --accent: #1d6fd6;      /* linkuri si inelul de focus */
  --accent-dark: #17599b;
  --ok: #157a4c;
  --warn: #b45309;
  --err: #b91c1c;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { background: var(--navy); color: #fff; }
.topbar-inner {
  max-width: 1400px; margin: 0 auto; padding: 10px 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.brand { display: flex; align-items: center; gap: 9px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-icon { height: 22px; width: auto; display: block; }
.brand-nume { font-weight: 600; font-size: 17px; letter-spacing: .02em; }
.brand-slogan { color: #9fb3cc; font-size: 12px; }
@media (max-width: 700px) { .brand-slogan { display: none; } }

/* blocul de identitate de pe pagina de autentificare */
.brand-hero { text-align: center; margin: 20px 0 24px; }
.brand-hero img { max-width: 300px; width: 80%; height: auto; }

/* butonul de autentificare cu Google */
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 10px 16px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink); font: inherit; font-weight: 500; text-decoration: none;
}
.btn-google:hover { background: #f8fafc; text-decoration: none; }
.separator {
  display: flex; align-items: center; gap: 12px; margin: 16px 0;
  color: var(--muted); font-size: 13px;
}
.separator::before, .separator::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

.container { max-width: 1400px; margin: 24px auto; padding: 0 24px; }
.container.narrow { max-width: 460px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.card h2 { margin-top: 0; font-size: 18px; }
.card h3 { font-size: 15px; }

/* titlurile de pagina se definesc o singura data, nu prin stiluri scrise in sabloane */
h1 { font-size: 22px; margin: 0 0 10px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd7f7; border-color: var(--accent); }

.btn {
  display: inline-block; padding: 8px 16px; border-radius: 6px; border: 1px solid transparent;
  background: var(--navy); color: #fff; font: inherit; cursor: pointer;
}
.btn:hover { background: var(--navy-hover); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #eef2f7; }
.btn-ghost { background: transparent; color: #cfe0f5; border: 1px solid #3b5474; }
.btn-ghost:hover { background: #1d3557; text-decoration: none; }
.btn-success { background: var(--ok); }
.btn-success:hover { background: #0f5c39; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-danger { background: #fff; color: var(--err); border-color: #f3caca; }
.btn-danger:hover { background: #fdf0f0; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.list tr:hover td { background: #f8fafc; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-nou, .badge-procesare { background: #e2e8f0; color: #334155; }
.badge-extras { background: #fef3c7; color: #92400e; }
.badge-verificat { background: #d1fae5; color: #065f46; }
.badge-exportat { background: #dbeafe; color: #1e40af; }
.badge-eroare { background: #fee2e2; color: #991b1b; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warn { background: #fef3c7; color: #92400e; }
.alert-ok { background: #d1fae5; color: #065f46; }

/* ascundere accesibila: invizibil pe ecran, dar prezent pentru tastatura si cititoare */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.upload-zone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 20px;
  text-align: center; color: var(--muted); background: #fbfdff; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--accent); }
.upload-zone.dragover { border-color: var(--accent); background: #eef5fd; }
/* inelul de focus apare cand se ajunge cu tastatura */
.upload-zone:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.upload-icon { font-size: 26px; line-height: 1; }
.upload-titlu { font-size: 17px; font-weight: 600; color: var(--ink); }
.upload-lista:not(:empty) {
  margin-top: 6px; padding: 6px 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 6px; color: var(--ink);
}
.btn:disabled { opacity: .6; cursor: progress; }

/* ---- ecranul de verificare split-view ---- */
.review-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px;
  height: calc(100vh - 130px); min-height: 500px;
}
.review-pane { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
/* antetul cu actiunile ramane lipit sus: pe ecran ingust altfel dispare la derulare,
   iar contabilul trebuie sa urce inapoi ca sa apese „Confirmă” */
.review-pane .pane-head {
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 2; background: var(--card);
}
.review-pane .pane-body { flex: 1; overflow: auto; padding: 14px; }
.review-pane .pane-body.noscroll { padding: 0; }
.doc-frame { width: 100%; height: 100%; border: 0; }
.doc-img { max-width: 100%; display: block; margin: 0 auto; }

.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.fields-grid .full { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 14px; padding: 4px 14px 12px; }
legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }

table.linii { width: 100%; border-collapse: collapse; font-size: 13px; }
table.linii th, table.linii td { border: 1px solid var(--line); padding: 3px; }
table.linii input { border: none; padding: 5px 6px; border-radius: 0; width: 100%; }
table.linii .col-desc { width: 34%; }
table.linii .num { text-align: right; }

.muted { color: var(--muted); font-size: 13px; }
.mt { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.total-line { font-weight: 600; }

/* ---- badge pentru tipul documentului (vizibil, colorat pe categorie) ---- */
.doctype {
  display: inline-block; padding: 3px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.doctype-factura_intrare { background: #dbeafe; color: #1e40af; }
.doctype-factura_iesire  { background: #dcfce7; color: #166534; }
.doctype-bon_fiscal      { background: #fef3c7; color: #92400e; }
.doctype-chitanta        { background: #f3e8ff; color: #6b21a8; }
.doctype-extras_bancar   { background: #cffafe; color: #155e75; }
.doctype-auto            { background: #e2e8f0; color: #334155; }
.doctype-lg { font-size: 15px; padding: 5px 16px; }

/* ---- indicatori si grafice in panoul de administrare ---- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-link { display: block; color: inherit; transition: border-color .15s, background .15s; }
.stat-link:hover { border-color: var(--accent); background: #f7fbff; text-decoration: none; }
.stat-link .stat-lbl { color: var(--accent); }
.stat-val { font-size: 24px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.stat-lbl { font-size: 12px; color: var(--muted); margin-top: 3px; }
.bara {
  background: var(--accent); height: 16px; border-radius: 4px; min-width: 2px;
}

/* ---- alegerea metodei de autentificare in doi pasi ---- */
.metode-2fa { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metoda {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column;
}
.metoda h3 { margin: 0 0 6px; }
.metoda p { margin: 0 0 12px; font-size: 13px; line-height: 1.5; flex: 1; }
@media (max-width: 700px) { .metode-2fa { grid-template-columns: 1fr; } }

/* ---- bara de unelte de deasupra listelor ----
   Aceeasi forma peste tot (cabinete, firme, documente): cautarea ocupa spatiul
   liber, filtrele stau la dreapta. Consistenta e ce face interfata sa para ingrijita. */
.bara-unelte {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 14px 0 12px;
}
.bara-unelte .creste { flex: 1 1 240px; min-width: 0; }
.bara-unelte label { margin: 0; font-size: 13px; color: var(--muted); }

.camp-cautare {
  width: 100%; padding: 10px 12px 10px 38px; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background-color: #fff;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 13px center;
}
.camp-cautare:focus {
  border-color: var(--accent); outline: 2px solid rgba(29, 111, 214, .16); outline-offset: 0;
}
.camp-cautare::-webkit-search-cancel-button { cursor: pointer; }

/* control segmentat: inlocuieste sirul de butoane care se rupea pe doua randuri */
.segmente {
  display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: #fff; max-width: 100%;
}
.segmente a {
  padding: 8px 13px; font-size: 13px; line-height: 1.2; color: var(--muted);
  text-decoration: none; border-left: 1px solid var(--line); white-space: nowrap;
}
.segmente a:first-child { border-left: 0; }
.segmente a:hover { background: #f1f5f9; text-decoration: none; color: var(--ink); }
.segmente a.activ { background: var(--navy); color: #fff; }
.segmente a.dezactivat { color: #b6c2d0; cursor: default; }
.segmente a.dezactivat:hover { background: #fff; color: #b6c2d0; }
.segmente a.activ:hover { background: var(--navy-hover); }
@media (max-width: 700px) { .segmente { overflow-x: auto; } }

/* rezumatul de deasupra unei liste: cate randuri se vad si ce valoare insumeaza */
.rezumat-lista {
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline;
  font-size: 13px; color: var(--muted); margin-bottom: 8px;
}
.rezumat-lista strong { color: var(--ink); font-size: 14px; }

/* ---- liste lungi: inaltime marginita, antet lipit ---- */
.lista-derulabila { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.lista-derulabila table.list { margin: 0; }
.lista-derulabila thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--card); box-shadow: inset 0 -1px 0 var(--line);
}
.fara-rezultate { padding: 16px; color: var(--muted); font-size: 14px; }

/* ---- ecran de lucru: se arata cand o actiune dureaza vizibil ---- */
.overlay-lucru {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(16, 36, 60, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.overlay-lucru[hidden] { display: none; }
.overlay-cutie {
  background: var(--card); border-radius: var(--radius); padding: 26px 30px;
  max-width: 360px; text-align: center; box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.overlay-titlu { font-size: 16px; font-weight: 600; margin: 14px 0 6px; }
.overlay-detaliu { font-size: 13px; color: var(--muted); line-height: 1.5; }

.rotitor {
  width: 34px; height: 34px; margin: 0 auto;
  border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: rotire .9s linear infinite;
}
.rotitor-mic { width: 16px; height: 16px; border-width: 2px; display: inline-block; vertical-align: -3px; }
@keyframes rotire { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rotitor { animation-duration: 2.5s; } }

/* banner pentru documentele aflate in citire */
.in-lucru {
  display: flex; align-items: center; gap: 12px;
  background: #eef4fb; border: 1px solid #c9dcf2; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px;
}
.in-lucru .text { font-size: 14px; }
.in-lucru .muted { display: block; font-size: 12px; margin-top: 2px; }

/* ---- grafic de evolutie ---- */
.grafic-comenzi { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 12px; }
.grafic-comenzi label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; }
.grafic-serie { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.grafic-pastila { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; }
.grafic-cadru { width: 100%; overflow-x: auto; }
.grafic-cadru svg { display: block; min-width: 420px; width: 100%; height: auto; }

/* rand de export: separator simplu, in loc de card in card */
.export-rand { border-top: 1px solid var(--line); padding: 14px 0 4px; }
.export-rand:first-of-type { border-top: 0; }

/* ---- pasii din pagina de instructiuni ---- */
.pas { display: flex; gap: 16px; align-items: flex-start; }
.pas-nr {
  flex: 0 0 34px; height: 34px; border-radius: 50%;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600;
}
.pas-continut { flex: 1; min-width: 0; }
.pas-continut h2 { margin: 4px 0 8px; }
.pas-continut p { margin: 0 0 8px; line-height: 1.55; }
.schema { width: 100%; max-width: 520px; height: auto; margin: 10px 0; }
code {
  background: #f1f5f9; padding: 1px 6px; border-radius: 4px;
  font-size: 13px; font-family: Consolas, monospace;
}

@media print {
  .topbar, .btn, form { display: none !important; }
  .card { border-color: #ccc; break-inside: avoid; page-break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
}

/* ---------------------------------------------------------- ecrane mici ----
   Clientii fotografiaza bonuri de pe telefon, deci fluxul de incarcare si
   citirea starii trebuie sa functioneze si la 360px latime. */
@media (max-width: 1000px) {
  /* verificarea documentelor: documentul deasupra, datele dedesubt */
  .review-layout {
    grid-template-columns: 1fr;
    height: auto;
    gap: 12px;
  }
  .review-pane { min-height: 380px; }
  .review-pane .pane-body { max-height: 70vh; }
}

@media (max-width: 700px) {
  .container { padding: 0 14px; margin: 16px auto; }
  .card { padding: 16px 14px; }
  .fields-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
  .stat-val { font-size: 20px; }
  h1 { font-size: 19px; }

  /* tabelele late devin derulabile pe orizontala, in loc sa iasa din ecran */
  table.list { display: block; overflow-x: auto; white-space: nowrap; }

  /* ...cu o exceptie: intr-o lista cu inaltime marginita, `display:block` ar muta
     contextul de lipire al antetului pe tabel (care n-are inaltime), iar antetul
     n-ar mai ramane vizibil la derulare. Acolo lasam containerul sa deruleze pe
     ambele axe si pastram tabelul ca tabel. */
  .lista-derulabila table.list { display: table; overflow-x: visible; }
  table.list td, table.list th { padding: 8px 8px; }

  /* tinte de atingere mai mari pe telefon */
  .btn { padding: 10px 16px; }
  .btn-sm { padding: 7px 12px; }
  .upload-zone { padding: 34px 16px; }
  .upload-titlu { font-size: 16px; }

  /* actiunile din bara de sus se aseaza pe rand, fara sa se inghesuie */
  .topbar-inner { padding: 8px 14px; }
  .row { gap: 8px; }
}
