/* ══════════════════════════════════════════════════════════════════
   Sistema — Fullstack unified CSS
   Dark / Light / Auto themes via CSS variables
   ══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600;700&family=Zen+Kaku+Gothic+New:wght@300;400;500;700&display=swap');

:root {
  /* Dark theme (default) */
  --bg: #0f1115;
  --bg-gradient: radial-gradient(1000px 640px at 88% -14%, rgba(91,141,255,.12), transparent 60%),
                  radial-gradient(760px 560px at -8% 16%, rgba(167,139,250,.10), transparent 55%),
                  linear-gradient(180deg, #0f1218, #0f1115);
  --surface: #171a21;
  --surface-hover: #1f232c;
  --card: rgba(23, 26, 33, .85);
  --border: #2a2f3a;
  --border2: rgba(148,163,184,.18);
  --text: #e8eaed;
  --text-secondary: #9aa0ab;
  --green: #3ddc84;
  --red: #ff5f57;
  --amber: #f5b942;
  --blue: #5b8dff;
  --violet: #a78bfa;
  --cyan: #2ad7ee;
  --accent: #6c8cff;
  --accent-hover: #85a0ff;
  --radius: 12px;
  --radius-lg: 16px;
  --transition: 0.18s ease;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, Consolas, monospace;
  --sans: 'Inter', 'Zen Kaku Gothic New', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Sidebar */
  --sidebar-w: 240px;
  --sidebar-bg: #13151b;
  --sidebar-border: #22262f;
}

[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-gradient: linear-gradient(180deg, #f4f5f7, #f0f1f5);
  --surface: #ffffff;
  --surface-hover: #eef0f4;
  --card: rgba(255,255,255,.92);
  --border: #dde1e8;
  --border2: rgba(148,163,184,.25);
  --text: #1b1f27;
  --text-secondary: #5c6470;
  --green: #1fa45b;
  --red: #d94f4a;
  --amber: #c98a12;
  --blue: #4a7de0;
  --accent: #5b78e0;
  --accent-hover: #4a66cc;
  --sidebar-bg: #e8eaf0;
  --sidebar-border: #d4d8e0;
}

/* Auto mode: follow system preference */
@media (prefers-color-scheme: light) {
  [data-theme="auto"] {
    --bg: #f4f5f7;
    --bg-gradient: linear-gradient(180deg, #f4f5f7, #f0f1f5);
    --surface: #ffffff;
    --surface-hover: #eef0f4;
    --card: rgba(255,255,255,.92);
    --border: #dde1e8;
    --border2: rgba(148,163,184,.25);
    --text: #1b1f27;
    --text-secondary: #5c6470;
    --green: #1fa45b;
    --red: #d94f4a;
    --amber: #c98a12;
    --blue: #4a7de0;
    --accent: #5b78e0;
    --accent-hover: #4a66cc;
    --sidebar-bg: #e8eaf0;
    --sidebar-border: #d4d8e0;
  }
}

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

body {
  font-family: var(--sans);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(108,140,255,.9), rgba(42,215,238,.85));
  box-shadow: 0 6px 20px -6px rgba(108,140,255,.5);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 22px;
  height: 22px;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .01em;
}

.sidebar-title small {
  display: block;
  font-size: .65rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: .06em;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 14px 10px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--surface-hover);
  text-decoration: none;
}

.sidebar-link.active {
  color: var(--accent);
  background: rgba(108,140,255,.12);
  font-weight: 600;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.home-star {
  margin-left: auto;
  font-size: .7rem;
  opacity: 0;
  transition: all var(--transition);
  pointer-events: none;
  color: var(--text-secondary);
}

.sidebar-link:hover .home-star {
  opacity: .3;
}

.sidebar-link.is-home .home-star {
  opacity: 1;
  color: #f59e0b;
  text-shadow: 0 0 6px rgba(245,158,11,.4);
}

.sidebar-link.long-pressing {
  position: relative;
}

.sidebar-link.long-pressing::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: var(--accent);
  opacity: .1;
  animation: press-fill .6s ease-out forwards;
}

