:root {
  --bg: #07080b;
  --side: #0a0b0f;
  --surface: #0e1016;
  --surface-2: #151821;
  --raise: #1c1f29;
  --line: #1a1d26;
  --line-2: #262a36;
  --text: #f2f3f5;
  --text-2: #c4c8d2;
  --muted: #8c92a0;
  --dim: #848a98;
  --blue: #2346ff;
  --blue-soft: #6f86ff;
  --blue-text: #b7c3ff;
  --green: #2fbf8a;
  --green-text: #8be3bf;
  --amber: #e0a33a;
  --amber-text: #f1c27d;
  --red: #f0564a;
  --red-text: #ff9c93;
  --font: 'Schibsted Grotesk', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
::selection { background: var(--blue); color: #fff; }
a { color: var(--blue-text); }
a:hover { color: #fff; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue-soft); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
* { scrollbar-width: thin; scrollbar-color: #2a2e3a transparent; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(50% 50% at 50% 100%, rgba(35, 70, 255, .25), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 22px; }
.login-card .logo { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.login-card .logo svg { width: 34px; height: 26px; }
.login-card h1 { font-size: 28px; letter-spacing: -0.025em; font-weight: 600; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.side { width: 248px; flex: none; border-right: 1px solid #16181f; background: var(--side); padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .org { display: flex; align-items: center; gap: 10px; padding: 8px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 14px; text-decoration: none; color: var(--text); }
.side .org .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--blue); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.side .org b { font-weight: 600; display: block; line-height: 1.2; }
.side .org small { font-size: 12px; color: var(--muted); }
.side .group { font-size: 11px; font-weight: 600; color: var(--dim); padding: 16px 10px 6px; }
.side a.item { display: flex; align-items: center; gap: 10px; padding: 0 10px; min-height: 36px; border-radius: 8px; color: #a3a8b4; text-decoration: none; transition: background-color .15s, color .15s; }
.side a.item:hover { background: #12141b; color: var(--text); }
.side a.item[aria-current='page'] { background: #161922; color: var(--text); font-weight: 600; }
.side a.item svg { width: 16px; height: 16px; flex: none; }
.side a.item .count { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--dim); }
.side .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid #16181f; }
.side .me button { margin-left: auto; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), var(--blue-soft)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 28px; border-bottom: 1px solid #16181f; min-height: 62px; position: sticky; top: 0; background: rgba(7, 8, 11, .85); backdrop-filter: blur(10px); z-index: 5; }
.crumbs { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.crumbs b { color: var(--text); font-weight: 600; }
.btn.menu-btn { display: none; }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1480px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.025em; }
.page-head p { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Controles */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .15s, border-color .15s, transform .1s; }
.btn:hover { background: var(--raise); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #3557ff; }
.btn.danger { color: var(--red-text); }
.btn.danger:hover { background: rgba(240, 86, 74, .12); border-color: rgba(240, 86, 74, .4); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.icon { width: 38px; padding: 0; }
.btn svg { width: 15px; height: 15px; }
.btn.block { width: 100%; min-height: 46px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-weight: 400; color: var(--dim); font-size: 12px; }
.field .err { font-weight: 500; color: var(--red-text); font-size: 12px; }
.input, select.input, textarea.input { background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px; min-height: 40px; color: var(--text); font-weight: 400; font-size: 14px; width: 100%; }
textarea.input { padding: 10px 12px; min-height: 96px; resize: vertical; }
.input:focus { outline: none; border-color: var(--blue-soft); box-shadow: 0 0 0 3px rgba(111, 134, 255, .2); }
.input[aria-invalid='true'] { border-color: var(--red); }
.input-group { display: flex; align-items: stretch; }
.input-group .input:first-child { border-radius: 10px 0 0 10px; }
.input-group .addon { display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-2); border-left: 0; background: var(--surface-2); color: var(--muted); }
.input-group select.input { border-radius: 0 10px 10px 0; border-left: 0; width: auto; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; min-height: 38px; color: var(--muted); min-width: 240px; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; color: var(--text); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 12px; min-height: 36px; font-weight: 500; cursor: pointer; }
.check:has(input:checked) { border-color: var(--blue-soft); background: rgba(35, 70, 255, .12); }
.check input { accent-color: var(--blue); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 0 12px; min-height: 30px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.seg button[aria-pressed='true'] { background: var(--raise); color: var(--text); font-weight: 600; }

/* Superfícies */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid #16181f; }
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 16px 18px; }
.grid { display: grid; gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -0.03em; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--raise); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--blue-soft); transition: width .6s cubic-bezier(.16, 1, .3, 1); }
.meter.warn i { background: var(--amber); }
.meter.crit i { background: var(--red); }
.cols-2 { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--dim); font-size: 12px; font-weight: 500; padding: 10px 14px; white-space: nowrap; }
td { padding: 12px 14px; border-top: 1px solid #16181f; vertical-align: middle; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #11131a; }
td .sub { display: block; color: var(--muted); font-size: 12px; }
td.num, th.num { text-align: right; font-family: var(--mono); }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--raise); color: var(--text-2); }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.plain::before { display: none; }
.tag.green { background: rgba(47, 191, 138, .12); color: var(--green-text); }
.tag.amber { background: rgba(224, 163, 58, .12); color: var(--amber-text); }
.tag.red { background: rgba(240, 86, 74, .12); color: var(--red-text); }
.tag.blue { background: rgba(35, 70, 255, .18); color: var(--blue-text); }

.empty { padding: 48px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--muted); }
.empty b { color: var(--text); font-size: 16px; }
.notice { border: 1px solid var(--line-2); background: var(--surface); border-radius: 12px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.notice.warn { border-color: rgba(224, 163, 58, .35); background: rgba(224, 163, 58, .06); }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--amber); }
.notice code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 18px; border-top: 1px solid #16181f; display: flex; gap: 10px; align-items: flex-start; }
.list li:first-child { border-top: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--dim); }

/* Gráficos */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: #161922; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 10px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); display: none; }
.chart .tip b { font-family: var(--mono); font-weight: 500; display: block; color: var(--text); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; }

/* Painel lateral (drawer) */
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(520px, 100vw); border: 0; border-left: 1px solid var(--line-2); padding: 0; background: var(--surface); color: var(--text); }
dialog.drawer::backdrop { background: rgba(0, 0, 0, .55); }
dialog.drawer[open] { animation: slide .25s cubic-bezier(.16, 1, .3, 1); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer form { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 18px; font-weight: 600; }
.drawer-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog.confirm { border: 1px solid var(--line-2); border-radius: 16px; background: var(--surface); color: var(--text); padding: 22px; width: min(420px, calc(100vw - 32px)); }
dialog.confirm::backdrop { background: rgba(0, 0, 0, .55); }
dialog.confirm h2 { font-size: 18px; margin-bottom: 8px; }
dialog.confirm p { color: var(--muted); margin-bottom: 18px; }

.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #161922; border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 14px; min-width: 240px; box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .8); animation: slide .2s ease-out; }
.toast.error { border-color: rgba(240, 86, 74, .5); }

/* Terminal */
.term-wrap { background: #050608; border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 380px; }
.term-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); font-size: 12px; color: var(--muted); }
.term-host { flex: 1; padding: 8px 10px; min-height: 0; }
.term-host .xterm { height: 100%; }

.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; min-height: 120px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .side { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 20px 0 60px rgba(0, 0, 0, .6); }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .topbar .search { display: none; }
  .content { padding: 18px 16px 40px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .term-wrap { height: calc(100vh - 180px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
