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

:root {
  --bg: #0d0d0d;
  --bg2: #141414;
  --bg3: #1a1a1a;
  --bg4: #222222;
  --border: #2a2a2a;
  --border2: #333;
  --text: #e8e8e8;
  --text2: #999;
  --text3: #666;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --orange: #f97316;
  --purple: #a855f7;
  --cyan: #06b6d4;
  --sidebar-w: 220px;
}

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

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo h1 { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: 0.02em; }
.sidebar-logo span { font-size: 15px; color: var(--text3); }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; cursor: pointer;
  color: var(--text2); font-size: 15px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg3); color: var(--accent); border-left-color: var(--accent); }
.nav-item .icon { font-size: 15px; width: 20px; text-align: center; }

.sidebar-stats {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.stat-row { display: flex; justify-content: space-between; font-size: 15px; color: var(--text3); }
.stat-row span:last-child { color: var(--text2); font-weight: 600; }

.main {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

.topbar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 10px 20px; display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.topbar h2 { font-size: 16px; font-weight: 600; flex: 1; }

.content { flex: 1; overflow-y: auto; padding: 20px; }

/* ─── Toolbar / Filters ─────────────────────────────────────────────────────── */
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input, .toolbar select {
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 6px 10px; border-radius: 6px;
  font-size: 16px; outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); }
.toolbar input { width: 200px; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 18px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 15px; font-weight: 500; transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg4); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--bg3); border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success { background: transparent; color: var(--green); border: 1px solid var(--green); }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-icon { padding: 6px 12px; background: transparent; border: 1px solid var(--border2); border-radius: 6px; color: var(--text2); cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.15s; }
.btn-icon:hover { background: var(--bg4); color: var(--text); }

/* ─── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg3); }
th {
  padding: 9px 12px; text-align: left; font-size: 15px; font-weight: 600;
  color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap; border-bottom: 1px solid var(--border);
}
td {
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle; font-size: 16px;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
.td-actions { display: flex; gap: 4px; align-items: center; }

/* ─── Badges & Pills ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: 15px; font-weight: 600;
}
.badge-ok { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-risk { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-inactive { background: rgba(102,102,102,0.2); color: var(--text3); }
.badge-active { background: rgba(34,197,94,0.12); color: var(--green); }
.badge-pending { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-completed { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-failed { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-blue { background: rgba(59,130,246,0.15); color: var(--accent); }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  background: rgba(59,130,246,0.12); color: var(--accent);
  font-size: 15px; margin: 1px;
}

.code-val {
  font-family: monospace; font-size: 16px; font-weight: 700;
}
.code-200 { color: var(--green); }
.code-0, .code-error { color: var(--red); }
.code-3xx { color: var(--yellow); }
.code-4xx, .code-5xx { color: var(--red); }

/* ─── Stats Cards ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px;
}
.stat-card .label { font-size: 15px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.stat-card .value { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-card .value.green { color: var(--green); }
.stat-card .value.red { color: var(--red); }
.stat-card .value.yellow { color: var(--yellow); }
.stat-card .value.blue { color: var(--accent); }

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 1000; padding: 40px 20px; overflow-y: auto;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; width: 100%; max-width: min(1100px, 96vw);
  position: relative;
}
.modal-header {
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.modal-header h3 { flex: 1; font-size: 15px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }

/* ─── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 8px 14px; cursor: pointer; font-size: 16px; font-weight: 500;
  color: var(--text3); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Site Card Detail ───────────────────────────────────────────────────────── */
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px 20px;
}
.detail-row { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 12px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-value { font-size: 15px; color: var(--text); font-weight: 500; word-break: break-all; }
.detail-value a { color: var(--accent); text-decoration: none; }
.detail-value a:hover { text-decoration: underline; }

.section-title {
  font-size: 15px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 16px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.headings-tree { display: flex; flex-direction: column; gap: 3px; }
.heading-item { display: flex; gap: 8px; }
.heading-tag { font-size: 12px; font-family: monospace; color: var(--accent); background: rgba(59,130,246,0.1); padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
.heading-text { font-size: 16px; color: var(--text2); }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 15px; color: var(--text3); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.05em; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 8px 10px; border-radius: 6px;
  font-size: 15px; outline: none; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ─── Log Timeline ───────────────────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0; margin-top: 4px;
}
.timeline-dot.check { background: var(--green); }
.timeline-dot.plugin { background: var(--purple); }
.timeline-dot.task { background: var(--yellow); }
.timeline-dot.error { background: var(--red); }
.timeline-dot.added { background: var(--cyan); }
.timeline-body { flex: 1; }
.timeline-event { font-size: 16px; font-weight: 500; color: var(--text); }
.timeline-desc { font-size: 15px; color: var(--text2); margin-top: 2px; }
.timeline-time { font-size: 12px; color: var(--text3); white-space: nowrap; }

/* ─── Empty States ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text3);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 16px; }

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

.loading-row td { text-align: center; padding: 40px; color: var(--text3); }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 10px 16px; border-radius: 8px;
  font-size: 15px; box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: all 0.3s; opacity: 0; transform: translateY(10px);
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { border-color: var(--green); color: var(--green); }
#toast.error { border-color: var(--red); color: var(--red); }

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

/* ─── Misc ───────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text3); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue { color: var(--accent); }
.monospace { font-family: monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.flex-gap { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Card-based tab layouts ─────────────────────────── */
.tab-cards { display: flex; flex-direction: column; gap: 16px; padding: 4px 0; }
.card-row   { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.card-row.wide { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.stat-card .sc-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text2); font-weight: 500; }
.stat-card .sc-value { font-size: 20px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card .sc-value.sm { font-size: 14px; font-weight: 500; }
.stat-card .sc-sub   { font-size: 11px; color: var(--text2); margin-top: 2px; }
.stat-card.accent-green { border-color: var(--green); }
.stat-card.accent-red   { border-color: var(--red); }
.stat-card.accent-yellow { border-color: #f0a500; }
.card-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text2); font-weight: 600; margin-bottom: -4px; }
.info-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.info-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; font-size: 13px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.info-row:last-child { border-bottom: none; padding-bottom: 0; }
.info-row .ir-label { color: var(--text2); white-space: nowrap; flex-shrink: 0; }
.info-row .ir-value { text-align: right; word-break: break-all; }
.ps-bar { display: flex; align-items: center; gap: 8px; }
.ps-bar-track { flex: 1; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.ps-bar-fill  { height: 100%; border-radius: 3px; transition: width .3s; }
