:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --panel-soft: #f9fbfc;
  --text: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --danger: #b42318;
  --warn: #a15c00;
  --ok: #177245;
  --info: #2563eb;
  --neutral: #475467;
  --shadow: 0 12px 28px rgba(21, 32, 43, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101418;
  --panel: #171d22;
  --panel-soft: #1d242b;
  --text: #eef2f6;
  --muted: #a8b3bf;
  --line: #2c3741;
  --primary: #2dd4bf;
  --primary-strong: #14b8a6;
  --danger: #f97066;
  --warn: #fdb022;
  --ok: #32d583;
  --info: #60a5fa;
  --neutral: #cbd5e1;
  --shadow: 0 16px 30px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  padding: 0 12px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

input,
textarea,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: var(--panel);
  color: var(--text);
}

textarea {
  resize: vertical;
}

.primary {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

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

.ghost,
.icon-btn {
  background: var(--panel-soft);
  color: var(--text);
  border: 1px solid var(--line);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  padding: 0;
  font-weight: 800;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover:not(:disabled) {
  color: #fff;
  background: var(--info);
  border-color: var(--info);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.icon-btn.primary:hover:not(:disabled) {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.24);
}

.danger-btn {
  color: var(--danger);
}

.danger-btn:hover:not(:disabled) {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 8px 18px rgba(180, 35, 24, 0.22);
}

.ok-btn {
  color: var(--ok);
}

.ok-btn:hover:not(:disabled) {
  color: #fff;
  background: var(--ok);
  border-color: var(--ok);
  box-shadow: 0 8px 18px rgba(23, 114, 69, 0.22);
}

.db-btn {
  color: #7c3aed;
}

.db-btn:hover:not(:disabled) {
  color: #fff;
  background: #7c3aed;
  border-color: #7c3aed;
  box-shadow: 0 8px 18px rgba(124, 58, 237, 0.22);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px clamp(16px, 4vw, 40px);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

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

.logo-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.logo-mark::before,
.logo-mark::after,
.logo-mark span {
  content: "";
  position: absolute;
  border-radius: 2px;
  background: #fff;
}

.logo-mark::before {
  width: 21px;
  height: 5px;
  top: 12px;
}

.logo-mark::after {
  width: 21px;
  height: 5px;
  top: 19px;
  opacity: 0.82;
}

.logo-mark span {
  width: 21px;
  height: 5px;
  top: 26px;
  opacity: 0.65;
}

.topbar h1,
.login-panel h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.4vw, 2.05rem);
}

.toolbar,
.actions,
.icon-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.55fr);
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 40px);
}

.panel,
.content-band,
.login-panel,
dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel,
.content-band {
  padding: 18px;
}

.content-band {
  margin: 0 clamp(16px, 4vw, 40px) 20px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h2 {
  margin: 0;
  font-size: 1rem;
}

.section-title span {
  color: var(--muted);
  font-size: 0.86rem;
}

.compact-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.compact-form.single {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.span-2 {
  grid-column: 1 / -1;
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
}

label small,
.hint {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.35;
}

.switch-line {
  display: flex;
  align-items: center;
  align-self: end;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--panel-soft);
}

.switch-line input {
  width: 18px;
  min-height: 18px;
}

.stat-grid,
.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}

.stat-grid strong {
  display: block;
  font-size: 1.35rem;
}

.stat-grid span,
.mini-grid span {
  color: var(--muted);
  font-size: 0.8rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}

.card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.inactive-card {
  opacity: 0.68;
}

.card-head,
.db-title,
.db-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

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

.paths p,
.artifact-list p {
  display: grid;
  gap: 3px;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.84rem;
}

.paths strong,
.artifact-list strong {
  color: var(--text);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.db-block {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.db-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: var(--panel-soft);
}

.db-row div:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.db-row span {
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.pill {
  width: max-content;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 800;
}

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

.telegram-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}

.env-chips {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.env-chip {
  display: grid;
  grid-template-columns: 125px 92px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  background: var(--panel-soft);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.env-chip:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.12);
  transform: translateY(-1px);
}

.env-chip strong {
  font-size: 0.82rem;
}

.env-chip span {
  width: max-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(102, 112, 133, 0.12);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.env-chip code {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-family: "Cascadia Mono", "Segoe UI Mono", monospace;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.status-line p {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 0.82rem;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 99px;
  box-shadow: 0 0 0 4px rgba(102, 112, 133, 0.14);
}

.status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(23, 114, 69, 0.14);
}

.status-dot.ready {
  background: #f2b84b;
  box-shadow: 0 0 0 4px rgba(242, 184, 75, 0.16);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.14);
}

.success {
  background: rgba(23, 114, 69, 0.14);
  color: var(--ok);
}

.neutral {
  background: rgba(102, 112, 133, 0.14);
  color: var(--neutral);
}

.running {
  background: rgba(253, 176, 34, 0.18);
  color: var(--warn);
}

.failed {
  background: rgba(180, 35, 24, 0.14);
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.active-run {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}

.progress-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
}

.progress {
  height: 9px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--line);
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 240ms ease;
}

.login-screen {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 28px;
}

dialog {
  width: min(620px, calc(100vw - 28px));
  padding: 18px;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.details-list {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.details-list dt {
  color: var(--muted);
  font-weight: 800;
}

.details-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

pre {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-soft);
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(520px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #17202a;
  color: white;
  box-shadow: var(--shadow);
  white-space: pre-line;
  z-index: 20;
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .layout,
  .compact-form,
  .compact-form.single {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stat-grid,
  .mini-grid,
  .env-chip {
    grid-template-columns: 1fr;
  }

  .env-chip {
    border-radius: 8px;
    align-items: start;
  }

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