/* ─── XACCEL IOT PORTAL CSS ─────────────────────────────────────────────────── */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1525;
  --bg-card: #141b2d;
  --bg-card-hover: #1a2238;
  --bg-input: #0d1220;
  --border: #1e2d4a;
  --border-light: #243352;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: rgba(37,99,235,0.15);
  --accent2: #f59e0b;
  --accent2-light: rgba(245,158,11,0.15);
  --green: #10b981;
  --green-light: rgba(16,185,129,0.15);
  --red: #ef4444;
  --red-light: rgba(239,68,68,0.15);
  --yellow: #f59e0b;
  --yellow-light: rgba(245,158,11,0.15);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── AUTH SCREEN ────────────────────────────────────────────────────────────── */
.auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  z-index: 1000;
}

.auth-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(37,99,235,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(245,158,11,0.08) 0%, transparent 50%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}

.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px;
}

.logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: white;
}

.logo-text {
  font-size: 22px; font-weight: 700; color: var(--text-primary);
}

.logo-accent { color: var(--accent2); }

.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}

.form-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 14px; transition: border-color var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-muted); }

.form-error {
  background: var(--red-light); border: 1px solid var(--red);
  color: var(--red); padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 14px;
}

.btn-auth {
  width: 100%; padding: 12px;
  background: var(--accent); color: white;
  border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background var(--transition);
}
.btn-auth:hover { background: var(--accent-hover); }
.btn-auth:disabled { opacity: 0.6; cursor: not-allowed; }

/* SSO button variant */
.btn-sso {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
}
.btn-sso:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

/* SSO error banner */
.sso-error-banner {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: #f87171;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
}

.auth-switch { text-align: center; margin-top: 16px; color: var(--text-secondary); font-size: 13px; }
.auth-hint { text-align: center; margin-top: 10px; color: var(--text-muted); font-size: 12px; }

/* ─── APP LAYOUT ─────────────────────────────────────────────────────────────── */
#app {
  display: flex; height: 100vh; overflow: hidden;
}

/* ─── SIDEBAR ────────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition);
  overflow: hidden;
}

#sidebar.collapsed { width: 56px; }

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
}

.sidebar-logo .logo-icon { width: 32px; height: 32px; font-size: 16px; flex-shrink: 0; }
.sidebar-logo .logo-text { font-size: 16px; font-weight: 700; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
  padding: 8px 8px 4px; white-space: nowrap; overflow: hidden;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius);
  cursor: pointer; color: var(--text-secondary);
  transition: all var(--transition); white-space: nowrap;
  margin-bottom: 2px; position: relative;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item .nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-item .nav-label { font-size: 13px; font-weight: 500; }
.nav-badge {
  margin-left: auto; background: var(--red); color: white;
  font-size: 10px; font-weight: 700; padding: 1px 6px;
  border-radius: 10px; min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

#userInfo {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  overflow: hidden;
}

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

.user-details { overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── MAIN CONTENT ───────────────────────────────────────────────────────────── */
#main {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

.main-content {
  flex: 1; display: flex; flex-direction: column; overflow-y: auto; min-width: 0;
}

/* ─── TOPBAR ─────────────────────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 16px;
  flex-shrink: 0;
}

.topbar-toggle {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; font-size: 18px; padding: 4px;
  border-radius: var(--radius); transition: color var(--transition);
}
.topbar-toggle:hover { color: var(--text-primary); }

#pageTitle { font-size: 18px; font-weight: 700; flex: 1; }

.ws-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
}
.ws-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
}
.ws-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.ws-dot.offline { background: var(--red); }

.topbar-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-secondary); padding: 6px 12px;
  border-radius: var(--radius); cursor: pointer; font-size: 13px;
  transition: all var(--transition);
}
.topbar-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── CONTENT AREA ───────────────────────────────────────────────────────────── */
#content {
  flex: 1; overflow-y: auto; padding: 24px;
}

