:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --gray-bg: #f1f5f9;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
}

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

/* Top navbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.topbar .brand a { color: var(--primary); }
.topbar .user { color: var(--text-muted); font-size: 0.9rem; }
.topbar .user a { margin-left: 1rem; }

/* Layout: sidebar + content */
.layout { display: flex; min-height: calc(100vh - 53px); }
.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  flex-shrink: 0;
}
.sidebar .group-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.5rem 1.25rem;
  margin-top: 0.5rem;
}
.sidebar a, .sidebar .disabled {
  display: block;
  padding: 0.5rem 1.25rem;
  color: var(--text);
  font-size: 0.92rem;
}
.sidebar a:hover { background: var(--gray-bg); text-decoration: none; }
.sidebar a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; border-right: 3px solid var(--primary); }
.sidebar .disabled { color: #cbd5e1; cursor: not-allowed; }
.sidebar .soon { font-size: 0.7rem; background: var(--gray-bg); color: var(--text-muted); padding: 0.1rem 0.4rem; border-radius: 4px; margin-left: 0.4rem; }

.content { flex: 1; padding: 1.5rem 2rem; max-width: 1100px; }

.breadcrumb { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
.breadcrumb a { color: var(--text-muted); }

h1 { font-size: 1.6rem; margin: 0.25rem 0 0.25rem; }
.subtitle { color: var(--text-muted); margin-bottom: 1.5rem; }

.flash { background: var(--primary-light); color: var(--primary-hover); padding: 0.6rem 1rem; margin-bottom: 1rem; border-radius: 6px; font-size: 0.9rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}
.btn:hover { background: var(--gray-bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger-bg); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-row { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.btn-row form { margin: 0; }

/* Table */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 0.78rem; text-transform: uppercase; color: var(--text-muted); padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
td { padding: 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
tr:last-child td { border-bottom: none; }
td a { font-weight: 600; }

/* Status badge */
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-ACTIVE { background: var(--success-bg); color: var(--success); }
.badge-SHUTOFF { background: var(--gray-bg); color: var(--text-muted); }
.badge-ERROR { background: var(--danger-bg); color: var(--danger); }
.badge-BUILD, .badge-REBOOT, .badge-HARD_REBOOT { background: var(--warning-bg); color: var(--warning); }

/* Service cards (home page) */
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: left;
}
.service-card.active { border-color: var(--primary); cursor: pointer; }
.service-card.active:hover { box-shadow: 0 2px 8px rgba(37,99,235,0.15); }
.service-card.disabled { opacity: 0.55; }
.service-card .icon { font-size: 1.6rem; }
.service-card .name { font-weight: 700; margin: 0.5rem 0 0.25rem; }
.service-card .desc { font-size: 0.82rem; color: var(--text-muted); }
.service-card .tag { font-size: 0.7rem; background: var(--gray-bg); color: var(--text-muted); padding: 0.1rem 0.4rem; border-radius: 4px; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tab-btn {
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Forms */
label { display: block; margin-top: 0.75rem; font-size: 0.88rem; font-weight: 500; }
input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  box-sizing: border-box;
}
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem 2rem; }
.info-grid div { font-size: 0.88rem; }
.info-grid .label { color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; margin-bottom: 0.15rem; }

/* Status spinner — used while a VPS is in a transitional state (BUILD/REBOOT/...) */
.spinner {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-left: 0.5rem;
  border: 2px solid rgba(217, 119, 6, 0.25);
  border-top-color: var(--warning);
  border-radius: 50%;
  vertical-align: middle;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Row fade-out, used when a deleted VPS is removed from the list without a full reload */
.row-removing { opacity: 0; transition: opacity 0.3s ease; }

/* Disabled action button (e.g. Detach Interface on the VPS's original NIC) */
.btn-disabled { color: #cbd5e1; border-color: var(--border); cursor: not-allowed; }
.btn-disabled:hover { background: none; }

/* Console preview thumbnail (iDRAC/iLO-style shortcut) next to General information */
.console-thumb {
  width: 160px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  text-align: center;
}
.console-thumb:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(37,99,235,0.15); }
.console-thumb-screen {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #0f172a;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.console-thumb-screen::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: repeating-linear-gradient(90deg, #334155 0 6px, #0f172a 6px 12px);
}
.console-thumb-play { color: #64748b; font-size: 1.6rem; }
.console-thumb:hover .console-thumb-play { color: var(--primary); }
.console-thumb-label { margin-top: 0.5rem; font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }

/* Inline console popup */
.console-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.console-modal-backdrop.open { display: flex; }
.console-modal {
  background: var(--surface);
  border-radius: 8px;
  width: min(900px, 92vw);
  height: min(650px, 85vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.console-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 600;
}
.console-modal-header button { background: none; border: none; font-size: 1.2rem; cursor: pointer; }
.console-modal iframe { flex: 1; border: none; width: 100%; }
