:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1a2332;
    --muted: #5c6b7a;
    --border: #d8dee6;
    --accent: #1d5f8a;
    --accent-hover: #164a6d;
    --accent-soft: #e8f2f8;
    --shadow: 0 2px 12px rgba(26, 35, 50, 0.08);
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1419;
        --surface: #1a2332;
        --text: #e8edf2;
        --muted: #9aa8b5;
        --border: #2d3a4a;
        --accent: #5ba3d0;
        --accent-hover: #7ab8de;
        --accent-soft: #1e3347;
        --shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    z-index: 100;
}

.skip-link:focus {
    left: 0;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.site-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
    justify-content: space-between;
}

.site-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.subtitle {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
}

.stat {
    font-size: 0.9rem;
    color: var(--muted);
}

.stat strong {
    color: var(--text);
    font-size: 1.1rem;
}

.stat--muted {
    font-size: 0.85rem;
}

.stat--link {
    font: inherit;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    text-align: left;
}

.stat--link:hover strong {
    text-decoration: underline;
}

.field--check {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    min-width: auto;
    padding-bottom: 0.35rem;
}

.field--check input {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
}

.field--check span {
    font-size: 0.9rem;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
}

.layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.toolbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.toolbar__row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    align-items: flex-end;
    margin-bottom: 0.75rem;
}

.toolbar__row:last-child {
    margin-bottom: 0;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 140px;
}

.field--grow {
    flex: 1 1 220px;
}

.field__label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

input,
select {
    font: inherit;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
}

input:focus,
select:focus,
button:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn {
    font: inherit;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn--ghost {
    background: transparent;
    color: var(--accent);
}

.btn--ghost:hover {
    background: var(--accent-soft);
}

.btn--sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.875rem;
}

.btn--icon {
    padding: 0.25rem 0.55rem;
    font-size: 1.5rem;
    line-height: 1;
    border: none;
    background: transparent;
    color: var(--muted);
}

.btn--icon:hover {
    color: var(--text);
    background: var(--accent-soft);
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    align-items: start;
}

@media (min-width: 900px) {
    .content-grid.has-detail {
        grid-template-columns: 1fr 380px;
    }
}

.list-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.list-panel__head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.list-panel__head h2 {
    margin: 0;
    font-size: 1.1rem;
}

.list-meta {
    margin: 0;
    font-size: 0.875rem;
    color: var(--muted);
}

.pub-list {
    min-height: 120px;
}

.pub-card {
    display: block;
    width: 100%;
    text-align: left;
    padding: 1rem 1.25rem;
    border: none;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: inherit;
    cursor: pointer;
    font: inherit;
}

.pub-card:hover,
.pub-card.is-active {
    background: var(--accent-soft);
}

.pub-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}

.pub-card__label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.pub-card__title {
    font-weight: 600;
    margin: 0 0 0.35rem;
}

.pub-card__meta {
    font-size: 0.875rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent);
}

.badge--ai {
    background: #e8f5e9;
    color: #2e7d32;
}

@media (prefers-color-scheme: dark) {
    .badge--ai {
        background: #1b3d22;
        color: #81c784;
    }
}

.empty-state {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--muted);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.detail-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.detail-panel[aria-hidden="true"] {
    display: none;
}

@media (max-width: 899px) {
    .detail-panel.is-open {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 50;
        max-height: none;
        border-radius: 0;
    }
}

.detail-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.detail-panel__header h2 {
    margin: 0;
    font-size: 1rem;
}

.detail-panel__body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.detail-section {
    margin-bottom: 1.25rem;
}

.detail-section h3 {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.detail-dl {
    margin: 0;
    display: grid;
    gap: 0.35rem 0.75rem;
    grid-template-columns: auto 1fr;
    font-size: 0.9rem;
}

.detail-dl dt {
    color: var(--muted);
    font-weight: 500;
}

.detail-dl dd {
    margin: 0;
}

.doc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.doc-item {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}

.doc-item:last-child {
    border-bottom: none;
}

.doc-item__top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.doc-item__name {
    font-size: 0.875rem;
    word-break: break-word;
    flex: 1 1 180px;
}

.doc-item__actions {
    display: flex;
    gap: 0.35rem;
}

.doc-commento {
    margin-top: 0.65rem;
    padding: 0.75rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 0.875rem;
}

.doc-commento__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.5rem;
}

.doc-commento__label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #2e7d32;
}

@media (prefers-color-scheme: dark) {
    .doc-commento__label {
        color: #81c784;
    }
}

.doc-commento__meta {
    font-size: 0.75rem;
    color: var(--muted);
}

.doc-commento__body {
    color: var(--text);
    line-height: 1.55;
}

.doc-commento__body p {
    margin: 0 0 0.5rem;
}

.doc-commento__body p:last-child {
    margin-bottom: 0;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 40;
}

.overlay[hidden] {
    display: none;
}

.pdf-modal {
    width: min(96vw, 960px);
    height: min(90vh, 800px);
    max-width: none;
    max-height: none;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--surface);
}

.pdf-modal::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.pdf-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.pdf-modal__header h2 {
    margin: 0;
    font-size: 1rem;
}

.pdf-modal__frame {
    width: 100%;
    height: calc(100% - 48px);
    border: none;
    display: block;
}

.loading {
    padding: 2rem;
    text-align: center;
    color: var(--muted);
}
