:root {
  --ink: #24384e;
  --muted: #8b9bb0;
  --line: #e4ebf3;
  --paper: #f3f6fb;
  --accent: #306cd6;
  --accent-dark: #215bc4;
  --ok: #27856c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.65 "Microsoft YaHei", "PingFang SC", sans-serif;
}

.shell {
  display: flex;
  min-height: 100vh;
  background: linear-gradient(to right, #172c44 0 210px, transparent 210px);
}

.sidebar {
  width: 210px;
  flex: 0 0 210px;
  background: #172c44;
  color: #a0b5cf;
  padding: 0 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 64px;
  min-height: 64px;
  padding: 0 6px;
  margin-bottom: 18px;
  color: #fff;
  font-size: 14px;
  letter-spacing: 0;
}

.brand-icon {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.nav {
  display: block;
  padding: 13px 15px;
  border-radius: 8px;
  margin: 4px 0;
  color: #97afc9;
  text-decoration: none;
  font-size: 13.5px;
  letter-spacing: 0;
}

.nav:hover { background: #203954; color: #fff; }
.nav.active { background: #2a4463; color: #fff; }

.content { flex: 1; min-width: 0; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 10px 32px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

header b { font-size: 15px; font-weight: 600; letter-spacing: 0; }

main { max-width: 1490px; margin: 18px auto 60px; padding: 0 32px; }

h1 {
  font-size: 29px;
  font-weight: 600;
  line-height: 1.4;
  color: #253950;
  letter-spacing: 1px;
  margin: 5px 0 9px;
}
h2 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 0; }
h3 { font-size: 16px; margin: 0; }

.hidden { display: none !important; }
.small { font-size: 12px; color: var(--muted); }
.warn { color: #b66743; }

body.logged-out .sidebar { display: none; }
body.logged-out header { display: none; }

.box {
  background: #fff;
  border: 1px solid #e2e9f2;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 4px #1d395802;
}

.narrow { max-width: 400px; margin: 8vh auto; }
.tag { font-size: 11px; letter-spacing: 2px; color: #9aa8b8; }

label { display: grid; gap: 6px; font-size: 12px; color: #778aa1; margin-bottom: 14px; }
input[type="text"], input[type="number"], input[type="password"] {
  border: 1px solid #dbe4f0;
  border-radius: 7px;
  padding: 11px 13px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  min-width: 0;
}

input:focus { outline: 0; border-color: #6993d4; box-shadow: 0 0 0 3px #306cd60d; }

button, .link-button {
  font: inherit;
  font-size: 13px;
  border: 1px solid #dbe4f0;
  background: #fff;
  color: #3e5771;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background .15s;
}

button:hover, .link-button:hover { background: #edf4fe; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, .link-button:focus-visible { outline: 3px solid #bdd0ef; outline-offset: 2px; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px #306cd61a;
}

button.primary:hover { background: var(--accent-dark); }
button.wide { width: 100%; margin-top: 12px; }

.execution-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 4px #1d395802;
}

.execution-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.execution-main strong { font-size: 13px; }
.execution-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  background: #edf3fb;
  color: #6884aa;
  white-space: nowrap;
}

.badge.on { background: #e3f2e9; color: var(--ok); }
.badge.bad { background: #fbe9e2; color: #b66743; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }

.stat {
  background: #fff;
  border: 1px solid #e2e9f2;
  border-radius: 11px;
  padding: 17px 21px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat small { display: block; color: #8d9bad; font-size: 11px; }
.stat strong {
  display: block;
  margin-top: 5px;
  font: 30px/1.3 "Segoe UI", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
.stat span {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  background: #eef3fb;
  border-radius: 10px;
  color: #7995b8;
  font-size: 18px;
}
.stat.success strong { color: var(--ok); }

.grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }
.grid > .box { margin-bottom: 16px; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 17px;
  gap: 10px;
  flex-wrap: wrap;
}

.step {
  display: inline-block;
  width: 25px;
  height: 25px;
  margin-right: 9px;
  border-radius: 6px;
  background: #eaf1fc;
  color: #5b83bd;
  font: 12px/25px "Segoe UI", Arial, sans-serif;
  text-align: center;
}

.dropzone {
  border: 1.5px dashed #c2d1e6;
  border-radius: 10px;
  padding: 25px 15px;
  text-align: center;
  background: #f8faff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dropzone.dragging { border-color: var(--accent); background: #e9f1fe; }
.drop-icon {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  margin-bottom: 2px;
  border-radius: 12px;
  background: #eaf1fd;
  color: #4074c2;
  font-size: 28px;
  line-height: 1;
}
.dropzone p { margin: 0; }

.material-list { margin-top: 12px; display: grid; gap: 8px; }

.material {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #edf1f6;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.material .label { flex: 1; min-width: 0; }
.material .label b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material .icon { font-size: 10px; background: #f1f5fa; color: #7b8ea5; border-radius: 4px; padding: 3px 6px; }

.summary { white-space: pre-wrap; font-size: 12px; color: #7b8ea5; margin: 10px 0 0; overflow-wrap: anywhere; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
th:first-child, td:first-child { width: 30px; padding-left: 0; }
th {
  text-align: left;
  font-weight: 400;
  font-size: 11px;
  color: #91a0b2;
  background: #f9fbfd;
  padding: 13px 8px;
  border-bottom: 1px solid #e9eff6;
  white-space: nowrap;
}
td { padding: 16px 8px; border-bottom: 1px solid #f0f4f9; vertical-align: top; overflow-wrap: anywhere; font-size: 12px; }
td button { padding: 5px 9px; font-size: 10px; white-space: nowrap; }
.result { color: #6b7c90; }

.badge.status { background: #f0f3f8; color: #5d6f85; }
.badge.status.success { background: #e3f2e9; color: var(--ok); }
.badge.status.error { background: #fbe9e2; color: #b66743; }
.badge.status.pending { background: #fff3e0; color: #a5702a; }

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.pagination > div { display: flex; align-items: center; gap: 8px; }

.log-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.log {
  background: #172b42;
  color: #bed1e7;
  border-radius: 10px;
  padding: 20px 23px;
  max-height: 260px;
  overflow: auto;
  font: 11px/1.9 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
}

.log-full { max-height: none; min-height: 60vh; }

.tool-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.primary-link { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary-link:hover { background: var(--accent-dark); }

.steps, .rules { margin: 8px 0 0; padding-left: 20px; color: #55657a; font-size: 12px; }
.steps li, .rules li { margin: 6px 0; }
code { background: #f1f5fa; border-radius: 4px; padding: 1px 5px; font-size: 12px; }

.notice { color: #b3311f; font-size: 13px; min-height: 18px; margin-top: 10px; white-space: pre-wrap; }

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  width: min(900px, calc(100vw - 32px));
  color: #334d68;
  border-color: #dfe8f2;
  box-shadow: 0 20px 80px #172b4220;
}
dialog::backdrop { background: #132b4380; backdrop-filter: blur(3px); }

.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.preview-body { max-height: 70vh; overflow: auto; display: grid; gap: 12px; }
.preview-body img { width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.preview-body h4 { margin: 6px 0; font-size: 13px; color: #6b7c90; }

.device-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid #eef2f7;
  font-size: 13px;
}

@media (max-width: 860px) {
  .shell { display: block; }
  .shell { background: none; }
  .sidebar {
    width: auto;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px 12px;
    gap: 4px;
  }
  .brand { height: auto; min-height: 0; padding: 0 10px 0 0; margin-bottom: 0; font-size: 13px; }
  .brand-icon { width: 24px; height: 24px; font-size: 13px; }
  .nav { padding: 7px 10px; font-size: 12.5px; }
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 22px; }
  header { height: 54px; padding: 8px 16px; }
  .task-table { min-width: 0; }
  main { margin-top: 14px; padding: 0 12px; }
  .stat span { display: none; }
}
