/*
 * Cine PE: app shell and components, on top of Bootstrap 5.3.
 * Design context: .impeccable.md (calm, dense, light workbench; one ink-blue accent; color only for meaning).
 */

/* ---------- Fonts (vendored, latin subset covers pt-BR) ---------- */
@font-face {
    font-family: "Public Sans";
    src: url("../lib/fonts/public-sans-latin-400-normal.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Public Sans";
    src: url("../lib/fonts/public-sans-latin-500-normal.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: "Public Sans";
    src: url("../lib/fonts/public-sans-latin-600-normal.woff2") format("woff2");
    font-weight: 600;
    font-display: swap;
}
@font-face {
    font-family: "Public Sans";
    src: url("../lib/fonts/public-sans-latin-700-normal.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: "Bricolage Grotesque";
    src: url("../lib/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
    font-weight: 200 800;
    font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
    /* Neutrals, tinted toward the accent hue (255) */
    --ink: oklch(0.24 0.02 255);
    --ink-2: oklch(0.40 0.02 255);
    --ink-3: oklch(0.52 0.018 255);
    --line: oklch(0.91 0.007 255);
    --line-strong: oklch(0.84 0.01 255);
    --line-input: oklch(0.6 0.02 255);
    --surface: oklch(0.995 0.002 255);
    --surface-sunken: oklch(0.973 0.004 255);
    --surface-hover: oklch(0.96 0.008 255);
    --surface-row-hover: oklch(0.985 0.004 255);
    --line-faint: oklch(0.95 0.005 255);

    /* Accent: the only decorative color */
    --accent: oklch(0.48 0.12 255);
    --accent-hover: oklch(0.42 0.12 255);
    --accent-soft: oklch(0.95 0.025 255);
    --accent-ink: oklch(0.38 0.11 255);

    /* Status: tinted backgrounds with dark text, all AA */
    --ok-bg: oklch(0.95 0.04 150);
    --ok-ink: oklch(0.37 0.09 150);
    --bad-bg: oklch(0.95 0.03 25);
    --bad-ink: oklch(0.44 0.15 25);
    --warn-bg: oklch(0.96 0.05 85);
    --warn-ink: oklch(0.41 0.09 70);
    --ok-line: oklch(0.86 0.065 150);
    --ok-bg-hover: var(--ok-bg-hover);
    --bad-line: oklch(0.87 0.05 25);
    --bad-bg-hover: var(--bad-bg-hover);
    --bad-ink-hover: var(--bad-ink-hover);
    --accent-line: oklch(0.88 0.04 255);

    /* Spacing (4pt) */
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Type scale (1.25) */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.25rem;
    --text-xl: 1.5625rem;
    --font-ui: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Bricolage Grotesque", var(--font-ui);
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --radius: 6px;
    --radius-sm: 4px;
    --sidebar-width: 232px;
    --tap: 2.75rem; /* minimum touch target (44px) */
    --shadow-dock: 0 -4px 12px oklch(0.24 0.02 255 / 0.06);
    --shadow-pop: 0 4px 16px oklch(0.24 0.02 255 / 0.12), 0 1px 3px oklch(0.24 0.02 255 / 0.08);

    /* Bootstrap mapping */
    --bs-body-font-family: var(--font-ui);
    --bs-body-font-size: var(--text-sm);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--surface-sunken);
    --bs-secondary-color: var(--ink-3);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--radius);
    --bs-border-radius-sm: var(--radius-sm);
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: 47, 87, 160;
    --bs-link-hover-color: var(--accent-hover);
    --bs-link-hover-color-rgb: 36, 72, 140;
    --bs-focus-ring-color: oklch(0.48 0.12 255 / 0.35);
    --bs-emphasis-color: var(--ink);
}

/* ---------- Base ---------- */
body {
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

a {
    text-underline-offset: 0.15em;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: var(--space-md);
    top: -3rem;
    z-index: 1100;
    padding: var(--space-xs) var(--space-md);
    background: var(--ink);
    color: var(--surface);
    border-radius: var(--radius);
}
.skip-link:focus {
    top: var(--space-md);
}

kbd {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    padding: 0.05rem 0.35rem;
    color: var(--ink-3);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: none;
}

/* ---------- Buttons & form controls ---------- */
.btn {
    --bs-btn-font-size: var(--text-sm);
    --bs-btn-font-weight: 500;
    --bs-btn-padding-y: 0.4375rem;
    --bs-btn-padding-x: 0.875rem;
    --bs-btn-border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}
.btn-sm {
    --bs-btn-font-size: var(--text-sm);
    --bs-btn-padding-y: 0.25rem;
    --bs-btn-padding-x: 0.5rem;
    gap: 0.375rem;
}
.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-hover);
    --bs-btn-hover-border-color: var(--accent-hover);
    --bs-btn-active-bg: var(--accent-hover);
    --bs-btn-active-border-color: var(--accent-hover);
    --bs-btn-color: var(--surface);
    --bs-btn-hover-color: var(--surface);
}
.btn-outline-secondary {
    --bs-btn-color: var(--ink);
    --bs-btn-border-color: var(--line-strong);
    --bs-btn-bg: var(--surface);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-bg: var(--surface-hover);
    --bs-btn-hover-border-color: var(--line-strong);
    --bs-btn-active-color: var(--ink);
    --bs-btn-active-bg: var(--surface-hover);
    --bs-btn-active-border-color: var(--line-strong);
}
.btn-quiet {
    --bs-btn-color: var(--ink-2);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-bg: var(--surface-hover);
    --bs-btn-active-bg: var(--surface-hover);
    --bs-btn-active-border-color: transparent;
    --bs-btn-border-color: transparent;
}
.btn-danger {
    --bs-btn-bg: var(--bad-ink);
    --bs-btn-border-color: var(--bad-ink);
    --bs-btn-hover-bg: var(--bad-ink-hover);
    --bs-btn-hover-border-color: var(--bad-ink-hover);
}

.form-control,
.form-select {
    font-size: var(--text-md);
    color: var(--ink);
    background-color: var(--surface);
    border-color: var(--line-input);
}
.form-control::placeholder {
    color: var(--ink-3);
}
.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--bs-focus-ring-color);
}
@media (min-width: 768px) {
    .form-control,
    .form-select {
        font-size: var(--text-sm);
    }
}

