:root {
    --bg: #0a0e13;
    --panel: #111823;
    --panel-2: #16202d;
    --line: #22303f;
    --text: #e8eef6;
    --muted: #8c9cae;
    --gold: #f2b21b;
    --gold-soft: #ffd166;
    --ok: #35c47a;
    --warn: #f0a52b;
    --bad: #ef5a5a;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--gold-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 12px; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; margin-top: 18px; }

code {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 12px;
    word-break: break-all;
}

pre.code-block {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    overflow-x: auto;
    font-size: 12px;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }

/* ---------- Layout ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 236px;
    flex: 0 0 236px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid var(--line);
}

.brand-logo { height: 34px; width: auto; max-width: 150px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; }
.brand-text .muted { font-size: 11px; }

.nav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; flex: 1; overflow-y: auto; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #c6d2e0;
    font-weight: 500;
}
.nav-link:hover { background: var(--panel-2); text-decoration: none; }
.nav-link.active { background: rgba(242, 178, 27, 0.14); color: var(--gold-soft); }
.nav-icon { width: 18px; text-align: center; opacity: 0.8; }

.sidebar-foot {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logout-link { color: var(--bad); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(10, 14, 19, 0.9);
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(6px);
}
.topbar-meta { display: flex; align-items: center; gap: 12px; }

.content { padding: 24px; max-width: 1280px; width: 100%; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.page-title { margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards e grids ---------- */

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
}

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

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--gold-soft); }

/* ---------- Formulários ---------- */

label { display: block; margin-bottom: 12px; font-weight: 500; color: #cfdae7; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    margin-top: 6px;
    padding: 9px 11px;
    background: #0d141c;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(242, 178, 27, 0.15);
}

textarea { resize: vertical; }

.form .form-actions { display: flex; gap: 10px; margin-top: 8px; }

.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px 14px;
}
.filters input, .filters select { margin-top: 0; width: auto; min-width: 180px; }
.filters .muted { margin-left: auto; }

.checks { display: flex; gap: 18px; flex-wrap: wrap; margin: 4px 0 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 500; }
.check input { width: auto; margin: 0; }
.radios { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }

.input-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.input-row input { margin-top: 0; }

.inline { display: inline-block; margin: 0; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.input-inline { margin-top: 0; padding: 5px 8px; font-size: 13px; }

/* ---------- Botões ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s ease, background 0.15s ease;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }

.btn-primary { background: var(--gold); border-color: var(--gold); color: #1a1405; }
.btn-ghost { background: transparent; }
.btn-ghost.is-active { background: rgba(242, 178, 27, 0.16); border-color: rgba(242, 178, 27, 0.4); color: var(--gold-soft); }
.btn-danger { background: rgba(239, 90, 90, 0.14); border-color: rgba(239, 90, 90, 0.45); color: #ff9a9a; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 4px; }

/* ---------- Tabelas ---------- */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table thead th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-kv th { width: 240px; color: var(--muted); font-weight: 500; }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.badge-ok { background: rgba(53, 196, 122, 0.16); color: #6ee7a8; }
.badge-warn { background: rgba(240, 165, 43, 0.16); color: #ffc76a; }
.badge-bad { background: rgba(239, 90, 90, 0.16); color: #ff9a9a; }
.badge-muted { background: rgba(255, 255, 255, 0.07); color: var(--muted); }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.page-link {
    padding: 6px 11px;
    border-radius: 7px;
    border: 1px solid var(--line);
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
}
.page-link.active { background: var(--gold); border-color: var(--gold); color: #1a1405; }

/* ---------- Alertas ---------- */

.alert, .flash {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    background: var(--panel-2);
}
.alert ul { margin: 6px 0 0 18px; padding: 0; }
.alert-bad, .flash-bad { border-color: rgba(239, 90, 90, 0.45); background: rgba(239, 90, 90, 0.1); color: #ffb3b3; }
.alert-ok, .flash-ok { border-color: rgba(53, 196, 122, 0.45); background: rgba(53, 196, 122, 0.1); color: #9ff0c3; }
.flash-warn { border-color: rgba(240, 165, 43, 0.45); background: rgba(240, 165, 43, 0.1); color: #ffd08a; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline-time { color: var(--muted); flex: 0 0 78px; font-variant-numeric: tabular-nums; }
.timeline-text { color: #cfdae7; }

.logo-preview {
    max-height: 60px;
    max-width: 240px;
    background: #0d141c;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
}

/* ---------- Login ---------- */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(700px 380px at 50% -10%, rgba(242, 178, 27, 0.16), transparent 70%),
        var(--bg);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 390px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 28px 26px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.login-logo { display: block; height: 54px; max-width: 100%; margin: 0 auto 14px; object-fit: contain; }
.login-card h1 { text-align: center; font-size: 20px; margin-bottom: 4px; }
.login-card > .muted { text-align: center; margin: 0 0 20px; }
.login-card .center { margin-top: 16px; }

/* ---------- Instalador ---------- */

.install-body {
    background:
        radial-gradient(700px 380px at 50% -10%, rgba(242, 178, 27, 0.14), transparent 70%),
        var(--bg);
    padding: 32px 16px;
}
.install-wrap { max-width: 720px; margin: 0 auto; }
.install-brand { text-align: center; margin-bottom: 18px; }
.install-logo { height: 56px; max-width: 100%; object-fit: contain; }
.install-wrap .card h2 { color: var(--gold-soft); margin-top: 6px; }
.install-wrap .card h2:first-child { margin-top: 0; }

.checklist { margin: 10px 0 14px 18px; padding: 0; }
.warn-box {
    border: 1px solid rgba(240, 165, 43, 0.45);
    background: rgba(240, 165, 43, 0.1);
    color: #ffd08a;
    border-radius: 8px;
    padding: 10px 12px;
}

/* ---------- Responsivo ---------- */

@media (max-width: 900px) {
    .app { flex-direction: column; }
    .sidebar { position: static; width: 100%; flex: none; height: auto; }
    .nav { flex-direction: row; overflow-x: auto; }
    .nav-link span:last-child { white-space: nowrap; }
    .sidebar-foot { display: none; }
    .content { padding: 16px; }
    .grid-2 { grid-template-columns: 1fr; }
    .ellipsis { max-width: 220px; }
    .table-kv th { width: 140px; }
}