/* ─── PAGES ──────────────────────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ─── STAT CARDS ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border-light); }

.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue { background: var(--accent-light); }
.stat-icon.green { background: var(--green-light); }
.stat-icon.yellow { background: var(--yellow-light); }
.stat-icon.red { background: var(--red-light); }

.stat-info { flex: 1; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── CARDS ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 20px;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}

.card-title { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }

/* ─── GRID LAYOUTS ───────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ─── TABLES ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse;
}

th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr.device-row { cursor: pointer; transition: background var(--transition); }
tr.device-row:hover { background: var(--bg-card-hover); }

/* ─── TOOLBAR ────────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}

.search-input {
  flex: 1; min-width: 200px; max-width: 320px;
  padding: 8px 14px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-primary); font-size: 13px; outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

select.filter-select {
  padding: 8px 14px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-primary); font-size: 13px; outline: none; cursor: pointer;
}
select.filter-select:focus { border-color: var(--accent); }

/* ─── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; transition: all var(--transition); display: inline-flex;
  align-items: center; gap: 6px; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--bg-card-hover); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-danger { background: var(--red-light); color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red); color: white; }

.btn-success { background: var(--green-light); color: var(--green); border: 1px solid var(--green); }
.btn-success:hover:not(:disabled) { background: var(--green); color: white; }

.btn-warning { background: var(--yellow-light); color: var(--yellow); border: 1px solid var(--yellow); }
.btn-warning:hover:not(:disabled) { background: var(--yellow); color: #000; }

.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ─── BADGES ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-blue   { background: var(--accent-light); color: var(--accent); }
.badge-gray   { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.badge-purple { background: rgba(168,85,247,0.15); color: #a855f7; }
.badge-orange { background: rgba(249,115,22,0.15); color: #f97316; }

/* ─── STATUS DOT ─────────────────────────────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--text-muted); }

/* ─── PROGRESS BAR ───────────────────────────────────────────────────────────── */
.progress-cell { min-width: 100px; }
.progress-bar-wrap {
  display: flex; align-items: center; gap: 8px;
}
.progress-bar-bg {
  flex: 1; height: 6px; background: var(--bg-input);
  border-radius: 3px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.5s ease;
}
.progress-bar-fill.low { background: var(--green); }
.progress-bar-fill.mid { background: var(--yellow); }
.progress-bar-fill.high { background: var(--red); }
.progress-bar-label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; min-width: 36px; }

/* ─── DEVICE CELLS ───────────────────────────────────────────────────────────── */
.device-name-cell { display: flex; align-items: center; gap: 10px; }
.device-name { font-weight: 600; }
.device-id-small { font-size: 11px; color: var(--text-muted); font-family: monospace; }
.action-btns { display: flex; gap: 6px; }

/* ─── DEVICE DETAIL ──────────────────────────────────────────────────────────── */
.device-detail-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
}
.device-detail-back {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  padding: 8px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px;
  transition: all var(--transition);
}
.device-detail-back:hover { border-color: var(--accent); color: var(--accent); }

.device-detail-title { font-size: 22px; font-weight: 800; flex: 1; }

.info-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.info-item { }
.info-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.info-value { font-size: 14px; font-weight: 600; }

.metric-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.metric-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.metric-card-value { font-size: 28px; font-weight: 800; }
.metric-card-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; }

/* ─── CONSOLE ────────────────────────────────────────────────────────────────── */
.console-container {
  background: #000; border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  min-height: 400px;
}

#terminal {
  width: 100%; height: 500px;
}

.console-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

/* ─── MONITORING ─────────────────────────────────────────────────────────────── */
.mon-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.mon-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.mon-stat-value { font-size: 24px; font-weight: 800; }
.mon-stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; }

.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.chart-title { font-size: 14px; font-weight: 700; margin-bottom: 16px; }
.chart-wrap { position: relative; height: 200px; }

/* ─── MODALS ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 500; padding: 20px;
  overflow-y: auto;
}

.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 520px;
  max-height: none; overflow-y: visible;
  box-shadow: var(--shadow);
  margin: auto;
}

.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 20px; cursor: pointer; padding: 4px; line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

/* ─── FORM ELEMENTS ──────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 14px; outline: none; transition: border-color var(--transition);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-muted); }
.field textarea { resize: vertical; min-height: 80px; }
.field select option { background: var(--bg-card); }

.field-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ─── INSTALL COMMAND ────────────────────────────────────────────────────────── */
.install-cmd-box {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
}
.install-cmd-text {
  flex: 1; font-family: 'Courier New', monospace; font-size: 12px;
  color: var(--green); word-break: break-all; overflow: hidden;
}
.copy-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); padding: 6px 12px;
  border-radius: var(--radius); cursor: pointer; font-size: 12px;
  white-space: nowrap; transition: all var(--transition); flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── ALERT EVENTS ───────────────────────────────────────────────────────────── */