/* Tags (type, category) and status labels */
.tag {
    display: inline-block;
    padding: 0.0625rem 0.4375rem;
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.5;
    color: var(--ink-2);
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.status {
    display: inline-block;
    padding: 0.0625rem 0.5rem;
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.5;
    border-radius: var(--radius-sm);
}
.status-ok { color: var(--ok-ink); background: var(--ok-bg); }
.status-bad { color: var(--bad-ink); background: var(--bad-bg); }
.status-warn { color: var(--warn-ink); background: var(--warn-bg); }

/* Flash messages */
.flash {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    border-radius: var(--radius);
    border: 1px solid transparent;
}
.flash .bi { font-size: var(--text-md); line-height: 1.3; }
.flash .btn-close { margin-left: auto; font-size: var(--text-xs); }
.flash-ok { color: var(--ok-ink); background: var(--ok-bg); border-color: var(--ok-line); }
.flash-bad { color: var(--bad-ink); background: var(--bad-bg); border-color: var(--bad-line); }
.flash-info { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent-line); }

/* Dropdowns and modals: quiet surfaces */
.dropdown-menu {
    --bs-dropdown-font-size: var(--text-sm);
    --bs-dropdown-border-color: var(--line);
    --bs-dropdown-link-hover-bg: var(--surface-hover);
    --bs-dropdown-link-active-bg: var(--accent-soft);
    --bs-dropdown-link-active-color: var(--accent-ink);
    box-shadow: var(--shadow-pop);
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}
.dropdown-item.text-danger { color: var(--bad-ink) !important; }
.modal-content {
    border: 0;
    box-shadow: var(--shadow-pop);
}
.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
}

