:root {
  --ink: #172135;
  --muted: #536078;
  --subtle: #78869e;
  --line: #e2e8f2;
  --bg: #f3f6fb;
  --card: #fff;
  --nav: #101a2b;
  --nav-text: #b1bfd5;
  --accent: #323ed2;
  --accent-hover: #252db0;
  --accent-quiet: #eef0ff;
  --green: #176646;
  --green-bg: #e9f7ef;
  --blue: #274db2;
  --blue-bg: #edf3ff;
  --amber: #8a560d;
  --amber-bg: #fff4de;
  --red: #9d2443;
  --red-bg: #ffecf0;
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #6570ff;
  outline-offset: 2px;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 29px; line-height: 1.3; letter-spacing: -.035em; }
h2 { font-size: 17px; line-height: 1.4; }
p { line-height: 1.6; }

.app-layout { display: grid; grid-template-columns: 215px minmax(0, 1fr); min-height: 100vh; }
.sidebar { min-height: 100vh; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 27px 17px 18px; background: var(--nav); color: white; }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 7px 33px; font-size: 16px; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 34px; display: grid; grid-template-columns: repeat(2, 6px); grid-auto-rows: 6px; gap: 3px; place-content: center; border-radius: 10px; background: #4854ed; box-shadow: 0 5px 14px #161f7b44; }
.brand-mark span { border-radius: 1px; background: white; }
.brand-mark span:nth-child(2) { opacity: .62; }
.main-nav { display: grid; gap: 5px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 45px; width: 100%; border: 0; border-radius: 8px; padding: 10px 11px; text-align: left; background: transparent; color: var(--nav-text); }
.nav-link:hover { color: white; background: #1d2b41; }
.nav-link.active { color: white; background: #2b375b; }
.nav-icon { width: 16px; height: 16px; flex: 0 0 16px; position: relative; color: currentColor; }
.nav-link.active .nav-icon { color: #aeb5ff; }
.grid-icon { border: 1.5px solid currentColor; border-radius: 3px; }
.grid-icon::before, .grid-icon::after { content: ""; position: absolute; background: currentColor; }
.grid-icon::before { left: 6px; top: 0; width: 1px; height: 13px; }
.grid-icon::after { left: 0; top: 6px; height: 1px; width: 13px; }
.list-icon { border: 1.5px solid currentColor; border-radius: 3px; }
.list-icon::before { content: ""; position: absolute; inset: 3px 3px auto; height: 1px; background: currentColor; box-shadow: 0 3px 0 currentColor, 0 6px 0 currentColor; }
.clock-icon { border: 1.5px solid currentColor; border-radius: 50%; }
.clock-icon::before { content: ""; position: absolute; left: 6px; top: 2px; width: 4px; height: 5px; border-left: 1px solid currentColor; border-bottom: 1px solid currentColor; }
.sidebar-footer { margin-top: auto; border-top: 1px solid #2a374c; padding: 13px 8px 0; display: grid; gap: 9px; }
.connection-label { display: flex; align-items: center; gap: 7px; color: #bed2d0; font-size: 12px; }
.connection-label.offline { color: #e6b7bc; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #62d09b; }
.offline .status-dot { background: #ef8c94; }
.link-button { padding: 3px 0; text-align: left; color: var(--nav-text); background: none; border: 0; width: fit-content; }
.link-button:hover { color: white; text-decoration: underline; }

.content { width: min(1500px, 100%); margin-inline: auto; padding: 29px 33px 43px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 23px; }
.page-header p { color: var(--muted); margin-top: 7px; }
.header-actions, .panel-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 37px; padding: 8px 13px; border-radius: 7px; border: 1px solid transparent; font-weight: 600; line-height: 1.25; white-space: nowrap; }
.primary { background: var(--accent); color: white; box-shadow: 0 3px 8px #323ed226; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary { background: white; color: #32415a; border-color: #dbe3ef; }
.secondary:hover:not(:disabled), .secondary[aria-pressed="true"] { background: var(--accent-quiet); color: var(--accent-hover); border-color: #c8cdf9; }
.button:disabled { opacity: .5; }
.button.compact { padding: 5px 9px; min-height: 31px; font-size: 12px; }
.button.danger { color: var(--red); }
.full-width { width: 100%; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.metric { display: grid; gap: 7px; min-height: 93px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); }
.metric span { color: var(--muted); font-weight: 600; }
.metric strong { color: #23345b; font-size: 27px; font-variant-numeric: tabular-nums; line-height: 1; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(305px, 1fr); gap: 17px; align-items: start; }
.task-grid { grid-template-columns: minmax(0, 1.7fr) minmax(270px, 1fr); }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 11px; background: var(--card); box-shadow: 0 2px 7px #2b3c5420; overflow: hidden; }
.panel-heading { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.panel-heading p { margin-top: 3px; font-size: 12px; color: var(--muted); }
.panel-body { display: grid; gap: 14px; padding: 16px; }
.panel-note { padding: 0 15px 13px; font-size: 12px; color: var(--muted); }

.check-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }
.device-list { display: grid; gap: 9px; padding: 12px; min-height: 250px; align-content: start; }
.device-row { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border: 1px solid var(--line); background: white; border-radius: 8px; }
.device-row.focused { background: #f7f8ff; border-color: #c9cdf8; }
.device-main { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; border: 0; text-align: left; padding: 0; background: transparent; color: var(--ink); }
.device-main:hover .device-name { color: var(--accent-hover); }
.device-phone { width: 27px; height: 36px; flex: 0 0 27px; position: relative; border: 1px solid #c8d1e3; border-radius: 6px; background: #eff3fa; }
.device-phone::before { content: ""; position: absolute; width: 8px; height: 2px; border-radius: 3px; top: 4px; left: 8px; background: #8b9ab5; }
.device-text { min-width: 0; display: grid; gap: 4px; }
.device-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.device-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.empty-state { align-self: center; display: grid; justify-items: center; gap: 7px; text-align: center; padding: 35px 13px; }
.empty-state p { color: var(--muted); font-size: 13px; }
.empty-state .button { margin-top: 5px; }
.pill { flex: 0 0 auto; display: inline-flex; min-height: 23px; padding: 3px 8px; border-radius: 15px; font-size: 11px; font-weight: 650; align-items: center; white-space: nowrap; }
.neutral { background: #ecf0f6; color: #536078; }
.success { background: var(--green-bg); color: var(--green); }
.working { background: var(--blue-bg); color: var(--blue); }
.warning { background: var(--amber-bg); color: var(--amber); }
.failed { background: var(--red-bg); color: var(--red); }

.preview-stage { display: flex; min-height: 315px; padding: 11px; align-items: center; justify-content: center; background: #172337; border-radius: 7px; margin: 13px 13px 10px; color: #b6c4db; text-align: center; }
.preview-stage img { display: block; width: auto; height: auto; max-width: 100%; max-height: 437px; border-radius: 5px; }
.preview-stage .tap-armed { cursor: crosshair; outline: 2px solid #9da6ff; outline-offset: 2px; }
.preview-controls { padding: 0 13px 9px; display: flex; gap: 6px; flex-wrap: wrap; }
.preview-controls .button { padding-inline: 9px; font-size: 12px; }
.preview-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 13px 11px; }
.preview-footer .panel-note { padding: 0; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field > label, .pair-label { color: var(--muted); font-size: 12px; font-weight: 650; }
input:not([type="checkbox"]), select, textarea { width: 100%; min-height: 36px; padding: 7px 9px; border: 1px solid #ced8e8; border-radius: 6px; background: white; color: var(--ink); }
input::placeholder, textarea::placeholder { color: #7c879c; }
.task-device-list { display: grid; gap: 7px; }
.task-target { display: flex; align-items: center; gap: 8px; min-height: 28px; color: var(--ink); }
.task-target .pill { margin-left: auto; }
#steps { display: grid; gap: 8px; }
.step { display: grid; gap: 9px; border: 1px solid var(--line); background: #f9fbfe; border-radius: 8px; padding: 10px; }
.step-heading { min-width: 0; display: grid; grid-template-columns: 40px minmax(120px, 1fr) auto; gap: 8px; align-items: center; }
.step-number { color: var(--muted); font-size: 12px; }
.step-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(125px, 100%), 1fr)); gap: 8px; padding-left: 48px; }
.step-fields:empty { display: none; }
.step-fields .grow { grid-column: 1/-1; }
.step-actions { display: flex; gap: 4px; }
.step-actions .button { padding-inline: 7px; }
.history-view { display: grid; gap: 16px; }
.table-wrap { overflow: auto; }
.result-table { width: 100%; border-collapse: collapse; text-align: left; min-width: 690px; }
.result-table th { background: #f7f9fc; color: var(--muted); font-size: 12px; font-weight: 650; }
.result-table th, .result-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.result-table tbody tr:last-child td { border-bottom: 0; }
.result-table td:nth-child(1) { min-width: 130px; }
.table-label { font-weight: 600; overflow-wrap: anywhere; }
.table-detail { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; display: block; max-width: 480px; }
.nowrap { white-space: nowrap; }
.filter-label { display: flex; align-items: center; color: var(--muted); font-size: 12px; gap: 8px; white-space: nowrap; }
.filter-label select { min-width: 85px; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 20% 5%, #e1e7fc, transparent 55%), var(--bg); }
.login-card { display: grid; gap: 12px; width: min(410px, 100%); padding: 27px; border-radius: 13px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 18px 40px #293d6722; }
.login-card h1 { margin-top: 3px; }
.login-card p:not(.form-error) { color: var(--muted); }
.login-card label { margin-top: 8px; font-weight: 650; }
.login-card .button { margin-top: 5px; }
.form-error { color: var(--red); font-size: 13px; }

dialog { width: min(480px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: 12px; padding: 19px; color: var(--ink); box-shadow: 0 20px 62px #10203c47; }
dialog::backdrop { background: #0b162a80; }
dialog > p { color: var(--muted); margin-bottom: 12px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.copy-field { display: flex; gap: 7px; }
.pair-code-row { display: flex; align-items: center; justify-content: space-between; min-height: 82px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 13px; margin-top: 14px; background: #f6f8ff; }
.pair-code-row strong { display: block; font-variant-numeric: tabular-nums; font-size: 27px; letter-spacing: .05em; }
.pair-code-row p { color: var(--muted); font-size: 11px; }
#pair-error { margin: 8px 0 0; }
.toast { position: fixed; z-index: 3; bottom: 18px; right: 19px; max-width: min(470px, calc(100vw - 38px)); border-radius: 8px; padding: 10px 14px; background: #182740; color: white; box-shadow: 0 6px 22px #10203c42; overflow-wrap: anywhere; }

@media (max-width: 1050px) {
  .app-layout { grid-template-columns: 170px minmax(0, 1fr); }
  .content { padding-inline: 19px; }
  .workspace-grid { grid-template-columns: minmax(0, 1.35fr) minmax(260px, 1fr); }
  .task-grid { grid-template-columns: minmax(0, 1.55fr) minmax(235px, .9fr); }
  .sidebar { padding-inline: 11px; }
}
@media (max-width: 790px) {
  .app-layout { display: block; }
  .sidebar { min-height: 0; height: auto; position: static; padding: 10px 13px; display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .brand { margin: 0 8px 0 0; font-size: 14px; }
  .brand-mark { width: 28px; height: 28px; flex-basis: 28px; }
  .main-nav { display: flex; gap: 2px; }
  .nav-link { min-height: 35px; gap: 4px; padding: 6px 8px; font-size: 12px; }
  .sidebar-footer { margin: 0 0 0 auto; border: 0; padding: 0; }
  .connection-label { display: none; }
  .link-button { font-size: 12px; }
  .content { padding: 17px 13px 29px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .metrics { gap: 6px; }
  .metric { min-height: 77px; padding: 11px 8px; }
  .metric strong { font-size: 23px; }
  .page-header { gap: 10px; }
  h1 { font-size: 24px; }
}
@media (max-width: 430px) {
  .panel-heading { flex-wrap: wrap; }
  .step-heading { grid-template-columns: 31px minmax(95px, 1fr) auto; gap: 5px; }
  .step-fields { padding-left: 0; }
  .step-actions .button { padding-inline: 4px; }
}
