:root {
  --bg: #0a0a0f;
  --surface: #141420;
  --border: #1e1e30;
  --text: #e0e0e8;
  --text-dim: #606080;
  --green: #00df00;
  --yellow: #f0c030;
  --orange: #e08020;
  --red: #e02020;
  --blue: #3080f0;
}

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

body {
  font-family: 'Segoe UI', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Login */
.login-box {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: min(400px, 90vw);
  text-align: center;
}
.login-box h1 { color: var(--green); font-size: 1.5rem; margin-bottom: .25rem; }
.subtitle { color: var(--text-dim); margin-bottom: 1.5rem; font-size: .85rem; }
.login-box input {
  width: 100%; padding: .75rem; margin-bottom: .75rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: .95rem;
}
.login-box button {
  width: 100%; padding: .75rem; border: none; border-radius: 6px;
  background: var(--green); color: var(--bg); font-weight: 600;
  font-size: 1rem; cursor: pointer;
}
.login-box button:hover { filter: brightness(1.2); }
.error { color: var(--red); font-size: .85rem; margin-top: .5rem; }

/* Header */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 10;
}
header h1 { font-size: 1.1rem; color: var(--green); }
.header-right { display: flex; align-items: center; gap: .75rem; font-size: .8rem; color: var(--text-dim); }
.icon-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: .3rem .5rem; cursor: pointer; font-size: .9rem;
}
.icon-btn:hover { border-color: var(--green); }

/* Gauge Row */
.gauge-row {
  display: flex; gap: 1rem; padding: 1rem; flex-wrap: wrap;
  justify-content: center;
}
.gauge-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem; text-align: center; min-width: 130px;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
}
.gauge svg { width: 100px; height: 100px; }
.gauge circle {
  fill: none; stroke-width: 8; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: center;
}
.gauge .bg { stroke: var(--border); }
.gauge .fg { stroke: var(--green); stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .6s, stroke .3s; }
.gauge text { text-anchor: middle; fill: var(--text); font-weight: 600; }
.gauge .val { font-size: 22px; }
.gauge .label { font-size: 11px; fill: var(--text-dim); }
.gauge-detail { font-size: .75rem; color: var(--text-dim); }

/* Storage mini gauges */
.storage-item {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem;
  font-size: .8rem;
}
.storage-bar {
  flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden;
}
.storage-bar-fill { height: 100%; border-radius: 4px; transition: width .5s; }
.storage-label { min-width: 70px; color: var(--text-dim); }
.storage-val { min-width: 45px; text-align: right; }