/* ---------- Shell ---------- */
.app-shell {
    min-height: 100vh;
}
@media (min-width: 992px) {
    .app-shell {
        display: grid;
        grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    }
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    height: 3.25rem;
    padding: 0 var(--space-xs);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.app-topbar .btn {
    min-width: var(--tap);
    min-height: var(--tap);
    justify-content: center;
    font-size: var(--text-lg);
}

.wordmark {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    text-decoration: none;
}
.wordmark:hover { color: var(--ink); }
.wordmark small {
    display: block;
    font-family: var(--font-ui);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0;
    color: var(--ink-3);
}

.app-sidebar {
    --bs-offcanvas-width: 280px;
    --bs-offcanvas-bg: var(--surface);
    background: var(--surface);
}
@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        border-right: 1px solid var(--line);
    }
}
.app-sidebar .offcanvas-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding: var(--space-lg) var(--space-sm);
}
.app-sidebar .wordmark {
    padding: 0 var(--space-sm);
}

.nav-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.nav-main a,
.nav-main button {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    min-height: 2.5rem;
    padding: 0 var(--space-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--ink-2);
    text-decoration: none;
    background: none;
    border: 0;
    border-radius: var(--radius);
}
.nav-main .bi {
    font-size: 1.0625rem;
    color: var(--ink-3);
}
.nav-main a:hover,
.nav-main button:hover {
    color: var(--ink);
    background: var(--surface-hover);
}
.nav-main a[aria-current="page"] {
    color: var(--accent-ink);
    background: var(--accent-soft);
}
.nav-main a[aria-current="page"] .bi {
    color: var(--accent);
}
.nav-main .nav-tag {
    margin-left: auto;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--ink-3);
}
.nav-main a[aria-current="page"] .nav-tag {
    color: var(--accent-ink);
}

.nav-user {
    margin-top: auto;
    padding-top: var(--space-md);
    border-top: 1px solid var(--line);
}
.nav-user-name {
    padding: 0 var(--space-sm) var(--space-xs);
    font-size: var(--text-xs);
    color: var(--ink-3);
}
.nav-user-name strong {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink);
}
.nav-user form {
    margin: 0;
}

.app-main {
    min-width: 0;
    padding: var(--space-lg) var(--space-md) var(--space-2xl);
}
@media (min-width: 768px) {
    .app-main {
        padding: var(--space-xl) var(--space-lg) var(--space-2xl);
    }
}

/* ---------- Page header ---------- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}
.page-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 650;
    letter-spacing: -0.015em;
    line-height: 1.2;
}
.page-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
}
.page-meta {
    margin: var(--space-2xs) 0 0;
    font-size: var(--text-sm);
    color: var(--ink-3);
}
.page-meta strong {
    font-weight: 600;
    color: var(--ink);
}
.page-actions {
    display: flex;
    gap: var(--space-xs);
}
.edition-select {
    width: auto;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    font-weight: 600;
    color: var(--ink-2);
}

/* ---------- Filter toolbar ---------- */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}
.filters-search {
    position: relative;
    flex: 1 1 18rem;
    max-width: 32rem;
}
.filters-search .bi-search {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-3);
    pointer-events: none;
}
.filters-search .form-control {
    padding-left: 2.25rem;
    padding-right: 2.25rem;
}
.filters-search kbd {
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}
.filters-more {
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    width: 100%;
}
.filters-more .form-select {
    width: 100%;
}
.filters-clear {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    min-height: var(--tap);
    padding: 0 var(--space-xs);
    font-size: var(--text-sm);
}
@media (min-width: 768px) {
    .filters-more {
        width: auto;
    }
    .filters-more .form-select {
        width: auto;
        max-width: 13rem;
    }
    .filters-clear {
        min-height: 0;
    }
}

