:root {
  --ink: #172033;
  --muted: #6b7280;
  --line: #e5e9f2;
  --panel: #ffffff;
  --canvas: #f4f7fb;
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --success: #0f9f6e;
  --warning: #d97706;
  --danger: #dc2626;
}

* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--canvas); }
code { color: #6d28d9; word-break: normal; overflow-wrap: anywhere; }
.min-w-0 { min-width: 0; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.app-sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 22px 16px; color: #e8eaf4; background: #11182a; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; color: #fff; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  font-size: 13px; font-weight: 800; letter-spacing: .04em;
  background: linear-gradient(135deg, #7067ff, #3b82f6); box-shadow: 0 8px 24px #4f46e555;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: #8993aa; font-size: 11px; font-weight: 500; }
.app-nav { display: grid; gap: 5px; }
.app-nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px; color: #9ea7bb;
  border-radius: 10px; text-decoration: none; font-size: 14px; font-weight: 600;
}
.app-nav a span { width: 20px; text-align: center; font-size: 17px; }
.app-nav a:hover, .app-nav a.active { color: #fff; background: #242d43; }
.app-nav a.active { box-shadow: inset 3px 0 0 #746cff; }
.sidebar-profile {
  display: grid; grid-template-columns: 38px minmax(0, 1fr) 28px; gap: 10px; align-items: center;
  margin-top: auto; padding: 14px 8px 0; border-top: 1px solid #293147;
}
.sidebar-profile .avatar {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: #343d57; color: #fff; font-weight: 700;
}
.sidebar-profile strong, .sidebar-profile small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile strong { color: #fff; font-size: 13px; }
.sidebar-profile small { color: #8590a7; font-size: 11px; }
.sidebar-profile button { border: 0; background: transparent; color: #9ba5ba; font-size: 18px; }

.app-main { min-width: 0; }
.app-topbar {
  height: 66px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88);
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10;
}
.sidebar-toggle { display: none; border: 0; background: transparent; font-size: 22px; }
.live-dot {
  display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 0 4px #0f9f6e20;
}
.app-content { max-width: 1500px; margin: 0 auto; padding: 30px; }
.page-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.page-heading h1 { margin: 0 0 5px; font-size: 28px; font-weight: 750; letter-spacing: -.025em; }
.page-heading p { margin: 0; color: var(--muted); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 15px;
  box-shadow: 0 6px 24px rgba(38, 50, 78, .045);
}
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 16px; font-weight: 700; }
.panel-body { padding: 20px; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric-card { padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.metric-card strong { display: block; margin-top: 10px; font-size: 28px; }
.metric-card span { color: var(--muted); font-size: 13px; }
.metric-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: #eef2ff; color: var(--brand); }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: #eef2f7; color: #536078;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge[data-status="ready"], .status-badge[data-status="succeeded"] { color: #08785a; background: #e7f8f1; }
.status-badge[data-status="failed"] { color: #b42318; background: #feeceb; }
.status-badge[data-status="stopped"] { color: #596579; background: #edf0f5; }
.status-badge[data-status="queued"], .status-badge[data-status="retrying"] { color: #9a6200; background: #fff5d8; }
.status-badge[data-status="running"], .status-badge[data-status="creating_vm"],
.status-badge[data-status="bootstrapping"], .status-badge[data-status="configuring_access"],
.status-badge[data-status="starting"], .status-badge[data-status="stopping"] { color: #3156b8; background: #eaf0ff; }
.status-badge[data-status="deleting"] { color: #9f1239; background: #fff0f4; }

.stand-progress { margin-bottom: 24px; padding: 16px; border-radius: 12px; background: #f7f8ff; }
.stand-progress-heading { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10px; color: #302b72; }
.stand-progress-heading span { font-weight: 750; }
.stand-progress-track { height: 10px; overflow: hidden; border-radius: 999px; background: #e2e6f2; }
.stand-progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #7058e8); transition: width .35s ease; }

.connection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.connection-card { padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcff; }
.connection-card h3 { margin: 0 0 3px; font-size: 15px; }
.connection-card .kind { color: var(--muted); font-size: 12px; }
.credential-row { display: grid; grid-template-columns: 68px minmax(0, 1fr) 26px; align-items: center; gap: 7px; margin-top: 9px; font-size: 13px; }
.credential-secret { font-family: var(--bs-font-monospace); letter-spacing: .08em; }
.copy-button, .reveal-button { border: 0; color: var(--brand); background: transparent; font-weight: 650; font-size: 12px; }
.connection-card .copy-button { width: 26px; padding: 0; overflow: hidden; font-size: 0; }
.connection-card .copy-button::before { content: "⧉"; font-size: 17px; }

.table { margin: 0; }
.table > :not(caption) > * > * { padding: 13px 16px; border-color: var(--line); vertical-align: middle; }
.table thead th { color: #778096; background: #fafbfe; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.table tbody td { font-size: 13px; }
.table-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.filter-bar .form-control, .filter-bar .form-select { max-width: 240px; }
.empty-state { padding: 46px 24px; text-align: center; }
.empty-state .empty-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 15px; border-radius: 18px; background: #eef2ff; color: var(--brand); font-size: 26px; }
.empty-state h2 { font-size: 19px; }
.empty-state p { max-width: 520px; margin: 0 auto 20px; color: var(--muted); }

.vpn-key {
  display: flex; gap: 10px; align-items: center; padding: 14px; border: 1px dashed #9ba5ff;
  border-radius: 10px; background: #f7f7ff;
}
.vpn-key code { flex: 1; color: #302b72; font-size: 14px; }
.notice { padding: 13px 15px; border-radius: 10px; background: #fff7e6; color: #7a4b00; font-size: 13px; }
.danger-zone { border-color: #ffd4d4; }
.pagination { margin: 16px 20px; }

.auth-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 20% 10%, #e8e7ff 0, transparent 34%),
              radial-gradient(circle at 85% 80%, #dbeafe 0, transparent 32%), #f7f8fc;
}
.auth-card { width: min(440px, 100%); padding: 32px; border: 1px solid #e2e5ee; border-radius: 20px; background: #fff; box-shadow: 0 24px 80px rgba(33, 42, 68, .12); }
.auth-logo { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 24px; border-radius: 15px; color: #fff; background: linear-gradient(135deg, #6d63ff, #3b82f6); font-weight: 800; }

@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .app-sidebar { position: fixed; left: -275px; width: 260px; transition: left .2s ease; }
  body.sidebar-open .app-sidebar { left: 0; }
  .sidebar-toggle { display: block; }
  .app-content { padding: 22px 16px; }
  .app-topbar { padding: 0 16px; }
  .connection-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .page-heading { display: block; }
  .page-heading .btn { margin-top: 14px; }
  .credential-row { grid-template-columns: 64px minmax(0, 1fr) 24px; }
}
