:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-2: #eef3f8;
    --text: #152033;
    --muted: #64748b;
    --border: #d9e2ec;
    --accent: #0b7a75;
    --accent-2: #174ea6;
    --danger: #b42318;
    --warning: #b7791f;
    --success: #1f7a3f;
    --shadow: 0 18px 40px rgba(21, 32, 51, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--accent-2); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
small { color: var(--muted); display: block; }

.app-shell { min-height: 100vh; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px clamp(16px, 4vw, 42px);
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 900;
}
.brand-mark.large { width: 74px; height: 74px; font-size: 26px; margin-bottom: 22px; }
.nav { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.nav a, .subnav a {
    padding: 9px 11px;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 650;
}
.nav a:hover, .subnav a:hover, .nav .admin-link { background: var(--surface-2); }
.logout-form { margin: 0; }
.content { width: min(1180px, calc(100% - 32px)); margin: 28px auto 56px; }

.auth-grid {
    min-height: calc(100vh - 130px);
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, .8fr);
    align-items: center;
    gap: clamp(24px, 7vw, 90px);
}
.auth-copy h1 { font-size: clamp(36px, 6vw, 72px); line-height: 1; margin-bottom: 18px; }
.auth-copy p { color: var(--muted); font-size: 18px; max-width: 560px; }
.auth-card { max-width: 430px; width: 100%; justify-self: end; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 22px;
}
.page-head h1 { margin-bottom: 6px; font-size: clamp(28px, 4vw, 42px); }
.page-head p { color: var(--muted); margin-bottom: 0; }

.panel, .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.panel { padding: clamp(18px, 3vw, 28px); margin-bottom: 22px; }
.panel.narrow { max-width: 620px; }
.centered { text-align: center; margin-inline: auto; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.stat-card { padding: 20px; }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.stat-card strong { display: block; font-size: 34px; line-height: 1.1; margin-top: 8px; }
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.section-title h2 { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

label { display: grid; gap: 7px; font-size: 14px; font-weight: 700; color: var(--text); }
input, select {
    min-height: 42px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    background: #fff;
    color: var(--text);
    font: inherit;
}
input:focus, select:focus { outline: 2px solid rgba(11,122,117,.22); border-color: var(--accent); }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
    align-items: end;
}
.form-grid.wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.settings-form h2 { margin-top: 24px; }
.settings-form h2:first-of-type { margin-top: 0; }
.compact { max-width: 320px; }
.tabs { margin-bottom: 18px; }

.button, .ghost-button, .mini-button {
    border: 0;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 800;
    font: inherit;
    min-height: 42px;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
}
.button.secondary { background: var(--accent-2); }
.button.small { min-height: 34px; padding: 7px 11px; font-size: 13px; }
.button.full { width: 100%; margin-top: 6px; }
.ghost-button { padding: 9px 12px; background: transparent; color: var(--text); border: 1px solid var(--border); }
.mini-button {
    min-height: 32px;
    padding: 6px 9px;
    background: var(--surface-2);
    color: var(--text);
}
.mini-button.danger { background: #fee4e2; color: var(--danger); }
.inline-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.alert {
    padding: 13px 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
    background: #fff;
    font-weight: 700;
}
.alert.success { color: var(--success); background: #edfdf3; }
.alert.error { color: var(--danger); background: #fff1f0; }
.alert.warning { color: var(--warning); background: #fff8e6; }
.muted { color: var(--muted); }
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    background: var(--surface-2);
}
.badge.open, .badge.filled, .badge.aprovado { color: var(--success); background: #e9f8ee; }
.badge.locked, .badge.bloqueado { color: var(--danger); background: #fff1f0; }
.badge.pending, .badge.pendente, .badge.warning { color: var(--warning); background: #fff8e6; }
.badge.rejeitado { color: var(--danger); background: #fee4e2; }
.status-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--warning);
    margin-bottom: 12px;
}

.subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 22px;
}
.subnav a { background: #fff; border: 1px solid var(--border); }

.responsive-table { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
td form { margin: 0; }
.score-inputs {
    display: grid;
    grid-template-columns: 64px 20px 64px;
    align-items: center;
    gap: 6px;
    max-width: 160px;
}
.score-inputs span { text-align: center; color: var(--muted); font-weight: 800; }

@media (max-width: 840px) {
    .topbar { align-items: flex-start; flex-wrap: wrap; }
    .brand { width: 100%; }
    .nav { width: calc(100% - 82px); }
    .content { width: min(100% - 20px, 1180px); margin-top: 18px; }
    .auth-grid { grid-template-columns: 1fr; align-items: start; padding-top: 22px; }
    .auth-card { justify-self: stretch; max-width: none; }
    .page-head { display: block; }
    .page-head .button, .page-head form { margin-top: 14px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid, .form-grid.wide { grid-template-columns: 1fr; }
    .section-title { align-items: flex-start; flex-direction: column; }

    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }
    tr {
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }
    td {
        display: grid;
        grid-template-columns: 120px minmax(0, 1fr);
        gap: 12px;
        border-bottom: 0;
        padding: 8px 0;
    }
    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        text-transform: uppercase;
        font-weight: 800;
    }
    td:empty { display: none; }
}

@media (max-width: 520px) {
    .stats-grid { grid-template-columns: 1fr; }
    .nav { width: 100%; }
    .logout-form { width: 100%; }
    .ghost-button { width: 100%; }
    td { grid-template-columns: 1fr; gap: 4px; }
    .score-inputs { grid-template-columns: 1fr 20px 1fr; max-width: 100%; }
}