@keyframes press-fill {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
  stroke: currentColor;
  fill: none;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

.theme-toggle:active {
  transform: scale(0.94);
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--card);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hamburger {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.hamburger:hover {
  color: var(--text);
  border-color: var(--accent);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Page Container ─────────────────────────────────────────── */
.page {
  padding: 24px;
  display: none;
}

.page.active {
  display: block;
}

/* ── Servidors Page ─────────────────────────────────────────── */
.svc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 18px;
}

.svc-header h1 {
  font-weight: 300;
  font-size: 1.7rem;
  letter-spacing: 0.02em;
  flex: 1;
}

.svc-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.svc-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 99px;
  padding: 8px 16px;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:active { transform: scale(0.97); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn.danger:hover {
  background: #ff7670;
  border-color: #ff7670;
}

.btn.danger-ghost {
  color: var(--red);
  border-color: rgba(255,95,87,.35);
}

.btn.danger-ghost:hover {
  border-color: var(--red);
  color: var(--red);
}

.btn.icon-only {
  flex: 0 0 auto !important;
  width: 30px;
  padding: 6px 0;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn svg { vertical-align: middle; }

.btn.auto.on {
  color: var(--green);
  border-color: rgba(61,220,132,.45);
  background: rgba(61,220,132,.08);
}

.btn.auto.on svg { color: var(--green); }

.btn.auto.off {
  color: var(--text-secondary);
}

.btn.auto.off:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.dot.on {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.dot.off {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

/* ── Service Cards ──────────────────────────────────────────── */
.svc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.svc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition), transform var(--transition);
}

.svc-card:hover {
  border-color: #3a4150;
  transform: translateY(-1px);
}

.svc-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.svc-card .name {
  font-weight: 500;
  font-size: 0.92rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent);
}

.svc-card .name:hover { text-decoration: underline; }

.svc-card .meta {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.svc-card .meta code {
  font-size: 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

.svc-card .note {
  font-size: 0.72rem;
  color: var(--amber);
}

.svc-card .res {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.res-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.res-item.cpu { color: #7aa2ff; border-color: rgba(108,140,255,.35); }
.res-item.ram { color: #7ee0a3; border-color: rgba(61,220,132,.3); }
.res-item.disk { color: #f5b942; border-color: rgba(245,185,66,.35); }
.res-item.gpu { color: #c79aff; border-color: rgba(168,130,255,.35); }
.res-item.gpu.on { color: #d4b4ff; border-color: var(--accent); background: rgba(108,140,255,.12); }

.svc-card .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.svc-card .controls .btn {
  flex: 1;
  justify-content: center;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.totals {
  margin-left: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.totals b { color: var(--text); }

/* ── Metrics Page ───────────────────────────────────────────── */
.metrics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-bottom: 18px;
}

.metrics-hud {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: pulse 2s infinite;
}

.chip {
  font-size: .62rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 8px;
  font-family: var(--mono);
}

.chip b { color: var(--text); font-weight: 600; }

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

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 120px; /* altura fija de fila, igual para todos los bloques */
  gap: 13px;
}

.m-card {
  background: var(--card);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px -18px rgba(0,0,0,.6);
  transition: border-color .25s, transform .25s, box-shadow .25s;
}

.m-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 18px 42px -20px rgba(0,0,0,.72);
}

.m-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.09), transparent);
}

.span4, .c1 { grid-column: span 1; }
.span5, .c2 { grid-column: span 2; }
.span6 { grid-column: span 2; }
.span7 { grid-column: span 3; }
.span8, .c3 { grid-column: span 3; }
.full, .c4 { grid-column: 1/-1; }

/* Fila que ocupa cada bloque (altura = N × 120px, igual para todos) */
.r2 { grid-row: span 2; }
.r3 { grid-row: span 3; }
.r4 { grid-row: span 4; }
.r5 { grid-row: span 5; }
.r6 { grid-row: span 6; }

/* Edit mode */
.dashboard-grid.editing .m-card,
.dashboard-grid.editing .sec {
  position: relative;
  outline: 2px dashed transparent;
  transition: outline-color .15s;
}
.dashboard-grid.editing .m-card:hover,
.dashboard-grid.editing .sec:hover {
  outline-color: var(--accent);
}
.dashboard-grid.editing .m-card.dragging,
.dashboard-grid.editing .sec.dragging {
  opacity: .5;
  outline-color: var(--red);
}
/* Drag handle */
.drag-handle {
  display: none;
  position: absolute;
  top: 6px;
  left: 6px;
  width: 18px;
  height: 18px;
  cursor: grab;
  z-index: 10;
  color: var(--text-secondary);
  opacity: .6;
}
.drag-handle:hover { opacity: 1; }
.drag-handle:active { cursor: grabbing; }
.dashboard-grid.editing .drag-handle { display: flex; align-items: center; justify-content: center; }
/* Drop indicator lines */
.dashboard-grid.editing .drop-before {
  position: relative;
}
.dashboard-grid.editing .drop-before::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  z-index: 10;
  box-shadow: 0 0 8px var(--accent);
}
.dashboard-grid.editing .drop-after {
  position: relative;
}
.dashboard-grid.editing .drop-after::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  z-index: 10;
  box-shadow: 0 0 8px var(--accent);
}
/* Resize handle */
.resize-handle {
  display: none;
  position: absolute;
  bottom: 0;
  right: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  z-index: 10;
  opacity: .5;
}
.resize-handle:hover { opacity: 1; }
.dashboard-grid.editing .resize-handle { display: block; }
/* Grid overlay during resize */
.grid-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  pointer-events: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr; /* las filas reparten el alto para pisar las filas reales */
  gap: 2px;
  padding: 0;
}
.grid-overlay .ov-cell {
  border: 1px dashed rgba(255,255,255,.15);
  min-height: 80px;
}
.grid-overlay .ov-cell.occupied {
  background: rgba(var(--accent-rgb, 255,165,0), .25);
  border: 2px solid var(--accent);
  border-radius: 8px;
}
.grid-overlay .ov-cell.preview {
  background: rgba(var(--accent-rgb, 255,165,0), .12);
  border: 1.5px dashed var(--accent);
  border-radius: 4px;
}
.resize-handle::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--text-secondary);
  border-bottom: 2px solid var(--text-secondary);
  border-radius: 0 0 3px 0;
}
/* Edit mode indicator */

@media (max-width: 920px) {
  .span4, .span5, .span6, .span7, .span8, .full,
  .c1, .c2, .c3, .c4 { grid-column: 1/-1 !important; }
  .drag-handle, .resize-handle { display: none !important; }
}

.c-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.c-title svg {
  width: 16px;
  height: 16px;
  stroke: var(--acc);
}

.sec {
  grid-column: 1/-1;
  align-self: center; /* el separador conserva su altura de contenido, centrado en su fila */
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent);
}

.sec svg { height: 16px; width: auto; stroke: var(--accent); }

.sec span {
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: .7rem;
  color: var(--text);
}

.sec i { flex: 1; height: 1px; background: var(--border); }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0;
  font-size: .74rem;
}

