:root {
  --bg: #0a0b0f;
  --bg-card: #12131a;
  --bg-card-hover: #1a1b25;
  --bg-accent: #161722;
  --text: #e8e9ed;
  --text-secondary: #8b8d9a;
  --text-muted: #5a5c6a;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --green: #00d2a0;
  --orange: #ffa348;
  --red: #ff6b6b;
  --yellow: #ffd93d;
  --blue: #54a0ff;
  --cyan: #00d2d3;
  --border: #1e2030;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --mono: "JetBrains Mono", monospace;
  --sans: "DM Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 800px at 20% -20%, rgba(108, 92, 231, 0.2), transparent 55%), var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

code,
.mono {
  font-family: var(--mono);
}

.page {
  min-height: 100vh;
}

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

.auth-card {
  width: min(460px, 100%);
  background: linear-gradient(145deg, rgba(108, 92, 231, 0.12), var(--bg-card));
  border: 1px solid rgba(108, 92, 231, 0.35);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
}

.subtitle {
  color: var(--text-secondary);
  font-size: 13px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.label {
  color: var(--text-secondary);
  font-size: 12px;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-accent);
  color: var(--text);
  padding: 12px 14px;
}

.textarea {
  min-height: 220px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
}

.btn-danger {
  background: linear-gradient(135deg, #d84f4f, var(--red));
}

.btn-warning {
  color: #1a1b2e;
  background: linear-gradient(135deg, #f2c53d, var(--orange));
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-good {
  background: linear-gradient(135deg, #00c495, var(--green));
}

.notice {
  margin-top: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
  color: #ffacac;
  padding: 10px 12px;
  font-size: 12px;
}

.success {
  border-color: rgba(0, 210, 160, 0.35);
  background: rgba(0, 210, 160, 0.08);
  color: #8ce8d2;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(22, 23, 34, 0.92), rgba(10, 11, 15, 0.95));
  backdrop-filter: blur(10px);
  padding: 20px 16px;
}

.nav {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.nav-btn.active {
  background: rgba(108, 92, 231, 0.2);
  border-color: rgba(108, 92, 231, 0.35);
  color: #d8d1ff;
}

.main {
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.title {
  margin: 0;
  font-size: 24px;
}

.title-sub {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.cards {
  display: grid;
  gap: 12px;
}

.cards.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cards.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.server-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.05), var(--bg-card));
  padding: 14px;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 12px;
}

.kpi {
  font-size: 28px;
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status.running {
  color: #91ead5;
  background: rgba(0, 210, 160, 0.15);
}

.status.starting,
.status.stopping,
.status.migrating {
  color: #ffd7a9;
  background: rgba(255, 163, 72, 0.14);
}

.status.stopped {
  color: #b9bbcb;
  background: rgba(139, 141, 154, 0.2);
}

.status.error {
  color: #ffbbbb;
  background: rgba(255, 107, 107, 0.15);
}

.grid-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.info-block {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.info-label {
  color: var(--text-muted);
  font-size: 11px;
}

.info-val {
  margin-top: 2px;
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.toolbar .row {
  margin: 0;
}

.terminal-wrap {
  height: 520px;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: #090b14;
}

.logs-box {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0d1018;
  min-height: 420px;
  max-height: 620px;
  overflow: auto;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.table th {
  color: var(--text-muted);
  font-weight: 600;
}

.table tr:hover td {
  background: rgba(108, 92, 231, 0.07);
}

.link-btn {
  border: none;
  color: var(--accent-light);
  background: none;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
}

.chart-wrap {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(84, 160, 255, 0.06), rgba(84, 160, 255, 0));
  padding: 10px;
}

.chart-title {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.chart-svg {
  width: 100%;
  height: 220px;
}

.history-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 13px;
}

.breadcrumb {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.subtabs button {
  border: 1px solid var(--border);
  background: var(--bg-accent);
  color: var(--text-secondary);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  cursor: pointer;
}

.subtabs button.active {
  color: #fff;
  border-color: rgba(108, 92, 231, 0.45);
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.65), rgba(108, 92, 231, 0.45));
}

.hidden {
  display: none !important;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-btn {
    white-space: nowrap;
  }

  .cards.cols-2,
  .cards.cols-3 {
    grid-template-columns: 1fr;
  }

  .grid-info {
    grid-template-columns: 1fr;
  }
}
