:root {
    --bg: #f4f6f9; --paper: #ffffff; --ink: #172233; --muted: #5a6577; --line: #dbe1e8; --soft: #edf1f6;
    --accent: #1f4f82; --accent-ink: #ffffff; --accent-soft: #e2ebf6; --mark: #ffe8a3;
    --ok: #1d7a4d; --ok-bg: #e0f3e8; --warn: #9a6200; --warn-bg: #fbefd5; --bad: #a33030;
    --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    --sans: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #10151d; --paper: #171e28; --ink: #e4e9f0; --muted: #98a3b3; --line: #2a3442; --soft: #1d2531;
        --accent: #86b4e8; --accent-ink: #0d1520; --accent-soft: #1c2b3d; --mark: #5c4a12;
        --ok: #7fd3a6; --ok-bg: #173424; --warn: #e7bf6d; --warn-bg: #3a2e14; --bad: #f09a9a;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--sans); }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font: 600 1.6rem/1.2 var(--serif); margin: 0; text-wrap: balance; }
h2 { font: 600 1.1rem/1.3 var(--sans); margin: 1.8rem 0 .7rem; }
h3 { font: 600 .78rem/1.3 var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .5rem; }
code { font: .85em var(--mono); background: var(--soft); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.eyebrow { margin: 0 0 .3rem; color: var(--muted); font-size: .85rem; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.25rem;
          background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font: 600 1.05rem var(--serif); color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-mark { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 6px;
              background: var(--accent); color: var(--accent-ink); margin-right: .35rem; font-family: var(--serif); }
.topbar nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: .35rem .75rem; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 500; }
.topbar nav a:hover { background: var(--soft); color: var(--ink); }
.topbar nav a.active { background: var(--accent-soft); color: var(--accent); }
.logout { color: var(--muted); text-decoration: none; font-size: .9rem; }
.page { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: .3rem; padding: .5rem .95rem; border-radius: 7px; border: 1px solid var(--line);
       background: var(--paper); color: var(--ink); font: 500 .92rem var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: default; }
input, select { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 7px; padding: .55rem .75rem; }
.linkish { background: none; border: 0; color: var(--accent); padding: .2rem 0; cursor: pointer; font: inherit; font-size: .85rem; }
.form-error { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); padding: .6rem .8rem; border-radius: 7px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1.75rem;
              display: grid; gap: .55rem; }
.login-card h1 { margin: .8rem 0 .4rem; }
.login-card label { font-size: .85rem; color: var(--muted); margin-top: .3rem; }
.login-card .btn { margin-top: .8rem; justify-content: center; }
.hint { font-size: .8rem; color: var(--muted); margin: .5rem 0 0; }

/* dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--line);
         border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tile { background: var(--paper); padding: 1rem 1.2rem; display: grid; gap: .15rem; align-content: start; }
.tile .k { font-size: .8rem; color: var(--muted); }
.tile .v { font: 600 1.7rem/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.tile .n { font-size: .8rem; color: var(--muted); }
.activity { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; }
.card-head { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.rates { display: flex; gap: 1.2rem; margin: .5rem 0 .6rem; color: var(--muted); font-size: .9rem; flex-wrap: wrap; }
.rates b { color: var(--ink); font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 56px; display: block; }
.spark rect { fill: var(--accent); opacity: .85; }
.spark-axis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); }
.pill { font-size: .72rem; font-weight: 600; padding: .2rem .55rem; border-radius: 999px; white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.tablebox { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; color: var(--muted); font-weight: 600; background: var(--soft); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.bad { color: var(--bad); font-weight: 600; }
.progress-cell { min-width: 180px; }
.bar { height: 7px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: .35rem; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.progress-cell small { color: var(--muted); font-size: .75rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1.25rem; }
@media (max-width: 520px) { .two-col { grid-template-columns: 1fr; } }

/* search */
.searchbar { display: flex; gap: .5rem; flex-wrap: wrap; }
.searchbar input { flex: 1 1 320px; font-size: 1.05rem; padding: .7rem .9rem; }
.syntax { margin: .4rem 0 1rem; font-size: .85rem; color: var(--muted); }
.syntax summary { cursor: pointer; width: fit-content; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); border-radius: 999px;
        padding: .25rem .7rem; font: 500 .82rem var(--sans); cursor: pointer; }
