:root {
    --font-base: 18px;
    --bg: #f4f4f5;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #d1d5db;
    --primary: #1e3a8a;
    --primary-hover: #1e40af;
    --primary-light: #eef2ff;
    --success: #155724;
    --success-bg: #d4edda;
    --danger: #b91c1c;
    --danger-bg: #fde2e2;
    --warning: #92400e;
    --warning-bg: #fff3cd;
    --radius: 8px;
}

* { box-sizing: border-box; }
html { font-size: var(--font-base); }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    line-height: 1.5;
}
a { color: var(--primary); }

/* ===== Topbar / navegacao ===== */
.topbar {
    background: #fff;
    border-bottom: 2px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.brand {
    font-size: 1.4em;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
}
.main-nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    flex: 1;
}
.main-nav a {
    padding: 0.6rem 1rem;
    text-decoration: none;
    color: var(--text);
    border-radius: var(--radius);
    font-weight: 600;
}
.main-nav a:hover,
.main-nav a.is-active {
    background: var(--primary-light);
    color: var(--primary);
}
.user-area {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}
.user-name { color: var(--muted); }
.btn-logout {
    background: #ef4444;
    color: #fff;
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-weight: 700;
}
.btn-logout:hover { background: #dc2626; }
.font-btn {
    background: #fff;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.8rem;
    font-weight: 700;
    cursor: pointer;
    font-size: 1em;
    min-width: 48px;
}
.font-btn + .font-btn { margin-left: 0.25rem; }
.font-btn:hover { background: var(--primary-light); }

/* ===== Conteudo ===== */
.content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}
.content-centered {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

h1 { font-size: 1.75em; margin: 0 0 1.5rem 0; }
h2 { font-size: 1.4em; margin: 1.5rem 0 1rem 0; }
h3 { font-size: 1.15em; margin: 1rem 0 0.5rem 0; }

/* ===== Cards ===== */
.card {
    background: var(--card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border: 1px solid var(--border);
}

/* ===== Formularios ===== */
.form-group { margin-bottom: 1.2rem; }
label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: #374151;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1em;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,58,138,.15);
}
textarea { min-height: 100px; }

/* ===== Botoes ===== */
.btn {
    display: inline-block;
    padding: 0.85rem 1.5rem;
    font-size: 1em;
    font-weight: 700;
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    min-height: 48px;
    line-height: 1.2;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-large { font-size: 1.1em; padding: 1rem 1.75rem; min-height: 56px; }
.btn-block { display: block; width: 100%; }

/* ===== Alertas ===== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-weight: 600;
    border-left: 6px solid;
}
.alert-success { background: var(--success-bg); color: var(--success); border-left-color: #10b981; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-left-color: #ef4444; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-left-color: #f59e0b; }

/* ===== Dashboard (KPIs) ===== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.kpi {
    background: #fff;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    border-left: 6px solid var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    text-decoration: none;
    color: inherit;
    display: block;
}
.kpi:hover { box-shadow: 0 4px 10px rgba(0,0,0,.08); transform: translateY(-1px); }
.kpi-label { color: var(--muted); font-size: 0.95em; font-weight: 600; }
.kpi-value { font-size: 2em; font-weight: 800; margin-top: 0.25rem; line-height: 1.1; }
.kpi-sub { color: var(--muted); margin-top: 0.25rem; font-weight: 600; }
.kpi-danger  { border-left-color: #ef4444; }
.kpi-danger  .kpi-value { color: var(--danger); }
.kpi-success { border-left-color: #10b981; }
.kpi-success .kpi-value { color: #065f46; }
.kpi-warning { border-left-color: #f59e0b; }
.kpi-warning .kpi-value { color: var(--warning); }

/* ===== Tela de login ===== */
.content-centered:has(.login-split) { padding: 0; }

.login-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    min-height: 100vh;
}
.login-art {
    background: #f4f6fa;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.login-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: #fff;
}
.login-card {
    background: var(--card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border: 1px solid var(--border);
    max-width: 420px;
    width: 100%;
}
.login-logo {
    display: block;
    margin: 0 auto 1rem;
    max-width: 180px;
    height: auto;
}
.login-card .subtitle { text-align: center; color: var(--muted); margin: 0 0 1.5rem; }

@media (max-width: 768px) {
    .login-split { grid-template-columns: 1fr; }
    .login-art { display: none; }
}

/* ===== Tabelas ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.table th, .table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th { background: var(--bg); font-weight: 700; color: #374151; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafa; }

/* ===== Badges de status ===== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 99px;
    font-size: 0.85em;
    font-weight: 700;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-muted   { background: #e5e7eb; color: #374151; }

/* ===== Toolbar (busca + acoes) ===== */
.toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}
.toolbar .search { flex: 1; min-width: 240px; }

/* ===== Select com busca ===== */
.ss-wrap { position: relative; }
.ss-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0; padding: 0; margin: -1px;
    opacity: 0;
}
.ss-trigger {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1em;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    font-family: inherit;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text);
    min-height: 48px;
}
.ss-trigger:hover { background: #fafafa; }
.ss-wrap.is-open .ss-trigger,
.ss-trigger:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,58,138,.15);
}
.ss-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-label.is-placeholder { color: var(--muted); }
.ss-caret { color: var(--muted); flex-shrink: 0; font-size: 0.8em; }
.ss-panel {
    position: absolute;
    z-index: 50;
    left: 0; right: 0; top: 100%;
    margin-top: 4px;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    overflow: hidden;
    max-height: 360px;
    display: flex;
    flex-direction: column;
}
.ss-search {
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0;
}
.ss-search:focus {
    outline: none;
    box-shadow: none !important;
    border-color: var(--border) !important;
}
.ss-list {
    list-style: none;
    margin: 0; padding: 0;
    overflow-y: auto;
    flex: 1;
}
.ss-item {
    padding: 0.7rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    outline: none;
}
.ss-item[hidden] { display: none; }
.ss-item:hover,
.ss-item:focus {
    background: var(--primary-light);
    color: var(--primary);
}
.ss-empty {
    padding: 1rem;
    color: var(--muted);
    text-align: center;
    font-style: italic;
}

/* ===== Responsivo ===== */
@media (max-width: 720px) {
    .content { padding: 1rem; }
    .topbar { padding: 0.5rem 1rem; }
    .user-name { display: none; }
    h1 { font-size: 1.5em; }
}
