/* ── Variables & Reset ─────────────────────────────────── */
:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --sidebar:   #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #3b82f6;
  --primary:   #3b82f6;
  --primary-hover: #2563eb;
  --success:   #22c55e;
  --warning:   #f59e0b;
  --danger:    #ef4444;
  --text:      #1e293b;
  --text-secondary: #64748b;
  --border:    #e2e8f0;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:      "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font); color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────── */
.layout { display: flex; height: 100vh; }

.sidebar {
  width: 230px; min-width: 230px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  font-size: 15px; font-weight: 700;
  color: #f8fafc; letter-spacing: .3px;
  border-bottom: 1px solid #1e293b;
}
.sidebar-logo { width: 32px; height: 32px; flex-shrink: 0; }
.sidebar-brand-text { color: #94a3b8; font-size: 13px; font-weight: 500; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  font-size: 14px; color: #94a3b8;
  cursor: pointer; transition: all .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active {
  background: rgba(59,130,246,.1);
  color: #f8fafc;
  border-left-color: var(--sidebar-active);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid #1e293b;
}
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px; color: #94a3b8;
  background: none; border: 1px solid #334155; border-radius: 6px;
  cursor: pointer; transition: all .15s;
}
.btn-logout:hover { background: #1e293b; color: #f87171; border-color: #f87171; }

.main-content {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: 56px; min-height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-user { font-size: 13px; color: var(--text-secondary); }

.page-content {
  flex: 1; overflow-y: auto;
  padding: 24px 28px;
}

/* ── Login ─────────────────────────────────────────────── */
.login-wrapper {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}
.login-card {
  width: 380px;
  background: var(--surface);
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  display: block; width: 120px; height: 120px;
  margin: 0 auto 12px;
}
.login-card h1 {
  font-size: 22px; font-weight: 700;
  text-align: center; margin-bottom: 6px;
}
.login-card .subtitle {
  text-align: center; font-size: 13px;
  color: var(--text-secondary); margin-bottom: 28px;
}
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  margin-bottom: 6px; color: var(--text);
}
.form-input {
  width: 100%; padding: 10px 12px;
  font-size: 14px; border: 1px solid var(--border);
  border-radius: 6px; outline: none; transition: border .15s;
  font-family: var(--font);
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  font-size: 14px; font-weight: 500;
  border: none; border-radius: 6px;
  cursor: pointer; transition: all .15s;
  font-family: var(--font);
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-outline {
  background: none; border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg); }

.login-error {
  padding: 10px 12px; margin-bottom: 16px;
  background: #fef2f2; color: #b91c1c;
  border: 1px solid #fecaca; border-radius: 6px;
  font-size: 13px; display: none;
}

/* ── Cards ─────────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.card-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.card-value.success { color: var(--success); }
.card-value.warning { color: var(--warning); }
.card-value.danger  { color: var(--danger); }

.section { margin-bottom: 24px; }
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--text); }

.chart-container {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }

/* ── Tables ────────────────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.table-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.search-input {
  flex: 1; max-width: 300px;
  padding: 8px 12px;
  font-size: 13px; border: 1px solid var(--border);
  border-radius: 6px; outline: none;
  font-family: var(--font);
}
.search-input:focus { border-color: var(--primary); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 16px; text-align: left; font-size: 13px; }
th {
  background: #f8fafc; color: var(--text-secondary);
  font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: .4px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { border-bottom: 1px solid #f1f5f9; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
td.mono { font-family: var(--mono); font-size: 12px; }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary);
}
.pagination-btns { display: flex; gap: 6px; }

/* ── Status badges ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  font-size: 12px; font-weight: 500;
  border-radius: 12px;
}
.badge-healthy  { background: #dcfce7; color: #166534; }
.badge-degraded { background: #fef3c7; color: #92400e; }
.badge-down, .badge-critical { background: #fee2e2; color: #991b1b; }
.badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  display: inline-block;
}
.badge-healthy .badge-dot  { background: var(--success); }
.badge-degraded .badge-dot { background: var(--warning); }
.badge-down .badge-dot, .badge-critical .badge-dot { background: var(--danger); }

.badge-status {
  padding: 2px 8px; font-size: 11px; font-weight: 600;
  border-radius: 4px; text-transform: uppercase;
}
.badge-SUCCEEDED { background: #dcfce7; color: #166534; }
.badge-FAILED    { background: #fee2e2; color: #991b1b; }
.badge-RUNNING   { background: #dbeafe; color: #1e40af; }
.badge-PENDING   { background: #f1f5f9; color: #475569; }
.badge-CANCELLED { background: #f5f5f4; color: #78716c; }

/* ── Log viewer ────────────────────────────────────────── */
.log-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
}
.log-toolbar select, .log-toolbar input {
  padding: 7px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px;
  outline: none; font-family: var(--font);
  background: #fff;
}
.log-toolbar select:focus, .log-toolbar input:focus { border-color: var(--primary); }
.log-toolbar .spacer { flex: 1; }

.log-viewer {
  background: #0d1117;
  color: #c9d1d9;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  padding: 16px;
  min-height: 500px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  border-radius: 0 0 var(--radius) var(--radius);
  border: 1px solid #30363d;
}
.log-line { white-space: pre-wrap; word-break: break-all; padding: 1px 0; }
.log-ts  { color: #6e7681; }
.log-svc { color: #79c0ff; font-weight: 500; }
.log-DEBUG    { color: #8b949e; }
.log-INFO     { color: #58a6ff; }
.log-WARNING  { color: #d29922; }
.log-ERROR    { color: #f85149; }
.log-CRITICAL { color: #ff7b72; font-weight: 700; }
.log-empty { color: #6e7681; text-align: center; padding: 60px 20px; font-size: 14px; }

.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Service monitor cards ─────────────────────────────── */
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.monitor-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
}
.monitor-card.healthy  { border-top-color: var(--success); }
.monitor-card.degraded { border-top-color: var(--warning); }
.monitor-card.down     { border-top-color: var(--danger); }
.monitor-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.monitor-card-name { font-size: 16px; font-weight: 600; }
.monitor-card-detail { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ── User detail modal ─────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 640px; max-width: 90vw;
  max-height: 85vh; overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--text-secondary);
}
.modal-close:hover { color: var(--text); }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 20px;
}
.detail-item label { display: block; font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px; }
.detail-item span  { font-size: 14px; font-weight: 500; }

/* ── Error list ────────────────────────────────────────── */
.error-list { list-style: none; }
.error-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.error-item:last-child { border-bottom: none; }
.error-msg { font-size: 13px; font-family: var(--mono); flex: 1; word-break: break-word; }
.error-count { font-size: 13px; font-weight: 600; color: var(--danger); white-space: nowrap; }

/* ── Loading / empty states ────────────────────────────── */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; color: var(--text-secondary); font-size: 14px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 60px; min-width: 60px; }
  .sidebar-brand, .nav-item span, .sidebar-footer { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .page-content { padding: 16px; }
  .chart-row { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
