:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #d9e2ec;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --accent: #f59e0b;
    --danger: #b42318;
    --ok: #047857;
    --shadow: 0 18px 45px rgba(25, 36, 58, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: 30px; }
h2 { margin-top: 28px; font-size: 20px; }
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
}
button:hover, .button:hover { background: var(--brand-dark); color: #fff; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 11px 12px;
    font: inherit;
}
textarea { resize: vertical; }
label { display: grid; gap: 7px; color: #344054; font-weight: 700; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    background: #0b1220;
    color: #fff;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-size: 20px; font-weight: 800; }
.brand img, .auth-brand img { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; background: #fff; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a {
    color: #cbd5e1;
    padding: 10px 12px;
    border-radius: 8px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.main { min-width: 0; padding: 28px; }
.topbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 24px;
}
.topbar div { display: grid; text-align: right; }
.topbar span, .muted { color: var(--muted); }
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}
.page-head p { margin: 8px 0 0; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat, .panel, .table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.stat { padding: 20px; display: grid; gap: 8px; }
.stat span { color: var(--muted); font-weight: 700; }
.stat strong { font-size: 30px; }
.panel { padding: 22px; }
.table-wrap { overflow-x: auto; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.toolbar input { max-width: 420px; }
.form, .form-grid { display: grid; gap: 16px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide, .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.section-title {
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--ink);
    font-size: 18px;
    font-weight: 800;
}
.check { display: flex; gap: 10px; align-items: center; }
.check input { width: auto; }
.actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.actions form { display: inline; }
.inline-upload {
    display: grid;
    gap: 8px;
    min-width: 220px;
}
.inline-upload input { padding: 8px; }
.inline-upload button { min-height: 36px; }
.ghost {
    background: #eef2f6;
    color: #1f2937;
    border-radius: 8px;
    min-height: 42px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.ghost:hover { background: #e2e8f0; color: #111827; }
.full { width: 100%; }
.link-danger {
    background: transparent;
    color: var(--danger);
    min-height: auto;
    padding: 0;
}
.link-danger:hover { background: transparent; color: #7a271a; }
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: #eef2f6;
    color: #344054;
    font-size: 12px;
    font-weight: 800;
    text-transform: capitalize;
}
.badge.ok, .badge.pago { background: #dcfce7; color: var(--ok); }
.badge.off, .badge.cancelado { background: #f2f4f7; color: #667085; }
.badge.em_aberto { background: #fef3c7; color: #92400e; }
.badge.vencido { background: #fee4e2; color: var(--danger); }
.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-weight: 700;
}
.alert.success { background: #dcfce7; color: var(--ok); }
.alert.error { background: #fee4e2; color: var(--danger); }
.message-list { display: grid; gap: 14px; }
.message-head { display: flex; justify-content: space-between; gap: 12px; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(15,118,110,.88), rgba(11,18,32,.94)),
        url("data:image/svg+xml,%3Csvg width='160' height='160' viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='.12'%3E%3Cpath d='M0 80h160v8H0zM76 0h8v160h-8z'/%3E%3C/g%3E%3C/svg%3E");
}
.auth-card {
    width: min(430px, 100%);
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 26px 70px rgba(0,0,0,.25);
}
.auth-brand { display: grid; gap: 8px; margin-bottom: 24px; }
.auth-brand h1 { font-size: 28px; }
.auth-brand p { margin: 0; color: var(--muted); }
.muted-link { display: inline-flex; margin-top: 4px; color: var(--muted); font-weight: 700; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .main { padding: 20px; }
    .stats-grid, .form-grid { grid-template-columns: 1fr; }
    .page-head, .toolbar { align-items: stretch; flex-direction: column; }
    .topbar { justify-content: flex-start; }
    .topbar div { text-align: left; }
}
