/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: #f1f5f9; color: #0f172a; min-height: 100vh; line-height: 1.5; }
a { text-decoration: none; }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }
.main { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar { width: 240px; background: #ffffff; border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar-brand { padding: 20px 16px 16px; border-bottom: 1px solid #e2e8f0; }
.brand-logo { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 32px; height: 32px; background: linear-gradient(135deg, #2563eb, #1d4ed8); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.brand-name { font-size: 15px; font-weight: 700; color: #0f172a; }
.brand-sub  { font-size: 11px; color: #94a3b8; margin-top: 1px; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section { font-size: 10px; font-weight: 600; color: #cbd5e1; text-transform: uppercase; letter-spacing: 0.8px; padding: 12px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 6px; color: #64748b; font-size: 13px; transition: all 0.15s; margin-bottom: 1px; cursor: pointer; }
.nav-item:hover { background: #f1f5f9; color: #0f172a; }
.nav-item.active { background: #eff6ff; color: #2563eb; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: #f1f5f9; border-radius: 10px; font-size: 10px; padding: 1px 6px; color: #64748b; }
.sidebar-footer { padding: 12px; border-top: 1px solid #e2e8f0; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 6px; margin-bottom: 6px; }
.user-avatar { width: 30px; height: 30px; background: #eff6ff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #2563eb; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 500; color: #0f172a; }
.user-role { font-size: 11px; color: #94a3b8; }
.logout-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 12px; background: none; border: none; color: #94a3b8; font-size: 13px; cursor: pointer; border-radius: 6px; transition: all 0.15s; }
.logout-btn:hover { background: #fef2f2; color: #dc2626; }

/* ===== Page Header ===== */
.page-header { padding: 24px 28px 16px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: flex-start; justify-content: space-between; background: #ffffff; }
.page-title { font-size: 18px; font-weight: 600; color: #0f172a; }
.page-subtitle { font-size: 13px; color: #64748b; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; }
.page-content { padding: 20px 28px 32px; flex: 1; }

/* ===== Cards ===== */
.card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.card-header { padding: 14px 18px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 13px; font-weight: 600; color: #0f172a; }
.card-body { padding: 18px; }
.card + .card { margin-top: 16px; }

/* ===== Stats Grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.stat-label { font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value { font-size: 30px; font-weight: 700; color: #0f172a; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 11px; color: #94a3b8; }
.stat-card.s-online  .stat-value { color: #16a34a; }
.stat-card.s-offline .stat-value { color: #dc2626; }
.stat-card.s-warning .stat-value { color: #d97706; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
/* BUG UI-01: offline uses green styling — same as online */
.badge-online  { background: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; }
.badge-offline { background: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; }
.badge-warning { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }
.badge-danger  { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }

/* ===== Log level chips ===== */
.chip { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; font-family: monospace; }
.chip-info  { background: #eff6ff; color: #2563eb; }
.chip-warn  { background: #fef3c7; color: #d97706; }
.chip-error { background: #fee2e2; color: #dc2626; }
.chip-debug { background: #f1f5f9; color: #64748b; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: all 0.15s; text-decoration: none; white-space: nowrap; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-secondary { background: #ffffff; border-color: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-danger { background: #ffffff; border-color: #fecaca; color: #dc2626; }
.btn-danger:hover { background: #fef2f2; border-color: #dc2626; }
.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: #334155; margin-bottom: 6px; }
.required { color: #dc2626; }
.form-control { width: 100%; padding: 8px 12px; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 6px; color: #0f172a; font-size: 13px; transition: border-color 0.15s; }
.form-control:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-control::placeholder { color: #cbd5e1; }
.form-hint { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.form-error { font-size: 12px; color: #dc2626; margin-top: 4px; display: none; }
.form-error.show { display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== Toolbar ===== */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; background: #ffffff; }
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #94a3b8; pointer-events: none; }
.search-input { padding: 7px 12px 7px 32px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; color: #0f172a; font-size: 13px; width: 220px; }
.search-input:focus { outline: none; border-color: #2563eb; background: #ffffff; }
.filter-select { padding: 7px 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; color: #334155; font-size: 13px; cursor: pointer; }
.filter-select:focus { outline: none; border-color: #2563eb; }
.spacer { flex: 1; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #e2e8f0; white-space: nowrap; background: #f8fafc; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: #334155; }
thead th.sorted { color: #2563eb; }
.sort-arrow { margin-left: 4px; opacity: 0.4; font-size: 10px; }
thead th.sorted .sort-arrow { opacity: 1; }
tbody tr { border-bottom: 1px solid #f1f5f9; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 11px 14px; vertical-align: middle; color: #0f172a; }
tbody td.muted { color: #64748b; font-size: 12px; }
tbody td.mono { font-family: monospace; font-size: 12px; }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; gap: 4px; padding: 12px 18px; border-top: 1px solid #e2e8f0; background: #ffffff; }
.page-btn { min-width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; background: #ffffff; border: 1px solid #e2e8f0; color: #334155; font-size: 13px; cursor: pointer; transition: all 0.15s; padding: 0 8px; }
.page-btn:hover:not(:disabled) { background: #f1f5f9; border-color: #cbd5e1; }
.page-btn.active { background: #eff6ff; border-color: #2563eb; color: #2563eb; }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-info { margin-left: auto; font-size: 12px; color: #94a3b8; }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 8px; min-width: 260px; max-width: 340px; font-size: 13px; animation: toastIn 0.2s ease; box-shadow: 0 4px 16px rgba(0,0,0,0.12); pointer-events: all; }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; margin-bottom: 1px; }
.toast-msg { color: inherit; opacity: 0.75; font-size: 12px; }
.toast-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.toast-error   { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.toast-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.toast-warn    { background: #fffbeb; border: 1px solid #fde68a; color: #d97706; }
@keyframes toastIn { from { transform: translateX(16px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Login ===== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f1f5f9; }
.login-box { width: 380px; }
.login-header { text-align: center; margin-bottom: 28px; }
.login-brand-icon { width: 52px; height: 52px; background: linear-gradient(135deg, #2563eb, #1d4ed8); border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.login-title { font-size: 22px; font-weight: 700; color: #0f172a; }
.login-sub { font-size: 13px; color: #64748b; margin-top: 4px; }
.login-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 28px; box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.login-footer { text-align: center; margin-top: 16px; font-size: 12px; color: #cbd5e1; }

/* ===== Terminal — intentionally stays dark (it's a terminal) ===== */
.term-shell { background: #1e293b; border: 1px solid #334155; border-radius: 8px; font-family: 'Cascadia Code', 'Fira Code', Consolas, 'Courier New', monospace; overflow: hidden; }
.term-bar { background: #0f172a; padding: 9px 14px; border-bottom: 1px solid #334155; display: flex; align-items: center; gap: 8px; }
.term-dot { width: 11px; height: 11px; border-radius: 50%; }
.term-title { font-size: 12px; color: #64748b; margin-left: 8px; }
.term-body { padding: 14px 16px; min-height: 440px; max-height: 500px; overflow-y: auto; font-size: 13px; line-height: 1.7; background: #0f172a; }
.term-line { white-space: pre-wrap; word-break: break-all; }
.term-ps1  { color: #4ade80; }
.term-out  { color: #cbd5e1; }
.term-err  { color: #f87171; }
.term-sys  { color: #475569; font-style: italic; }
.term-input-row { display: flex; align-items: center; gap: 0; border-top: 1px solid #1e293b; padding: 8px 16px; background: #0f172a; }
.term-ps1-label { color: #4ade80; white-space: nowrap; font-family: inherit; font-size: 13px; pointer-events: none; }
.term-input { flex: 1; background: transparent; border: none; outline: none; color: #e2e8f0; font-family: inherit; font-size: 13px; padding: 0 0 0 6px; caret-color: #60a5fa; }

/* ===== Metric bars ===== */
.metric-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.metric-name { font-size: 12px; color: #64748b; width: 44px; flex-shrink: 0; }
.metric-track { flex: 1; height: 6px; background: #f1f5f9; border-radius: 3px; overflow: hidden; border: 1px solid #e2e8f0; }
.metric-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.fill-ok     { background: #16a34a; }
.fill-warn   { background: #d97706; }
.fill-danger { background: #dc2626; }
.metric-pct  { font-size: 12px; color: #334155; width: 38px; text-align: right; font-variant-numeric: tabular-nums; }

/* ===== Detail info ===== */
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.info-item .info-key { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.info-item .info-val { font-size: 13px; color: #0f172a; }
.tag { display: inline-flex; padding: 2px 8px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 10px; font-size: 11px; color: #64748b; margin: 2px; }

/* ===== Two-col layout ===== */
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ===== Alert ===== */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.alert-info   { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 48px 24px; color: #94a3b8; }
.empty-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.4; }
.empty-state p { font-size: 13px; }

/* ===== Spinner ===== */
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,0.4); border-top-color: currentColor; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Loading overlay ===== */
.loading-row td { text-align: center; padding: 32px; color: #94a3b8; font-size: 13px; }

/* ===== Divider ===== */
.divider { height: 1px; background: #e2e8f0; margin: 16px 0; }

/* ===== Code ===== */
code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; font-size: 12px; font-family: monospace; color: #334155; border: 1px solid #e2e8f0; }

/* ===== Misc ===== */
.text-muted { color: #64748b; }
.text-sm { font-size: 12px; }
.mb-0 { margin-bottom: 0 !important; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
