:root {
    --surface-1: #fcfcfb;
    --page-plane: #f9f9f7;
    --text-primary: #0b0b0b;
    --text-secondary: #52514e;
    --text-muted: #898781;
    --gridline: #e1e0d9;
    --border: rgba(11, 11, 11, 0.10);
    --accent: #2a78d6;
    --accent-hover: #184f95;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --success-bg: #eaf7ea;
    --success-text: #006300;
    --error-bg: #fdeceb;
    --error-text: #b3261e;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --surface-1: #1a1a19;
        --page-plane: #0d0d0d;
        --text-primary: #ffffff;
        --text-secondary: #c3c2b7;
        --text-muted: #898781;
        --gridline: #2c2c2a;
        --border: rgba(255, 255, 255, 0.10);
        --accent: #3987e5;
        --accent-hover: #5ea0ec;
        --series-2: #d95926;
        --series-3: #199e70;
        --success-bg: #103a10;
        --success-text: #6fd66f;
        --error-bg: #3a1512;
        --error-text: #e66767;
    }
}

:root[data-theme="dark"] {
    --surface-1: #1a1a19;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-hover: #5ea0ec;
    --series-2: #d95926;
    --series-3: #199e70;
    --success-bg: #103a10;
    --success-text: #6fd66f;
    --error-bg: #3a1512;
    --error-text: #e66767;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--page-plane);
    color: var(--text-primary);
}

@media (prefers-reduced-motion: no-preference) {
    body,
    .card,
    .topbar,
    input,
    select,
    textarea,
    .btn,
    .theme-toggle {
        transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
    }
}

a {
    color: var(--accent);
}

.topbar {
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    text-decoration: none;
    color: var(--text-primary);
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav a {
    text-decoration: none;
    color: var(--text-secondary);
    margin-left: 16px;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
}

.nav a.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

.theme-toggle {
    margin-left: 16px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--gridline);
    background: var(--surface-1);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}

.theme-toggle:hover {
    background: var(--page-plane);
}

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

.theme-toggle .icon-moon {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun {
        display: none;
    }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon {
        display: inline;
    }
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
    display: inline;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 28px 20px 60px;
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 20px;
}

h2 {
    font-size: 1.05rem;
    margin: 0 0 14px;
}

details.card {
    padding: 0;
}

details.card > summary {
    list-style: none;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

details.card > summary::-webkit-details-marker {
    display: none;
}

details.card > summary::after {
    content: '+';
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 400;
}

details.card[open] > summary::after {
    content: '−';
}

details.card > summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

details.card > .details-body {
    padding: 0 20px 20px;
}

.hero {
    text-align: center;
    padding: 40px 20px;
}

.subtitle {
    color: var(--text-secondary);
    margin-top: 4px;
}

.hero-stat {
    margin: 28px 0;
}

.hero-stat-inline {
    margin: 0 0 20px;
    text-align: left;
}

.hero-stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    font-variant-numeric: proportional-nums;
}

.hero-stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 780px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.form .field,
.filters .field {
    margin-bottom: 16px;
}

.filters {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.filters .field {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

input[type="text"],
input[type="url"],
input[type="date"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gridline);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--surface-1);
    color: var(--text-primary);
    font-family: inherit;
}

textarea {
    resize: vertical;
}

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

.field-hint {
    margin: 6px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    color: var(--text-primary);
}

.radio-option input {
    width: auto;
}

.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

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

.btn-secondary {
    background: var(--surface-1);
    border-color: var(--gridline);
    color: var(--text-primary);
}

.btn-link {
    background: transparent;
    color: var(--text-secondary);
}

.btn-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.btn-delete:hover {
    background: var(--error-bg);
    color: var(--error-text);
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert ul {
    margin: 0;
    padding-left: 18px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 14px;
    font-size: 0.9rem;
}

.table th,
.table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--gridline);
}

.table th {
    color: var(--text-secondary);
    font-weight: 600;
}

.table-scroll {
    overflow-x: auto;
}

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

canvas {
    max-height: 280px;
}

.descricao-cell {
    display: block;
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Impede que um texto sem espaços (ex.: motivo digitado muito longo) estique a tabela inteira. */
.table td {
    word-break: break-word;
    overflow-wrap: break-word;
}

.linha-clicavel {
    cursor: pointer;
}

.linha-clicavel:hover {
    background: var(--page-plane);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 11, 11, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-card {
    position: relative;
    background: var(--surface-1);
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 6px;
    border-radius: 6px;
}

.modal-close:hover {
    background: var(--page-plane);
    color: var(--text-primary);
}

.modal-field {
    margin-bottom: 14px;
}

.modal-field label {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.modal-field div {
    white-space: pre-wrap;
    word-break: break-word;
}
