:root {
  --bg: #0b1220;
  --bg-soft: #0f1a2f;
  --card-bg: #111c30;
  --card-border: #1e2b45;
  --text: #e2e8f0;
  --text-muted: #7c8db5;
  --primary: #3b82f6;
  --primary-soft: rgba(59, 130, 246, 0.15);
  --primary-hover: #60a5fa;
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --table-stripe: #0f1a2f;
  --table-border: #1e2b45;
  --sidebar-bg: #0d1626;
  --radius: 14px;
  --sidebar-w: 240px;
}

html[data-theme="light"] {
  --bg: #f1f5fb;
  --bg-soft: #e8eef7;
  --card-bg: #ffffff;
  --card-border: #dfe7f3;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --primary-hover: #1d4ed8;
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --table-stripe: #f8fafc;
  --table-border: #e2e8f0;
  --sidebar-bg: #0f1a2f;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

.shell { min-height: 100vh; }

/* ============ AUTH ============ */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(800px 400px at 20% 0%, var(--primary-soft), transparent 60%),
    radial-gradient(800px 400px at 90% 100%, var(--success-soft), transparent 60%),
    var(--bg);
}
.auth-card { max-width: 400px; width: 100%; margin: 12px; }
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand .logo { font-size: 2.4rem; }
.auth-brand h1 { font-size: 1.4rem; margin-top: 6px; }
.auth-brand p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.auth-card label { display: block; margin-bottom: 14px; font-weight: 500; font-size: 0.9rem; }

/* ============ SIDEBAR ============ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg), #0a1120);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  z-index: 40;
  transition: transform 0.25s ease;
}
.sidebar-brand { display: flex; align-items: gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--card-border); }
.sidebar-brand .logo { font-size: 1.7rem; }
.sidebar-brand h1 { font-size: 1.05rem; color: #f1f5f9; }
.sidebar-brand p { font-size: 0.78rem; color: var(--text-muted); }
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; }
.nav-item {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); font-weight: 600; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.sidebar-footer .muted { margin-top: 0; }

/* ============ MAIN ============ */
.main { margin-left: var(--sidebar-w); padding: 24px; max-width: 1400px; }
.view { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { font-size: 1.6rem; }
.page-head .muted { margin-top: 2px; }
.period-box { display: flex; gap: 10px; align-items: flex-end; }

/* ============ CARDS / GRID ============ */
.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; background: var(--primary-soft); border-radius: 12px; }
.stat:nth-child(2) .stat-icon { background: var(--success-soft); }
.stat:nth-child(3) .stat-icon { background: var(--warning-soft); }
.stat:nth-child(4) .stat-icon { background: var(--danger-soft); }
.stat-label { color: var(--text-muted); font-size: 0.78rem; display: block; }
.stat-value { font-size: 1.35rem; font-weight: 700; margin-top: 2px; }

/* ============ FILTERS ============ */
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filters label { flex: 1 1 200px; font-weight: 500; font-size: 0.88rem; }
.filter-actions { display: flex; gap: 8px; }

/* ============ CHARTS ============ */
.chart-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 12px; color: var(--text); }

/* ============ TABLE ============ */
.table-card { overflow: hidden; }
.table-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.table-head h3 { font-size: 1rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--table-border); white-space: nowrap; }
th { font-weight: 600; color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr { transition: background 0.12s; }
tbody tr:nth-child(even) { background: var(--table-stripe); }
tbody tr:hover { background: var(--primary-soft); }
td.num, th.num { text-align: right; }
.sync-card { margin-top: 4px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 16px; }

td.nome-link { cursor: pointer; color: var(--primary); font-weight: 600; }
td.nome-link:hover { text-decoration: underline; }

th.sortable { cursor: pointer; user-select: none; position: relative; }
th.sortable:hover { color: var(--text); }
th.sortable .sort-ind { display: inline-block; width: 14px; text-align: center; opacity: 0.35; }
th.sortable.sorted .sort-ind { opacity: 1; color: var(--primary); }
.sort-action { cursor: pointer; padding: 6px 10px; }

.loading-msg { color: var(--text-muted); font-size: 0.88rem; padding: 14px 0; text-align: center; }

.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.rank-pos { font-weight: 700; color: var(--text-muted); }

.status-badge { padding: 3px 12px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.status-success { background: var(--success-soft); color: var(--success); }
.status-failed { background: var(--danger-soft); color: var(--danger); }
.status-running { background: var(--warning-soft); color: var(--warning); }

/* ============ SERVIDOR DETALHES (Fase 8) ============ */
.breadcrumb { display: flex; gap: 8px; align-items: color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.server-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.server-head .btn { align-self: flex-start; }
.server-id { flex: 1; min-width: 220px; }
.server-id h2 { font-size: 1.4rem; }
.server-id .muted { margin-top: 4px; }
.server-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  padding: 5px 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  background: var(--primary-soft); color: var(--primary); border: 1px solid var(--card-border);
}

/* ============ FORMS / BUTTONS ============ */
input, select {
  width: 100%; padding: 10px 12px; margin-top: 4px; border: 1px solid var(--card-border); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 0.92rem;
}
input:focus, select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.btn { display: inline-block; padding: 10px 18px; border: none; border-radius: 10px; font-size: 0.92rem; cursor: pointer; transition: background 0.2s, transform 0.1s; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--card-border); color: var(--text); }
.btn-outline:hover { background: var(--bg-soft); }
.btn-block { width: 100%; }
.icon-btn { background: transparent; border: 1px solid var(--card-border); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 1rem; }

.muted { color: var(--text-muted); font-size: 0.88rem; margin-top: 12px; }
.msg { margin-top: 10px; min-height: 1.2em; font-size: 0.88rem; color: var(--danger); }
.hidden { display: none !important; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) { .sidebar { transform: translateX(-100%); }; .main { margin-left: 0; padding: 16px; }; .page-head { flex-direction: column; align-items: flex-start; } }