:root {
    --brand-red: #d90000;
    --brand-red-dark: #ad0000;
    --brand-red-soft: #fff0f0;
    --text-primary: #111111;
    --text-secondary: #5f5f5f;
    --border-neutral: #dddddd;
    --surface: #ffffff;
    --surface-muted: #f4f4f4;
    --footer-background: #111111;
    --focus-color: #d90000;
    --success: #246447;
    --danger: #8b2330;
    --radius: 12px;
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    background: var(--footer-background);
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
    background: var(--surface);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.5;
}

img { max-width: 100%; }

a {
    color: var(--brand-red);
    text-decoration-thickness: .08em;
    text-underline-offset: .16em;
}

a:hover { color: var(--brand-red-dark); }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--focus-color);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    z-index: 100;
    top: 8px;
    left: 8px;
    padding: 10px 14px;
    color: white;
    background: var(--brand-red);
    border-radius: 6px;
    transform: translateY(-160%);
}

.skip-link:focus {
    color: white;
    transform: translateY(0);
}

.site-header {
    flex: 0 0 auto;
    background: var(--surface);
    border-top: 5px solid var(--brand-red);
    border-bottom: 1px solid var(--border-neutral);
}

.topbar {
    width: min(1280px, 92vw);
    min-height: 82px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

.brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 18px;
    color: var(--text-primary);
    text-decoration: none;
}

.brand:hover { color: var(--text-primary); }

.brand img {
    width: clamp(120px, 13vw, 176px);
    max-height: 58px;
    object-fit: contain;
}

.brand-copy {
    min-width: 0;
    padding-left: 18px;
    display: grid;
    border-left: 1px solid var(--border-neutral);
    line-height: 1.2;
}

.brand-copy strong { font-size: 1.08rem; }

.brand-copy span {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: .9rem;
}

.topbar nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.topbar nav a,
.nav-button {
    min-height: 44px;
    padding: 10px 11px;
    display: inline-flex;
    align-items: center;
    color: var(--text-primary);
    background: transparent;
    border: 0;
    border-radius: 7px;
    font: inherit;
    font-size: .92rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.topbar nav a:hover,
.nav-button:hover {
    color: var(--brand-red);
    background: var(--brand-red-soft);
}

.logout-form {
    margin: 0;
    display: inline-flex;
}

.nav-button { cursor: pointer; }

.container {
    width: min(1180px, 92vw);
    min-width: 0;
    margin: 42px auto 72px;
    flex: 1 0 auto;
}

.site-footer {
    flex: 0 0 auto;
    color: white;
    background: var(--footer-background);
}

.footer-content {
    width: min(1180px, 92vw);
    min-height: 112px;
    margin: 0 auto;
    padding: 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.footer-content p { margin: 0; }

.footer-content p:first-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.footer-content p:last-child {
    color: #e0e0e0;
    text-align: right;
}

.public-hero {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr);
    gap: clamp(28px, 5vw, 68px);
    align-items: center;
    padding: clamp(28px, 5vw, 64px);
    background: var(--surface);
    border: 1px solid var(--border-neutral);
    border-top: 5px solid var(--brand-red);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .07);
}

.institutional-column,
.request-card { min-width: 0; }

.official-eyebrow,
.eyebrow {
    margin: 0 0 10px;
    color: var(--brand-red);
    font-size: .76rem;
    font-weight: 850;
    letter-spacing: .11em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin-top: 0;
    color: var(--text-primary);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(1.9rem, 4vw, 2.8rem);
}

h2 { font-size: 1.2rem; }

.institutional-text {
    max-width: 640px;
    margin: 0;
    color: var(--text-secondary);
    font-size: 1.08rem;
}

.service-areas { margin-top: 34px; }
.service-areas h2 { margin-bottom: 14px; }

.service-areas ul {
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 20px;
    list-style: none;
}

.service-areas li {
    position: relative;
    min-width: 0;
    padding-left: 18px;
    overflow-wrap: anywhere;
}

.service-areas li::before {
    content: "";
    position: absolute;
    top: .58em;
    left: 0;
    width: 7px;
    height: 7px;
    background: var(--brand-red);
    border-radius: 50%;
}

