:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #111827;
  --muted: #5f6b7a;
  --line: #d9dee7;
  --brand: #3562ff;
  --brand-dark: #2348d8;
  --green: #00b86b;
  --danger: #dc2626;
  --soft: #eef3ff;
  --shadow: 0 8px 22px rgba(18, 25, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="search"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

button {
  cursor: pointer;
  font-weight: 700;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 52px;
  padding: 0 24px;
  background: #121212;
  color: #fff;
}

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

.brand-mark,
.offer-logo {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: #050505;
  color: #fff;
  font-weight: 900;
}

.brand-mark {
  background: var(--brand);
}

.top-nav nav {
  display: flex;
  gap: 18px;
  margin-right: auto;
}

.top-nav a {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.credit {
  color: #d1d5db;
  font-size: 14px;
}

.credit strong {
  color: var(--green);
}

.auth-button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

main {
  min-height: calc(100vh - 52px);
}

.signup-form {
  display: grid;
  gap: 12px;
}

.signup-form input {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.signup-form button {
  min-height: 40px;
  padding: 0 18px;
}

.signup-form output {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

.signup-form output.success {
  color: #087f5b;
}

.signup-form output.error {
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.auth-modal {
  position: relative;
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.auth-modal h2 {
  margin: 6px 0 8px;
  font-size: 24px;
}

.auth-modal p {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
}

.modal-kicker {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  background: #dfe7ff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 8px;
  padding: 4px;
  border-radius: 8px;
  background: #eef2f7;
}

.auth-tabs button {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.auth-tabs button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

#signupForm[hidden],
#loginForm[hidden] {
  display: none;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.search-band {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.search-band label {
  display: grid;
  gap: 8px;
  max-width: 920px;
  padding: 0 24px;
  color: var(--text);
  font-size: 14px;
}

.search-band input {
  height: 42px;
  padding: 0 14px;
}

.create-layout {
  display: grid;
  grid-template-columns: 320px minmax(620px, 1fr);
  gap: 18px;
  align-items: start;
  padding: 18px 24px 32px;
}

.left-panel,
.results-panel {
  display: grid;
  gap: 16px;
}

.template-card,
.filter-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.template-card,
.filter-panel {
  padding: 20px;
}

.template-tags,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-tags span,
.chip-row button,
.badge {
  padding: 5px 11px;
  border: 0;
  border-radius: 999px;
  background: #eef0f3;
  color: #445064;
  font-size: 12px;
  font-weight: 800;
}

.chip-row button.active,
.template-tags span:first-child {
  background: #dfe7ff;
  color: var(--brand);
}

.template-logo {
  margin: 24px auto 18px;
  width: 58px;
  font-size: 54px;
  font-weight: 900;
  line-height: 1;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-size: 18px;
}

.template-card p {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.primary {
  border: 0;
  background: var(--brand);
  color: #fff;
}

.primary:hover {
  background: var(--brand-dark);
}

.wide {
  width: 100%;
  min-height: 42px;
}

.field {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field select,
.quick-filters select {
  height: 38px;
  padding: 0 10px;
}

.range-line {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 12px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}

output {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-align: center;
}

.filter-title,
.switch-row,
.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filter-title button {
  padding: 8px 12px;
  color: var(--brand);
}

.switch-row {
  margin-top: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}

.switch-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.quick-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
  padding: 0 0 10px;
}

.result-summary {
  padding: 6px 0 10px;
  color: var(--muted);
}

.result-summary strong {
  color: var(--text);
}

.instances-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.instances-panel[hidden] {
  display: none;
}

.instances-head,
.instance-card,
.instance-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.instances-head,
.instance-card {
  justify-content: space-between;
}

.instances-head button,
.instance-action {
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.instances-head button {
  border: 0;
}

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

.instance-card {
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.instance-card span,
.instance-hint,
.ssh-line {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.instance-error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 12px;
  word-break: break-word;
}

.ssh-line code {
  color: var(--text);
}

.compact-list {
  display: grid;
  gap: 8px;
}

.offer-row {
  display: grid;
  grid-template-columns: 44px 1.4fr 0.8fr 1.1fr 1fr 0.9fr 92px;
  gap: 12px;
  align-items: center;
  min-height: 104px;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 7px rgba(17, 24, 39, 0.06);
}

.offer-row.selected {
  border-color: var(--brand);
  background: var(--soft);
}

.offer-row strong {
  display: block;
  margin-bottom: 5px;
}

.offer-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.tiny {
  color: #111827 !important;
  font-size: 10px !important;
}

.offer-gpu strong {
  font-size: 19px;
}

.offer-price {
  text-align: right;
}

.offer-price strong {
  color: #111827;
  font-size: 16px;
}

.rent-button {
  min-height: 36px;
  border: 0;
  background: #3d92df;
  color: #fff;
}

.rent-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.show-more {
  width: 100%;
  margin-top: 10px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: #e4e4e4;
}

.empty-state {
  display: grid;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.empty-state {
  min-height: 120px;
  place-items: center;
  text-align: center;
}

.empty-state.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--danger);
}

@media (max-width: 1180px) {
  .create-layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .offer-row {
    grid-template-columns: 44px 1.4fr 0.8fr 1fr;
  }

  .offer-health,
  .offer-price,
  .rent-button {
    grid-column: span 1;
  }
}

@media (max-width: 820px) {
  .top-nav {
    height: auto;
    flex-wrap: wrap;
    padding: 14px;
  }

  .top-nav nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .create-layout,
  .quick-filters {
    grid-template-columns: 1fr;
  }

  .offer-row {
    grid-template-columns: 1fr;
  }

  .offer-logo,
  .offer-price {
    text-align: left;
  }
}