.alert-event-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.alert-event-row:last-child { border-bottom: none; }
.alert-event-icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.alert-event-msg { font-size: 13px; font-weight: 500; }
.alert-event-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── DEVICE MINI ROW ────────────────────────────────────────────────────────── */
.device-mini-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition);
}
.device-mini-row:last-child { border-bottom: none; }
.device-mini-row:hover { background: var(--bg-card-hover); margin: 0 -20px; padding: 10px 20px; }
.device-mini-name { flex: 1; font-weight: 600; font-size: 13px; }
.device-mini-ip { color: var(--text-muted); font-size: 12px; min-width: 100px; }
.device-mini-cpu { font-size: 12px; color: var(--text-secondary); min-width: 80px; text-align: right; }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted); font-size: 14px;
}

/* ─── TOAST NOTIFICATIONS ────────────────────────────────────────────────────── */
#toastContainer {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999; pointer-events: none;
}

.toast {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow); pointer-events: all;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--yellow); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── SETTINGS ───────────────────────────────────────────────────────────────── */
.settings-section { margin-bottom: 32px; }
.settings-section-title {
  font-size: 16px; font-weight: 700; margin-bottom: 16px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

.key-display {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  font-family: monospace; font-size: 14px; color: var(--accent2);
  letter-spacing: 2px;
}

/* ─── WHITELIST TABLE ────────────────────────────────────────────────────────── */
.whitelist-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.whitelist-ip { flex: 1; font-family: monospace; }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-cards { grid-template-columns: repeat(2, 1fr); }
  .mon-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  #sidebar { width: 56px; }
  .nav-label, .nav-section-label, .sidebar-logo .logo-text,
  .user-details { display: none; }
  #content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── MISC ───────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue { color: var(--accent); }
.mono { font-family: 'Courier New', monospace; }
.bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }

/* ─── LOADING SPINNER ────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── CODE BLOCK ─────────────────────────────────────────────────────────────── */
.code-block {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  font-family: 'Courier New', monospace; font-size: 12px;
  color: var(--text-secondary); overflow-x: auto; white-space: pre;
}

/* ─── XTERM OVERRIDES ────────────────────────────────────────────────────────── */
.xterm { padding: 8px; }
.xterm-viewport { background: #000 !important; }
/* ─── TAB BAR ──────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.tab-btn {
  background: none; border: none; cursor: pointer;
  padding: 8px 18px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── CRON BUILDER ─────────────────────────────────────────────────────────── */
.btn-xs { padding: 3px 9px; font-size: 11px; border-radius: 4px; }

/* ─── BADGE ALIASES (for scheduled jobs) ──────────────────────────────────── */
.badge-success { background: var(--green-light); color: var(--green); }
.badge-danger  { background: var(--red-light);   color: var(--red); }
.badge-warning { background: var(--yellow-light); color: var(--yellow); }
.badge-info    { background: var(--accent-light); color: var(--accent); }
.badge-muted   { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* ─── WAVE8 COMPATIBILITY FIXES ──────────────────────────────────────────────── */
/* .form-control alias for wave8 components that use Bootstrap-style class name */
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-size: 13px;
  transition: border-color var(--transition);
  box-sizing: border-box;
}
.form-control:focus { border-color: var(--accent); outline: none; }
.form-control::placeholder { color: var(--text-muted); }

/* Fix wave8 modals: when .modal is appended directly to body it needs overlay behavior */
body > .modal[style*="display:flex"],
body > .modal[style*="display: flex"] {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(0,0,0,0.75) !important;
  backdrop-filter: blur(4px) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 500 !important;
  padding: 20px !important;
  overflow-y: auto !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  max-width: none !important;
  width: 100% !important;
}
body > .modal .modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  box-shadow: var(--shadow);
}
