:root {
  --ink: #111827;
  --muted: #667085;
  --line: #dfe5ec;
  --surface: #ffffff;
  --page: #f3f6f8;
  --blue: #1769e0;
  --blue-hover: #0e56bf;
  --green: #15966a;
  --magenta: #bd238f;
  --red: #c9363e;
  --amber-bg: #fff8e7;
  --amber-border: #e9c972;
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.app-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.header-inner,
.workspace,
footer {
  width: min(100% - 32px, 960px);
  margin-inline: auto;
}

.header-inner {
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 124px;
  height: 46px;
  object-fit: contain;
}

.header-copy {
  flex: 1;
  min-width: 0;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.header-copy h1,
.header-copy p,
.section-heading h2,
.section-heading p,
.profile-heading h3,
.empty-state,
footer {
  margin: 0;
}

.header-copy h1 {
  font-size: 20px;
  line-height: 1.4;
}

.header-copy p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 17px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #98a2b3;
}

.status-badge[data-tone="ready"] {
  color: #08784f;
  border-color: #9bdac2;
  background: #eefbf5;
}

.status-badge[data-tone="ready"] .status-dot {
  background: var(--green);
}

.status-badge[data-tone="busy"] .status-dot {
  background: var(--magenta);
}

.status-badge[data-tone="error"] {
  color: var(--red);
  border-color: #f1b7bb;
  background: #fff4f4;
}

.status-badge[data-tone="error"] .status-dot {
  background: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 20px;
  padding-block: 32px 20px;
}

.device-panel,
.setup-panel,
.log-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.device-panel,
.setup-panel {
  padding: 24px;
}

.section-heading,
.profile-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.section-heading h2 {
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.35;
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 18px;
  font-weight: 750;
}

.button-primary {
  color: #ffffff;
  background: var(--blue);
}

.button-primary:hover:not(:disabled) {
  background: var(--blue-hover);
}

.button-secondary {
  color: var(--ink);
  border-color: #b8c3d1;
  background: #ffffff;
}

.button-danger-quiet {
  color: var(--red);
  border-color: #efc3c6;
  background: #fffafa;
}

.button-icon {
  margin-right: 5px;
  font-size: 18px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 24px 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.device-grid div {
  min-width: 0;
  padding: 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.device-grid dt {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.device-grid dd {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 14px;
  font-weight: 750;
}

.notice {
  padding: 13px 14px;
  border: 1px solid #bad1ef;
  border-radius: 6px;
  color: #174b83;
  background: #f1f7fe;
  font-size: 13px;
  line-height: 1.6;
}

.notice + .notice {
  margin-top: 12px;
}

.notice-warning {
  color: #76570c;
  border-color: var(--amber-border);
  background: var(--amber-bg);
}

.notice[data-tone="success"] {
  color: #08784f;
  border-color: #9bdac2;
  background: #eefbf5;
}

.notice[data-tone="error"] {
  color: #a1262d;
  border-color: #f1b7bb;
  background: #fff4f4;
}

#wifiForm {
  margin-top: 24px;
}

.field {
  display: block;
  margin-top: 16px;
}

.field > span {
  display: block;
  margin-bottom: 8px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid #b8c3d1;
  border-radius: 6px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.13);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #475467;
  background: transparent;
  font-size: 20px;
}

.password-field .icon-button {
  position: absolute;
  top: 4px;
  right: 5px;
}

.icon-button:hover:not(:disabled) {
  background: #edf2f7;
}

.validation-message {
  min-height: 20px;
  margin: 9px 0 0;
  color: var(--red);
  font-size: 12px;
}

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

.profile-section {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.profile-heading h3 {
  font-size: 15px;
}

.profile-list {
  min-height: 56px;
  margin: 10px 0 14px;
}

.empty-state {
  padding: 17px 0;
  color: var(--muted);
  font-size: 13px;
}

.profile-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
}

.profile-name {
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
}

.profile-meta {
  margin-left: 8px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.profile-remove {
  min-width: 36px;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--red);
  background: transparent;
  font-size: 19px;
}

.profile-remove:hover {
  background: #fff1f2;
}

.log-panel {
  grid-column: 1 / -1;
  overflow: hidden;
  box-shadow: none;
}

.log-panel summary {
  padding: 14px 18px;
  cursor: pointer;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.log-panel pre {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  color: #dbe7f5;
  background: #16202c;
  font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

footer {
  padding: 8px 0 32px;
  color: #98a2b3;
  text-align: center;
  font-size: 12px;
}

@media (max-width: 760px) {
  .header-inner {
    min-height: 76px;
    flex-wrap: wrap;
    padding-block: 12px;
  }

  .brand-logo {
    width: 96px;
    height: 38px;
  }

  .header-copy {
    padding-left: 12px;
  }

  .header-copy h1 {
    font-size: 17px;
  }

  .status-badge {
    width: 100%;
    justify-content: center;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding-top: 20px;
  }

  .device-panel,
  .setup-panel {
    padding: 18px;
  }

  .section-heading {
    align-items: flex-end;
  }

  .section-heading h2 {
    font-size: 19px;
  }

  .action-row {
    grid-template-columns: 1fr;
  }

  .log-panel {
    grid-column: auto;
  }
}

@media (max-width: 460px) {
  .header-copy {
    border-left: 0;
  }

  .header-copy p {
    display: none;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

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