:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #dde3ec;
  --text: #1a2332;
  --muted: #5c6b80;
  --accent: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --step: #eef2ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  padding: 1rem;
  max-width: 720px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 1rem 0;
}

header h1 { font-size: 1.45rem; font-weight: 700; }
.subtitle { color: var(--muted); font-size: 0.9rem; margin-top: 0.35rem; }

.step-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.step-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--step);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-head h2 { font-size: 1.05rem; flex: 1; }

.hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.75rem; }

.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.actions { margin-top: 1rem; }

button {
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

button:hover:not(:disabled) { filter: brightness(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff; }
button.danger { background: #fee2e2; color: var(--err); }

.file-label {
  background: var(--step);
  color: var(--accent);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  border: 1px dashed var(--accent);
}

.file-label.disabled { opacity: 0.45; pointer-events: none; }

input[type="text"] {
  flex: 1;
  min-width: 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font-size: 0.9rem;
}

.badge {
  font-size: 0.78rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-weight: 600;
}
.badge.on { background: #dcfce7; color: var(--ok); }
.badge.off { background: #f1f5f9; color: var(--muted); }
.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.err { background: #fee2e2; color: var(--err); }
.badge.lock { background: #e0e7ff; color: var(--accent); }

.info-grid {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.info-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--muted); }
.info-val { word-break: break-word; font-weight: 500; white-space: pre-wrap; line-height: 1.45; }

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.status-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
}

.status-item .label { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.25rem; }
.status-item .value {
  font-size: 0.88rem;
  font-weight: 600;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.4;
}

.uom-preview-wrap { margin-top: 0.75rem; }
.uom-preview-wrap.hidden { display: none; }
#uom-preview {
  width: 100%;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.log-toggle { font-size: 0.85rem; color: var(--muted); cursor: pointer; user-select: none; }
.log-toggle input { margin-right: 0.35rem; }

#log-panel { display: none; margin-top: 0.75rem; }
#log-panel.open { display: block; }

#log {
  background: #1e293b;
  color: #94a3b8;
  border-radius: 8px;
  padding: 0.75rem;
  max-height: 180px;
  overflow-y: auto;
  font-size: 0.72rem;
  font-family: ui-monospace, monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

.hidden { display: none !important; }
.empty-hint { color: var(--muted); font-size: 0.85rem; font-style: italic; }

.info-box {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.55;
}

#wifi-tune-hint strong {
  display: block;
  margin-bottom: 0.35rem;
}
#wifi-tune-hint .wifi-tune-steps {
  margin: 0.35rem 0 0.5rem 1.2rem;
  padding: 0;
}
#wifi-tune-hint .wifi-tune-steps > li {
  margin: 0.35rem 0;
}
#wifi-tune-hint .wifi-tune-steps ul {
  margin: 0.35rem 0 0.15rem;
  padding-left: 1.15rem;
  list-style: disc;
}
#wifi-tune-hint .wifi-tune-steps ul li {
  margin: 0.2rem 0;
}
#wifi-tune-hint .wifi-tune-note {
  margin: 0.5rem 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 520px) {
  .status-grid { grid-template-columns: 1fr; }
  .info-row { grid-template-columns: 90px 1fr; }
}
