:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warning: #a16207;
  --warning-soft: #fefce8;
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); font-size: 14px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 420px);
  display: grid;
  gap: 20px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-muted);
  font-weight: 800;
  letter-spacing: -0.04em;
}
.brand-mark.small { width: 36px; height: 36px; border-radius: 10px; font-size: 12px; }

h1, h2, h3, p { margin: 0; }
h1 { margin-top: 4px; font-size: 24px; letter-spacing: -0.03em; }
h2 { margin-top: 3px; font-size: 21px; letter-spacing: -0.025em; }
h3 { font-size: 15px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; }
.muted { color: var(--muted); line-height: 1.55; }

.field { display: grid; gap: 7px; }
.field > span { font-size: 12px; font-weight: 650; color: #334155; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease;
}
input, select { height: 42px; padding: 0 12px; }
textarea { min-height: 150px; padding: 12px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.button.primary { color: white; background: var(--accent); border-color: var(--accent); }
.button.subtle { background: var(--surface); border-color: var(--border); }
.button.danger { color: var(--danger); background: var(--danger-soft); border-color: #fecaca; }
.button.success { color: var(--success); background: var(--success-soft); border-color: #bbf7d0; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button.full { width: 100%; }
.button.small { min-height: 32px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.form-error { color: var(--danger); font-size: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 14px; }
.sidebar-brand span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.nav-list { display: grid; gap: 5px; }
.nav-item {
  min-height: 40px;
  padding: 0 12px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #475569;
  font-weight: 600;
}
.nav-item.active { background: var(--accent-soft); border-color: #dbeafe; color: #1d4ed8; }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; padding-top: 16px; }
.user-chip { padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); overflow: hidden; }
.user-chip strong, .user-chip span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { font-size: 12px; }
.user-chip span { margin-top: 3px; color: var(--muted); font-size: 11px; }

.main-content { min-width: 0; }
.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 24px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--border);
}
.content-area { width: min(100%, 1240px); margin: 0 auto; padding: 22px 24px 40px; }

.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 15px; border-bottom: 1px solid var(--border); }
.card-body { padding: 15px; }
.card-footer { padding: 13px 15px; border-top: 1px solid var(--border); background: var(--surface-muted); border-radius: 0 0 var(--radius) var(--radius); }
.server-card { padding: 16px; display: grid; gap: 16px; }
.server-card-top { display: flex; justify-content: space-between; gap: 12px; }
.server-card h3 { margin-top: 4px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 12px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.actions.right { justify-content: flex-end; }

.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-muted); color: #475569; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.badge.running { color: var(--success); background: var(--success-soft); border-color: #bbf7d0; }
.badge.suspended, .badge.exited, .badge.dead { color: var(--danger); background: var(--danger-soft); border-color: #fecaca; }
.badge.restarting, .badge.created { color: var(--warning); background: var(--warning-soft); border-color: #fde68a; }

.stat-card { padding: 14px; }
.stat-card span { color: var(--muted); font-size: 11px; font-weight: 650; }
.stat-card strong { display: block; margin-top: 7px; font-size: 20px; letter-spacing: -0.03em; }
.progress { height: 6px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #e2e8f0; }
.progress > div { height: 100%; width: 0; background: var(--accent); border-radius: inherit; }

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.detail-head h3 { margin-top: 5px; font-size: 19px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 4px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.tab { min-height: 34px; padding: 0 13px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.tab.active { background: var(--surface-muted); color: var(--text); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--border); text-align: left; font-size: 12px; white-space: nowrap; }
th { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; background: var(--surface-muted); }
tr:last-child td { border-bottom: 0; }
.file-name { border: 0; background: transparent; color: var(--text); font-weight: 650; padding: 0; }
.file-name:hover { color: var(--accent); }

.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.breadcrumb { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.breadcrumb button { border: 0; padding: 0; background: transparent; color: var(--accent); }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.code-block { min-height: 320px; max-height: 560px; overflow: auto; margin: 0; padding: 15px; border-radius: 10px; background: #0f172a; color: #dbeafe; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(15,23,42,.45); }
.modal { width: min(100%, 680px); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.modal.large { width: min(100%, 920px); }
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); background: var(--surface-muted); }
.modal-body { padding: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full-span { grid-column: 1 / -1; }

.toast-root { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast { width: min(360px, calc(100vw - 36px)); padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 12px; }
.toast.error { color: var(--danger); border-color: #fecaca; background: var(--danger-soft); }
.toast.success { color: var(--success); border-color: #bbf7d0; background: var(--success-soft); }
.loading { padding: 50px 20px; text-align: center; color: var(--muted); }
.mobile-only { display: none; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; transform: translateX(-100%); width: 238px; transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .grid.two, .grid.four { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .topbar { padding: 13px 16px; }
  .content-area { padding: 16px; }
  .grid.two, .grid.four, .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-span { grid-column: auto; }
  .detail-head { display: grid; }
  .actions.right { justify-content: flex-start; }
}
