:root {
  --bg: #06080c;
  --surface: #0c1018;
  --surface2: #101822;
  --border: #1a2535;
  --border-glow: #00e5ff15;
  --text: #d8e4ef;
  --text-dim: #4a6080;
  --accent: #00e5ff;
  --accent-dim: #00e5ff40;
  --green: #00e87b;
  --yellow: #ffc832;
  --orange: #ff8c32;
  --red: #ff3050;
  --blue: #00aaff;
  --purple: #a855f7;
}

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

body {
  font-family: 'Segoe UI', -apple-system, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 0%, #00e5ff06 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, #a855f708 0%, transparent 60%);
  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-top: 2px solid var(--accent);
  border-radius: 12px;
  padding: 2.5rem;
  width: min(400px, 90vw);
  text-align: center;
  box-shadow: 0 0 60px #00e5ff08, 0 20px 40px rgba(0,0,0,.4);
}
.login-box h1 {
  color: var(--accent); font-size: 1.4rem; margin-bottom: .25rem;
  letter-spacing: 3px; text-transform: uppercase;
  text-shadow: 0 0 20px var(--accent-dim);
}
.subtitle { color: var(--text-dim); margin-bottom: 1.5rem; font-size: .75rem; letter-spacing: 2px; text-transform: uppercase; }
.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 input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 8px var(--accent-dim); }
.login-box button {
  width: 100%; padding: .75rem; border: none; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #0088cc);
  color: var(--bg); font-weight: 700;
  font-size: .9rem; cursor: pointer; letter-spacing: 1px; text-transform: uppercase;
}
.login-box button:hover { filter: brightness(1.15); box-shadow: 0 0 20px var(--accent-dim); }
.error { color: var(--red); font-size: .85rem; margin-top: .5rem; }

/* OOBE Banner — always visible when active */
.oobe-banner {
  background: linear-gradient(90deg, rgba(255,48,80,.18), rgba(255,140,50,.12));
  border-bottom: 2px solid var(--red);
  padding: .8rem 1rem;
  font-size: .8rem;
  color: var(--red);
  font-weight: 600;
  text-align: center;
  animation: pulse 2s infinite;
}
.oobe-banner small { display: block; font-size: .65rem; font-weight: 400; color: var(--text); margin-top: .3rem; }

/* Health Bar — mobile only */
.health-bar {
  display: none;
  padding: .5rem .75rem;
  font-size: .8rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.health-bar.ok { background: linear-gradient(90deg, rgba(0,232,123,.08), rgba(0,229,255,.05)); color: var(--green); border-bottom: 2px solid var(--green); }
.health-bar.warn { background: linear-gradient(90deg, rgba(255,200,50,.08), rgba(255,140,50,.05)); color: var(--yellow); border-bottom: 2px solid var(--yellow); }
.health-bar.bad { background: linear-gradient(90deg, rgba(255,48,80,.12), rgba(255,48,80,.05)); color: var(--red); border-bottom: 2px solid var(--red); animation: pulse 1.5s infinite; }

/* Status Badges — mobile only */
.status-badges {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  padding: .4rem .5rem;
  justify-content: center;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: .6rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.badge .badge-dot {
  width: 5px; height: 5px; border-radius: 50%;
}
.badge.ok .badge-dot { background: var(--green); }
.badge.warn .badge-dot { background: var(--yellow); }
.badge.bad .badge-dot { background: var(--red); }

/* Header */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem 1rem; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface) 100%);
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.header-brand {
  display: flex; align-items: center; gap: .5rem;
}
.header-logo {
  width: 28px; height: 28px; border-radius: 4px;
}
header h1 {
  font-size: 1rem; color: var(--accent);
  letter-spacing: 3px; text-transform: uppercase; font-weight: 700;
  text-shadow: 0 0 12px var(--accent-dim);
}
.header-right { display: flex; align-items: center; gap: .6rem; font-size: .75rem; color: var(--text-dim); }
.icon-btn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-dim); padding: .3rem .5rem; cursor: pointer; font-size: .85rem;
  transition: all .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 8px var(--accent-dim); }

/* System Row */
.sys-row {
  display: flex; gap: .6rem; padding: .6rem; flex-wrap: wrap;
  align-items: flex-start; justify-content: center;
}
/* Metric Icons (CPU / RAM) */
.metric-icon {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .4rem;
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer; transition: all .2s;
  position: relative; min-width: 52px;
}
.metric-icon:hover { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-dim); }
.hw-icon { width: 36px; height: 36px; color: var(--accent); opacity: .7; }
.metric-pct {
  font-size: .7rem; font-weight: 700;
  font-family: 'Courier New', monospace;
  color: var(--green); margin-top: .1rem;
}
.metric-pct.warn { color: var(--yellow); }
.metric-pct.high { color: var(--orange); }
.metric-pct.crit { color: var(--red); }