/* Network */
.net-row {
  display: flex; gap: .75rem; padding: 0 1rem .5rem; flex-wrap: wrap;
  justify-content: center;
}
.net-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem .8rem; font-size: .8rem;
  min-width: 180px;
}
.net-card .nic-name { color: var(--text-dim); font-size: .7rem; margin-bottom: .3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.net-rate { display: flex; justify-content: space-between; gap: .5rem; }
.net-rate span { font-family: 'Courier New', monospace; }
.net-up { color: var(--green); }
.net-down { color: var(--blue); }

/* Server Chassis — Supermicro CSE-216 */
.drive-section { padding: .5rem 1rem; }
.drive-section h2 { font-size: .9rem; color: var(--text-dim); margin-bottom: .5rem; }
.drive-section h2 span { color: var(--green); }

.server-chassis {
  background: linear-gradient(180deg, #222228 0%, #1a1a1f 50%, #18181d 100%);
  border: 2px solid #3a3a42;
  border-radius: 4px;
  padding: 0;
  position: relative;
  box-shadow: 0 2px 20px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06);
  overflow: hidden;
}

.chassis-inner {
  display: flex;
}

/* Bay area — holds the 12x2 drive grid */
.bay-area {
  flex: 1;
  padding: 6px 4px;
  background: linear-gradient(180deg, #1d1d24 0%, #161619 100%);
  border-right: 2px solid #2a2a30;
}

.drive-grid {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
}

/* Right-side control panel */
.chassis-panel {
  width: 54px;
  background: linear-gradient(180deg, #252530 0%, #1c1c24 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  gap: 5px;
  flex-shrink: 0;
}
.panel-logo {
  font-size: .45rem;
  font-weight: 700;
  color: #4a8adf;
  letter-spacing: 1px;
  font-family: Arial, sans-serif;
  text-align: center;
  line-height: 1.1;
}
.panel-model {
  font-size: .4rem;
  color: #444;
  font-family: 'Courier New', monospace;
}
.panel-leds {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: auto;
}
.panel-led-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.panel-led {
  width: 5px; height: 5px; border-radius: 50%;
  flex-shrink: 0;
}
.pwr-led { background: var(--green); box-shadow: 0 0 4px var(--green); }
.hdd-led { background: var(--blue); box-shadow: 0 0 3px var(--blue); }
.nic-led { background: var(--green); box-shadow: 0 0 3px var(--green); }
.led-label {
  font-size: .4rem;
  color: #555;
  font-family: 'Courier New', monospace;
}
.panel-btn {
  margin-top: 4px;
  font-size: .4rem;
  color: #555;
  border: 1px solid #333;
  border-radius: 2px;
  padding: 1px 4px;
  font-family: 'Courier New', monospace;
  cursor: default;
}

/* Rack ears with screw holes */
.chassis-ears {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  height: 0;
  position: relative;
  top: -50%;
  pointer-events: none;
}
.ear-hole {
  display: none;
}

/* Drive Bay — 2.5" hot-swap caddy */
.drive-card {
  background: linear-gradient(180deg, #202028 0%, #18181e 40%, #1c1c22 100%);
  border: 1px solid #2a2a35;
  border-radius: 2px;
  padding: 0;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
.drive-card:hover { border-color: var(--green); box-shadow: 0 0 6px rgba(0,223,0,.15); }
.drive-card.warning { border-color: var(--yellow); }
.drive-card.critical { border-color: var(--red); box-shadow: 0 0 6px rgba(224,32,32,.25); }
.drive-card.offline { opacity: .3; border-color: #600; }

/* Caddy handle — latch at bottom of vertical tray */
.drive-handle {
  background: linear-gradient(90deg, #383840 0%, #30303a 50%, #383840 100%);
  height: 10px;
  border-top: 1px solid #48484f;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.drive-handle::after {
  content: '';
  width: 8px; height: 3px;
  background: #5a5a62;
  border-radius: 1px;
}

/* Drive body — vertical stack: LED on top, info below */
.drive-body {
  padding: .25rem .1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  min-height: 60px;
}

/* Bay LED */
.drive-status {
  width: 5px; height: 5px; border-radius: 50%;
  flex-shrink: 0;
}
.drive-status.ok { background: var(--green); box-shadow: 0 0 3px var(--green); }
.drive-status.warn { background: var(--yellow); box-shadow: 0 0 5px var(--yellow); }
.drive-status.bad { background: var(--red); box-shadow: 0 0 5px var(--red); animation: pulse 1s infinite; }
.drive-status.offline { background: #600; }
@keyframes pulse { 50% { opacity: .3; } }

.drive-info {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.drive-slot {
  font-size: .42rem;
  color: #4a4a55;
  font-family: 'Courier New', monospace;
  line-height: 1;
}
.drive-temp {
  font-size: .7rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  line-height: 1.3;
}
.drive-serial {
  font-size: .38rem;
  color: #3a3a44;
  font-family: 'Courier New', monospace;
  line-height: 1;
}

/* NVMe section — wider cards */
.nvme-section { margin-top: .5rem; }
.nvme-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.nvme-grid .drive-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
  text-align: center;
}
.nvme-grid .drive-card .drive-handle { display: none; }
.nvme-grid .drive-card .drive-body {
  flex-direction: row;
  align-items: center;
  gap: .6rem;
  padding: .3rem;
  min-height: auto;
}
.nvme-grid .drive-status { width: 10px; height: 10px; flex-shrink: 0; }
.nvme-grid .drive-info { text-align: left; }
.nvme-grid .drive-model { font-size: .75rem; color: var(--text-dim); }
.nvme-grid .drive-usage { font-size: .7rem; color: var(--text-dim); }
.nvme-grid .drive-temp { font-size: 1.1rem; }
.nvme-grid .drive-serial { font-size: .6rem; }
.nvme-grid .drive-slot { display: none; }

/* Info Cards Grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: .75rem;
  padding: .75rem 1rem;
}
.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
}
.info-card h3 {
  font-size: .65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: .4rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .25rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.info-card.collapsed h3 {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}
.info-card h3::after {
  content: '\25B2';
  font-size: .5rem;
  transition: transform .2s;
}
.info-card.collapsed h3::after {
  transform: rotate(180deg);
}
.info-card.collapsed .card-body {
  display: none;
}

/* All card body content — consistent small text */
.card-body { font-size: .7rem; }

/* Status list items (Docker, Services, AMP) */
.status-item {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .15rem 0;
  border-bottom: 1px solid var(--border);
}
.status-item:last-child { border-bottom: none; }
.status-dot {
  width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.up { background: var(--green); box-shadow: 0 0 3px var(--green); }
.status-dot.down { background: var(--red); box-shadow: 0 0 4px var(--red); animation: pulse 1s infinite; }
.status-dot.warn { background: var(--yellow); }
.status-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-detail { color: var(--text-dim); font-size: .6rem; }

/* Pool health */
.pool-stat { display: flex; justify-content: space-between; padding: .15rem 0; font-size: .7rem; }
.pool-stat dt { color: var(--text-dim); }
.pool-stat dd { font-family: 'Courier New', monospace; }

/* Disk I/O */
.io-row { display: flex; justify-content: space-between; padding: .12rem 0; font-size: .65rem; border-bottom: 1px solid var(--border); }
.io-row:last-child { border-bottom: none; }
.io-name { color: var(--text-dim); flex: 1; }
.io-read { color: var(--blue); min-width: 60px; text-align: right; font-family: 'Courier New', monospace; }
.io-write { color: var(--green); min-width: 60px; text-align: right; font-family: 'Courier New', monospace; }

/* Top processes */
.proc-row { display: flex; gap: .25rem; padding: .12rem 0; font-size: .6rem; border-bottom: 1px solid var(--border); }
.proc-row:last-child { border-bottom: none; }
.proc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proc-cpu { color: var(--yellow); min-width: 40px; text-align: right; font-family: 'Courier New', monospace; }
.proc-mem { color: var(--blue); min-width: 45px; text-align: right; font-family: 'Courier New', monospace; }

/* Panels/Modals */
.panel-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.7); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 3rem;
}
.panel-content {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; width: min(600px, 95vw); max-height: 80vh;
  overflow-y: auto; padding: 1.25rem;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.panel-header h2 { font-size: 1rem; }
.panel-header button { background: none; border: none; color: var(--text); font-size: 1.5rem; cursor: pointer; }

/* Alert items */
.alert-item {
  display: flex; gap: .5rem; padding: .5rem; border-bottom: 1px solid var(--border);
  font-size: .8rem; align-items: flex-start;
}
.alert-item.critical .alert-badge { background: var(--red); }
.alert-item.warning .alert-badge { background: var(--yellow); }
.alert-badge {
  width: 8px; height: 8px; border-radius: 50%; margin-top: .3rem; flex-shrink: 0;
}
.alert-msg { flex: 1; }
.alert-time { color: var(--text-dim); font-size: .7rem; }

/* Modal detail */
.detail-grid {
  display: grid; grid-template-columns: auto 1fr; gap: .3rem .75rem;
  font-size: .85rem;
}
.detail-grid dt { color: var(--text-dim); }
.detail-grid dd { font-family: 'Courier New', monospace; }

/* Responsive */
@media (max-width: 900px) {
  /* SAS chassis grid — scoped to bay-area only */
  .bay-area .drive-grid { grid-template-columns: repeat(12, 1fr); }
  .bay-area .drive-body { min-height: 45px; }
  .bay-area .drive-temp { font-size: .55rem; }
  .bay-area .drive-slot { font-size: .3rem; }
  .bay-area .drive-serial { display: none; }
  .bay-area .drive-handle { height: 3px; }
  .bay-area .drive-status { width: 4px; height: 4px; }
  .chassis-panel { width: 40px; padding: 4px 2px; }
  .panel-logo { font-size: .35rem; }
  .panel-model { font-size: .3rem; }
  .panel-led { width: 4px; height: 4px; }
  .led-label { font-size: .3rem; }
  .panel-btn { font-size: .3rem; padding: 1px 2px; }
  .gauge-row { padding: .5rem; }
  .gauge svg { width: 80px; height: 80px; }
  header h1 { font-size: .9rem; }

  /* NVMe — keep readable on mobile */
  .nvme-grid .drive-card { padding: .6rem; }
  .nvme-grid .drive-card .drive-body { gap: .5rem; padding: .4rem; }
  .nvme-grid .drive-temp { font-size: 1rem; }
  .nvme-grid .drive-model { font-size: .7rem; }
  .nvme-grid .drive-serial { font-size: .55rem; display: block; }
  .nvme-grid .drive-status { width: 8px; height: 8px; }

  /* Info cards */
  .info-grid { grid-template-columns: 1fr 1fr; gap: .5rem; padding: .5rem; }
  .info-card { padding: .5rem; }
  .info-card h3 { font-size: .65rem; margin-bottom: .3rem; padding-bottom: .2rem; letter-spacing: .5px; }
  .status-item { padding: .12rem 0; font-size: .65rem; }
  .pool-stat { font-size: .7rem; }
  .io-row { font-size: .65rem; }
  .proc-row { font-size: .6rem; }
  .proc-mem, .proc-cpu { min-width: 35px; }
  .io-read, .io-write { min-width: 55px; }
}
@media (max-width: 400px) {
  .info-grid { grid-template-columns: 1fr; }
}