.row .l { color: var(--text-secondary); }
.row .v { font-weight: 600; font-variant-numeric: tabular-nums; }

.bar {
  height: 8px;
  border-radius: 6px;
  background: rgba(255,255,255,.06);
  overflow: hidden;
  position: relative;
}

.bar>i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: var(--accent);
  background-image: linear-gradient(90deg, rgba(255,255,255,.22), transparent 60%);
  transition: width .45s cubic-bezier(.22,.61,.36,1);
}

/* Hero metric */
.c-metric {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0; /* la altura la fija el nº de filas (row-span), no el contenido */
  justify-content: space-between;
}

.c-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.c-top .l {
  display: flex;
  align-items: center;
  gap: 8px;
}

.c-top .l svg {
  width: 16px;
  height: 16px;
  stroke: var(--accent);
}

.gaugewrap {
  position: relative;
  width: 142px;
  height: 142px;
  margin: 6px auto 2px;
  overflow: visible;
}

.gaugewrap .gauge {
  width: 142px;
  height: 142px;
  transform: rotate(-90deg);
  overflow: visible;
  filter: none;
}

.gcore {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.gcore .num {
  font-size: 2.35rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.gcore .lbl {
  font-size: .58rem;
  color: var(--text-secondary);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: 2px;
}

.spark {
  height: 36px;
  width: 100%;
  margin-top: 2px;
}

.spark svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.c-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: .64rem;
  color: var(--text-secondary);
  font-family: var(--mono);
}

.tag {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 8px;
}

.tag b { color: var(--text); font-weight: 600; }

/* Temperatures */
.tgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 700px) {
  .tgrid { grid-template-columns: 1fr; }
}