/* Compact storage in sys-row */
.storage-compact {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .5rem .6rem;
  display: flex; gap: .6rem; align-items: center;
  transition: border-color .2s;
}
.storage-compact:hover { border-color: var(--accent); }
.stor-item {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  font-size: .65rem; font-family: 'Courier New', monospace;
}
.stor-letter { font-weight: 700; color: var(--text); }
.stor-pct { font-weight: 600; }
.stor-bar {
  width: 28px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.stor-bar-fill { height: 100%; border-radius: 2px; }

/* Compact network in sys-row */
.net-compact {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .5rem .6rem;
  display: flex; flex-direction: column; gap: .3rem;
  font-size: .65rem;
}
.net-item {
  display: flex; align-items: center; gap: .4rem;
}
.net-name { color: var(--text-dim); font-size: .55rem; min-width: 50px; }
.net-rates { font-family: 'Courier New', monospace; display: flex; gap: .4rem; }
.net-down { color: var(--blue); }
.net-up { color: var(--green); }

/* 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, #12161e 0%, #0c1018 50%, #0a0e14 100%);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent-dim);
  border-radius: 6px;
  padding: 4px;
  position: relative;
  box-shadow: 0 4px 24px rgba(0,0,0,.5), 0 0 30px #00e5ff05;
}

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


/* Drive Bay — skinny 2.5" caddy, LED only */
.drive-card {
  background: linear-gradient(180deg, #141c28 0%, #0e1420 40%, #101822 100%);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 60px;
}
.drive-card:hover { border-color: var(--accent); box-shadow: 0 0 8px var(--accent-dim); }
.drive-card.warning { border-color: var(--yellow); box-shadow: 0 0 6px rgba(255,200,50,.15); }
.drive-card.critical { border-color: var(--red); box-shadow: 0 0 8px rgba(255,48,80,.2); }
.drive-card.offline { opacity: .3; border-color: var(--red); }

/* Caddy handle */
.drive-handle {
  background: linear-gradient(90deg, #1a2535 0%, #152030 50%, #1a2535 100%);
  height: 8px;
  border-top: 1px solid #253545;
  display: flex; align-items: center; justify-content: center;
}
.drive-handle::after {
  content: ''; width: 6px; height: 2px; background: #304050; border-radius: 1px;
}

/* Drive body — just LED centered, fill the caddy height */
.drive-body {
  padding: .4rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}

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

/* Hidden on SAS cards — only shown in modal */
.drive-info { display: none; }

/* NVMe row — icon style */
.nvme-row {
  display: flex; gap: .5rem; padding: .3rem .6rem; justify-content: center;
}
.nvme-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: .35rem .6rem;
  display: flex; align-items: center; gap: .4rem;
  cursor: pointer; transition: border-color .15s;
  font-size: .7rem;
}
.nvme-card:hover { border-color: var(--accent); box-shadow: 0 0 8px var(--accent-dim); }
.nvme-icon {
  font-size: .65rem; color: var(--text-dim);
  font-family: 'Courier New', monospace;
  display: flex; align-items: center; gap: .4rem;
}
.drv-svg { width: 32px; height: auto; color: var(--accent); opacity: .85; }
.nvme-letter { font-weight: 700; color: var(--text); font-size: .8rem; }
.nvme-led {
  width: 6px; height: 6px; border-radius: 50%;
}
.nvme-led.ok { background: var(--green); box-shadow: 0 0 3px var(--green); }
.nvme-led.warn { background: var(--yellow); box-shadow: 0 0 4px var(--yellow); }
.nvme-led.bad { background: var(--red); box-shadow: 0 0 4px var(--red); }

/* 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-dot.idle { background: var(--blue); box-shadow: 0 0 3px var(--blue); }
.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; }

/* Plex streams */
.stream-item {
  display: flex; gap: .35rem; padding: .25rem 0; border-bottom: 1px solid var(--border);
  font-size: .65rem; align-items: flex-start;
}
.stream-item:last-child { border-bottom: none; }
.stream-state { font-size: .7rem; flex-shrink: 0; margin-top: .05rem; }
.stream-info { flex: 1; min-width: 0; }
.stream-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stream-meta { color: var(--text-dim); font-size: .55rem; margin-top: .1rem; }
.stream-time {
  font-size: .55rem; color: var(--text-dim);
  font-family: 'Courier New', monospace;
  margin-top: .1rem;
}

/* Settings page layout */
.settings-page {
  display: flex;
  min-height: calc(100vh - 60px);
}
.settings-nav {
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  flex-shrink: 0;
}
.snav-btn {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: var(--text-dim);
  padding: .7rem 1rem;
  font-size: .8rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.snav-btn:hover { color: var(--text); background: var(--surface2); }
.snav-btn.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--surface2);
}
.snav-icon { font-size: 1rem; }
.settings-main {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-width: 700px;
}
.sec-content { font-size: .8rem; }
.sec-content h4 { margin-top: 1.25rem; }
.sec-content h4:first-child { margin-top: 0; }

@media (max-width: 768px) {
  .settings-page { flex-direction: column; }
  .settings-nav {
    width: 100%; padding: .4rem 0;
    display: flex; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .snav-btn {
    border-left: none; border-bottom: 2px solid transparent;
    white-space: nowrap; padding: .5rem .75rem;
  }
  .snav-btn.active { border-left: none; border-bottom-color: var(--accent); }
  .snav-icon { display: none; }
  .settings-main { padding: 1rem; }
}

/* Old modal styles (kept for compat) */
.settings-content { max-width: 500px; }
.settings-tabs {
  display: flex; gap: 2px; margin-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.tab {
  background: none; border: none; color: var(--text-dim);
  padding: .4rem .7rem; font-size: .7rem; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all .15s;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }
.tab-content { font-size: .75rem; }

.settings-input {
  width: 100%; padding: .5rem; margin-bottom: .5rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-size: .8rem;
}
.settings-input:focus { outline: none; border-color: var(--accent); }
.settings-btn {
  padding: .45rem .8rem; border: 1px solid var(--border);
  border-radius: 4px; background: var(--surface); color: var(--text);
  font-size: .7rem; cursor: pointer; transition: all .15s;
}
.settings-btn:hover { border-color: var(--accent); }
.settings-btn.primary {
  background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600;
}
.settings-btn.danger { background: var(--red); color: #fff; border-color: var(--red); }

.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .35rem 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { color: var(--text); }
.setting-desc { font-size: .6rem; color: var(--text-dim); }

/* Toggle switch */
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 10px;
  cursor: pointer; transition: .2s;
}
.toggle .slider::before {
  content: ''; position: absolute; height: 16px; width: 16px; left: 2px; bottom: 2px;
  background: var(--text-dim); border-radius: 50%; transition: .2s;
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(16px); background: var(--bg); }

/* Theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.theme-card {
  padding: .5rem; border: 2px solid var(--border); border-radius: 6px;
  cursor: pointer; text-align: center; font-size: .65rem; transition: all .15s;
}
.theme-card.active { border-color: var(--accent); }
.theme-card:hover { border-color: var(--accent-dim); }
.theme-preview {
  height: 30px; border-radius: 3px; margin-bottom: .3rem;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .7rem;
}

/* User list */
.user-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .75rem;
}

/* 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) {
  /* Mobile health bar + badges */
  .health-bar { display: block; }
  .status-badges { display: flex; }

  /* Compact system row */
  .sys-row { gap: .4rem; padding: .4rem; }
  .metric-icon { padding: .3rem; min-width: 44px; }
  .hw-icon { width: 30px; height: 30px; }
  .metric-pct { font-size: .6rem; }
  .storage-compact { padding: .3rem .4rem; gap: .4rem; }
  .net-compact { padding: .3rem .4rem; font-size: .6rem; }

  /* SAS chassis */
  .drive-section { padding: .3rem .3rem; }
  .server-chassis { padding: 3px; }
  .drive-card { height: 50px; }
  .drive-handle { height: 5px; }
  .drive-status { width: 5px; height: 5px; }

  /* NVMe compact */
  .nvme-row { gap: .3rem; padding: .2rem .4rem; }

  /* Info cards */
  .info-grid { grid-template-columns: 1fr; gap: .4rem; padding: .4rem .5rem; }
  .info-card { padding: .4rem .5rem; }
  .info-card h3 { font-size: .6rem; }
  .status-item { padding: .1rem 0; font-size: .6rem; }
  .pool-stat { font-size: .65rem; }
  .io-row { font-size: .6rem; }
  .proc-row { font-size: .55rem; }
  .proc-mem, .proc-cpu { min-width: 30px; }
  .io-read, .io-write { min-width: 50px; }

  header {
    flex-wrap: wrap;
    padding: .4rem .75rem;
    gap: .3rem;
  }
  .header-brand { width: 100%; gap: .4rem; justify-content: flex-start; }
  header h1 { font-size: .85rem; letter-spacing: 2px; }
  .header-logo { width: 24px; height: 24px; }
  .header-right {
    width: 100%;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    padding-top: .35rem;
    margin-top: .1rem;
  }
}
