:root {
  --brand: #0f4c81;
  --brand-ink: #ffffff;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #5d6b7c;
  --border: #d7dde5;
  --chip: #eef2f7;
  --ok-bg: #e6f4ea;  --ok: #1e6b34;
  --err-bg: #fdecea; --err: #a32020;
  --info-bg: #e8f0fb; --info: #1d4f91;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #4a9be0;
    --brand-ink: #08131f;
    --bg: #0f141a;
    --card: #18202a;
    --text: #e6ebf1;
    --muted: #9aa8b8;
    --border: #2c3846;
    --chip: #222d3a;
    --ok-bg: #173323;  --ok: #8fd6a4;
    --err-bg: #3a1a1a; --err: #f2a3a3;
    --info-bg: #182a40; --info: #9cc3f2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* altfel display: flex/inline-flex din clase ar anula atributul hidden */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }

/* Bara de sus rămâne albă și în modul întunecat, ca logo-ul să se vadă corect */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .5rem .875rem; padding-top: max(.5rem, env(safe-area-inset-top));
  background: #ffffff; color: #1b2430;
  border-bottom: 1px solid #e3e7ec;
}
.brand { display: flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none; min-width: 0; }
.brand img { display: block; height: 36px; width: auto; }
.brand-text { display: flex; align-items: baseline; gap: .35rem; min-width: 0; color: #1b2430; white-space: nowrap; }
.brand-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; color: #000000; }
.brand-doc { color: #fec803; }   /* galbenul din siglă */
/* Versiunea arată la fel ca subtitlul „Încărcare documente” */
.brand-version, .brand-sub { font-size: .95rem; font-weight: 600; color: #5d6b7c; letter-spacing: 0; }
.brand-sub { overflow: hidden; text-overflow: ellipsis; }
.brand-sep { color: #8a96a5; }
/* Pe telefoanele înguste, subtitlul trece sub nume */
@media (max-width: 480px) {
  .brand-text { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.15; }
  .brand-version, .brand-sub { font-size: .8rem; }
  .brand-sep { display: none; }
}
.topbar nav { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; font-size: .9rem; }
.topbar nav a, .linklike {
  color: #1b2430; text-decoration: none; font: inherit; font-weight: 600;
  background: none; border: 0; padding: .5rem 0; cursor: pointer;
}
.topbar form { margin: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom)); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.card.narrow { max-width: 420px; margin: 2rem auto; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.stack { display: grid; gap: 1rem; margin-top: 1rem; }

label { display: grid; gap: .35rem; font-weight: 600; }
input[type=email], input[type=password], textarea, select {
  width: 100%; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: .75rem;
}
input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px;
}
fieldset { border: 0; margin: 0; padding: 0; }
legend { font-weight: 600; margin-bottom: .5rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 52px; padding: .75rem 1rem; border-radius: 12px;
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--chip); color: var(--text);
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); width: 100%; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.alert { margin: 0; padding: .75rem 1rem; border-radius: 10px; }
.alert.error { background: var(--err-bg); color: var(--err); }
.alert.success { background: var(--ok-bg); color: var(--ok); }
.alert.info { background: var(--info-bg); color: var(--info); }

.badge { font-size: .8rem; padding: .15rem .55rem; border-radius: 99px; background: var(--chip); white-space: nowrap; }
.status-nou, .status-in_procesare { background: var(--info-bg); color: var(--info); }
.status-procesat, .status-exportat { background: var(--ok-bg); color: var(--ok); }
.status-eroare { background: var(--err-bg); color: var(--err); }
.footer { max-width: 1180px; margin: 0 auto; padding: 0 1rem calc(1.5rem + env(safe-area-inset-bottom)); text-align: center; }


/* ---- Portal ---- */
.topbar nav .who { color: #5d6b7c; font-weight: 600; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) { .topbar nav .who { display: none; } }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: .5rem 0 1rem; }
.page-head p { margin: .2rem 0 0; }
.summary { display: flex; gap: .5rem; margin: 0; }
.summary div { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: .45rem .8rem; min-width: 6.5rem; }
.summary dt { font-size: .75rem; color: var(--muted); }
.summary dd { margin: 0; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary .alert-stat dd { color: var(--err); }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.filters label { font-size: .85rem; min-width: 12rem; flex: 0 1 16rem; }
.filters select { padding: .55rem .6rem; }

.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.docs { width: 100%; border-collapse: collapse; font-size: .92rem; }
.docs th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: .7rem .8rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.docs td { padding: .65rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.docs tbody tr:last-child td { border-bottom: 0; }
.docs tbody tr { position: relative; }
.docs tbody tr:hover { background: color-mix(in srgb, var(--brand) 6%, var(--card)); }
.docs .num { text-align: right; font-variant-numeric: tabular-nums; }
.rowlink { font-weight: 700; text-decoration: none; }
.rowlink::after { content: ""; position: absolute; inset: 0; }   /* tot rândul e clicabil */

/* Procentul OCR */
.score { display: inline-block; min-width: 3.6rem; text-align: center; font-weight: 700; font-size: .85rem; padding: .12rem .5rem; border-radius: 99px; font-variant-numeric: tabular-nums; }
.score-good { background: var(--ok-bg); color: var(--ok); }
.score-fair { background: #fff3c4; color: #6b4e00; }
.score-poor { background: var(--err-bg); color: var(--err); }
.score-none { color: var(--muted); }
@media (prefers-color-scheme: dark) { .score-fair { background: #3a2f0a; color: #f5d77a; } }
.legend { margin-top: .75rem; display: flex; flex-wrap: wrap; gap: .35rem .6rem; align-items: center; }
.legend .score { min-width: 0; }
.empty { text-align: center; padding: 2rem 1rem; }
.empty p { margin: .25rem 0; }

/* Pe telefon, tabelul devine o listă de carduri */
@media (max-width: 760px) {
  .table-card { background: none; border: 0; overflow: visible; }
  .docs thead { display: none; }
  .docs, .docs tbody, .docs tr, .docs td { display: block; }
  .docs tr { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .8rem; margin-bottom: .6rem; }
  .docs td { border: 0; padding: .2rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .docs td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; }
  .docs .num { text-align: right; }
}

/* Pagina unui document */
.back { display: inline-block; margin: .25rem 0 .75rem; text-decoration: none; font-weight: 600; }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem 1.25rem; margin: 1rem 0 0; }
.meta dt { font-size: .75rem; color: var(--muted); }
.meta dd { margin: .1rem 0 0; font-weight: 600; overflow-wrap: anywhere; }
.pages { display: grid; gap: 1rem; margin-top: 1rem; }
.page { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 760px) { .page { grid-template-columns: 1fr; } }
.page-view { display: block; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--chip); }
.page-view img { display: block; width: 100%; height: auto; max-height: 460px; object-fit: contain; background: #fff; }
.page-view .ph { display: grid; place-items: center; aspect-ratio: 3 / 4; font-weight: 700; color: var(--muted); text-decoration: none; }
.page-info h2 { font-size: 1rem; margin: 0 0 .5rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.page-info .actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.page-info .btn { min-height: 40px; padding: .4rem .8rem; font-size: .9rem; text-decoration: none; }
.ocr-text summary { cursor: pointer; font-weight: 600; }
.ocr-text pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85rem; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: .75rem; max-height: 22rem; overflow: auto; margin: .5rem 0 0; }

/* Administrare */
.topbar nav a { white-space: nowrap; }
.btn.btn-inline { width: auto; min-height: 44px; font-size: .95rem; text-decoration: none; }
.filters .grow { flex: 1 1 18rem; }
.filters input[type=search] { padding: .55rem .6rem; }
.filters .btn { align-self: flex-end; min-height: 42px; }
.docs tr.inactive td { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; margin-top: 1rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid input[type=text], .form-grid input[type=tel] {
  width: 100%; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: .75rem;
}
.form-grid input:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
.has-error input, .has-error textarea { border-color: var(--err); }
.field-error { color: var(--err); font-size: .85rem; font-weight: 500; }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.option { display: flex; gap: .65rem; align-items: flex-start; font-weight: 600; font-size: .95rem; }
.option input { width: 22px; height: 22px; margin: .1rem 0 0; flex-shrink: 0; accent-color: var(--brand); }
.option .muted { display: block; font-weight: 400; font-size: .875rem; }
.related { margin-top: 1rem; }
.related h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.related h2 + * { margin-top: 0; }
.related ul + h2, .related p + h2 { margin-top: 1.25rem; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
code { font-size: .8rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .1rem .35rem; overflow-wrap: anywhere; }
@media (max-width: 480px) { .hide-narrow { display: none; } }
