/* Painel da plataforma (/plataforma). Tema claro/escuro por tokens. */

:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --surface-hover: #f3f4f6;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #111827;
    --text-2: #374151;
    --muted: #5b6474; /* era #6b7280: 4.3:1 sobre --brand-soft */
    --faint: #9ca3af;
    --brand: #4f46e5;
    --brand-hover: #4338ca;
    --brand-soft: #eef2ff;
    --brand-text: #4338ca;
    --on-brand: #ffffff;
    --ok: #047857;      --ok-soft: #ecfdf5;   --ok-dot: #10b981;
    --warn: #b45309;    --warn-soft: #fffbeb; --warn-dot: #f59e0b;
    --err: #b91c1c;     --err-soft: #fef2f2;  --err-dot: #ef4444;
    --info: #1d4ed8;    --info-soft: #eff6ff; --info-dot: #3b82f6;
    --neutral: #4b5563; --neutral-soft: #f3f4f6; --neutral-dot: #9ca3af;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25);
    --ring: 0 0 0 3px rgba(79, 70, 229, .18);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar: 248px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0b0d12;
        --surface: #12151c;
        --surface-2: #161a22;
        --surface-hover: #1b202a;
        --border: #232936;
        --border-strong: #313949;
        --text: #e8eaf0;
        --text-2: #c3c8d4;
        --muted: #8b93a4;
        --faint: #636b7c;
        --brand: #5b57ef; /* era #6d6af5: texto branco a 4.2:1 */
        --brand-hover: #4f46e5;
        --brand-soft: rgba(109, 106, 245, .14);
        --brand-text: #a5a8ff;
        --ok: #34d399;      --ok-soft: rgba(16, 185, 129, .12);
        --warn: #fbbf24;    --warn-soft: rgba(245, 158, 11, .12);
        --err: #f87171;     --err-soft: rgba(239, 68, 68, .12);
        --info: #60a5fa;    --info-soft: rgba(59, 130, 246, .12);
        --neutral: #aab1bf; --neutral-soft: rgba(148, 163, 184, .12);
        --shadow-sm: none;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
        --ring: 0 0 0 3px rgba(109, 106, 245, .3);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0d12;
    --surface: #12151c;
    --surface-2: #161a22;
    --surface-hover: #1b202a;
    --border: #232936;
    --border-strong: #313949;
    --text: #e8eaf0;
    --text-2: #c3c8d4;
    --muted: #8b93a4;
    --faint: #636b7c;
    --brand: #5b57ef; /* era #6d6af5: texto branco a 4.2:1 */
    --brand-hover: #4f46e5;
    --brand-soft: rgba(109, 106, 245, .14);
    --brand-text: #a5a8ff;
    --ok: #34d399;      --ok-soft: rgba(16, 185, 129, .12);
    --warn: #fbbf24;    --warn-soft: rgba(245, 158, 11, .12);
    --err: #f87171;     --err-soft: rgba(239, 68, 68, .12);
    --info: #60a5fa;    --info-soft: rgba(59, 130, 246, .12);
    --neutral: #aab1bf; --neutral-soft: rgba(148, 163, 184, .12);
    --shadow-sm: none;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
    --ring: 0 0 0 3px rgba(109, 106, 245, .3);
}

:root.dark {
    color-scheme: dark;
    --bg: #0b0d12;
    --surface: #12151c;
    --surface-2: #161a22;
    --surface-hover: #1b202a;
    --border: #232936;
    --border-strong: #313949;
    --text: #e8eaf0;
    --text-2: #c3c8d4;
    --muted: #8b93a4;
    --faint: #636b7c;
    --brand: #5b57ef; /* era #6d6af5: texto branco a 4.2:1 */
    --brand-hover: #4f46e5;
    --brand-soft: rgba(109, 106, 245, .14);
    --brand-text: #a5a8ff;
    --ok: #34d399;
    --ok-soft: rgba(16, 185, 129, .12);
    --warn: #fbbf24;
    --warn-soft: rgba(245, 158, 11, .12);
    --err: #f87171;
    --err-soft: rgba(239, 68, 68, .12);
    --info: #60a5fa;
    --info-soft: rgba(59, 130, 246, .12);
    --neutral: #aab1bf;
    --neutral-soft: rgba(148, 163, 184, .12);
    --shadow-sm: none;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
    --ring: 0 0 0 3px rgba(109, 106, 245, .3);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background:
        radial-gradient(1000px 420px at top left, rgba(99, 102, 241, 0.08), transparent 55%),
        radial-gradient(900px 420px at bottom right, rgba(59, 130, 246, 0.09), transparent 50%),
        var(--bg);
    color: var(--text);
    font: 14px/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body, button, input, select, textarea {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

button, input, select, textarea {
    box-sizing: border-box;
    transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease, transform .16s ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.card, .stat, .toolbar, .section, .table-wrap table {
    box-shadow: var(--shadow-sm);
}

.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]),
select,
textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    padding: 10px 12px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="submit"]):not([type="button"]):focus,
select:focus,
textarea:focus {
    border-color: rgba(79, 70, 229, 0.55);
    box-shadow: var(--ring);
}