/* ---------- Data table ---------- */
.data-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.data-panel-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-sm);
    color: var(--ink-3);
    border-bottom: 1px solid var(--line);
}
.data-panel-bar .pager-step {
    display: flex;
    gap: var(--space-2xs);
}

.data-table {
    width: 100%;
    margin: 0;
    font-size: var(--text-sm);
    border-collapse: separate;
    border-spacing: 0;
}
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--ink-3);
    text-align: left;
    white-space: nowrap;
    background: var(--surface);
    border-bottom: 1px solid var(--line-strong);
}
.data-table thead th a {
    color: inherit;
    text-decoration: none;
}
.data-table thead th a:hover {
    color: var(--ink);
}
.data-table thead th a.asc::after,
.data-table thead th a.desc::after {
    font-family: "bootstrap-icons";
    margin-left: 0.25rem;
    color: var(--accent);
}
.data-table thead th a.asc::after { content: "\f145"; }
.data-table thead th a.desc::after { content: "\f124"; }
.data-table tbody td {
    padding: var(--space-sm) var(--space-md);
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
}
.data-table tbody tr:last-child td {
    border-bottom: 0;
}
.data-table tbody tr:hover td {
    background: var(--surface-row-hover);
}
.data-table .col-num {
    width: 4.5rem;
    text-align: right;
    color: var(--ink-3);
    font-weight: 500;
}
.data-table .col-film {
    min-width: 14rem;
}
.data-table .col-uf,
.data-table .col-date {
    white-space: nowrap;
    color: var(--ink-2);
}
.data-table .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.film-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
}
a.film-name:hover {
    color: var(--accent);
    text-decoration: underline;
}
.film-producer {
    display: block;
    margin-top: 0.125rem;
    font-size: var(--text-xs);
    color: var(--ink-3);
}
.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs);
}

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
}
.row-actions .muted {
    padding: 0 var(--space-xs);
    font-size: var(--text-xs);
    color: var(--ink-3);
}
.password-pop {
    min-width: 15rem;
    padding: var(--space-sm);
}
.password-pop code {
    display: block;
    margin-bottom: var(--space-xs);
    padding: var(--space-xs);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--ink);
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
    word-break: break-all;
    user-select: all;
}

/* Action labels: icon-only between md and xl to keep the column compact */
@media (min-width: 768px) and (max-width: 1199.98px), (max-width: 359.98px) {
    .row-actions .action-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

/* Mobile: rows become stacked items */
@media (max-width: 767.98px) {
    .data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }
    .data-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "film uf"
            "tags tags"
            "actions actions";
        gap: var(--space-xs) var(--space-sm);
        padding: var(--space-md);
        border-bottom: 1px solid var(--line);
    }
    .data-table tbody tr:last-child {
        border-bottom: 0;
    }
    .data-table tbody td {
        display: block;
        padding: 0;
        border: 0;
    }
    .data-table tbody tr:hover td {
        background: none;
    }
    .data-table .col-num { display: none; }
    .data-table .col-film { grid-area: film; min-width: 0; }
    .data-table .col-uf { grid-area: uf; }
    .data-table .col-tags { grid-area: tags; }
    .data-table .col-actions {
        grid-area: actions;
        width: auto;
        text-align: left;
    }
    .film-number {
        margin-right: var(--space-2xs);
        font-weight: 500;
        color: var(--ink-3);
    }
    /* Watch / Ficha / Senha share the row equally; "⋯" stays square at the end */
    .row-actions {
        display: flex;
        gap: var(--space-xs);
    }
    .row-actions > .btn,
    .row-actions > .dropdown {
        flex: 1 1 0;
        min-width: 0;
    }
    .row-actions > .dropdown:last-child {
        flex: none;
    }
    .row-actions > .btn,
    .row-actions > .dropdown > .btn {
        justify-content: center;
        width: 100%;
        min-height: var(--tap);
        padding-left: var(--space-xs);
        padding-right: var(--space-xs);
        border: 1px solid var(--line-strong);
    }
    .row-actions > .dropdown:last-child > .btn {
        width: var(--tap);
    }
    .row-actions .muted {
        flex: 1 1 0;
        align-self: center;
        text-align: center;
    }
}
@media (min-width: 768px) {
    .film-number { display: none; }
}

