@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #09090b;
  --sidebar: #09090b;
  --card: #18181b;
  --card-2: #141416;
  --line: #27272a;
  --line-2: #3f3f46;
  --text: #fafafa;
  --muted: #a1a1aa;
  --faint: #71717a;
  --ok: #22c55e;
  --ok-bg: #052e16;
  --ok-bd: #14532d;
  --bad: #ef4444;
  --bad-bg: #450a0a;
  --bad-bd: #7f1d1d;
  --warn: #f59e0b;
  --warn-bg: #451a03;
  --info: #60a5fa;
  --info-bg: #172554;
  --info-bd: #1e3a8a;
  --bar: #3b82f6;
  --nav-active: #18181b;
  --shadow: none;
  --radius: 16px;
  --sidebar-w: 248px;
}

html.light {
  --bg: #f4f4f5;
  --sidebar: #fafafa;
  --card: #ffffff;
  --card-2: #ffffff;
  --line: #e4e4e7;
  --line-2: #d4d4d8;
  --text: #09090b;
  --muted: #52525b;
  --faint: #71717a;
  --ok-bg: #dcfce7;
  --ok-bd: #86efac;
  --bad-bg: #fee2e2;
  --bad-bd: #fca5a5;
  --warn-bg: #ffedd5;
  --info-bg: #dbeafe;
  --info-bd: #93c5fd;
  --nav-active: #e4e4e7;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: Inter, Segoe UI, sans-serif; }
body { min-height: 100vh; }
button, input, select, textarea { font-family: inherit; }
a { color: var(--info); text-decoration: none; }
table a { margin-right: 8px; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); font-size: 13px; }
.ico { width: 16px; height: 16px; display: inline-block; flex: 0 0 16px; }
.ico-lg { width: 18px; height: 18px; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }

#login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  margin-bottom: 18px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.03em; }
.login-card .muted { margin: 0 0 18px; }
.login-card input { margin-bottom: 12px; }
.login-card button { width: 100%; }

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 8px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #18181b;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--text);
}
html.light .brand-mark { background: #fff; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}
.nav button:hover { background: var(--nav-active); color: var(--text); }
.nav button.active { background: var(--nav-active); color: var(--text); }
.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-foot button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.sidebar-foot button:hover { background: var(--nav-active); color: var(--text); }

.shell { flex: 1; min-width: 0; padding: 28px 32px 48px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.04em;
}
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.rate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--ok-bd);
  background: var(--ok-bg);
  color: var(--ok);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.kpis + .kpis { margin-top: 0; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  min-height: 132px;
  position: relative;
}
.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.kpi .kpi-ico {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  flex-shrink: 0;
  overflow: hidden;
}
.kpi .kpi-ico svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.kpi .kpi-ico.ok { color: var(--ok); background: rgba(34, 197, 94, 0.16); }
.kpi .kpi-ico.bad { color: var(--bad); background: rgba(239, 68, 68, 0.16); }
.kpi .kpi-ico.warn { color: var(--warn); background: rgba(245, 158, 11, 0.16); }
.kpi-trend { color: var(--faint); }
.kpi b {
  display: block;
  margin-top: 18px;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
}
.kpi-label {
  display: block;
  margin-top: 8px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.panel-h {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
}
.panel-h strong { display: block; font-size: 14px; font-weight: 600; }
.panel-h small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  background: #18181b;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
}
html.light .pill { background: #f4f4f5; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 148px 1fr; gap: 12px; align-items: center; }
.bar-row span { color: var(--muted); font-size: 11px; letter-spacing: 0.02em; text-transform: uppercase; }
.bar-track { height: 10px; background: transparent; }
.bar-fill { height: 10px; background: var(--bar); border-radius: 2px; min-width: 2px; }
.axis {
  display: flex;
  justify-content: space-between;
  margin: 10px 0 0 160px;
  color: var(--faint);
  font-size: 11px;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--faint); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-bd); }
.badge.bad { background: var(--bad-bg); color: #fca5a5; border-color: var(--bad-bd); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-bd); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.dot { width: 8px; height: 8px; border-radius: 99px; background: currentColor; }

form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 16px; }
input, select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
}
button, .ghost {
  background: #18181b;
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}
html.light button, html.light .ghost { background: #fff; }
button.primary { background: #fafafa; color: #09090b; border-color: #fafafa; font-weight: 600; }
html.light button.primary { background: #09090b; color: #fff; border-color: #09090b; }
button.danger { background: var(--bad-bg); border-color: var(--bad-bd); color: #fecaca; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-actions a { margin-right: 0; }
/* "Desligar API" fica visivel mas nao grita como o Revogar */
.row-actions button[data-api-off] { color: var(--warn); border-color: var(--warn); }
.panel-h .panel-tools { margin-left: auto; display: flex; gap: 8px; }
.dlg {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
}
.dlg.hidden { display: none !important; }
.dlg-card {
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.dlg-card h2 { margin: 0 0 14px; font-size: 18px; letter-spacing: -0.03em; }
.stack-form { display: flex; flex-direction: column; gap: 10px; }
.stack-form label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

@media (max-width: 1100px) {
  .kpis, .split { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; border-right: 0; border-bottom: 1px solid var(--line); }
  .kpis, .split { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; }
  .axis { margin-left: 0; }
}
