:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --bg-soft: #111418;
  --surface: #171b20;
  --surface-raised: #1f242b;
  --surface-hover: #28303a;
  --line: #333a44;
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #f4f0e8;
  --muted: #a9b0ba;
  --faint: #737b86;
  --green: #49d17d;
  --green-dark: #1f7a49;
  --amber: #e4b456;
  --red: #ff5f6d;
  --blue: #69a7ff;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 14% 0%, rgba(73, 209, 125, 0.12), transparent 28rem),
    linear-gradient(180deg, #101318 0%, var(--bg) 36rem);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: translateY(1px);
}

.app-shell {
  min-height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) 14px calc(90px + env(safe-area-inset-bottom));
}

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

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(73, 209, 125, 0.45);
  border-radius: 8px;
  background: linear-gradient(135deg, #1f7a49, #20252b 68%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(31, 122, 73, 0.22);
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.08;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
}

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(31, 36, 43, 0.88);
  color: var(--text);
  font-size: 22px;
  box-shadow: var(--shadow);
}

.status-board {
  display: grid;
  grid-template-columns: 1.35fr 0.75fr 0.9fr;
  gap: 8px;
  margin-bottom: 14px;
}

.status-main,
.status-metric {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(23, 27, 32, 0.9);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

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

.status-main small,
.status-metric small,
.field span,
.switch-row small,
.list-item small,
.job-row span {
  color: var(--muted);
  font-size: 12px;
}

.status-main strong,
.status-metric strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255, 95, 109, 0.14);
}

.status-dot.is-on {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(73, 209, 125, 0.16);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.action-button {
  min-height: 92px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(23, 27, 32, 0.92);
  color: var(--text);
  text-align: left;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.18);
}

.action-button.action-start {
  border-color: rgba(73, 209, 125, 0.34);
  background: linear-gradient(135deg, #1f7a49, #182219);
}

.action-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
}

.action-button b {
  display: block;
  margin-bottom: 5px;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.16;
}

.action-button small {
  display: block;
  color: rgba(244, 240, 232, 0.72);
  font-size: 12px;
  line-height: 1.25;
}

.panel {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(23, 27, 32, 0.94);
  box-shadow: var(--shadow);
}

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

.pill {
  max-width: 50%;
  overflow: hidden;
  padding: 6px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-panel {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.job-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--bg-soft);
}

.job-row strong {
  color: var(--text);
  text-align: right;
  overflow-wrap: anywhere;
}

.download-progress-card {
  padding: 12px;
  border: 1px solid rgba(73, 209, 125, 0.28);
  border-radius: 8px;
  background: rgba(73, 209, 125, 0.08);
}

.download-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.download-progress-head span {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.download-progress-head strong {
  color: var(--green);
  font-size: 18px;
  font-weight: 950;
}

.download-progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
}

.download-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber));
  transition: width 0.25s ease;
}

.download-progress-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.last-error-panel {
  margin-top: 12px;
  border: 1px solid rgba(255, 95, 109, 0.36);
  border-radius: 8px;
  background: rgba(255, 95, 109, 0.08);
  overflow: hidden;
}

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

.last-error-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border-bottom: 1px solid rgba(255, 95, 109, 0.18);
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.last-error-head strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
}

.last-error-body {
  padding: 11px;
}

.last-error-body b {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 13px;
}

.last-error-body p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.last-error-body small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #0a0c0f;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber));
}

.health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.health-item,
.list-item {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg-soft);
}

.health-item b {
  display: block;
  margin-bottom: 5px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.health-item.is-ok b {
  color: var(--green);
}

.health-item.is-bad b {
  color: var(--red);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090b0e;
  color: var(--text);
  outline: none;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 112px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(73, 209, 125, 0.12);
}

.solid-button,
.wide-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 850;
}

.solid-button {
  padding: 0 14px;
  background: var(--green);
  color: #061009;
}

.solid-button.wide,
.wide-button {
  width: 100%;
}

.wide-button {
  background: var(--surface-raised);
  color: var(--text);
}

.ghost-button {
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  background: var(--surface-raised);
  color: var(--text);
}

.ghost-button.danger {
  color: var(--red);
}

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

.list-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.32;
}

.list-empty {
  color: var(--muted);
  font-size: 13px;
}

.field,
.switch-row {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.switch-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg-soft);
}

.switch-row strong {
  display: block;
  margin-bottom: 3px;
}

.switch-row input {
  width: 48px;
  height: 28px;
  accent-color: var(--green);
}

.path-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.path-list code {
  display: block;
  overflow-wrap: anywhere;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #090b0e;
  color: var(--text);
}

.logs-panel {
  padding-bottom: 10px;
}

.logs-box {
  min-height: 420px;
  max-height: 62vh;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #07090c;
  color: #d9e0e8;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  background: rgba(11, 13, 16, 0.94);
  backdrop-filter: blur(16px);
}

.nav-item {
  min-width: 0;
  height: 52px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.nav-item span {
  display: block;
  font-size: 16px;
  line-height: 1;
}

.nav-item.is-active {
  background: var(--surface-raised);
  color: var(--text);
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 14px;
  display: none;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #11161d;
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.is-visible {
  display: block;
}

@media (min-width: 720px) {
  .app-shell {
    max-width: 1040px;
    margin: 0 auto;
  }

  .quick-actions {
    grid-template-columns: repeat(4, 1fr);
  }

  .bottom-nav {
    right: calc((100vw - min(1040px, 100vw)) / 2);
    left: calc((100vw - min(1040px, 100vw)) / 2);
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .status-board {
    grid-template-columns: 1.15fr 0.75fr;
  }

  .status-metric:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 380px) {
  .quick-actions,
  .health-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .nav-item {
    font-size: 10px;
  }
}