.chip.ghost { background: none; border-color: var(--line); color: var(--muted); }
.results-layout { display: grid; grid-template-columns: 250px 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 860px) { .results-layout { grid-template-columns: 1fr; } }
.facets { display: grid; gap: 1.2rem; position: sticky; top: 70px; }
@media (max-width: 860px) { .facets { position: static; } }
.facet ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.facet-item { display: flex; justify-content: space-between; gap: .5rem; width: 100%; border: 0; background: none; color: var(--ink);
              font: .86rem var(--sans); padding: .3rem .45rem; border-radius: 6px; cursor: pointer; text-align: left; }
.facet-item:hover { background: var(--soft); }
.facet-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.facet-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.results { display: grid; gap: .8rem; min-width: 0; }
.results > p { margin: 0; }
.hit { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1.1rem; min-width: 0; }
.hit-title { font: 600 1.02rem/1.35 var(--serif); text-decoration: none; }
.hit-title:hover { text-decoration: underline; }
.hit-meta { display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin-top: .3rem; font-size: .82rem; color: var(--muted); }
.hit-subject { font-size: .88rem; margin-top: .35rem; }
.snippet { margin: .5rem 0 0; font-size: .88rem; color: var(--ink); border-left: 3px solid var(--line); padding-left: .7rem; overflow-wrap: anywhere; }
mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: .5rem; color: var(--muted); }

/* document */
.doc-title { max-width: 60ch; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.doc-layout { display: grid; grid-template-columns: 320px 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .doc-layout { grid-template-columns: 1fr; } }
.meta-card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; font-size: .88rem; }
.meta-card dl { margin: 0; display: grid; gap: .1rem; }
.meta-card dt { color: var(--muted); font-size: .75rem; margin-top: .55rem; }
.meta-card dd { margin: 0; overflow-wrap: anywhere; }
.meta-card details { margin-top: 1rem; }
.meta-card summary { cursor: pointer; color: var(--accent); }
.all-fields dt { font-family: var(--mono); }
.doc-body { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; min-width: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--soft); }
.tabs button { border: 0; background: none; padding: .7rem 1rem; font: 500 .9rem var(--sans); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.pdf-frame { width: 100%; height: 78vh; border: 0; display: block; background: #fff; }
.doc-text { margin: 0; padding: 1.2rem 1.4rem; white-space: pre-wrap; font: .9rem/1.6 var(--serif); max-height: 78vh; overflow: auto; }

/* explore */
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.inline-form input { min-width: 260px; }
.year-chart { display: flex; align-items: flex-end; gap: 4px; height: 190px; background: var(--paper); border: 1px solid var(--line);
              border-radius: 10px; padding: 1rem 1rem 1.8rem; overflow-x: auto; }
.year-bar { position: relative; flex: 1 0 26px; height: 100%; display: flex; align-items: flex-end; text-decoration: none; }
.year-bar .fill { display: block; width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.year-bar:hover .fill { filter: brightness(1.2); }
.year-label { position: absolute; bottom: -1.4rem; left: 50%; transform: translateX(-50%); font-size: .68rem; color: var(--muted); }
.explore-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; margin-top: 1.5rem; }
@media (max-width: 420px) { .explore-grid { grid-template-columns: 1fr; } }
.barlist { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; min-width: 0; }
.barlist ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.barlist a { position: relative; display: flex; justify-content: space-between; gap: .75rem; padding: .3rem .5rem;
             color: var(--ink); text-decoration: none; font-size: .86rem; border-radius: 5px; overflow: hidden; }
.barlist a:hover { background: var(--soft); }
.bl-label { position: relative; z-index: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-count { position: relative; z-index: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
.bl-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); z-index: 0; }

/* Blazor defaults */
#blazor-error-ui { color-scheme: light only; background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
                   display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "A apărut o eroare."; }
h1:focus { outline: none; }
