:root {
  color-scheme: light dark;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #171a21;
  --muted: #667085;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #b45309;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --surface: #171a20;
    --surface-2: #20242c;
    --border: #2c323d;
    --text: #e7eaf0;
    --muted: #9aa3b2;
    --accent: #6d94ff;
    --accent-hover: #84a5ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  height: 40px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin: 14px 0 8px;
}

.hidden {
  display: none !important;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-inner {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
}

h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

p {
  color: var(--muted);
  font-size: 13px;
}

.shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.auth-card {
  width: min(400px, 100%);
  margin: 72px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.auth-card button {
  width: 100%;
  margin-top: 18px;
}

.dashboard {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

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

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

.secondary-btn:hover {
  background: var(--border);
}

.small-btn {
  width: auto;
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.create-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.subdomain-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.subdomain-field input {
  border: 0;
  border-radius: 0;
  direction: ltr;
  text-align: left;
}

.subdomain-field span {
  color: var(--muted);
  direction: ltr;
  padding-inline: 10px 12px;
  border-inline-start: 1px solid var(--border);
  white-space: nowrap;
}

.instances-list {
  display: grid;
  gap: 12px;
}

.instance-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.instance-main {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.instance-title {
  font-weight: 700;
  direction: ltr;
  text-align: left;
}

.instance-meta {
  color: var(--muted);
  font-size: 13px;
  direction: ltr;
  text-align: left;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
}

.badge.running {
  color: var(--success);
}

.badge.stopped {
  color: var(--warning);
}

.badge.error {
  color: var(--danger);
}

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

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

.danger-btn:hover {
  background: rgba(220, 38, 38, 0.08);
}

.message {
  min-height: 20px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(8px);
  background: #111827;
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 14px;
  opacity: 0;
  transition: 160ms ease;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 32px));
  text-align: center;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 700px) {
  .create-row,
  .actions {
    grid-template-columns: 1fr;
  }

  .instance-main,
  .panel-heading {
    flex-direction: column;
  }
}
