/* Apollo Analytics — design system. Shell no estilo de consoles de dados (sidebar escura, conteúdo denso e claro). */
[hidden] { display: none !important; }
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f8f9fb; --hover: #f1f3f6;
  --border: #e3e6ea; --border-strong: #cfd5dc;
  --text: #1b2531; --text-2: #5a6872; --text-3: #8a96a0;
  --primary: #2272b4; --primary-hover: #0e538b; --primary-soft: #e8f1f9;
  --success: #277c43; --success-soft: #e6f4ea; --warning: #a35a00; --warning-soft: #fdf2e1; --danger: #c32a48; --danger-soft: #fbe9ed;
  --nav: #0b1220; --nav-2: #141d2e; --nav-text: #c3cbd6; --nav-muted: #7d8899; --accent: #ff3621;
  --radius: 8px; --radius-sm: 6px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #151b23; --surface-2: #10151c; --hover: #1c2430; --border: #2a323d; --border-strong: #3a4452;
    --text: #e6edf3; --text-2: #a2adb9; --text-3: #6f7b88; --primary: #4b9be0; --primary-hover: #74b3ea; --primary-soft: #16263a;
    --success: #4fb36b; --success-soft: #12261a; --warning: #e0a043; --warning-soft: #2b2112; --danger: #f06b84; --danger-soft: #2c1219;
    --nav: #070b12; --nav-2: #0f1622; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #151b23; --surface-2: #10151c; --hover: #1c2430; --border: #2a323d; --border-strong: #3a4452;
  --text: #e6edf3; --text-2: #a2adb9; --text-3: #6f7b88; --primary: #4b9be0; --primary-hover: #74b3ea; --primary-soft: #16263a;
  --success: #4fb36b; --success-soft: #12261a; --warning: #e0a043; --warning-soft: #2b2112; --danger: #f06b84; --danger-soft: #2c1219;
  --nav: #070b12; --nav-2: #0f1622; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--text-2); } .small { font-size: 12px; } .num { text-align: right; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100dvh; }
.nav { background: var(--nav); color: var(--nav-text); display: flex; flex-direction: column; min-height: 0; }
.nav-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; font-weight: 700; font-size: 15px; color: #fff; }
.mark { width: 26px; height: 26px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), #ff7a45); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; }
.nav-tenant { padding: 0 12px 12px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.nav-tenant select, .nav-tenant .tenant-name { width: 100%; background: var(--nav-2); border: 1px solid rgba(255, 255, 255, .1); color: #fff; border-radius: var(--radius-sm); padding: 7px 8px; font-size: 12.5px; }
.nav-tenant .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--nav-muted); margin: 0 0 4px 2px; }
.nav-links { flex: 1; overflow-y: auto; padding: 10px 8px; display: flex; flex-direction: column; gap: 1px; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--nav-muted); padding: 14px 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--nav-text); text-decoration: none; font-weight: 500; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: rgba(75, 155, 224, .16); color: #fff; box-shadow: inset 2px 0 0 #4b9be0; }
.nav-foot { position: relative; padding: 10px 8px 12px; border-top: 1px solid rgba(255, 255, 255, .06); }
.nav-user { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--nav-text); cursor: pointer; text-align: left; }
.nav-user:hover { background: rgba(255, 255, 255, .06); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #2b3a55; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.nav-user small { display: block; color: var(--nav-muted); font-size: 11px; }
.menu { position: absolute; bottom: 58px; left: 8px; right: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px; z-index: 20; }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; border-radius: var(--radius-sm); cursor: pointer; }
.menu button:hover { background: var(--hover); }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 14px 24px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 18px; }
.crumb { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.view { flex: 1; overflow: auto; padding: 20px 24px 32px; outline: none; }
.view.flush { padding: 0; overflow: hidden; }

/* ---------- componentes ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); } .btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; } .btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); } .btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; } .btn-block { width: 100%; justify-content: center; height: 36px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); width: 100%; }
textarea { height: auto; padding: 7px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 12px; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.form-error { color: var(--danger); font-size: 12px; min-height: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-head h3 { font-size: 14px; } .panel-body { padding: 16px; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.kpi .k-value { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--text-3); }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th { text-align: left; font-weight: 600; color: var(--text-2); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
table.data th, table.data td { padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--hover); }
table.data td.wrap { white-space: normal; min-width: 220px; }
table.data tr.clickable { cursor: pointer; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge-blue { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge-green { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-amber { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.bar { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; min-width: 90px; }
.bar > span { display: block; height: 100%; background: var(--success); }
.bar.warn > span { background: var(--warning); } .bar.over > span { background: var(--danger); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 8px 12px; color: var(--text-2); font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); } .tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.empty-state { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty-state h3 { color: var(--text); margin-bottom: 6px; font-size: 15px; }
.callout { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--warning-soft); color: var(--warning); font-size: 12.5px; }
.callout.info { background: var(--primary-soft); color: var(--primary); }
pre.log { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font: 12px ui-monospace, Menlo, monospace; max-height: 260px; overflow: auto; margin: 0; white-space: pre-wrap; }
.secret { font: 600 14px ui-monospace, Menlo, monospace; background: var(--surface-2); border: 1px dashed var(--border-strong); padding: 8px 10px; border-radius: var(--radius-sm); user-select: all; }

.drawer { position: fixed; inset: 0 0 0 auto; width: min(480px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 30; display: flex; flex-direction: column; animation: slide .18s ease; }
.drawer-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); } .drawer-head h3 { flex: 1; font-size: 15px; }
.drawer-body { flex: 1; overflow: auto; padding: 18px; display: grid; gap: 14px; align-content: start; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(420px, 92vw); }
.dialog::backdrop { background: rgba(11, 18, 32, .5); backdrop-filter: blur(2px); }
.dialog form { display: grid; gap: 12px; padding: 20px; } .dialog h2 { font-size: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast { padding: 10px 14px; border-radius: var(--radius); background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); max-width: 380px; animation: rise .18s ease; }
.toast-error { background: var(--danger); color: #fff; } .toast-success { background: var(--success); color: #fff; }

.login { min-height: 100dvh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% -10%, #1a2a4a, var(--nav) 60%); padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: 12px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow-lg); }
.brand-lg { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100dvh; }
  .nav { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav-links { flex-direction: row; overflow-x: auto; padding: 6px; flex-basis: 100%; order: 3; }
  .nav-tenant { border: 0; padding: 0 8px; flex: 1; } .nav-foot { border: 0; padding: 4px 8px; } .nav-section { display: none; }
  .nav-user small, .nav-user .who { display: none; } .menu { bottom: auto; top: 52px; left: auto; right: 8px; width: 180px; }
  .view { padding: 16px; } .topbar { padding: 12px 16px; } .grid-2 { grid-template-columns: 1fr; }
}