input::placeholder,
textarea::placeholder {
    color: var(--faint);
}

::selection {
    background: rgba(79, 70, 229, 0.18);
}

.auth-layout {
    background:
        radial-gradient(900px 480px at 8% 8%, rgba(99, 102, 241, 0.24), transparent 42%),
        radial-gradient(760px 420px at 92% 92%, rgba(59, 130, 246, 0.24), transparent 38%),
        linear-gradient(135deg, #0f172a 0%, #111827 32%, #1d4ed8 100%);
}

.auth-layout .min-h-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-layout .min-h-screen > .relative {
    width: min(100%, 32rem);
    position: relative;
    z-index: 1;
}

.auth-layout .min-h-screen > .relative > .bg-white {
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 32px 70px rgba(15, 23, 42, 0.42);
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(10px);
}

.auth-layout .min-h-screen > .relative > .bg-white > .bg-gradient-to-br {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.auth-layout .btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
}

.app-shell {
    width: min(100%, 1600px);
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    padding: 20px 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(249,250,251,0.9));
    box-shadow: var(--shadow-sm);
}

html.dark .page-header {
    background: linear-gradient(180deg, rgba(18,21,28,0.96), rgba(22,26,34,0.9));
}

.page-title {
    margin: 0;
    font-size: clamp(1.4rem, 1rem + 0.8vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--text);
}

.page-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.92rem;
}

.panel, .card, .surface-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
    color: var(--text);
}

.panel-header, .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.panel-title, .card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.table-wrap {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface);
}

.table-wrap table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrap th,
.table-wrap td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.table-wrap thead th {
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.table-wrap tbody tr:hover {
    background: var(--surface-hover);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: var(--neutral-soft);
    color: var(--neutral);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.badge-primary {
    background: rgba(79, 70, 229, 0.12);
    border-color: rgba(79, 70, 229, 0.18);
    color: var(--brand);
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.18);
    color: var(--ok);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.18);
    color: var(--warn);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.18);
    color: var(--err);
}

.badge-info {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.18);
    color: var(--info);
}

.btn, .btn-primary, .btn-secondary, .btn-success, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0.7rem 1.1rem;
    border-radius: 12px;
    border: 1px solid transparent;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease, border-color .16s ease, color .16s ease;
}

.btn:hover, .btn-primary:hover, .btn-secondary:hover, .btn-success:hover, .btn-danger:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-hover));
    color: var(--on-brand);
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.18);
}

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

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    box-shadow: 0 10px 22px rgba(16, 185, 129, 0.18);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    box-shadow: 0 10px 22px rgba(239, 68, 68, 0.18);
}

a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; color: var(--text-2); }
.icon { flex-shrink: 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40;
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #4f46e5, #4338ca); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .02em; box-shadow: 0 4px 12px -2px rgba(79, 70, 229, .45); }
.logo-text { line-height: 1.2; }
.logo-text strong { display: block; font-size: 14.5px; }
.logo-text span { font-size: 12px; color: var(--muted); }
.nav { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 6px; }
.nav a {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 500; text-decoration: none; transition: background .12s, color .12s;
}
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--surface-hover); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand-text); }
.nav a.active .icon { color: var(--brand-text); }
.nav .count { margin-left: auto; font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 0 7px; }
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }

.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.theme-switch button { border: 0; background: transparent; color: var(--muted); padding: 6px 0; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow), inset 0 0 0 1px var(--border-strong); }