.request-card,
.hero-card,
.panel,
.ticket-card,
.stat {
    background: var(--surface);
    border: 1px solid var(--border-neutral);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .055);
}

.request-card { padding: clamp(24px, 4vw, 38px); }

.request-card h2 {
    margin-bottom: 8px;
    font-size: clamp(1.45rem, 3vw, 1.85rem);
}

.identification-form button { width: 100%; }

.privacy-note {
    margin: 18px 0 0;
    color: var(--text-secondary);
    font-size: .84rem;
}

.narrow {
    max-width: 570px;
    margin: 6vh auto 0;
}

.hero-card { padding: clamp(28px, 5vw, 52px); }

.lead {
    margin: 0 0 28px;
    color: var(--text-secondary);
}

.page-heading {
    margin-bottom: 26px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.page-heading p:last-child {
    margin: 5px 0 0;
    color: var(--text-secondary);
}

label {
    margin-bottom: 7px;
    display: block;
    color: var(--text-primary);
    font-weight: 750;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid #b9b9b9;
    border-radius: 8px;
    font: inherit;
}

textarea { resize: vertical; }

input:focus,
select:focus,
textarea:focus { border-color: var(--brand-red); }

small { color: var(--text-secondary); }

button,
.button {
    min-height: 44px;
    padding: 11px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    background: var(--brand-red);
    border: 1px solid var(--brand-red);
    border-radius: 8px;
    font: inherit;
    font-weight: 750;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button:hover {
    color: white;
    background: var(--brand-red-dark);
    border-color: var(--brand-red-dark);
}

.button-secondary {
    color: var(--text-primary);
    background: var(--surface);
    border-color: var(--border-neutral);
}

.button-secondary:hover {
    color: var(--brand-red);
    background: var(--brand-red-soft);
    border-color: var(--brand-red);
}

.form-stack {
    display: grid;
    gap: 12px;
}

.form-stack button { margin-top: 7px; }
.assignment-form { margin-bottom: 24px; }

.form-grid {
    padding: 28px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.full-width { grid-column: 1 / -1; }

.actions {
    display: flex;
    justify-content: flex-end;
}

.alert {
    margin: 0 0 22px;
    padding: 13px 15px;
    color: var(--text-primary);
    background: var(--brand-red-soft);
    border-left: 4px solid var(--brand-red);
    border-radius: 6px;
}

.alert-error {
    color: #741d28;
    background: #fbecef;
    border-color: var(--danger);
}

.alert-success {
    color: #19583b;
    background: #e9f6f0;
    border-color: var(--success);
}

.cards-list {
    display: grid;
    gap: 14px;
}

.ticket-card {
    min-width: 0;
    padding: 22px;
    display: flex;
    justify-content: space-between;
    gap: 28px;
}

.ticket-card > div:first-child { min-width: 0; }

.ticket-card h2 {
    margin-left: 8px;
    display: inline;
}

.ticket-card p {
    margin-bottom: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ticket-number {
    color: var(--brand-red);
    font-weight: 800;
}

.ticket-meta {
    min-width: 165px;
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 8px;
}

.ticket-meta time {
    color: var(--text-secondary);
    font-size: .87rem;
}

.answer {
    margin-top: 16px;
    padding: 12px;
    background: var(--surface-muted);
    border-left: 3px solid var(--brand-red);
    border-radius: 7px;
}

.badge {
    padding: 4px 9px;
    display: inline-block;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

.priority-alta { color: #8b2330; background: #f9dfe3; }
.priority-media { color: #76500a; background: #ffedc7; }
.priority-baixa { color: #246447; background: #dff2e8; }
.status-aberto { color: #365a74; background: #e4eef5; }
.status-em_andamento { color: #775209; background: #f7e9c8; }
.status-resolvido { color: #246447; background: #dff2e8; }

.filters,
.dashboard-tools {
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.filters label { margin: 0; }

.filters select {
    width: auto;
    min-width: 190px;
}

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border-neutral);
    border-radius: var(--radius);
    overscroll-behavior-inline: contain;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-neutral);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--text-primary);
    background: var(--surface-muted);
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

td a {
    color: var(--brand-red);
    font-weight: 750;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }

.empty-state,
.empty-cell {
    padding: 36px;
    color: var(--text-secondary);
    text-align: center;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    gap: 22px;
}

.users-layout {
    display: grid;
    grid-template-columns: minmax(280px, .78fr) minmax(0, 1.22fr);
    gap: 22px;
}

.panel {
    min-width: 0;
    padding: 26px;
}

.history-panel { margin-top: 22px; }

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

.timeline-item {
    position: relative;
    padding: 4px 0 22px 24px;
    border-left: 2px solid var(--brand-red);
}

.timeline-item::before {
    content: "";
    position: absolute;
    top: 7px;
    left: -6px;
    width: 10px;
    height: 10px;
    background: var(--surface);
    border: 2px solid var(--brand-red);
    border-radius: 50%;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: var(--text-secondary);
    font-size: .88rem;
}

.timeline-action {
    margin: 6px 0;
    color: var(--brand-red);
    font-weight: 750;
}

.timeline-status { margin: 6px 0; }

.timeline-message {
    margin-top: 10px;
    padding: 12px;
    background: var(--surface-muted);
    border-radius: 7px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.timeline-empty {
    margin-bottom: 0;
    color: var(--text-secondary);
}

dl {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 9px 16px;
}

dt { color: var(--text-secondary); }

dd {
    min-width: 0;
    margin: 0;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.description {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.stats {
    margin-bottom: 24px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.stat {
    padding: 21px 24px;
    border-top: 3px solid var(--brand-red);
}

.stat span {
    display: block;
    color: var(--text-secondary);
}

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

.dashboard-tools a {
    padding: 7px 10px;
    border-radius: 6px;
    text-decoration: none;
}

.dashboard-tools a.active {
    color: white;
    background: var(--brand-red);
}

.user-actions {
    min-width: 210px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.user-actions form { margin: 0; }

.button-small {
    min-height: 36px;
    padding: 7px 10px;
    font-size: .84rem;
}

.password-panel { margin-left: auto; margin-right: auto; }

@media (max-width: 800px) {
    .topbar {
        padding: 15px 0;
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .topbar nav {
        padding-top: 10px;
        justify-content: flex-start;
        border-top: 1px solid var(--border-neutral);
    }

    .public-hero {
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
    }

    .request-card { width: 100%; }

    .page-heading,
    .ticket-card {
        align-items: stretch;
        flex-direction: column;
    }

    .form-grid,
    .detail-grid,
    .users-layout { grid-template-columns: minmax(0, 1fr); }

    .full-width { grid-column: auto; }

    .ticket-meta {
        min-width: 0;
        align-items: flex-start;
    }

    .footer-content {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .footer-content p:last-child { text-align: left; }
}

@media (max-width: 520px) {
    .topbar,
    .container,
    .footer-content { width: calc(100% - 32px); }

    .brand { gap: 11px; }
    .brand img { width: 122px; }

    .brand-copy { padding-left: 11px; }
    .brand-copy strong { font-size: .98rem; }
    .brand-copy span { font-size: .78rem; }

    .topbar nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
    }

    .topbar nav a,
    .logout-form,
    .nav-button { width: 100%; }

    .topbar nav a,
    .nav-button {
        justify-content: flex-start;
        white-space: normal;
    }

    .container {
        margin-top: 28px;
        margin-bottom: 48px;
    }

    .public-hero {
        padding: 24px 18px;
        gap: 30px;
    }

    .service-areas ul { grid-template-columns: minmax(0, 1fr); }

    .request-card,
    .hero-card,
    .panel,
    .form-grid,
    .ticket-card { padding: 20px 18px; }

    .page-heading .button,
    .actions button { width: 100%; }

    .filters {
        align-items: stretch;
        flex-direction: column;
    }

    .filters select {
        width: 100%;
        min-width: 0;
    }

    .dashboard-tools {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-tools a { display: block; }
    .stats { grid-template-columns: minmax(0, 1fr); }

    dl {
        grid-template-columns: minmax(0, 1fr);
        gap: 3px;
    }

    dt:not(:first-child) { margin-top: 9px; }
}
