/* ============== Design tokens ============== */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --surface-3: #f0f1f3;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-dim: rgba(37, 99, 235, 0.08);
  --accent-glow: rgba(37, 99, 235, 0.20);
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --text: #111827;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============== App shell ============== */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ============== Top bar ============== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 0 28px;
  height: 56px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; font-size: 15px; color: var(--text); }
.topbar__brand-name { color: var(--text); }
.topbar__brand-dim { color: var(--text-muted); font-weight: 400; font-size: 12px; }
.topbar__center { flex: 1; display: flex; justify-content: center; }
.topbar__right { display: flex; align-items: center; gap: 10px; }

/* ============== Buttons ============== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; transition: background .15s, box-shadow .15s;
  border: none; cursor: pointer;
}
.btn--primary {
  background: var(--accent); color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn--danger:hover { background: #fee2e2; }
.btn--icon-sm { width: 26px; height: 26px; padding: 4px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; }
.btn--icon-sm:hover { background: var(--surface-2); }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--subtle { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.btn--subtle:hover { background: var(--surface-3); color: var(--text); }

/* ============== Client pill ============== */
.client-pill {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px; color: var(--text);
  transition: border-color .15s, background .15s;
  position: relative; cursor: pointer;
}
.client-pill:hover { border-color: var(--accent); }
.client-pill__avatar {
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  background: var(--accent-dim); color: var(--accent);
}
.client-pill__name { font-weight: 500; }
.client-pill__chev { color: var(--text-muted); font-size: 11px; }
.client-pill__menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  overflow: hidden; z-index: 100;
}
.client-pill__option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; font-size: 13px; cursor: pointer;
  transition: background .1s; color: var(--text);
}
.client-pill__option:hover { background: var(--surface-2); }
.client-pill__option--active { background: var(--accent-dim); color: var(--accent); }

/* ============== User menu ============== */
.user-menu {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--accent-glow);
}

/* ============== Page / layout ============== */
.page { max-width: 1200px; margin: 0 auto; padding: 32px 28px; }

/* ============== Stat row ============== */
.stat-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px;
}
.stat {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.stat__icon {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  background: var(--accent-dim);
  color: var(--accent);
  display: grid; place-items: center; flex-shrink: 0;
}
.stat__value { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 6px; line-height: 1; }
.stat__label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.stat__body { flex: 1; }

/* ============== Section head ============== */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; color: var(--text); }
.section { margin-bottom: 32px; }
.section-head__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ============== Server grid ============== */
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

