:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --text: #172026;
  --muted: #65717a;
  --line: #d9e0e4;
  --accent: #176b5b;
  --accent-weak: #e8f5f1;
  --steel: #31414c;
  --soft: #edf1f3;
  --danger-bg: #fff2f0;
  --danger-text: #9f1d17;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: var(--steel);
  color: white;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

nav a {
  border-radius: 6px;
  color: var(--steel);
  padding: 8px 10px;
}

nav a:hover {
  background: var(--soft);
}

.nav-logout {
  margin: 0;
}

.nav-logout button {
  min-height: 34px;
  background: var(--soft);
  color: var(--steel);
  padding: 0 10px;
}

.page {
  width: min(1120px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.card,
.upload,
table,
.tree,
.form-panel,
.summary,
.xml-block,
.hero-panel,
.page-hero,
.action-panel,
.step-row,
.section-block,
.status-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.card {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  color: var(--text);
}

.card span,
.meta,
.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lead {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.hero-panel,
.page-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
  padding: 20px;
}

.hero-panel {
  border-left: 4px solid var(--accent);
}

.primary-action,
.button-link,
.download-button,
.small-button,
.inline-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-weight: 600;
}

.primary-action,
.button-link {
  min-height: 38px;
  padding: 0 14px;
}

.primary-action,
.button-link,
.download-button {
  background: var(--accent);
  color: white;
}

.download-button {
  min-height: 30px;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
}

.download-button + .download-button {
  margin-left: 6px;
}

.button-link.secondary,
.secondary-button,
.secondary-link,
.secondary-download {
  background: var(--soft);
  color: var(--steel);
}

.secondary-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 600;
  cursor: pointer;
}

.secondary-link {
  min-height: 36px;
  padding: 8px 12px;
}

.inline-action {
  min-height: 30px;
  background: var(--accent-weak);
  padding: 0 9px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-bottom: 16px;
  overflow: hidden;
}

.status-strip div {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.status-strip div:last-child {
  border-right: 0;
}

.status-strip strong {
  font-size: 22px;
}

.status-strip span {
  color: var(--muted);
  font-size: 13px;
}

.workflow {
  display: grid;
  gap: 10px;
}

.step-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
}

.step-row h2,
.action-panel h2,
.section-head h2,
.form-panel h2 {
  margin: 0;
  font-size: 18px;
}

.step-row p,
.action-panel p,
.form-panel p {
  margin: 5px 0 0;
  color: var(--muted);
}

.step-num {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--steel);
  color: white;
  font-weight: 700;
}

.action-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 10px;
}

.section-block {
  margin-top: 16px;
  padding: 16px;
}

.help-block {
  margin-bottom: 18px;
}

.help-block summary {
  cursor: pointer;
  font-weight: 700;
}

.help-block ol {
  margin: 14px 0 0;
  padding-left: 22px;
}

.help-block li {
  margin: 8px 0;
}

.help-gallery {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.help-gallery figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.help-gallery img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  border: 1px solid var(--line);
  object-fit: contain;
  overflow: auto;
}

.help-gallery figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.upload {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px;
}

button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  font-weight: 600;
  cursor: pointer;
}

.danger-button {
  min-height: 30px;
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid #f1aaa3;
  padding: 0 10px;
}

td form,
.hero-actions form {
  margin: 0;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  width: min(680px, 100%);
}

.login-page {
  min-height: 100vh;
  background: #eef2f4;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 24px;
  box-shadow: 0 18px 42px rgb(23 32 38 / 8%);
}

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

.login-brand h1 {
  font-size: 24px;
}

.login-brand p {
  margin: 2px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form button {
  width: 100%;
  min-height: 40px;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef3f3;
  font-size: 13px;
}

code {
  font-family: "Cascadia Mono", "Consolas", monospace;
}

.alert,
.notice {
  margin-bottom: 14px;
  border-radius: 8px;
  padding: 12px 14px;
}

.alert {
  border: 1px solid #f1aaa3;
  background: var(--danger-bg);
  color: var(--danger-text);
}

.notice {
  border: 1px solid #a7d7cc;
  background: #eefaf7;
  color: #14584b;
}

.generated-download {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.download-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tree {
  padding: 14px;
  overflow: auto;
}

.device-results {
  display: grid;
  gap: 10px;
}

.device-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
}

.tree pre {
  margin: 0;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 13px;
}

.compact {
  justify-content: space-between;
}

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

.small-button {
  min-height: 28px;
  background: var(--accent);
  color: white;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
}

.tree-list,
.tree-list ul {
  list-style: none;
  margin: 0;
  padding-left: 22px;
}

.tree-list {
  padding-left: 0;
}

.tree-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  border-bottom: 1px solid #edf1f2;
}

.device-result .tree-row {
  border-bottom: 0;
}

.form-panel,
.summary {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.form-panel {
  min-width: 0;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 6px;
}

input,
select,
textarea {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
}

textarea {
  min-height: 260px;
  resize: vertical;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 13px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  min-height: 0;
}

dl {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 8px 14px;
  margin: 0;
}

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

dd {
  margin: 0;
}

h2 {
  margin: 20px 0 10px;
  font-size: 20px;
}

h3 {
  margin: 12px 0 8px;
  font-size: 15px;
}

.xml-block {
  margin-bottom: 12px;
  padding: 12px;
}

.xml-edit-block {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.xml-block pre {
  overflow: auto;
  white-space: pre-wrap;
}

.error-text {
  color: var(--danger-text);
}

.warning-text {
  color: #8a5d00;
}

.variant-list {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.7;
}

.node-details {
  margin: 4px 0 8px 18px;
  border-left: 2px solid var(--line);
  padding: 6px 0 8px 12px;
}

.node-details summary {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}

.compact-dl {
  grid-template-columns: 140px 1fr;
  margin: 8px 0;
}

.params-table {
  border-radius: 0;
  font-size: 13px;
}

.params-table th,
.params-table td {
  padding: 6px 8px;
}

@media (max-width: 640px) {
  .topbar,
  .upload,
  .hero-panel,
  .page-hero,
  .action-panel,
  .step-row,
  .generated-download,
  .two-column,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  .action-panel,
  .step-row,
  .two-column,
  .search-form,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .status-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .status-strip div:last-child {
    border-bottom: 0;
  }
}