/* ---------- Dashboard ---------- */
.stat-strip {
    display: flex;
    flex-wrap: wrap;
    margin: 0 0 var(--space-xl);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.stat-group {
    display: flex;
}
.stat-strip > .stat,
.stat-group {
    flex: 1 1 auto;
    padding: var(--space-md) var(--space-lg);
    border-right: 1px solid var(--line);
}
.stat-strip > :last-child {
    border-right: 0;
}
.stat-group {
    gap: var(--space-lg);
}
.stat dt {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--ink-3);
    white-space: nowrap;
}
.stat dd {
    margin: var(--space-2xs) 0 0;
    font-size: var(--text-lg);
    font-weight: 650;
    line-height: 1.2;
}
.stat dd a {
    color: var(--ink);
    text-decoration: none;
}
.stat dd a:hover {
    color: var(--accent);
    text-decoration: underline;
}
.stat-lead dd {
    font-family: var(--font-display);
    font-size: var(--text-xl);
}
.stat-of {
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--ink-3);
}
@media (max-width: 767.98px) {
    .stat-strip {
        flex-direction: column;
    }
    .stat-strip > .stat,
    .stat-group {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: var(--space-sm) var(--space-md);
    }
    .stat-strip > :last-child {
        border-bottom: 0;
    }
}

.dash-grid {
    display: grid;
    gap: var(--space-lg);
    align-items: start;
}
@media (min-width: 1200px) {
    .dash-grid {
        grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr);
    }
}
.data-panel-head {
    padding: var(--space-md) var(--space-md) var(--space-sm);
}
.data-panel-head h2 {
    margin: 0;
    font-size: var(--text-md);
    font-weight: 600;
}
.data-panel-head p {
    margin: var(--space-2xs) 0 0;
    font-size: var(--text-xs);
    color: var(--ink-3);
}
.data-panel-foot {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
    border-top: 1px solid var(--line);
}
.panel-empty {
    margin: 0;
    padding: var(--space-md);
    color: var(--ink-3);
}

.region-table {
    width: 100%;
    font-size: var(--text-sm);
    border-collapse: collapse;
}
.region-table th,
.region-table td {
    padding: var(--space-xs) var(--space-sm);
    border-top: 1px solid var(--line);
}
.region-table th:first-child,
.region-table td:first-child {
    padding-left: var(--space-md);
}
.region-table th:last-child,
.region-table td:last-child {
    padding-right: var(--space-md);
}
.region-table thead th {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--ink-3);
    white-space: nowrap;
    border-top: 0;
}
.region-table thead .group {
    text-align: center;
    border-bottom: 1px solid var(--line);
}
.region-table abbr {
    text-decoration: none;
    cursor: help;
}
.region-table .num {
    width: 3.5rem;
    text-align: right;
}
.region-table .total {
    font-weight: 600;
}
.region-table .zero {
    color: var(--ink-3);
}
.region-table tbody th {
    font-weight: 400;
}
.region-row th,
.region-row td {
    font-weight: 600;
}
.region-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    min-height: 2rem;
    margin: -0.25rem 0;
    padding: 0;
    font: inherit;
    color: var(--ink);
    background: none;
    border: 0;
}
.region-toggle .bi {
    font-size: var(--text-xs);
    color: var(--ink-3);
    transition: transform 0.15s ease-out;
}
.region-toggle[aria-expanded="false"] .bi {
    transform: rotate(-90deg);
}
.region-toggle:hover {
    color: var(--accent);
}
.state-row th {
    padding-left: calc(var(--space-md) + 1.25rem) !important;
    color: var(--ink-2);
}
.state-row td,
.state-row th {
    border-top-color: var(--line-faint);
}
.state-row.is-empty th {
    color: var(--ink-3);
}
.region-table tfoot .other-row th {
    color: var(--ink-2);
    font-weight: 400;
}
.region-table tfoot .total-row th,
.region-table tfoot .total-row td {
    font-weight: 700;
    border-top: 1px solid var(--line-strong);
}
@media (prefers-reduced-motion: reduce) {
    .region-toggle .bi { transition: none; }
}

