/* 墨屏计划 · 后台样式
   纸墨基调：米白纸面、近黑墨色、一点朱砂。无阴影、无渐变、细线分隔，
   与墨水屏的观感保持一致。 */

:root {
  --paper: #f4f1e9;
  --surface: #fbf9f3;
  --surface-2: #eeeae0;
  --ink: #1b1b19;
  --ink-2: #4a4a44;
  --muted: #7c7a70;
  --line: #d8d3c5;
  --line-strong: #b9b2a0;
  --accent: #a2432b;
  --accent-soft: #f0e2d9;
  --ok: #3f6b4a;
  --warn: #8a6a1f;
  --danger: #a3352b;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --r: 2px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- 登录页 */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,.035) 1px, transparent 0);
  background-size: 7px 7px;
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  padding: 40px 36px 32px;
  position: relative;
}
.login-card::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid var(--line);
  pointer-events: none;
}
.login-mark {
  width: 34px; height: 34px;
  border: 1.5px solid var(--ink);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 18px;
  margin-bottom: 22px;
}
.login-card h1 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: .04em;
  margin: 0 0 6px;
}
.login-card p.sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .02em;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.input {
  width: 100%;
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 9px 11px;
  border-radius: var(--r);
  outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--ink); }
.input::placeholder { color: #b3ada0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  padding: 8px 15px;
  border-radius: var(--r);
  cursor: pointer;
  letter-spacing: .02em;
  transition: opacity .15s, background .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .85; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn.ghost:hover { border-color: var(--ink); opacity: 1; }
.btn.danger { background: transparent; border-color: #d3b7b0; color: var(--danger); }
.btn.danger:hover { background: #f6eae6; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }

.alert {
  border: 1px solid #ddc0b8;
  background: #f7ece7;
  color: #7d3323;
  padding: 9px 12px;
  border-radius: var(--r);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------- 框架 */

.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  padding: 26px 0 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 22px;
  border-bottom: 1px solid var(--line);
}
.brand .mark {
  width: 30px; height: 30px;
  border: 1.5px solid var(--ink);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 16px;
  flex: none;
}
.brand .name { font-family: var(--serif); font-size: 16px; letter-spacing: .05em; }
.brand .sub { font-size: 11px; color: var(--muted); letter-spacing: .08em; }

.nav { padding: 14px 0; display: flex; flex-direction: column; gap: 2px; }
.nav button {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 22px;
  cursor: pointer;
  color: var(--ink-2);
  border-left: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: .02em;
}
.nav button:hover { background: rgba(0,0,0,.03); color: var(--ink); }
.nav button.active {
  border-left-color: var(--accent);
  color: var(--ink);
  background: rgba(255,255,255,.6);
  font-weight: 600;
}
.nav svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.6; opacity: .8; }

.rail-foot {
  margin-top: auto;
  padding: 16px 22px 0;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}
.rail-foot .row { display: flex; justify-content: space-between; gap: 8px; }
.dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong);
  display: inline-block;
}
.dot.on { background: var(--ok); }
.dot.err { background: var(--danger); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(244,241,233,.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.topbar h2 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .06em;
  margin: 0;
}
.topbar .date { color: var(--muted); font-size: 12.5px; letter-spacing: .04em; }
.topbar .spacer { flex: 1; }

.content { padding: 28px 32px 64px; max-width: 1120px; width: 100%; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card > h3 {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .08em;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card > h3 .tag { margin-left: auto; }
.card .hint { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.card .hint code { font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); padding: 1px 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  padding: 2px 7px;
  border-radius: 1px;
  color: var(--muted);
  background: transparent;
}
.tag.ledu { color: #2f4a6b; border-color: #b9c7d6; background: #eef2f7; }
.tag.classin { color: #6b3f2f; border-color: #d6c1b5; background: #f7efe9; }
.tag.manual { color: #4a4a2f; border-color: #cfcaae; background: #f4f3e4; }

/* ---------------------------------------------------------------- 日期条 */

.datestrip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 18px;
}
.daychip {
  border: 1px solid var(--line);
  background: var(--surface);
  min-width: 64px;
  padding: 8px 6px 7px;
  border-radius: var(--r);
  cursor: pointer;
  text-align: center;
  flex: none;
}
.daychip .w { font-size: 10.5px; letter-spacing: .1em; color: var(--muted); }
.daychip .d { font-family: var(--serif); font-size: 18px; line-height: 1.25; }
.daychip .n { font-size: 10px; color: var(--accent); height: 12px; }
.daychip:hover { border-color: var(--line-strong); }
.daychip.active { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.daychip.active .w, .daychip.active .n { color: #cfc8b8; }
.daychip.today .d { font-weight: 700; }

/* ---------------------------------------------------------------- 计划列表 */

.planlist { display: grid; gap: 0; }
.plan {
  display: grid;
  grid-template-columns: 16px 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px dashed var(--line);
}
.plan:last-child { border-bottom: 0; }
.plan .time {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.plan .title { font-size: 14.5px; }
.plan .meta { color: var(--muted); font-size: 12px; margin-top: 1px; }
.plan .title .note { color: var(--muted); font-size: 12px; margin-left: 8px; }
.plan.past { opacity: .62; }
.plan .ops { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.plan:hover .ops { opacity: 1; }

.star { width: 16px; height: 16px; display: grid; place-items: center; }
.star svg { width: 15px; height: 15px; stroke: var(--ink-2); fill: none; stroke-width: 1.4; }
.star.filled svg { fill: var(--ink); stroke: var(--ink); }

/* 复选框 */
.check {
  width: 15px; height: 15px;
  border: 1.4px solid var(--ink-2);
  border-radius: 1px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  background: transparent;
  padding: 0;
}
.check svg { width: 12px; height: 12px; stroke: var(--surface); fill: none; stroke-width: 2.4; opacity: 0; }
.check.on { background: var(--ink); border-color: var(--ink); }
.check.on svg { opacity: 1; }

.tiplist { display: grid; }
.tip {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px dashed var(--line);
}
.tip:last-child { border-bottom: 0; }
.tip.done .text { color: var(--muted); text-decoration: line-through; }
.tip .ops { opacity: 0; }
.tip:hover .ops { opacity: 1; }

.empty {
  padding: 34px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
}

/* ---------------------------------------------------------------- 表单 */

.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.formgrid .full { grid-column: 1 / -1; }
.formgrid label { font-size: 11px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; display: block; margin-bottom: 5px; }
.formgrid .input { background: var(--paper); }
.row-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 34px; height: 18px; border: 1px solid var(--line-strong); border-radius: 10px; position: relative; background: var(--surface-2); cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--line-strong); transition: transform .15s, background .15s; }
.switch input:checked { background: var(--ink); border-color: var(--ink); }
.switch input:checked::after { transform: translateX(16px); background: var(--surface); }

.statusline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  padding: 7px 0;
}
.statusline b { color: var(--ink-2); font-weight: 600; }
.statusline .dot { flex: none; }

.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ---------------------------------------------------------------- 日志 / 设备 */

.logs { max-height: 520px; overflow: auto; font-family: var(--mono); font-size: 11.5px; }
.logrow { display: grid; grid-template-columns: 132px 54px 1fr; gap: 10px; padding: 5px 2px; border-bottom: 1px solid #eae6da; }
.logrow .t { color: var(--muted); }
.logrow .lv { text-transform: uppercase; letter-spacing: .08em; font-size: 10px; padding-top: 1px; }
.logrow .lv.info { color: var(--ok); }
.logrow .lv.warn { color: var(--warn); }
.logrow .lv.error { color: var(--danger); }

.device {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 2px;
  border-bottom: 1px dashed var(--line);
}
.device:last-child { border-bottom: 0; }
.device .n { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.device .m { color: var(--muted); font-size: 12px; margin-top: 2px; }

.codebox {
  font-family: var(--mono);
  font-size: 30px;
  letter-spacing: .22em;
  padding: 12px 0 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  margin: 10px 0;
}

/* ---------------------------------------------------------------- 弹窗 / 提示 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24,22,18,.38);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 24px 26px;
  max-height: 88vh;
  overflow: auto;
}
.modal h3 { font-family: var(--serif); font-size: 17px; margin: 0 0 14px; letter-spacing: .05em; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--surface);
  padding: 9px 16px;
  border-radius: var(--r);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 60;
  max-width: min(520px, 90vw);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { border-bottom: 0; padding: 0 12px 0 4px; }
  .brand .sub { display: none; }
  .nav { flex-direction: row; padding: 0; gap: 2px; }
  .nav button { border-left: 0; border-bottom: 2px solid transparent; padding: 7px 10px; white-space: nowrap; }
  .nav button.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .nav button span { display: none; }
  .rail-foot { display: none; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .plan { grid-template-columns: 16px 54px minmax(0,1fr); }
  .plan .ops { grid-column: 2 / -1; opacity: 1; justify-content: flex-end; }
}
