:root {
  --bg: #0b0f18;
  --panel: #131a29;
  --panel-2: #0f1522;
  --border: #232d42;
  --text: #e8ebf3;
  --muted: #8994ac;
  --accent: #5b7cfa;
  --accent-2: #8b5cf6;
  --ok: #35c789;
  --err: #ef5a6f;
  --warn: #f0b429;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }

/* ---- shell ---- */
.app-shell { display: flex; min-height: 100vh; }
.main-sidebar {
  width: 250px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--border); padding: 22px 16px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; padding: 0 4px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.brand-text { font-weight: 600; font-size: 15px; letter-spacing: .2px; }

.nav-primary { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.nav-primary a, .nav-bottom a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 500;
}
.nav-ic { width: 16px; text-align: center; opacity: .85; }
.nav-primary a:hover, .nav-bottom a:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-primary a.active { background: rgba(91,124,250,.14); color: var(--text); }

.nav-divider { height: 1px; background: var(--border); margin: 16px 4px; }

.nav-vds-context { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vds-context-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 10px; margin-bottom: 2px; }
.vds-context-name { font-size: 14px; font-weight: 600; padding: 0 10px; margin-bottom: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-apps { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-apps a.app-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--text);
}
.nav-apps a.app-row:hover { background: rgba(255,255,255,.04); }
.nav-apps a.app-row.active { background: rgba(91,124,250,.14); box-shadow: inset 2px 0 0 var(--accent); }
.nav-apps a.app-row.maint { opacity: .45; }
.app-name { display: block; font-size: 13px; }
.app-version { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-maint { background: var(--muted); }
.dot-running { background: var(--ok); box-shadow: 0 0 0 3px rgba(53,199,137,.15); }
.dot-stopped { background: var(--err); }
.dot-none { background: transparent; border: 1px solid var(--muted); }

.nav-bottom { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }

.shell-content { flex: 1; min-width: 0; padding: 34px 40px; max-width: 1080px; }
.bare-content { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

/* ---- generic ---- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
h1 { font-size: 21px; margin: 0 0 18px; letter-spacing: -.2px; }
h2 { font-size: 15.5px; margin: 0 0 4px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-ok, .badge-running { background: rgba(53,199,137,.15); color: var(--ok); }
.badge-err, .badge-stopped { background: rgba(239,90,111,.15); color: var(--err); }
.badge-unknown { background: rgba(139,148,172,.15); color: var(--muted); }
.badge-maint { background: rgba(240,180,41,.14); color: var(--warn); }

form.inline { display: inline-block; }
label { display: block; margin: 14px 0 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 120px; font-family: ui-monospace, monospace; }

button, .btn {
  display: inline-block; background: var(--accent); color: #fff; border: none;
  padding: 9px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none;
}
button.secondary, .btn.secondary { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
button.danger { background: var(--err); }
button:hover, .btn:hover { filter: brightness(1.08); }
.actions-grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 13.5px; }
.flash-ok { background: rgba(53,199,137,.1); color: var(--ok); border: 1px solid rgba(53,199,137,.25); }
.flash-error { background: rgba(239,90,111,.1); color: var(--err); border: 1px solid rgba(239,90,111,.25); }

.login-box { width: 100%; max-width: 360px; }
.muted { color: var(--muted); font-size: 13px; }

.install-prompt { text-align: center; padding: 44px 24px; }
.install-prompt h2 { margin-bottom: 6px; font-size: 18px; }

/* ---- VDS picker (dashboard) ---- */
.vds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.vds-card {
  display: block; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s;
}
.vds-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.vds-card .vname { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.vds-card .vip { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.vds-card .vmeta { display: flex; justify-content: space-between; align-items: center; }
.vds-card-add {
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px;
  border: 1px dashed var(--border); border-radius: 12px; padding: 18px; text-decoration: none;
  color: var(--muted); min-height: 96px;
}
.vds-card-add:hover { border-color: var(--accent); color: var(--text); }
.vds-card-add .plus { font-size: 22px; }

.busy-wrap { position: relative; }
.busy-wrap.is-busy .busy-content {
  filter: blur(4px); opacity: .45; pointer-events: none; user-select: none;
}
.busy-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.busy-overlay-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px 34px; text-align: center; max-width: 360px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.busy-overlay-box strong { display: block; margin: 10px 0 4px; font-size: 14.5px; }
.gear-spin {
  display: inline-block; font-size: 34px; line-height: 1; color: var(--accent);
  animation: spin 2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 60px 20px; }
.empty-state h2 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }

@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .main-sidebar { width: 100%; height: auto; position: static; }
  .shell-content { padding: 22px; }
}