.tpanel {
  background: rgba(255,255,255,.028);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.thead {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.thead svg { width: 16px; height: 16px; stroke: var(--accent); }

.tmain {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.tbig {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.tbig small {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.tsecondary {
  font-size: .72rem;
  color: var(--text-secondary);
  font-family: var(--mono);
  margin: 10px 0 12px;
}

.tbar {
  height: 7px;
  border-radius: 6px;
  background: rgba(255,255,255,.06);
  overflow: hidden;
}

.tbar>i {
  display: block;
  height: 100%;
  border-radius: 6px;
  transition: width .4s;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.tleg {
  display: flex;
  justify-content: space-between;
  font-size: .58rem;
  color: var(--text-secondary);
  font-family: var(--mono);
  margin-top: 5px;
}

.cpu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.core {
  text-align: center;
  background: rgba(255,255,255,.035);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 2px;
}

.core b {
  display: block;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

.core span {
  font-size: .56rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.core .disc {
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,.07);
  margin: 6px 6px 0;
  overflow: hidden;
}

.core .disc>i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width .3s;
}

/* GPU */
.cu-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 14px;
}

.cu {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: .5rem;
  color: var(--text-secondary);
  transition: .35s;
  position: relative;
  overflow: hidden;
}

.cu.on {
  background: var(--cyan);
  border-color: transparent;
  color: #04222a;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(42,215,238,.45);
}

.cu.hot {
  background: #e0743b;
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 12px rgba(224,116,59,.55);
}

.cu-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: .6rem;
  color: var(--text-secondary);
}

.cu-meta b {
  font-size: .84rem;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.gpu-det {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 14px;
}

.gpu-det .gd {
  background: var(--bg);
  padding: 10px 12px;
}

.gpu-det .gd .k {
  font-size: .56rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.gpu-det .gd .v {
  font-size: .9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.cu-band {
  height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,.07);
  overflow: hidden;
  margin-top: 8px;
}

.cu-band>i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), rgba(42,215,238,.4));
  transition: width .4s;
  border-radius: 3px;
}

/* Fan control */
.fanctl {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pbar {
  height: 7px;
  border-radius: 6px;
  background: rgba(255,255,255,.07);
  overflow: hidden;
  margin-top: 9px;
}

.pbar>i {
  display: block;
  height: 100%;
  border-radius: 6px;
  width: var(--pc,0%);
  transition: width .4s;
  box-shadow: 0 0 8px rgba(255,255,255,.15);
}

.fanctl .frow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.auto-btn {
  cursor: pointer;
  font-family: inherit;
  font-size: .64rem;
  font-weight: 700;
  border-radius: 8px;
  padding: 5px 12px;
  border: 1px solid;
  letter-spacing: .04em;
  transition: transform .15s;
}

.auto-btn:active { transform: scale(.96); }

input[type=range].fan {
  width: 100%;
  height: 22px;
  cursor: pointer;
}

.dev {
  font-size: .6rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}

/* Network */
.net-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 11px;
}

.ifc {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
}

.ifc .nm {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: .05em;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
}

.ifc .nm svg {
  width: 14px;
  height: 14px;
  stroke: var(--cyan);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 8px;
  padding: 3px 9px;
  font-size: .66rem;
  font-family: var(--mono);
}

.pill b { font-weight: 600; }

/* Disk */
.dsk {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255,255,255,.028);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.dsk:last-child { margin-bottom: 0; }

.dsk-ring {
  position: relative;
  width: 76px;
  height: 76px;
  flex: 0 0 auto;
}

.dsk-ring svg {
  width: 76px;
  height: 76px;
  display: block;
  overflow: visible;
}

.dsk-ring .n {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .92rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.dsk-body { flex: 1; }

.dsk-nm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .72rem;
  font-weight: 700;
  margin-bottom: 8px;
  font-family: var(--mono);
}

.dsk-nm .mount { color: var(--text); }
.dsk-nm .fs { color: var(--text-secondary); font-weight: 500; font-size: .6rem; }

.dsk-bar {
  height: 9px;
  border-radius: 6px;
  background: rgba(255,255,255,.06);
  overflow: hidden;
}

.dsk-bar>i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), rgba(255,255,255,.25) 130%);
  box-shadow: 0 0 8px var(--accent);
  transition: width .4s;
}