.me { display: flex; align-items: center; gap: 10px; }
.me-info { min-width: 0; flex: 1; line-height: 1.25; }
.me-info strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-info span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.icon-btn { border: 1px solid transparent; background: transparent; color: var(--muted); width: 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

.content { flex: 1; min-width: 0; margin-left: var(--sidebar); }
.topbar { display: none; }
.container { max-width: 1120px; margin: 0 auto; padding: 28px 32px 64px; }
.scrim { display: none; }

@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
    .shell.nav-open .sidebar { transform: none; }
    .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 30; }
    .content { margin-left: 0; }
    .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
    .topbar .logo { width: 28px; height: 28px; font-size: 11px; }
    .container { padding: 20px 16px 48px; }
}

/* ---------- Page header ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; margin-bottom: 14px; }
.back:hover { color: var(--text); text-decoration: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; line-height: 1.2; letter-spacing: -.02em; margin: 0; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px;
    border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 14px;
    cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, box-shadow .12s;
    background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--brand-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { background: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-outline { background: var(--surface); color: var(--err); border-color: var(--border-strong); }
.btn-danger-outline:hover { background: var(--err-soft); border-color: var(--err); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-body { padding: 20px 24px; }
.card-head { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-foot { padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; justify-content: flex-end; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-foot .hint { margin: 0 auto 0 0; }
.stack > * + * { margin-top: 20px; }

/* Seções estilo "configurações": descrição à esquerda, campos à direita */
.section { display: grid; grid-template-columns: 280px 1fr; gap: 32px; padding: 28px 0; border-top: 1px solid var(--border); }
.section:first-of-type { border-top: 0; padding-top: 0; }
.section-info h2 { font-size: 15px; margin: 0 0 6px; font-weight: 600; }
.section-info p { margin: 0; color: var(--muted); font-size: 13.5px; }
@media (max-width: 900px) { .section { grid-template-columns: 1fr; gap: 14px; } }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); }
.stat-icon.ok { background: var(--ok-soft); color: var(--ok); }
.stat-icon.warn { background: var(--warn-soft); color: var(--warn); }
.stat-icon.err { background: var(--err-soft); color: var(--err); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) {
    .stats { gap: 10px; }
    .stat { padding: 14px; }
    .stat-icon { display: none; }
    .stat-value { font-size: 22px; }
}

/* ---------- Toolbar & table ---------- */
.toolbar { display: flex; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { padding-left: 36px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow), inset 0 0 0 1px var(--border-strong); }
.segmented button { white-space: nowrap; }
@media (max-width: 760px) {
    .toolbar .search { max-width: none; flex-basis: 100%; }
    .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; transition: background .1s; }
tbody tr.clickable:hover { background: var(--surface-hover); }
td.num { font-variant-numeric: tabular-nums; }
td.end { text-align: right; width: 1%; white-space: nowrap; color: var(--faint); }

.entity { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.avatar { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex-shrink: 0; background: var(--brand-soft); color: var(--brand-text); }
.avatar.lg { width: 52px; height: 52px; border-radius: 12px; font-size: 18px; }
.avatar.round { border-radius: 99px; width: 32px; height: 32px; font-size: 12px; }
.entity strong { display: block; color: var(--text); font-weight: 600; }
.entity span { font-size: 12.5px; color: var(--muted); }

.meter { height: 6px; width: 110px; background: var(--neutral-soft); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.meter > span.near { background: var(--warn-dot); }
.meter > span.full { background: var(--err-dot); }

@media (max-width: 760px) {
    table.responsive thead { display: none; }
    table.responsive tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; padding: 16px; border-bottom: 1px solid var(--border); }
    table.responsive td { padding: 0; border: 0; }
    table.responsive td:first-child { grid-column: 1 / -1; }
    table.responsive td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; font-weight: 500; }
    table.responsive td.end { display: none; }
}

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; background: var(--neutral-soft); color: var(--neutral); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 99px; background: var(--neutral-dot); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.ok::before { background: var(--ok-dot); }
.badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.warn::before { background: var(--warn-dot); }
.badge.err { background: var(--err-soft); color: var(--err); } .badge.err::before { background: var(--err-dot); }
.badge.info { background: var(--info-soft); color: var(--info); } .badge.info::before { background: var(--info-dot); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }

