:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #151517;
  --surface-2: #1c1c20;
  --surface-3: #111113;
  --line: #303034;
  --line-soft: #242428;
  --text: #f6f6f3;
  --muted: #919198;
  --accent: #ff4d2e;
  --accent-soft: rgba(255, 77, 46, 0.12);
  --success: #59d292;
  --warning: #ffc65c;
  --danger: #ff8e7a;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 78% 0, rgba(255, 77, 46, 0.13), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .44; }

.topbar {
  display: flex;
  width: min(1420px, calc(100% - 48px));
  min-height: 76px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand span {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  font-size: 12px;
  font-weight: 900;
}
.brand strong { font-size: 17px; }
.top-actions { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 11px; }

main { width: min(1420px, calc(100% - 48px)); margin: 0 auto; padding: 52px 0 72px; }
.auth-layout {
  display: grid;
  grid-template-columns: 1.35fr .65fr;
  gap: 72px;
  align-items: center;
  min-height: 620px;
}
.eyebrow, .step-label {
  margin: 0 0 11px;
  color: #ff795f;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: clamp(40px, 5vw, 68px); line-height: 1.02; letter-spacing: -.055em; }
h1 span { color: var(--accent); }
.lead { max-width: 720px; margin: 17px 0 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.card {
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
}
.setup-card { max-width: 720px; margin: 80px auto; padding: 30px; }
.setup-card h1 { font-size: 32px; }
.setup-card p:last-child { color: var(--muted); line-height: 1.7; }
code { color: #ff8a74; }
.auth-card { padding: 28px; }
.auth-card h2 { margin: 0 0 24px; font-size: 18px; }

label { display: block; margin: 0; }
label > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; }
input:not([type="checkbox"]), select {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
}
input:focus, select:focus { border-color: var(--accent); }
.auth-card label + label { margin-top: 14px; }
.primary-button, .secondary-button, .text-button { border: 0; color: white; }
.primary-button {
  width: 100%;
  min-height: 50px;
  border-radius: 10px;
  background: var(--accent);
  font-weight: 780;
}
.auth-card .primary-button { margin-top: 18px; }
.secondary-button {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: #c7c7cc;
}
.auth-card .secondary-button { width: 100%; margin-top: 10px; }
.text-button { padding: 0; background: none; color: #ff8a74; font-size: 10px; }
.form-message { min-height: 18px; margin: 12px 0 0; color: var(--warning); font-size: 10px; line-height: 1.55; }

.hero-row, .section-heading, .subheading, .job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.hero-row { margin-bottom: 28px; }
.hero-row h1 { font-size: clamp(34px, 4vw, 54px); }
.control-grid { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; align-items: start; }
.device-card { position: sticky; top: 20px; padding: 22px; }
.composer-card, .jobs-card { padding: 24px; }
.section-heading { margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 16px; }
.section-heading span { color: var(--muted); font-size: 9px; }
.section-heading .step-label { margin-bottom: 5px; }
.local-note, .privacy-note { margin: 14px 0 0; color: var(--muted); font-size: 9px; line-height: 1.6; }

.device-list { display: grid; gap: 9px; }
.device-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 11px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  text-align: left;
  color: inherit;
}
.device-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.device-dot { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--muted); }
.device-item.online .device-dot { background: var(--success); box-shadow: 0 0 10px rgba(89, 210, 146, .65); }
.device-item strong, .device-item small { display: block; }
.device-item strong { font-size: 11px; }
.device-item small { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.5; }

.device-alerts { display: grid; gap: 7px; margin-bottom: 16px; }
.device-alert {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border: 1px solid rgba(255, 198, 92, .25);
  border-radius: 8px;
  color: #c5a96f;
  font-size: 9px;
  line-height: 1.45;
}
.device-alert.required { border-color: rgba(255, 77, 46, .38); color: #e18a79; }
.device-alert a { flex: 0 0 auto; color: #ff8a74; text-decoration: none; }

.job-form { display: grid; gap: 18px; }
.product-toolbar { display: grid; grid-template-columns: minmax(240px, .8fr) 1.2fr; gap: 16px; align-items: end; }
.catalog-numbers {
  display: flex;
  min-height: 46px;
  padding: 0 14px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface-3);
}
.catalog-numbers strong { font-size: 10px; font-weight: 600; }
.catalog-numbers small { color: var(--success); font-size: 9px; }
.module-panel { padding: 16px; border: 1px solid var(--line-soft); border-radius: 13px; background: var(--surface-3); }
.subheading { margin-bottom: 12px; }
.subheading strong, .subheading small { display: block; }
.subheading strong { font-size: 11px; }
.subheading small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.module-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.module-button {
  display: flex;
  min-width: 0;
  padding: 11px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
}
.module-button:not(:disabled):hover { border-color: var(--accent); transform: translateY(-1px); }
.module-button strong, .module-button small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.module-button strong { font-size: 10px; }
.module-button small { margin-top: 4px; color: var(--muted); font-size: 8px; }
.module-button.missing { border-color: rgba(255, 198, 92, .16); }
.module-action { display: grid; flex: 0 0 auto; width: 23px; height: 23px; place-items: center; border-radius: 50%; background: var(--accent-soft); color: #ff8a74; font-weight: 800; }

.composition-field { display: block; }
.sequence-preview { display: flex; flex-wrap: wrap; gap: 7px; min-height: 30px; }
.sequence-chip {
  display: inline-flex;
  min-height: 30px;
  padding: 0 7px 0 9px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}
.sequence-chip > span { color: #ff8a74; font-size: 8px; }
.sequence-chip strong { font-size: 9px; }
.sequence-chip button { padding: 0 3px; border: 0; background: transparent; color: var(--muted); }
.sequence-chip button:hover { color: var(--danger); }

.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.switch-setting {
  display: flex;
  min-height: 46px;
  padding: 0 13px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.switch-setting > span { margin: 0; }
.switch-setting strong, .switch-setting small { display: block; }
.switch-setting strong { color: var(--text); font-size: 10px; }
.switch-setting small { margin-top: 3px; font-size: 8px; }
.switch-setting input { width: 34px; height: 18px; accent-color: var(--accent); }
.privacy-note { margin: -3px 0 0; }
.validation-card { padding: 11px 13px; border-radius: 9px; font-size: 9px; line-height: 1.55; }
.validation-card.warning { border: 1px solid rgba(255, 198, 92, .25); background: rgba(255, 198, 92, .06); color: #d5b777; }
.validation-card.ready { border: 1px solid rgba(89, 210, 146, .25); background: rgba(89, 210, 146, .06); color: #83d9ab; }

.jobs-card { margin-top: 18px; }
.job-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.job-item { padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-3); }
.job-item.completed { border-color: rgba(89, 210, 146, .28); }
.job-item.failed { border-color: rgba(255, 77, 46, .32); }
.job-header > div strong, .job-header > div small { display: block; }
.job-header strong { font-size: 11px; }
.job-header small { margin-top: 4px; color: var(--muted); font-size: 8px; }
.job-badge { padding: 4px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 8px; }
.completed .job-badge { color: var(--success); }
.failed .job-badge { color: var(--danger); }
.job-composition { margin: 11px 0; color: #b3b3b8; font-size: 9px; line-height: 1.55; }
.job-progress-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; align-items: center; }
.progress-track { height: 5px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #ff8a74); transition: width .25s ease; }
.job-progress-row > span { color: var(--muted); font-size: 8px; }
.job-status-message { margin: 9px 0 0; color: var(--muted); font-size: 8px; line-height: 1.5; }
.failed .job-status-message { color: var(--danger); }
.job-outputs { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; align-items: center; }
.job-outputs a { padding: 6px 9px; border: 1px solid rgba(255, 77, 46, .28); border-radius: 7px; color: #ff8a74; font-size: 8px; text-decoration: none; }
.job-outputs small { flex-basis: 100%; color: var(--muted); font-size: 8px; }
.empty-jobs { padding: 18px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 10px; }

.empty-card { margin-bottom: 18px; padding: 22px; }
.empty-card h2 { margin: 0 0 7px; font-size: 15px; }
.empty-card p { margin: 0; color: var(--muted); font-size: 11px; }
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 380px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #222226;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .4);
  font-size: 11px;
}
.hidden { display: none !important; }

@media (max-width: 1000px) {
  .control-grid { grid-template-columns: 1fr; }
  .device-card { position: static; }
  .module-list, .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .topbar, main { width: min(100% - 28px, 1420px); }
  main { padding-top: 34px; }
  .auth-layout { grid-template-columns: 1fr; gap: 34px; min-height: auto; }
  .hero-row { align-items: flex-start; }
  .hero-row .secondary-button { flex: 0 0 auto; }
  .product-toolbar, .module-list, .settings-grid, .job-list { grid-template-columns: 1fr; }
  .catalog-numbers { align-items: flex-start; flex-direction: column; justify-content: center; }
  .composer-card, .jobs-card, .device-card { padding: 18px; }
  .section-heading { align-items: flex-start; }
}
