/* DCUBIX Cloud dashboard — palette per validated reference (dataviz) */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-cpu: #2a78d6;   /* blue, slot 1 */
  --series-ram: #1baf7a;   /* aqua, slot 2 */
  --series-disk: #4a3aa7;  /* violet, slot 5 */
  --series-in: #2a78d6;
  --series-out: #1baf7a;
  --status-good: #0ca30c;
  --status-critical: #d03b3b;
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-cpu: #3987e5;
    --series-ram: #199e70;
    --series-disk: #9085e9;
    --series-in: #3987e5;
    --series-out: #199e70;
    --accent: #3987e5;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 650; }
.muted { color: var(--muted); }

/* ---------- login (split screen) ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

/* Left brand hero — always the coloured panel, both themes */
.auth-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  color: #fff;
  overflow: hidden;
  background: linear-gradient(150deg, #2547e0 0%, #3a2fb0 55%, #4a2fa0 100%);
}
/* faint geometric lines in the background */
.auth-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 80% 15%, rgba(255, 255, 255, 0.12), transparent 40%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 44px);
  pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }

.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.14em;
}
.auth-logo-mark {
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 7px;
  padding: 2px;
  object-fit: contain;
}

.auth-hero-mid { max-width: 460px; }
.auth-hero-star {
  width: 66px;
  height: 66px;
  background: #fff;
  border-radius: 14px;
  padding: 5px;
  object-fit: contain;
  margin-bottom: 28px;
}
.auth-hero-title {
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  line-height: 1.08;
  font-weight: 700;
  margin: 0 0 20px;
}
.auth-hero-title .wave { display: inline-block; }
.auth-hero-copy {
  font-size: 1.02rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.82);
  margin: 0;
}
.auth-hero-foot { font-size: 13px; color: rgba(255, 255, 255, 0.6); }

/* Right form panel — theme-aware */
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--surface);
}
.auth-form-wrap { width: 100%; max-width: 360px; }
.auth-brand {
  font-weight: 650;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 48px;
}
.auth-title { font-size: 30px; font-weight: 700; margin: 0 0 6px; }
.auth-sub { color: var(--ink-2); margin: 0 0 32px; }

.auth-field { display: flex; flex-direction: column; margin-bottom: 22px; }
.auth-field label { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.auth-field input {
  border: 0;
  border-bottom: 1.5px solid var(--baseline);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  padding: 8px 2px;
  transition: border-color 0.15s;
}
.auth-field input::placeholder { color: var(--muted); }
.auth-field input:focus { outline: none; border-bottom-color: var(--accent); }

.auth-btn {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.auth-btn:hover { opacity: 0.9; }
.auth-btn:disabled { opacity: 0.6; cursor: wait; }

.auth-error {
  color: var(--status-critical);
  font-size: 13px;
  margin: 0 0 16px;
}
.auth-hint { color: var(--muted); font-size: 13px; margin: 28px 0 0; }

@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero {
    padding: 28px 24px;
    min-height: auto;
  }
  .auth-hero-mid { max-width: none; }
  .auth-hero-star { width: 46px; height: 46px; padding: 4px; border-radius: 10px; margin-bottom: 16px; }
  .auth-hero-title { font-size: clamp(1.8rem, 7vw, 2.4rem); margin-bottom: 12px; }
  .auth-hero-copy { font-size: 0.95rem; }
  .auth-hero-foot { display: none; }
  .auth-panel { padding: 32px 24px; }
  .auth-brand { margin-bottom: 28px; }
}

/* ---------- shell ---------- */
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; object-fit: contain; display: block; }
.brand h1 { font-size: 20px; }
.brand-name { font-weight: 650; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

/* nav tabs */
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.tab:hover { background: var(--grid); }
.tab.active { background: var(--accent); color: #fff; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px 16px; }
  .brand-name { display: none; }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; text-align: center; }
}

.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 40px; }

.ghost-btn {
  background: none;
  border: 1px solid var(--baseline);
  border-radius: 8px;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  padding: 5px 12px;
  cursor: pointer;
}
.ghost-btn:hover { background: var(--grid); }

