/* ERS Anuário — plataforma de gestão e consulta.
   Follows the printed anuário's identity: ERS red for the brand and actions, a light grey
   ground, and per-category accent colours that come from the data, not from here. */

:root {
    /* From the official logo artwork (wwwroot/img/logo_ers.svg). */
    --ers-red: #e4002b;
    --ers-red-dark: #b30022;
    --ers-grey: #63666a;

    --ink: #1c1c1e;
    --ink-soft: #55575c;
    --ink-faint: #8b8d93;

    --ground: #f2f2f3;
    --surface: #ffffff;
    --line: #e3e3e5;

    --ok: #4c8c1b;
    --warn: #b26a00;
    --late: #c0271c;

    --radius: 6px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font: 400 15px/1.5 Roboto, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--ers-red-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

/* ── Chrome ─────────────────────────────────────────────────────────────── */

.masthead {
    background: var(--surface);
    border-bottom: 3px solid var(--ers-red);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: .75rem; }
.brand:hover { text-decoration: none; }

.brand-logo { height: 2.8rem; width: auto; display: block; }

.brand-sub {
    color: var(--ink-faint);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .14em;
}

.masthead nav { margin-left: auto; display: flex; gap: 1.25rem; }
.masthead nav a { color: var(--ink-soft); font-weight: 500; }
.masthead nav a:hover { color: var(--ers-red-dark); }

main { padding: 1.75rem 1.5rem 4rem; max-width: 1400px; margin: 0 auto; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: .85rem; }

/* ── Surfaces ───────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ── Numbers row ────────────────────────────────────────────────────────── */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.stat { background: var(--surface); padding: .85rem 1rem; }

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
}

.stat-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--ink-faint);
    margin-top: .15rem;
}

.stat-value.is-late { color: var(--late); }
.stat-value.is-ok { color: var(--ok); }

/* ── Tables ─────────────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; }

th, td {
    text-align: left;
    padding: .55rem .6rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--ink-faint);
    font-weight: 600;
    white-space: nowrap;
}

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.table-scroll { overflow-x: auto; }

/* ── Badges ─────────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .03em;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge-pending { background: #f1f1f2; color: var(--ink-soft); border-color: var(--line); }
.badge-received { background: #fff3dc; color: var(--warn); border-color: #f2dcae; }
.badge-published { background: #eaf5e0; color: var(--ok); border-color: #cfe6bb; }
.badge-withdrawn { background: #f1f1f2; color: var(--ink-faint); border-color: var(--line); text-decoration: line-through; }
.badge-late { background: #fdeceb; color: var(--late); border-color: #f5cdca; }

/* ── Forms and buttons ──────────────────────────────────────────────────── */

label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-soft); margin-bottom: .2rem; }

input[type=text], input[type=number], input[type=date], input[type=file], select, textarea {
    width: 100%;
    padding: .42rem .55rem;
    border: 1px solid #c9c9cc;
    border-radius: 4px;
    font: inherit;
    background: var(--surface);
    color: var(--ink);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--ers-red);
    outline-offset: -1px;
    border-color: var(--ers-red);
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .75rem;
    align-items: end;
    margin-bottom: .75rem;
}

.btn {
    display: inline-block;
    padding: .45rem .9rem;
    border: 1px solid var(--ers-red);
    border-radius: 4px;
    background: var(--ers-red);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover { background: var(--ers-red-dark); border-color: var(--ers-red-dark); text-decoration: none; }

.btn-quiet { background: var(--surface); color: var(--ink-soft); border-color: #c9c9cc; }
.btn-quiet:hover { background: #f6f6f7; color: var(--ink); border-color: var(--ink-faint); }

.btn-small { padding: .22rem .55rem; font-size: .78rem; font-weight: 500; }

.inline-form { display: inline; }

.notice {
    padding: .7rem 1rem;
    border-left: 3px solid var(--ok);
    background: #eaf5e0;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 1.25rem;
}

.notice-warn { border-left-color: var(--warn); background: #fff3dc; }

/* ── Category groups (admin) ────────────────────────────────────────────── */

.category { margin-bottom: 1.5rem; }

.category-head {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem .8rem;
    border-radius: var(--radius) var(--radius) 0 0;
    color: #fff;
    font-weight: 600;
}

.category-body {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: .5rem .8rem .8rem;
}

.category-count { margin-left: auto; font-size: .8rem; font-weight: 500; opacity: .9; }

/* ── Shared ─────────────────────────────────────────────────────────────── */

.empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--ink-faint);
}
