/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg2: #161b27;
  --bg3: #1e2535;
  --border: #2a3147;
  --text: #e2e8f0;
  --text-gray: #6b7db3;
  --accent: #4f8ef7;
  --accent2: #7c5cbf;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --font: 'Segoe UI', system-ui, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
  --sidebar: 220px;
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
}

.logo-icon { font-size: 24px; }
.logo-title { font-weight: 700; font-size: 16px; color: var(--text); }
.logo-sub { font-size: 11px; color: var(--text-gray); }

.sidebar-nav {
  list-style: none;
  padding: 16px 0;
  flex: 1;
}

.sidebar-nav li a {
  display: block;
  padding: 10px 20px;
  color: var(--text-gray);
  text-decoration: none;
  border-radius: 0;
  transition: all .15s;
}

.sidebar-nav li a:hover { color: var(--text); background: var(--bg3); }
.sidebar-nav li.active a { color: var(--accent); background: rgba(79,142,247,.1); border-right: 2px solid var(--accent); }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.btn-logout { color: var(--text-gray); text-decoration: none; font-size: 13px; }
.btn-logout:hover { color: var(--red); }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar);
  flex: 1;
  padding: 28px 32px;
  max-width: calc(100vw - var(--sidebar));
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h2 { font-size: 20px; font-weight: 600; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.section-title { font-size: 15px; font-weight: 600; color: var(--text-gray); margin: 24px 0 12px; text-transform: uppercase; letter-spacing: .5px; }

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  background: var(--bg3);
}

.card-body { padding: 16px; }
.terminal-controls { display: flex; gap: 8px; }

/* ── Terminal ── */
.terminal {
  background: #080c14;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  padding: 12px 16px;
  height: 280px;
  overflow-y: auto;
  color: #a8c0e8;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-logs { height: 520px; }
.terminal-card { margin-bottom: 24px; }

.log-line { padding: 1px 0; }
.log-out  { color: #c8daf0; }
.log-err  { color: #f87171; }
.log-warn { color: #fbbf24; }
.log-info { color: #34d399; }

/* ── Tenant Grid ── */
.tenants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.tenant-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color .15s;
}
.tenant-card:hover { border-color: var(--accent); }

.tenant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.tenant-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 12px;
}

.meta-item { color: var(--text-gray); }

.tenant-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.status-green  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-red    { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-blue   { background: var(--blue); box-shadow: 0 0 6px var(--blue); animation: pulse 1s infinite; }
.status-gray   { background: var(--text-gray); }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .4; }
}

.run-all-row {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

/* ── Badges ── */
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 99px;
  font-weight: 600;
}
.badge-running { background: rgba(59,130,246,.2); color: var(--blue); }
.badge-idle    { background: rgba(34,197,94,.15); color: var(--green); }
.badge-cron    { background: rgba(124,92,191,.2); color: #a78bfa; font-family: var(--mono); font-size: 10px; }
.badge-nocron  { background: var(--bg3); color: var(--text-gray); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #3a7ae0; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost   { background: var(--bg3); color: var(--text-gray); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-sm      { padding: 5px 10px; font-size: 12px; }
.btn-full    { width: 100%; justify-content: center; }

/* ── Forms ── */
input[type="text"], input[type="password"], select.select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }

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

.cron-input { font-family: var(--mono); font-size: 12px; width: 180px; }

/* ── Toggle ── */
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  width: 40px; height: 22px;
  background: var(--bg3);
  border-radius: 99px;
  position: relative;
  border: 1px solid var(--border);
  transition: background .2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: var(--text-gray);
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: transform .2s, background .2s;
}
.toggle input:checked + .toggle-slider { background: rgba(79,142,247,.25); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::after { transform: translateX(18px); background: var(--accent); }

/* ── Tables ── */
.schedule-table, .ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.schedule-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-gray);
  font-size: 11px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.schedule-table td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(42,49,71,.5);
  vertical-align: middle;
}
.ref-table td { padding: 6px 12px; color: var(--text-gray); }
.ref-table td:first-child { color: #a78bfa; font-family: var(--mono); font-size: 12px; }

/* ── Alerts ── */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-error   { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.3); color: #86efac; }

/* ── Login ── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 360px;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 24px; font-weight: 700; margin-top: 8px; }
.login-logo .accent { color: var(--accent); }
.login-sub { color: var(--text-gray); font-size: 13px; margin-top: 4px; }
.login-form .btn { margin-top: 8px; }

/* ── Utils ── */
.text-gray { color: var(--text-gray) !important; }
.text-red  { color: var(--red) !important; }
code { background: var(--bg3); padding: 2px 6px; border-radius: 4px; font-family: var(--mono); font-size: 11px; color: #a78bfa; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-gray); }
