:root {
  color-scheme: dark;
  --bg: #0b0e0d;
  --surface: #121716;
  --surface-2: #1a211f;
  --text: #e9efec;
  --text-2: #a2ada8;
  --text-3: #707c76;
  --border: rgba(233, 239, 236, 0.08);
  --border-strong: rgba(233, 239, 236, 0.16);
  --accent: #3fdd8a;
  --accent-ink: #04150b;
  --accent-text: #57e79b;
  --accent-soft: rgba(63, 221, 138, 0.12);
  --danger: #ff6f61;
  --danger-text: #ff8a7e;
  --danger-soft: rgba(255, 111, 97, 0.1);
  --danger-border: rgba(255, 111, 97, 0.28);
  --warn: #e8b45c;
  --warn-soft: rgba(232, 180, 92, 0.12);
  --track: rgba(233, 239, 236, 0.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #e9eeeb;
  --text: #0f1613;
  --text-2: #46524c;
  --text-3: #75817b;
  --border: rgba(15, 22, 19, 0.09);
  --border-strong: rgba(15, 22, 19, 0.18);
  --accent: #12a55e;
  --accent-ink: #04150b;
  --accent-text: #0b7a46;
  --accent-soft: rgba(18, 165, 94, 0.12);
  --danger: #c93a2e;
  --danger-text: #b02e23;
  --danger-soft: rgba(201, 58, 46, 0.07);
  --danger-border: rgba(201, 58, 46, 0.28);
  --warn: #a06a13;
  --warn-soft: rgba(160, 106, 19, 0.1);
  --track: rgba(15, 22, 19, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 720px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 16px;
}

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

.brand-mark {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.who {
  flex: none;
  max-width: 40%;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
}

.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  border-radius: 9px;
  padding: 9px 10px;
  min-height: 38px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab.is-active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.tab-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 12px;
}

.section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.lead {
  margin: -4px 0 14px;
  font-size: 13.5px;
  color: var(--text-2);
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 32px 16px;
  font-size: 13px;
  color: var(--text-3);
}

.led {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
}

.led--live {
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

.led--ok {
  background: var(--accent);
}

.led--warn {
  background: var(--warn);
}

.led--bad {
  background: var(--danger);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

#orders-body {
  display: grid;
  gap: 10px;
}

.order-card {
  appearance: none;
  display: grid;
  gap: 9px;
  width: 100%;
  padding: 14px;
  text-align: left;
  color: inherit;
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.order-card:hover {
  border-color: var(--border-strong);
}

.order-card:active {
  background: var(--surface-2);
}

.order-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.order-kind {
  font-size: 14.5px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-meta {
  display: flex;
  align-items: center;
  gap: 6px 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.order-meta .mono {
  font-family: var(--mono);
  font-size: 11.5px;
}

.status {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}

.status--live {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: transparent;
}

.status--ok {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: transparent;
}

.status--warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: transparent;
}

.status--bad {
  color: var(--danger-text);
  background: var(--danger-soft);
  border-color: transparent;
}

.progress {
  display: grid;
  gap: 6px;
}

.progress__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.progress__row span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress__track {
  height: 5px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.5s ease;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 34px 16px 26px;
  text-align: center;
}

.empty-art {
  width: 150px;
  height: auto;
  color: var(--text-3);
  margin-bottom: 8px;
}

.empty-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.empty-text {
  margin: 0;
  max-width: 270px;
  font-size: 13px;
  color: var(--text-2);
}

.install-btn {
  width: 100%;
  margin-top: 14px;
}

.hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn--primary:hover {
  filter: brightness(1.04);
}

.btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn--ghost:hover {
  background: var(--surface-2);
}

.btn--danger {
  background: transparent;
  border-color: var(--danger-border);
  color: var(--danger-text);
}

.btn--danger:hover {
  background: var(--danger-soft);
}

.btn--small {
  min-height: 34px;
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 10px;
}

.btn--block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  filter: none;
}

.btn:focus-visible,
.tab:focus-visible,
.order-card:focus-visible,
.input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.detail-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
}

.detail-title {
  margin: 0;
  min-width: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
}

.card {
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
}

.card + .card {
  margin-top: 10px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.kv {
  display: grid;
  gap: 9px;
}

.kv__row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.kv__key {
  font-size: 12.5px;
  color: var(--text-3);
}

.kv__val {
  font-size: 13.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.server-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.server-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.server-row:last-child {
  padding-bottom: 0;
}

.server-role {
  font-size: 12.5px;
  color: var(--text-3);
}

.server-endpoint {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  overflow-wrap: anywhere;
  text-align: right;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.progress + .steps {
  margin-top: 12px;
}

.step {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.step:first-child {
  padding-top: 0;
  border-top: 0;
}

.step:last-child {
  padding-bottom: 0;
}

.step__dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--text-3);
}

.step__body {
  min-width: 0;
}

.step__title {
  font-size: 13.5px;
  color: var(--text);
}

.step__detail {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-3);
  overflow-wrap: anywhere;
}

.step__state {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  padding-top: 1px;
}

.step--pending .step__title {
  color: var(--text-3);
}

.step--running .step__dot {
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

.step--running .step__state {
  color: var(--accent-text);
}

.step--succeeded .step__dot {
  background: var(--accent);
}

.step--succeeded .step__state {
  color: var(--accent-text);
}

.step--failed .step__dot {
  background: var(--danger);
}

.step--failed .step__state {
  color: var(--danger-text);
}

.step--skipped .step__dot,
.step--rolled_back .step__dot {
  background: var(--warn);
}

.step--skipped .step__state,
.step--rolled_back .step__state {
  color: var(--warn);
}

.alert {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--danger-border);
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger-text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.access {
  display: grid;
  gap: 8px;
}

.error-box {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-2);
  font-size: 13.5px;
}

.error-box .btn {
  margin-top: 12px;
}

.ip-form {
  display: grid;
  gap: 8px;
  margin-bottom: 4px;
}

.field-label {
  font-size: 12.5px;
  color: var(--text-2);
}

.input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: var(--text-3);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ip-form .btn {
  margin-top: 2px;
}

.ip-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text-2);
}

.ip-status.is-error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger-text);
}

.ip-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
  font-size: 13.5px;
  color: var(--text-2);
}

.ip-summary strong {
  color: var(--text);
  font-weight: 600;
}

.ip-summary a {
  white-space: nowrap;
  color: var(--text-3);
  text-decoration: none;
  border-bottom: 1px dotted var(--border-strong);
}

.node-list {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}

.node {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
}

.node:first-child {
  border-top: 0;
}

.node__city {
  min-width: 0;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.node__name {
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3);
}

.node__side {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.node--ok .node__side {
  color: var(--accent-text);
}

.node--closed .node__side,
.node--failed .node__side,
.node--timeout .node__side {
  color: var(--text-3);
}

.note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-3);
}

.footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}

.footer a {
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 1px dotted var(--border-strong);
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.gate-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 320px;
  text-align: center;
}

.gate-card .brand-mark {
  margin-bottom: 6px;
}

.gate-card h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.gate-card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: calc(100vw - 40px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