.vote-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.vote-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--line);
}
.vote-film {
    display: block;
    font-weight: 600;
}
.vote-meta {
    display: block;
    font-size: var(--text-xs);
    color: var(--ink-3);
}

/* ---------- Curadoria (jury, phone-first) ---------- */
.progress-line {
    height: 4px;
    margin: calc(var(--space-sm) * -1) 0 var(--space-lg);
    overflow: hidden;
    background: var(--line);
    border-radius: 2px;
}
.progress-line span {
    display: block;
    height: 100%;
    background: var(--accent);
}
.data-panel-head .count {
    margin-left: var(--space-2xs);
    font-weight: 500;
    color: var(--ink-3);
}
.film-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.film-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    min-height: 3.5rem;
    padding: var(--space-sm) var(--space-md);
    color: var(--ink);
    text-decoration: none;
    border-top: 1px solid var(--line);
}
.film-card:hover {
    background: var(--surface-hover);
}
.film-card .bi {
    color: var(--ink-3);
}
.film-card-title {
    display: block;
    font-size: var(--text-md);
    font-weight: 600;
}
.film-card-meta {
    display: block;
    margin-top: 0.125rem;
    font-size: var(--text-sm);
    color: var(--ink-3);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    min-height: var(--tap);
    margin: calc(var(--space-sm) * -1) 0 var(--space-xs);
    font-size: var(--text-sm);
    color: var(--ink-2);
    text-decoration: none;
}
.back-link:hover {
    color: var(--accent);
}
.film-head {
    margin-bottom: var(--space-lg);
}
.watch-block {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm) var(--space-lg);
    margin-bottom: var(--space-xl);
}
.watch-block .btn-lg {
    --bs-btn-font-size: var(--text-md);
    min-height: 3rem;
    padding-left: var(--space-lg);
    padding-right: var(--space-lg);
}
.watch-password {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}
.watch-password > span {
    font-size: var(--text-sm);
    color: var(--ink-3);
}
.watch-password code {
    padding: var(--space-xs) var(--space-sm);
    font-family: var(--font-mono);
    font-size: var(--text-md);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    user-select: all;
}
.watch-password .btn {
    min-height: var(--tap);
}
.watch-note {
    margin: 0;
    color: var(--ink-3);
}
.film-body {
    max-width: 48rem;
}
.film-body p {
    max-width: 70ch;
}