.dsk-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: .62rem;
  color: var(--text-secondary);
  font-family: var(--mono);
  margin-top: 7px;
  flex-wrap: wrap;
}

.dsk-meta b { color: var(--text); font-weight: 600; }

/* ── Toast ──────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 200;
  max-width: 90vw;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show { display: flex; }

.modal {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.modal.modal-wide { max-width: 480px; }

.modal.modal-tall {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal.modal-tall .modal-actions { margin-top: auto; }

.modal h2 {
  font-weight: 500;
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.modal p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.5;
}

.modal input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  letter-spacing: 0.05em;
  outline: none;
  transition: border-color var(--transition);
}

.modal input:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.path-crumb {
  font-size: 0.7rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.75rem;
}

.breadcrumb .crumb {
  cursor: pointer;
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 6px;
}

.breadcrumb .crumb:hover {
  background: var(--surface-hover);
  text-decoration: underline;
}

.breadcrumb .crumb.cur {
  color: var(--text-secondary);
  cursor: default;
}

.breadcrumb .crumb.cur:hover {
  text-decoration: none;
  background: none;
}

.file-list {
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
  max-height: 46vh;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.8rem;
}

.file-row:hover { background: var(--surface-hover); }

.file-row .fname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row .fsize {
  color: var(--text-secondary);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.file-row.dir .fname {
  color: var(--accent);
  font-weight: 500;
}

.file-row .fmeta {
  color: var(--text-secondary);
  font-size: 0.68rem;
  flex-shrink: 0;
}

.asset-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.asset-list .asset {
  font-size: 0.7rem;
  font-family: var(--mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text-secondary);
  word-break: break-all;
}

.asset-list .asset.del {
  color: var(--red);
  border-color: rgba(255,95,87,.35);
}

.asset-list .asset.log {
  color: var(--amber);
  border-color: rgba(245,185,66,.3);
}

.up-row {
  color: var(--accent);
  font-weight: 500;
}

.loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
  font-weight: 300;
}

/* ── Footer ─────────────────────────────────────────────────── */
.m-foot {
  grid-column: 1/-1;
  text-align: center;
  color: var(--text-secondary);
  font-size: .6rem;
  opacity: .45;
  margin-top: 8px;
  letter-spacing: .05em;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .hamburger {
    display: flex;
  }

  .svc-cards {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}

.sidebar-overlay.show {
  display: block;
}

/* ── Spin animation ─────────────────────────────────────────── */
.spin {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Voltatges color fix ────────────────────────────────────── */
.pill[data-color] {
  border-left-color: var(--pill-color, var(--accent));
}

/* ── Arduino widget desktop scaling ────────────────────────── */
.ard-room .ard-body {
  margin-top: 8px;
}

@media (min-width: 921px) {
  .ard-room .ard-body {
    padding: 20px 0;
    margin-top: 8px;
  }
  .ard-room .ard-body svg {
    width: 72px;
    height: 164px;
  }
  .ard-room .ard-body .tbig {
    font-size: 4rem;
  }
  .ard-room .ard-body .tbig small {
    font-size: 1.6rem;
  }
  .ard-room .ard-body .tsecondary {
    font-size: .92rem;
  }
}

/* ── Reescala dels continguts a la mida del bloc (nº de files) ── */
.dashboard-grid .m-card {
  container-type: size;
  display: flex;
  flex-direction: column;
  justify-content: space-between; /* reparte el contenido para llenar el bloque */
}
.dashboard-grid .m-card > .c-top,
.dashboard-grid .m-card > .c-title {
  flex: 0 0 auto;
}
/* Los grids de celdas (cores, freq, CU, red) llenan el alto y reparten filas */
.dashboard-grid .cpu-grid,
.dashboard-grid .cu-grid,
.dashboard-grid .net-grid {
  flex: 1 1 auto;
  min-height: 0;
  align-content: space-evenly;
}

/* Gauges (Uso de CPU / GPU / Memoria): el cercle i el numeret lliguen l'alçada */
.c-metric .gaugewrap {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  margin: 4px auto 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  position: relative;
}
.c-metric .gaugewrap .gauge {
  width: min(80cqh, 90cqw);
  height: min(80cqh, 90cqw);
}
.c-metric .gcore .num { font-size: 20cqh; }
.c-metric .gcore .lbl { font-size: 4.5cqh; margin-top: 1cqh; }
.c-metric .spark { flex: 1 1 auto; min-height: 0; height: auto; }

/* Habitació (Arduino): termòmetre i textos s'estiren amb el bloc */
.ard-room { padding: 10px 16px 12px; } /* menys marge per aprofitar el bloc */
.ard-room .c-top { padding-bottom: 0; }
.ard-room .ard-body { flex: 1 1 auto; min-height: 0; gap: 16px; }
.ard-room .ard-body svg { height: min(70cqh, 60cqw); width: auto; }
.ard-room .ard-body .tbig { font-size: 14cqh; }
.ard-room .ard-body .tbig small { font-size: 5.4cqh; }
.ard-room .ard-body .tsecondary { font-size: 4.6cqh; }

/* Gràfic de temperatura: omple tot l'alçada del bloc */
#th-canvas { width: 100% !important; height: 100% !important; }
.dashboard-grid [data-wid="th-chart"] > canvas,
.dashboard-grid [data-wid="th-chart"] canvas { display: block; }

/* ── CPU cores / freq: reixos que reparteixen l'alçada (sense ratllar ni apelmagarse) ── */
.dashboard-grid [data-wid="cpu-cores"] .cpu-grid,
.dashboard-grid [data-wid="cpu-freq"] .cpu-grid {
  grid-template-columns: repeat(9, minmax(0,1fr));
  grid-auto-rows: minmax(40px, 1fr);   /* les files reparteixen l'alçada del bloc -> res de cel·les apelmagades */
  align-content: stretch;
  gap: 10px;
  margin-top: 12px;
}
.dashboard-grid [data-wid="cpu-freq"] .cpu-grid { grid-template-columns: repeat(12, minmax(0,1fr)); }
.dashboard-grid [data-wid="cpu-cores"] .core,
.dashboard-grid [data-wid="cpu-freq"] .core {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 2px; gap: 3px;
}
.dashboard-grid [data-wid="cpu-cores"] .core b,
.dashboard-grid [data-wid="cpu-freq"] .core b { font-size: .95rem; }
.dashboard-grid [data-wid="cpu-cores"] .core span,
.dashboard-grid [data-wid="cpu-freq"] .core span { font-size: .62rem; }
.dashboard-grid [data-wid="cpu-cores"] .core .disc,
.dashboard-grid [data-wid="cpu-freq"] .core .disc { width: 72%; margin: 5px auto 0; height: 4px; }
/* xarxa: centrar per no desbordar el marge inferior */
.dashboard-grid [data-wid="sys-net"] .net-grid { align-content: center; gap: 6px; }

@media (max-width: 768px) {
  .dashboard-grid [data-wid="cpu-cores"] .cpu-grid,
  .dashboard-grid [data-wid="cpu-freq"] .cpu-grid { grid-template-columns: repeat(6, minmax(0,1fr)); }
}
.dashboard-grid [data-wid="gpu-cu"] .cu-grid {
  grid-template-columns: repeat(14, 1fr);
  gap: 5px;
  margin-top: 8px;
  align-content: start;
}
.dashboard-grid [data-wid="gpu-cu"] .cu { aspect-ratio: 1; border-radius: 6px; }
.dashboard-grid [data-wid="gpu-cu"] .gpu-det { margin-top: 8px; }
.dashboard-grid [data-wid="gpu-cu"] .cu-band { margin-top: 6px; }

/* ── Menú lateral: apps marcadas + casilla «Menú» en cada servidor (14/09/2026) ── */
.menu-toggle {
  position: relative;
  gap: 5px;
  padding: 8px 12px;
}
.menu-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}
.menu-toggle.on {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.menu-toggle.on svg { opacity: 1; }
.menu-toggle svg { opacity: .65; }

.sidebar-app span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-app::after {
  content: "↗";
  margin-left: auto;
  font-size: .75rem;
  opacity: .45;
}
#sidebar-apps .sidebar-app:hover::after { opacity: 1; }
