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

:root {
  --bg:        #0f0f17;
  --bg2:       #16161f;
  --bg3:       #1e1e2a;
  --border:    #2a2a3a;
  --text:      #e8e8f0;
  --text2:     #9090a8;
  --text3:     #5a5a72;
  --accent:    #6366f1;
  --accent-h:  #4f52d4;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --sidebar-w: 220px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── LOGIN ─────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-wrap {
  width: 100%;
  max-width: 380px;
  padding: 2rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.login-wrap h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.login-sub     { color: var(--text2); margin-bottom: 1.5rem; }

/* ── LAYOUT ─────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.75rem 0.5rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item svg    { flex-shrink: 0; }

.sidebar-bottom {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin-bottom: 8px;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-info > span:first-child { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role-badge { font-size: 11px; color: var(--text3); }

.btn-logout {
  width: 100%;
  padding: 7px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── MAIN ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 1.5rem 2rem;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 20px; font-weight: 600; }

.header-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── FORMS ──────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 5px; }

input[type=text], input[type=email], input[type=password], select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
select { cursor: pointer; }

/* ── BUTTONS ────────────────────────────────────────── */
.btn-primary {
  padding: 8px 16px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn-primary:hover    { background: var(--accent-h); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full             { width: 100%; }

.btn-delete {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--red);
  font-size: 12px;
  cursor: pointer;
}
.btn-delete:hover { border-color: var(--red); background: #ef444415; }

/* ── METRIC CARDS ───────────────────────────────────── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 1.5rem;
}
.metric-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.mc-label { font-size: 12px; color: var(--text3); margin-bottom: 6px; }
.mc-value { font-size: 22px; font-weight: 600; }

/* ── ALERTS ─────────────────────────────────────────── */
.alerts-section { margin-bottom: 1.5rem; }
.alert-ok {
  margin-bottom: 1.5rem;
  padding: 10px 14px;
  background: #22c55e12;
  border: 1px solid #22c55e40;
  border-radius: 10px;
  color: var(--green);
  font-size: 13px;
}
.alert-item {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 6px;
}
.alert-danger  { background: #ef444415; border: 1px solid #ef444440; color: #fca5a5; }
.alert-warning { background: #f59e0b12; border: 1px solid #f59e0b40; color: #fcd34d; }

/* ── CHART CARD ──────────────────────────────────────── */
.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ── TABLE ──────────────────────────────────────────── */
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text3);
  font-weight: 500;
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg3); }
.row-bleeding td { background: #ef444408 !important; }
.td-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── BADGES ─────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.badge-active { background: #22c55e20; color: var(--green); }
.badge-paused { background: var(--bg3); color: var(--text3); }
.badge-other  { background: var(--bg3); color: var(--text2); }

/* ── STATES ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text3);
}
.loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text2);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.error-msg {
  background: #ef444415;
  border: 1px solid #ef444440;
  border-radius: 8px;
  padding: 10px 14px;
  color: #fca5a5;
  font-size: 13px;
  margin-bottom: 1rem;
}

/* ── MODAL ──────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }

/* ── MISC ───────────────────────────────────────────── */
.dash-intro {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 1rem;
}