.vote-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    max-width: 48rem;
    margin-top: var(--space-lg);
}
.btn-vote {
    --bs-btn-font-size: var(--text-md);
    --bs-btn-font-weight: 600;
    justify-content: center;
    min-height: 3.25rem;
    border-width: 1px;
}
.btn-vote-yes {
    --bs-btn-color: var(--ok-ink);
    --bs-btn-bg: var(--ok-bg);
    --bs-btn-border-color: var(--ok-line);
    --bs-btn-hover-color: var(--ok-ink);
    --bs-btn-hover-bg: var(--ok-bg-hover);
    --bs-btn-hover-border-color: var(--ok-ink);
    --bs-btn-active-bg: var(--ok-bg-hover);
}
.btn-vote-no {
    --bs-btn-color: var(--bad-ink);
    --bs-btn-bg: var(--bad-bg);
    --bs-btn-border-color: var(--bad-line);
    --bs-btn-hover-color: var(--bad-ink);
    --bs-btn-hover-bg: var(--bad-bg-hover);
    --bs-btn-hover-border-color: var(--bad-ink);
    --bs-btn-active-bg: var(--bad-bg-hover);
}
.vote-done {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    max-width: 48rem;
    margin-top: var(--space-lg);
    padding: var(--space-md);
    font-size: var(--text-sm);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.vote-done-date {
    color: var(--ink-3);
}
@media (max-width: 767.98px) {
    .watch-block .btn-lg {
        width: 100%;
        justify-content: center;
    }
    /* Vote stays within thumb reach while reading */
    .vote-bar {
        position: sticky;
        bottom: 0;
        z-index: 1010;
        margin: var(--space-lg) calc(var(--space-md) * -1) calc(var(--space-2xl) * -1);
        padding: var(--space-sm) var(--space-md) calc(var(--space-sm) + env(safe-area-inset-bottom));
        background: var(--surface);
        border-top: 1px solid var(--line);
        box-shadow: var(--shadow-dock);
    }
}

/* Label/value lists on record pages */
.facts {
    display: grid;
    gap: var(--space-2xs) var(--space-md);
    margin: 0 0 var(--space-md);
}
.facts dt {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--ink-3);
}
.facts dd {
    margin: 0 0 var(--space-xs);
    overflow-wrap: anywhere;
}
.facts code {
    padding: 0.0625rem 0.375rem;
    font-size: var(--text-sm);
    color: var(--ink);
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
}
@media (min-width: 576px) {
    .facts {
        grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr);
    }
    .facts dt {
        padding-top: 0.125rem;
    }
    .facts dd {
        margin-bottom: 0;
    }
}

/* Empty / no-result state */
.empty-state {
    max-width: 28rem;
    padding: var(--space-2xl) var(--space-lg);
}
.empty-state h2 {
    margin: 0 0 var(--space-xs);
    font-size: var(--text-md);
    font-weight: 600;
}
.empty-state p {
    margin: 0 0 var(--space-md);
    color: var(--ink-3);
}

/* Pagination */
.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--line);
}
.pagination {
    --bs-pagination-font-size: var(--text-sm);
    --bs-pagination-color: var(--ink-2);
    --bs-pagination-bg: var(--surface);
    --bs-pagination-border-color: var(--line-strong);
    --bs-pagination-hover-color: var(--ink);
    --bs-pagination-hover-bg: var(--surface-hover);
    --bs-pagination-hover-border-color: var(--line-strong);
    --bs-pagination-active-bg: var(--accent);
    --bs-pagination-active-border-color: var(--accent);
    --bs-pagination-disabled-color: var(--ink-3);
    --bs-pagination-disabled-bg: var(--surface);
    --bs-pagination-focus-box-shadow: 0 0 0 3px var(--bs-focus-ring-color);
    margin: 0;
}
.page-size {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--text-sm);
    color: var(--ink-3);
}
.page-size .form-select {
    width: auto;
}

/* ---------- Login ---------- */
.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: var(--space-lg) var(--space-md);
}
.login-panel {
    width: 100%;
    max-width: 22rem;
}
.login-panel .wordmark {
    display: block;
    margin-bottom: var(--space-xl);
    font-size: var(--text-xl);
}
.login-panel .form-group {
    margin-bottom: var(--space-md);
}
.login-panel label {
    margin-bottom: var(--space-2xs);
    font-weight: 500;
}
.login-panel .btn {
    width: 100%;
    justify-content: center;
    min-height: var(--tap);
    margin-top: var(--space-xs);
}

/* Error pages reuse the login panel */
.error-panel {
    max-width: 30rem;
}
.error-panel .btn {
    width: auto;
}

/* Long or unbroken titles (URLs, run-together words) wrap instead of widening the page */
.page-title,
.film-name,
.film-card-title,
.vote-film,
.film-producer,
.page-meta {
    overflow-wrap: anywhere;
}
.film-card > span,
.vote-list li > div {
    min-width: 0;
}


/* Votos: "Apagar voto" is a secondary action; keep it compact on phones */
@media (max-width: 767.98px) {
    .votes-table .row-actions > .btn {
        flex: none;
        width: auto;
        min-height: var(--tap);
        border-color: transparent;
    }
}