/* ---------- Forms ---------- */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .fields { grid-template-columns: 1fr; } }
label, .label { display: block; font-weight: 500; font-size: 13.5px; color: var(--text-2); margin-bottom: 6px; }
.optional { color: var(--faint); font-weight: 400; }
input, select {
    width: 100%; height: 40px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    transition: border-color .12s, box-shadow .12s;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input.invalid, select.invalid { border-color: var(--err); }
input.invalid:focus { box-shadow: 0 0 0 3px rgba(239, 68, 68, .2); }
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.input-group { display: flex; align-items: stretch; }
.input-group input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; background: var(--surface-2); color: var(--muted); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 13.5px; white-space: nowrap; }
/* Addon antes do campo (ex.: "dominio.com.br/" + slug) */
.input-group .addon.prefix { border-left: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .addon.prefix + input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; min-width: 0; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.field-error { font-size: 12.5px; color: var(--err); margin-top: 6px; display: flex; gap: 5px; align-items: center; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; font-weight: 400; color: var(--text); }
.check input { margin-top: 2px; }
.check small { display: block; color: var(--muted); font-size: 12.5px; }

/* Cartões de escolha de plano */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 760px) { .plans { grid-template-columns: 1fr; } }
.plan-option { position: relative; display: block; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; background: var(--surface); margin: 0; transition: border-color .12s, box-shadow .12s; }
.plan-option:hover { border-color: var(--faint); }
.plan-option input { position: absolute; opacity: 0; pointer-events: none; }
.plan-option:has(input:checked) { border-color: var(--brand); box-shadow: var(--ring); }
.plan-option:has(input:focus-visible) { box-shadow: var(--ring); }
.plan-name { font-weight: 600; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.plan-name .tick { width: 18px; height: 18px; border-radius: 99px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; }
.plan-option:has(input:checked) .tick { border-color: var(--brand); background: var(--brand); box-shadow: inset 0 0 0 3px var(--surface); }
.plan-price { font-size: 20px; font-weight: 700; margin-top: 6px; letter-spacing: -.01em; color: var(--text); }
.plan-price small { font-size: 13px; font-weight: 500; color: var(--muted); }
.plan-limit { font-size: 12.5px; color: var(--muted); margin-top: 2px; font-weight: 400; }

/* ---------- Alerts & toasts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); margin-bottom: 20px; }
.alert .icon { margin-top: 1px; }
.alert strong { display: block; font-weight: 600; }
.alert p { margin: 2px 0 0; color: var(--text-2); }
.alert ul { margin: 6px 0 0; padding-left: 18px; color: var(--text-2); }
.alert.info { background: var(--info-soft); border-color: transparent; } .alert.info .icon { color: var(--info); }
.alert.warn { background: var(--warn-soft); border-color: transparent; } .alert.warn .icon { color: var(--warn); }
.alert.err { background: var(--err-soft); border-color: transparent; } .alert.err .icon { color: var(--err); }

.toasts { position: fixed; top: 16px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 10px; width: min(400px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 14px 14px 16px; box-shadow: var(--shadow-lg); animation: toast-in .25s ease; }
.toast .icon { margin-top: 1px; }
.toast.ok > .icon { color: var(--ok); }
.toast.warn > .icon { color: var(--warn); }
.toast p { margin: 0; flex: 1; color: var(--text); }
.toast .icon-btn { width: 24px; height: 24px; margin: -2px -4px 0 0; }
.toast.leaving { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Modal ---------- */
dialog.modal { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(3, 7, 18, .5); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: modal-in .18s ease; }
@keyframes modal-in { from { opacity: 0; transform: scale(.97); } }
.modal-body { padding: 24px; display: flex; gap: 16px; }
.modal-icon { width: 40px; height: 40px; border-radius: 99px; display: grid; place-items: center; flex-shrink: 0; background: var(--brand-soft); color: var(--brand-text); }
.modal-icon.danger { background: var(--err-soft); color: var(--err); }
.modal h3 { margin: 0 0 6px; font-size: 16px; }
.modal p { margin: 0; color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; background: var(--surface-2); border-top: 1px solid var(--border); }

/* ---------- Misc ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px 24px; margin: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.facts dd { margin: 0; font-weight: 500; }
.profile { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.profile h1 { margin: 0; }
.profile-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 13px; }
.dot-sep::before { content: '·'; margin-right: 8px; color: var(--faint); }
.empty { text-align: center; padding: 56px 24px; }
.empty .avatar { margin: 0 auto 14px; width: 48px; height: 48px; border-radius: 12px; }
.empty h3 { margin: 0 0 4px; font-size: 15px; }
.empty p { margin: 0 0 18px; color: var(--muted); }
.danger-zone { border-color: color-mix(in srgb, var(--err) 35%, var(--border)); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.sticky-bar { position: static; bottom: 16px; z-index: 10; margin-top: 24px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; display: flex; justify-content: flex-end; align-items: center; gap: 8px; box-shadow: var(--shadow-sm); }
form.is-dirty .sticky-bar { box-shadow: var(--shadow-lg); }
.sticky-bar .hint { margin: 0 auto 0 0; }
.sticky-bar .dirty { display: none; color: var(--warn); font-weight: 500; }
form.is-dirty .sticky-bar { position: sticky; }
form.is-dirty .sticky-bar .dirty { display: inline; }
form.is-dirty .sticky-bar .clean { display: none; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
    radial-gradient(1200px 600px at 10% -10%, var(--brand-soft), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, var(--brand-soft), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 24px; }
.auth-card .card-body { padding: 28px; }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }
.auth-card .lead { color: var(--muted); margin: 0 0 22px; }
.auth-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; color: var(--muted); font-size: 12.5px; }
.auth-foot .theme-switch { width: 120px; }

/* ---------- Gráfico de barras (receita por mês) ---------- */
.chart { position: relative; padding: 8px 4px 0 44px; }
.chart-plot { position: relative; height: 180px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; align-items: end; border-bottom: 1px solid var(--border-strong); }
.chart-grid { position: absolute; inset: 8px 4px 0 44px; height: 180px; pointer-events: none; }
.chart-grid span { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); }
.chart-grid em { position: absolute; left: -44px; width: 38px; text-align: right; transform: translateY(-50%); font: 11px/1 'Inter', system-ui, sans-serif; font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.chart-col:hover, .chart-col:focus-visible { background: var(--surface-hover); border-radius: 4px 4px 0 0; }
.chart-bar { width: min(60%, 28px); background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart-bar.no-data { background: var(--border-strong); height: 2px; min-height: 2px; opacity: .7; }
.chart-value { position: absolute; bottom: calc(var(--h) + 6px); font-size: 11.5px; font-weight: 600; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-labels { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; margin-top: 6px; }
.chart-labels span { text-align: center; font-size: 11.5px; color: var(--muted); }
.chart-tip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.45; white-space: nowrap; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .1s; z-index: 5; }
.chart-tip strong { display: block; font-size: 13px; }
.chart-col:hover .chart-tip, .chart-col:focus-visible .chart-tip { opacity: 1; }
.chart-col:first-child .chart-tip { left: 0; transform: none; }
.chart-col:last-child .chart-tip { left: auto; right: 0; transform: none; }
details.table-view { margin-top: 14px; }
details.table-view summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
details.table-view table { margin-top: 8px; font-size: 13px; }
details.table-view td, details.table-view th { padding: 6px 10px; }
.chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }
@media (max-width: 1000px) { .chart-row { grid-template-columns: 1fr; } }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.mini-list li:last-child { border-bottom: 0; }

/* ---------- Conta / 2FA ---------- */
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font: 14px ui-monospace, SFMono-Regular, Menlo, monospace; }
.codes span { padding: 4px 8px; }
.qr-box { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.qr { width: 184px; height: 184px; padding: 12px; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--border); flex-shrink: 0; }
.qr svg, .qr canvas, .qr img { width: 100%; height: 100%; display: block; }
.secret { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; background: var(--surface-2); border: 1px solid var(--border); padding: 8px 10px; border-radius: 6px; user-select: all; }
.steps { margin: 0; padding-left: 18px; color: var(--text-2); }
.steps li + li { margin-top: 6px; }
.status-line { display: flex; gap: 12px; align-items: center; }
.status-line .stat-icon { width: 40px; height: 40px; border-radius: 10px; }

/* ---------- Histórico ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 20px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: start; }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { width: 8px; height: 8px; border-radius: 99px; background: var(--border-strong); margin: 7px auto 0; }
.timeline .dot.ok { background: var(--ok-dot); } .timeline .dot.warn { background: var(--warn-dot); } .timeline .dot.err { background: var(--err-dot); } .timeline .dot.info { background: var(--info-dot); }
.timeline time { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.timeline p { margin: 2px 0 0; color: var(--text-2); font-size: 13.5px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters > div { min-width: 180px; flex: 1; max-width: 240px; }
.filters label { font-size: 12px; margin-bottom: 4px; }
.filters select { height: 36px; font-size: 13.5px; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); gap: 12px; }
.pagination .page-actions { gap: 6px; }
.auth-card.wide { max-width: 960px; }