.server-select {
  background: var(--page);
  border: 1px solid var(--baseline);
  color: var(--ink);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  padding: 5px 10px;
  cursor: pointer;
}
.server-select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.state-badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state-badge.good { color: var(--status-good); }
.state-badge.bad { color: var(--status-critical); }

/* ---------- server head & range filter ---------- */
.server-head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
}
.server-head h2 { font-size: 22px; }
.server-head p { margin: 4px 0 0; font-size: 13px; }

.range-row { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.range-row button {
  border: 0;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 7px;
  cursor: pointer;
}
.range-row button:hover { background: var(--grid); }
.range-row button.active { background: var(--accent); color: #fff; }

/* ---------- stat tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tile-label { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.tile-value { font-size: 26px; font-weight: 650; }
.tile-sub { font-size: 12px; color: var(--muted); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-cpu { background: var(--series-cpu); }
.dot-ram { background: var(--series-ram); }
.dot-disk { background: var(--series-disk); }
.dot-in { background: var(--series-in); }
.dot-out { background: var(--series-out); }

/* ---------- cards & charts ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 8px;
}
.card-head h3 { font-size: 15px; font-weight: 650; flex: 1; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

.chart-body { position: relative; }
.chart-body svg { display: block; width: 100%; height: auto; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 32px 0; text-align: center; }

.chart-table { max-height: 220px; overflow: auto; margin-top: 8px; }

.tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink);
  min-width: 120px;
}
.tooltip .tt-time { color: var(--muted); margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.tooltip .tt-row b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--grid);
  padding: 8px 10px;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--grid); }
.data-table td.num { font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: 0; }

.backups-card { margin-bottom: 20px; }
.backups-meta { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.download-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  padding: 4px 12px;
  cursor: pointer;
}
.download-btn:hover { background: var(--accent); color: #fff; }
.download-btn:disabled { opacity: 0.5; cursor: wait; }
.empty { text-align: center; padding: 24px 0; }

.banner-error {
  background: color-mix(in srgb, var(--status-critical) 10%, var(--surface));
  border: 1px solid var(--status-critical);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin: 0 0 16px;
}

.foot { text-align: center; font-size: 12px; margin-top: 8px; }

/* ---------- profile ---------- */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 650; margin: 0 0 14px; }

.field-list { margin: 0; }
.field { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.field:last-child { border-bottom: 0; }
.field dt { color: var(--muted); font-size: 14px; }
.field dd { margin: 0; font-weight: 600; }

.server-list { list-style: none; margin: 0; padding: 0; }
.server-list li { padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.server-list li:last-child { border-bottom: 0; }

.auth-ok { color: var(--status-good); font-size: 13px; margin: 0 0 16px; }

/* the profile change-password form reuses .auth-field / .auth-btn from login */
.profile-grid .auth-btn { margin-top: 10px; }

/* ---------- skeleton loading ---------- */
.skeleton {
  display: inline-block;
  background: var(--grid);
  border-radius: 6px;
  color: transparent !important;
  user-select: none;
  pointer-events: none;
  animation: skeleton-pulse 1.3s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* dashboard */
#server-label.skeleton { width: 180px; height: 24px; }
#server-meta.skeleton { width: 260px; max-width: 100%; height: 12px; }
.tile-value.skeleton { width: 76px; height: 24px; margin: 4px 0 5px; }
.tile-sub.skeleton { width: 90px; height: 11px; }
.skeleton-chart {
  display: block;
  width: 100%;
  aspect-ratio: 600 / 220;
  border-radius: 8px;
}

/* backups table + profile lists */
.sk-line { height: 13px; width: 130px; }
.sk-cell-lg { height: 13px; width: 240px; max-width: 50vw; }
.sk-cell-md { height: 13px; width: 140px; }
.sk-cell-sm { height: 13px; width: 56px; }
.sk-btn { height: 27px; width: 90px; border-radius: 7px; }
.field dd.skeleton { width: 150px; height: 15px; }
