:root {
    --ink: #233A34;
    --muted: #5c736b;
    --paper: #F4F3EC;
    --card: #FBFBF6;
    --line: #d5d8c8;
    --accent: #A5B992;
    --navy: #14221F;
    --warm: #F1F0E9;
    --sage-pale: #C5D1AD;
    --clay: #D6AD8D;
    --font-ui: "Source Sans 3", Arial, Helvetica, "Segoe UI", sans-serif;
    --state-ok: #2c4a62;
    --state-ok-bg: #e7eef3;
    --state-wait: #5c5a52;
    --state-wait-bg: #eeebe3;
    --state-warn: #8a5a32;
    --state-warn-bg: #f3eadc;
    --state-bad: #8f3d38;
    --state-bad-bg: #f6e4e0;
}

html, body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.55;
    letter-spacing: 0.005em;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2 {
    font-weight: 600;
    letter-spacing: -0.015em;
    margin: 0 0 0.55rem;
}

h1 {
    font-size: 1.7rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

a { color: var(--navy); }

code {
    font-size: 0.88em;
    background: #e4e8dc;
    padding: 0.12rem 0.32rem;
    border-radius: 3px;
}

.app-shell { min-height: 100vh; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    padding: 0.85rem 2.25rem;
    background: var(--navy);
    color: var(--warm);
    position: relative;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
    padding: 0.15rem 0.2rem 0.15rem 0;
}

.brand-symbol {
    display: block;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.brand-logo {
    display: block;
    width: 150px;
    height: auto;
}

.brand-sub {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--warm);
    opacity: 0.72;
}

.topbar-nav {
    display: flex;
    gap: 1.35rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

.nav-links,
.nav-session {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem 0.15rem;
}

.nav-session {
    gap: 0.85rem;
    padding-left: 1rem;
    border-left: 1px solid rgba(241, 240, 233, 0.18);
}

.nav-links a {
    color: rgba(241, 240, 233, 0.78);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 0.38rem 0.62rem;
    border-radius: 4px;
    line-height: 1.2;
}

.nav-links a:hover {
    color: var(--warm);
    background: rgba(241, 240, 233, 0.08);
}

.nav-links a.active {
    color: var(--warm);
    background: rgba(241, 240, 233, 0.12);
}

.who {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.72;
    letter-spacing: 0.01em;
}

.topbar form { margin: 0; }

.linkish {
    background: transparent;
    border: 0;
    color: rgba(241, 240, 233, 0.78);
    cursor: pointer;
    text-decoration: none;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    padding: 0.35rem 0.15rem;
}

.linkish:hover { color: var(--warm); }

a.linkish { color: rgba(241, 240, 233, 0.78); }

.topbar .notes {
    font-size: 0.82rem;
    color: rgba(241, 240, 233, 0.86);
    position: relative;
}

.topbar .notes summary {
    cursor: pointer;
    list-style: none;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.topbar .notes summary::-webkit-details-marker { display: none; }

.topbar .notes ul {
    position: absolute;
    margin: 0.4rem 0 0;
    right: 0;
    min-width: 16rem;
    max-width: 22rem;
    background: var(--navy);
    border: 1px solid rgba(241, 240, 233, 0.16);
    padding: 0.65rem 0.9rem;
    box-shadow: 0 8px 24px rgba(20, 34, 31, 0.28);
    z-index: 20;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.4rem 1.5rem 4rem;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.lede, .meta, .hint {
    color: var(--muted);
    max-width: 40rem;
}

.lede { line-height: 1.6; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 1.35rem 1.5rem 1.55rem;
    margin: 1.35rem 0;
}

.panel p { margin-top: 0; }

label {
    display: block;
    margin: 0.85rem 0;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink);
}

input, select, button, .panel input, .panel select {
    font: inherit;
}

input, select {
    display: block;
    width: 100%;
    max-width: 28rem;
    margin-top: 0.32rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
    box-sizing: border-box;
}

input:focus, select:focus {
    outline: 2px solid rgba(35, 58, 52, 0.22);
    outline-offset: 1px;
    border-color: #8aa090;
}

button {
    margin-top: 0.75rem;
    background: var(--navy);
    color: var(--warm);
    border: 0;
    border-radius: 4px;
    padding: 0.52rem 1.15rem;
    cursor: pointer;
    font-weight: 500;
    letter-spacing: 0.02em;
}

button:hover:not(:disabled) {
    filter: brightness(1.08);
}

button:disabled { opacity: 0.55; cursor: not-allowed; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

th, td {
    text-align: left;
    padding: 0.6rem 0.45rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.hit-definitivo td {
    background: var(--state-bad-bg);
}

.state {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.2;
    padding: 0.16rem 0.42rem;
    border-radius: 3px;
    text-transform: none;
}

.state-ok {
    color: var(--state-ok);
    background: var(--state-ok-bg);
}

.state-wait {
    color: var(--state-wait);
    background: var(--state-wait-bg);
}

.state-warn {
    color: var(--state-warn);
    background: var(--state-warn-bg);
}

.state-bad {
    color: var(--state-bad);
    background: var(--state-bad-bg);
}

label.check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.4rem 0;
    font-weight: 500;
}

.panel h3 {
    font-size: 1.02rem;
    margin: 1.2rem 0 0.6rem;
}

.alert {
    background: var(--state-warn-bg);
    color: var(--ink);
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--state-warn);
    border-radius: 0 4px 4px 0;
}

.alert-bad {
    background: var(--state-bad-bg);
    border-left-color: var(--state-bad);
}

.plain { padding-left: 1.1rem; }

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
    margin-bottom: 1.15rem;
}

.auth-product {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--muted);
}

.auth-card {
    width: min(28rem, 100%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 2.1rem 2rem 1.7rem;
    box-shadow: 0 10px 30px rgba(20, 34, 31, 0.06);
}

.auth-card h1 { margin-bottom: 0.4rem; }

.auth-alt {
    margin-top: 1.15rem;
}

.auth-card a {
    color: var(--ink);
}

button.quiet {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.row-actions select,
.row-actions button {
    margin-top: 0;
}

.row-actions select {
    max-width: 12rem;
}

.entity-picks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
    margin: 0.25rem 0 0.6rem;
}

.entity-picks .check {
    margin: 0.15rem 0;
}

#blazor-error-ui {
    background: #efe8dc;
    bottom: 0;
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

h1:focus { outline: none; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 1rem;
}

.dashboard-grid th.num,
.dashboard-grid td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 0 1rem;
}

.table-wrap {
    overflow-x: auto;
}

.ws-stage {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.stat-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 500;
}

.stat-value {
    margin: 0.2rem 0 0;
    font-size: 1.55rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

pre.xml {
    overflow: auto;
    background: #e4e8dc;
    padding: 0.9rem;
    font-size: 0.82rem;
    border-radius: 4px;
}

a.buttonish {
    display: inline-block;
    margin: 0.75rem 0.5rem 0 0;
    background: var(--navy);
    color: var(--warm);
    text-decoration: none;
    padding: 0.52rem 1.15rem;
    border-radius: 4px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.notes {
    color: var(--warm);
    font-size: 0.9rem;
}

.notes a { color: var(--warm); }

@media (max-width: 820px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.9rem 1.1rem 1rem;
    }

    .topbar-nav,
    .nav-links,
    .nav-session {
        justify-content: flex-start;
    }

    .nav-session {
        padding-left: 0;
        border-left: 0;
        padding-top: 0.35rem;
        border-top: 1px solid rgba(241, 240, 233, 0.18);
        width: 100%;
    }

    .page {
        padding: 1.6rem 1.1rem 3rem;
    }
}
