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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --primary: #6366f1;
  --primary-dark: #4f52d8;
  --text: #e2e8f0;
  --muted: #64748b;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: -0.3px;
}
.logo span { color: var(--primary); }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.muted-text { color: var(--muted); font-size: 0.78rem; }

/* ── Nav ── */
nav {
  display: flex;
  gap: 2px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tab {
  background: none;
  border: none;
  color: var(--muted);
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-size: 0.88rem;
  font-weight: 500;
  transition: color 0.15s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Tab content ── */
.tab-content { display: none; padding: 24px; }
.tab-content.active { display: block; }

/* ── Section titles ── */
.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 14px;
  margin-top: 28px;
}
.section-title:first-child { margin-top: 0; }

/* ── Gauge cards ── */
.gauges-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.gauge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.gauge-ring {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 12px;
}

.gauge-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: var(--surface2);
  stroke-width: 8;
}

.gauge-fill {
  fill: none;
  stroke: var(--green);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease, stroke 0.4s ease;
}

.gauge-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
}

.gauge-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.gauge-sub {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Info card (uptime) */
.info-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.info-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

/* ── Apps health grid (dashboard) ── */
.apps-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.health-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 0.2s;
}
.health-card:hover { border-color: var(--primary); }
.health-card.down { border-color: var(--red); }

.health-icon { font-size: 1.3rem; }

.health-info { flex: 1; min-width: 0; }

.health-name {
  font-weight: 600;
  font-size: 0.88rem;
}

.health-domain {
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-dot.up { background: var(--green); box-shadow: 0 0 6px var(--green); }
.health-dot.down { background: var(--red); box-shadow: 0 0 6px var(--red); }

.health-label {
  font-size: 0.78rem;
  font-weight: 500;
}

.health-meta {
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 40px;
  text-align: right;
}

/* ── Container stats table ── */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.82rem;
}

.stats-table thead {
  background: var(--surface2);
}

.stats-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.stats-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.stats-table tr:last-child td { border-bottom: none; }

.stats-table tr:hover { background: var(--surface2); }

.stat-name {
  font-weight: 600;
  color: var(--text);
}

.stat-io {
  font-size: 0.75rem;
  color: var(--muted);
}

.stat-bar {
  display: inline-block;
  width: 50px;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 6px;
}

.stat-bar-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* ── Container list (detail tab) ── */
#container-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.container-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.2s;
}
.container-card:hover { border-color: var(--primary); }

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.exited  { background: var(--red); }
.status-dot.other   { background: var(--yellow); }

.card-name {
  font-weight: 600;
  font-size: 0.92rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-image {
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-status {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.card-actions { display: flex; gap: 6px; }

/* ── Apps grid (detail tab) ── */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.app-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, background 0.2s;
}
.app-card:hover {
  border-color: var(--primary);
  background: var(--surface2);
}
.app-card.app-down { border-color: var(--red); }

.app-icon { font-size: 1.5rem; line-height: 1; }

.app-info {
  flex: 1;
  min-width: 0;
}

.app-name {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
}

.app-url {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--surface2);
}
.app-status-badge.up { color: var(--green); }
.app-status-badge.down { color: var(--red); }

.app-response {
  font-size: 0.72rem;
  color: var(--muted);
}

.app-arrow {
  color: var(--muted);
  font-size: 1rem;
  transition: color 0.2s;
}
.app-card:hover .app-arrow { color: var(--primary); }

/* ── Buttons ── */
button { cursor: pointer; font-family: inherit; }

.btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--surface2);
  color: var(--text);
  transition: all 0.15s;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-logs { color: var(--muted); }

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}
.btn-icon:hover { color: var(--text); }

/* ── Log box ── */
.log-box {
  background: #0a0c14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  color: #94a3b8;
  max-height: 460px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.modal-header button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}
.modal-header button:hover { color: var(--text); }

.modal-box .log-box {
  border: none;
  border-radius: 0;
  flex: 1;
  max-height: none;
}

/* ── Misc ── */
.hidden { display: none !important; }

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 60px 0;
  font-size: 0.9rem;
}

.spinning { animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 640px) {
  .gauges-row { grid-template-columns: repeat(2, 1fr); }
  .apps-health-grid { grid-template-columns: 1fr; }
  header { padding: 12px 16px; }
  .tab-content { padding: 16px; }
}