/* ============== Server card ============== */
.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow .2s, border-color .2s;
  cursor: pointer;
  display: flex; flex-direction: column;
}
.server-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.10); border-color: var(--border-strong); }
.server-card__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 18px 12px;
}
.server-card__title { font-size: 14px; font-weight: 700; margin-bottom: 2px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.server-card__sub { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }
.server-card__menu { color: var(--text-muted); }
.server-card__stack {
  margin: 0 0 14px 0;
  height: 60px;
  background: var(--surface-2);
  border: none;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
}
.server-card__body { padding: 0 18px 14px; }
.server-card__footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  margin-top: auto;
}
.server-card__meta { display: flex; align-items: center; gap: 14px; }
.server-card__meta-item { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.server-card__actions { display: flex; gap: 8px; margin-top: auto; }

/* ============== Server info ============== */
.server-info {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
  margin-bottom: 14px; padding: 0 18px;
}
.server-info__row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); min-width: 0; }
.server-info__row .ico { color: var(--text-muted); width: 14px; flex-shrink: 0; }
.server-info__row strong { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============== Health bar ============== */
.health { margin-bottom: 16px; padding: 0 18px; display: flex; flex-direction: column; gap: 6px; }
.health__row { display: flex; align-items: center; gap: 10px; }
.health__label { font-size: 11px; color: var(--text-muted); width: 32px; font-family: var(--mono); }
.health__bar { flex: 1; height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.health__bar > div { height: 100%; border-radius: 999px; transition: width .3s; }
.health__val { font-size: 11px; color: var(--text-dim); font-family: var(--mono); width: 38px; text-align: right; }
.health--green > div { background: var(--success); }
.health--amber > div { background: var(--warning); }
.health--red > div { background: var(--danger); }

/* ============== Status dots & pills ============== */
.dot {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.dot--success { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.dot--warning { background: var(--warning); box-shadow: 0 0 0 3px rgba(217,119,6,.15); }
.dot--danger  { background: var(--danger);  box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
.dot--muted   { background: var(--text-dim); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.pill--running  { background: #f0fdf4; color: var(--success); }
.pill--starting { background: #fffbeb; color: var(--warning); }
.pill--stopped  { background: #f3f4f6; color: var(--text-muted); }
.pill--error    { background: #fef2f2; color: var(--danger); }
.pill--exited   { background: #fef2f2; color: var(--danger); }
.pill--restarting { background: #fffbeb; color: var(--warning); }

/* ============== Stack visual ============== */
.stack-visual { display: flex; gap: 4px; flex-wrap: wrap; }
.stack-badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px; letter-spacing: .03em; }
.stack-icons { display: flex; align-items: center; gap: 8px; }
.stack-icons__chip {
  background: var(--surface-3);
  border-radius: 8px;
  padding: 6px 10px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-family: var(--mono); color: var(--text-dim);
  border: 1px solid var(--border);
}

/* ============== Crumbs ============== */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.crumbs__back {
  display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; transition: background .15s;
}
.crumbs__back:hover { background: var(--surface-3); }
.crumbs__sep { color: var(--text-dim); }
.crumbs__current { color: var(--text); font-weight: 600; }

/* ============== Client switcher ============== */
.client-switcher {
  position: relative;
}
.client-switcher__btn {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer; transition: border-color .15s;
}
.client-switcher__btn:hover { border-color: var(--accent); }
.client-switcher__avatar {
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  background: var(--accent-dim); color: var(--accent);
}
.client-switcher__name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-switcher__menu {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden; z-index: 200;
  padding: 6px;
}
.client-switcher__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; font-size: 13px; cursor: pointer;
  color: var(--text); transition: background .1s; width: 100%; text-align: left;
  background: none; border: none;
}
.client-switcher__item:hover { background: var(--surface-2); }
.client-switcher__item--active { background: var(--accent-dim); color: var(--accent); }

/* ============== User dropdown ============== */
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--accent-glow);
  position: relative;
  transition: background .15s;
}
.user-avatar:hover { background: var(--accent); color: #fff; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden; z-index: 200;
  padding: 6px;
}
.user-dropdown__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; font-size: 13px; cursor: pointer;
  color: var(--text); transition: background .1s; width: 100%; text-align: left;
  background: none; border: none;
}
.user-dropdown__item:hover { background: var(--surface-2); }
.user-dropdown__item--danger { color: var(--danger); }
.user-dropdown__item--danger:hover { background: #fef2f2; }

/* ============== Drawers ============== */
@keyframes drawer-slide-in-right {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes drawer-slide-in-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes drawer-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.25); z-index: 50;
  animation: drawer-fade-in .18s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh;
  width: 520px; max-width: 100vw;
  background: var(--surface);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,0.12);
  z-index: 51;
  animation: drawer-slide-in-right .22s cubic-bezier(.4,0,.2,1);
}
.drawer--bottom {
  position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto;
  max-height: 72vh; width: 100%;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.12);
  animation: drawer-slide-in-up .22s cubic-bezier(.4,0,.2,1);
}
.drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer__head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.drawer__close { color: var(--text-muted); padding: 6px; border-radius: 6px; }
.drawer__close:hover { background: var(--surface-2); color: var(--text); }
.drawer__body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer__foot {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-shrink: 0;
}

/* ============== Stepper ============== */
.stepper { display: flex; align-items: flex-start; gap: 0; padding: 0 0 24px; }
.stepper__item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.stepper__step {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; font-size: 12px; font-weight: 700;
  border: 2px solid var(--border); color: var(--text-muted); background: var(--surface);
  transition: all .2s; flex-shrink: 0;
}
.stepper__step--active  { border-color: var(--accent); color: var(--accent); }
.stepper__step--current { border-color: var(--accent); color: var(--accent); }
.stepper__step--done    { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper__label { font-size: 11px; color: var(--text-muted); white-space: nowrap; text-align: center; }
.stepper__item--current .stepper__label { color: var(--accent); font-weight: 600; }
.stepper__bar     { flex: 1; height: 2px; background: var(--border); border-radius: 99px; margin-top: 14px; }
.stepper__bar--done { background: var(--accent); }
.stepper__line     { flex: 1; height: 2px; background: var(--border); border-radius: 99px; margin-top: 14px; }
.stepper__line--done { background: var(--accent); }
.stepper__num { font-family: var(--mono); font-size: 12px; }

/* ============== Template cards ============== */
.template-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.template-card {
  padding: 14px; border-radius: var(--radius-md);
  border: 2px solid var(--border); background: var(--surface);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.template-card:hover { border-color: var(--accent); background: var(--accent-dim); }
.template-card--selected { border-color: var(--accent); background: var(--accent-dim); }
.template-card__icon {
  width: 44px; height: 44px;
  background: var(--surface-3);
  border-radius: 10px;
  display: grid; place-items: center;
  margin-bottom: 10px;
  font-size: 22px;
}
.template-card__name { font-weight: 600; margin: 0 0 4px; font-size: 14px; }
.template-card__stack { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }

/* ============== Size cards ============== */
.size-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.size-card {
  padding: 14px 12px; border-radius: var(--radius-md); text-align: center;
  border: 2px solid var(--border); background: var(--surface);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.size-card:hover { border-color: var(--accent); }
.size-card--selected { border-color: var(--accent); background: var(--accent-dim); }
.size-card__emoji { font-size: 20px; }
.size-card__name { font-size: 13px; font-weight: 600; margin: 4px 0 2px; color: var(--text); }
.size-card__instance { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }
.size-card__specs { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.size-card__desc { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ============== Form fields ============== */
.field { margin-bottom: 16px; }
.field__label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; letter-spacing: .04em; text-transform: uppercase; }
.field__input {
  width: 100%; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
  outline: none; transition: border-color .15s;
}
.field__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input { width: 100%; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input--mono { font-family: var(--mono); font-size: 12px; }

/* ============== Launch progress ============== */
.launch-step { display: flex; align-items: center; gap: 12px; padding: 10px 0; font-size: 13px; }
.launch-step--done { color: var(--success); }
.launch-step--active { color: var(--accent); }
.launch-step--pending { color: var(--text-dim); }
.launch-step__icon { width: 22px; height: 22px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; }
.launch-step--done .launch-step__icon { background: var(--success); border-color: var(--success); color: #fff; }

.launch-steps { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }

/* ============== Spinner ============== */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
.spinner--lg { width: 32px; height: 32px; border-width: 3px; }
.spinner--sm { width: 12px; height: 12px; border-width: 1.5px; }

/* ============== Skeleton ============== */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton--text { height: 14px; border-radius: 4px; }
.skeleton--title { height: 20px; border-radius: 4px; }
.skeleton--circle { border-radius: 50%; }

/* ============== Server detail ============== */
.detail-head {
  display: grid; grid-template-columns: 1fr auto; gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 26px;
}
.detail-head__left { display: flex; gap: 16px; }
.detail-head__icon {
  width: 56px; height: 56px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.detail-head__title {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0;
  display: flex; align-items: center; gap: 10px;
}
.detail-head__meta {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12px; color: var(--text-muted);
  font-family: var(--mono);
}
.detail-head__right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; flex-shrink: 0; }
.detail-head__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 24px; gap: 0; }
.tab {
  padding: 10px 18px; border: none; background: transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab--active { color: var(--accent); border-bottom-color: var(--accent); }

/* ============== Containers ============== */
.container-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.container-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column;
}
.container-card:hover { border-color: var(--border-strong); }
.container-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.container-card__name { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.container-card__image { font-size: 11px; color: var(--text-muted); font-family: var(--mono); margin-bottom: 10px; }
.container-card__ports { font-family: var(--mono); font-size: 11px; color: var(--text-dim); background: var(--surface-2); padding: 4px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.container-card__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }

/* ============== Env table ============== */
.env-table { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.env-table__row {
  display: grid; grid-template-columns: 0.8fr 1.6fr auto auto;
  gap: 12px; align-items: center;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  border-left: 3px solid transparent;
}
.env-table__row:first-child { border-top: none; }
.env-table__row--header { background: var(--surface-2); color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; padding: 12px 18px; }
.env-table__row--modified { border-left-color: var(--accent); background: rgba(37, 99, 235, 0.03); }
.env-table__row--new { border-left-color: var(--success); background: rgba(22,163,74,0.03); }
.env-table__row .key { font-family: var(--mono); font-size: 13px; font-weight: 500; }
.env-table__row .value-input { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 6px 10px; color: var(--text); font-family: var(--mono); font-size: 12px; width: 100%; outline: none; }
.env-table__row .value-input:hover { border-color: var(--border); }
.env-table__row .value-input:focus { border-color: var(--accent); background: var(--surface-2); }
.env-table__row .ico-btns { display: flex; gap: 4px; }

.env-rows { display: flex; flex-direction: column; gap: 8px; }
.env-row { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; align-items: center; }
.env-row--modified { background: rgba(37, 99, 235, 0.03); padding: 4px 8px; border-radius: 8px; }
.env-row__act { padding: 6px; border-radius: 6px; color: var(--text-muted); transition: background .1s; cursor: pointer; }
.env-row__act:hover { background: var(--surface-2); }
.env-row__act--active { color: var(--accent); }

.save-bar {
  position: sticky; bottom: 30px;
  margin-top: 18px;
  background: var(--surface-2);
  border: 1px solid var(--warning);
  border-radius: 12px;
  padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.save-bar__msg { display: flex; align-items: center; gap: 8px; color: var(--warning); font-weight: 500; font-size: 13px; }
.save-bar__actions { display: flex; gap: 8px; }

/* ============== Collapse/Table ============== */
.collapse-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  cursor: pointer;
}
.collapse-head--closed { border-radius: 14px; }
.collapse-head h3 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.collapse-head__chev { color: var(--text-muted); transition: transform .2s; }
.collapse-head--open .collapse-head__chev { transform: rotate(180deg); }

.tbl-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
}

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 12px 16px; text-align: left; font-size: 13px; }
.tbl thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 500;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.tbl tbody tr { border-top: 1px solid var(--border); transition: background .12s; }
.tbl tbody tr:hover { background: rgba(0,0,0,0.015); }
.tbl td.mono { font-family: var(--mono); font-size: 12px; }
.tbl td .row-actions { display: flex; gap: 6px; }

/* ============== Logs drawer ============== */
.logs-stream {
  flex: 1;
  background: #f8fafc;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  padding: 16px 22px;
  overflow-y: auto;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.logs-stream .line .ts { color: var(--text-muted); margin-right: 10px; }
.logs-stream .line .lvl-err { color: var(--danger); }
.logs-stream .line .lvl-warn { color: var(--warning); }
.logs-toolbar { display: flex; gap: 8px; align-items: center; padding: 10px 22px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.logs-toolbar .input { flex: 1; max-width: 320px; }

.mini-logs {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin: 12px 0;
  max-height: 100px;
  overflow: hidden;
  position: relative;
}
.mini-logs::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 24px; background: linear-gradient(transparent, var(--surface-2)); }
.mini-logs .line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.8; }
.mini-logs .line .ts { color: var(--text-muted); margin-right: 8px; }

/* ============== Status ticker ============== */
.status-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 6px 22px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  z-index: 60;
  display: flex; align-items: center; gap: 14px;
  min-height: 28px;
}
.status-bar__indicator { display: flex; align-items: center; gap: 6px; }
.status-bar__op { color: var(--text); display: flex; align-items: center; gap: 8px; }
.status-bar__right { margin-left: auto; color: var(--text-muted); }

/* ============== Toasts ============== */
.toasts { position: fixed; right: 22px; bottom: 50px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 280px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: slideL .25s ease;
}
@keyframes slideL { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--info { border-left-color: var(--accent); }

/* ============== Empty state ============== */
.empty {
  text-align: center;
  padding: 60px 20px;
  background: transparent;
  color: var(--text-muted);
}
.empty__art {
  width: 140px; height: 100px;
  margin: 0 auto 18px;
  opacity: 0.9;
}
.empty__title { font-size: 16px; margin: 0 0 8px; font-weight: 600; color: var(--text); }
.empty__desc { color: var(--text-muted); margin: 0 0 22px; font-size: 13px; }

/* ============== Popover / context menu ============== */
.popover {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 30;
}
.popover__item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background .1s;
  color: var(--text);
}
.popover__item:hover { background: var(--surface-2); }
.popover__item--danger { color: var(--danger); }
.popover__sep { height: 1px; background: var(--border); margin: 4px 0; }

.access-row { display: grid; grid-template-columns: 160px 1fr auto; gap: 12px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border); }
.access-row:first-child { border-top: none; }
.access-row__lbl { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.access-row__val { font-size: 14px; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.access-row__act { display: flex; gap: 6px; align-items: center; }

.toggle {
  width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong);
  cursor: pointer; position: relative; transition: background .2s; flex-shrink: 0; display: inline-block;
}
.toggle--on { background: var(--accent); }
.toggle::after {
  content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: left .2s;
}
.toggle--on::after { left: 19px; }

/* ============== Badge ============== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.badge--blue   { background: #eff6ff; color: #1d4ed8; }
.badge--green  { background: #f0fdf4; color: #15803d; }
.badge--yellow { background: #fffbeb; color: #b45309; }
.badge--red    { background: #fef2f2; color: #b91c1c; }
.badge--gray   { background: #f3f4f6; color: #374151; }

/* ============== Copy button ============== */
.copy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted); cursor: pointer;
  transition: background .15s;
}
.copy-btn:hover { background: var(--surface-3); color: var(--text); }

/* ============== Env cards (new card-based env vars) ============== */
.env-cards { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.env-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) 1fr auto;
  gap: 12px;
  align-items: center;
}
.env-card--new { border-left-color: var(--success); }
.env-card__key { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }
.env-card__value { display: flex; align-items: center; gap: 6px; }
.env-card__value .value-input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 10px; color: var(--text); font-family: var(--mono); font-size: 12px; outline: none;
  transition: border-color .15s;
}
.env-card__value .value-input:focus { border-color: var(--accent); background: var(--surface); }
.env-card__actions { display: flex; gap: 4px; align-items: center; }

/* ============== Backup cards ============== */
.backup-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.backup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
}
.backup-card__header { display: flex; align-items: center; gap: 10px; }
.backup-card__title { font-size: 13px; font-weight: 600; color: var(--text); }
.backup-card__date { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.backup-card__meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.backup-card__actions { display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }

/* ============== Allowlist cards ============== */
.allowlist-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 12px 0; }
.allowlist-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-card);
}
.allowlist-card__header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.allowlist-card__label { font-size: 13px; font-weight: 600; color: var(--text); }
.allowlist-card__ip { font-family: var(--mono); font-size: 13px; color: var(--text-muted); }
.allowlist-card__services { display: flex; gap: 6px; flex-wrap: wrap; }
.allowlist-card__footer { display: flex; justify-content: flex-end; padding-top: 4px; border-top: 1px solid var(--border); margin-top: 4px; }

/* ============== Service toggle button ============== */
.service-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.service-toggle--on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.service-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ============== Add IP form ============== */
.add-ip-form {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.add-ip-form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-ip-form__services { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.add-ip-form__footer { display: flex; justify-content: flex-end; }

/* ============== Logo ============== */
.logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: grid; place-items: center;
  color: #fff;
  position: relative;
}
.logo-mark--sm { width: 26px; height: 26px; border-radius: 6px; }

/* ============== Login page ============== */
.login {
  display: flex; min-height: 100vh;
  background: var(--bg);
}
.login__left {
  width: 420px; flex-shrink: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px 48px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.login__right {
  flex: 1; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #1e3a5f 0%, #1a2744 50%, #0f1a2e 100%);
  display: flex; align-items: center; justify-content: center;
}
.login__right canvas { position: absolute; inset: 0; }
.login__overlay {
  position: relative; z-index: 2;
  color: rgba(255,255,255,0.5); font-size: 11px;
  font-family: var(--mono); text-align: center;
}
.login__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; }
.login__brand-name { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.login__title { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; color: var(--text); margin: 0 0 6px; }
.login__subtitle { font-size: 14px; color: var(--text-muted); margin: 0 0 32px; }
.login__field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.login__field label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: .04em; text-transform: uppercase; }
.login__input {
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 14px; outline: none;
  transition: border-color .15s;
}
.login__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.login__forgot { font-size: 12px; color: var(--accent); display: block; text-align: right; margin-top: 10px; }
.login__footer { font-size: 11px; color: var(--text-dim); margin-top: auto; padding-top: 32px; }
.btn--lg { padding: 11px 20px; font-size: 14px; }
.btn--block { width: 100%; justify-content: center; }

/* ============== Responsive ============== */
@media (max-width: 768px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .server-grid { grid-template-columns: 1fr; }
  .page { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
}
