/* ScreenSync — 纸感浅色管理台 */
:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --panel-2: #fbfaf7;
  --ink: #16160f;
  --ink-2: #3d3d35;
  --muted: #8a897f;
  --line: #e5e3da;
  --line-2: #d3d0c4;
  --accent: #16160f;
  --danger: #b4372a;
  --ok: #2f6b3f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 22, 15, .04), 0 8px 24px -18px rgba(22, 22, 15, .3);
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }

/* ---------- 启动 / 登录 ---------- */
.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.boot-mark { width: 34px; height: 34px; border: 2px solid var(--line-2); border-top-color: var(--ink); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-art {
  background: #16160f; color: #f6f5f1; padding: 56px; display: flex; flex-direction: column;
  justify-content: space-between; position: relative; overflow: hidden;
}
.auth-art::after {
  content: ""; position: absolute; width: 520px; height: 720px; right: -120px; top: 50%;
  transform: translateY(-50%) rotate(6deg); border-radius: 14px;
  background: repeating-linear-gradient(0deg, #f6f5f1 0 1px, transparent 1px 30px), #23231a;
  opacity: .5; border: 2px solid #45453a;
}
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 650; letter-spacing: .02em; z-index: 1; }
.auth-brand .dot { width: 10px; height: 10px; background: #f6f5f1; border-radius: 2px; }
.auth-copy { z-index: 1; max-width: 420px; }
.auth-copy h1 { font-size: 34px; line-height: 1.32; letter-spacing: -.02em; }
.auth-copy p { color: #b8b7ab; margin-top: 16px; font-size: 14px; }
.auth-meta { z-index: 1; color: #7c7b70; font-size: 12px; display: flex; gap: 18px; }
.auth-form { display: grid; place-items: center; padding: 40px; }
.auth-card { width: min(380px, 100%); }
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 26px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: .02em; }
.input {
  width: 100%; padding: 11px 13px; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 10px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(22, 22, 15, .07); }
.input::placeholder { color: #b5b3a8; }
textarea.input { resize: vertical; min-height: 72px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--accent); color: #fff; cursor: pointer; font-weight: 550;
  transition: transform .08s, opacity .15s, background .15s;
}
.btn:hover { opacity: .9; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--panel-2); border-color: var(--ink); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); border-color: #e8d0cb; background: transparent; }
.btn.danger:hover { background: #fdf5f3; }
.auth-alt { margin-top: 16px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-alt a { color: var(--ink); border-bottom: 1px solid var(--line-2); cursor: pointer; }
.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; display: none; }
.alert.err { display: block; background: #fdf5f3; color: var(--danger); border: 1px solid #eccfc9; }

/* ---------- 布局 ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: var(--panel-2); border-right: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.side-brand .mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.side-brand b { font-size: 15px; letter-spacing: -.01em; }
.side-brand span { display: block; font-size: 11px; color: var(--muted); font-weight: 400; letter-spacing: .04em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px;
  color: var(--ink-2); cursor: pointer; font-size: 13.5px; transition: background .12s;
}
.nav-item:hover { background: #efeee8; }
.nav-item.on { background: var(--ink); color: #fff; }
.nav-item .ico { width: 16px; height: 16px; opacity: .85; flex: none; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item.on .count { color: #b9b8ad; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; font-size: 12px; color: var(--muted); }
.side-user { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 11px; color: var(--ink-2); font-weight: 600; flex: none; }
.side-user .nm { color: var(--ink); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .em { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-links { display: flex; gap: 12px; font-size: 12px; }
.side-links a { cursor: pointer; }
.side-links a:hover { color: var(--ink); }

.main { min-width: 0; padding: 30px 38px 70px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 25px; }
.page-head .desc { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-head .spacer { flex: 1; }

/* ---------- 卡片 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(470px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.empty {
  border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 46px 20px;
  text-align: center; color: var(--muted); background: var(--panel-2);
}
.empty b { display: block; color: var(--ink); margin-bottom: 6px; font-size: 15px; }

/* 设备卡 */
.device { display: grid; grid-template-columns: 196px 1fr; overflow: hidden; height: 100%; }
.device-screen {
  background: #efeee8; padding: 18px; display: grid; place-items: center; border-right: 1px solid var(--line);
}
.screen-frame {
  width: 100%; aspect-ratio: 758 / 1024; background: #fff; border: 7px solid #1c1c16;
  border-radius: 5px; overflow: hidden; box-shadow: 0 10px 24px -16px rgba(0,0,0,.6);
  position: relative;
}
.screen-frame img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.screen-frame.sm { border-width: 5px; }
.device-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.device-title { display: flex; align-items: center; gap: 10px; }
.device-title h3 { font-size: 17px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: #c6ddcb; background: #f2f8f3; }
.badge.off { color: var(--muted); }
.badge.mode { color: var(--ink-2); }
.kv { display: flex; flex-wrap: wrap; gap: 12px 20px; font-size: 12.5px; color: var(--muted); }
.kv b { color: var(--ink-2); font-weight: 550; }
.device-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.mono { font-family: var(--mono); letter-spacing: .04em; }

/* 素材 */
.drop {
  border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 26px;
  text-align: center; color: var(--muted); background: var(--panel-2); margin-bottom: 18px;
  transition: border-color .15s, background .15s; cursor: pointer;
}
.drop:hover, .drop.hot { border-color: var(--ink); background: #f2f1ea; color: var(--ink); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(154px, 1fr)); gap: 12px; }
.thumb { position: relative; border-radius: 11px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; filter: grayscale(1); transition: filter .2s; }
.thumb:hover img { filter: grayscale(0); }
.thumb .meta { padding: 7px 9px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.thumb .meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb .del {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.62); color: #fff; cursor: pointer; line-height: 1;
  opacity: 0; transition: opacity .15s; font-size: 13px;
}
.thumb:hover .del { opacity: 1; }

/* 通道 */
.channel { padding: 16px; display: flex; flex-direction: column; gap: 12px; height: 100%; }
.channel .top { display: flex; gap: 14px; }
.channel .prev { width: 86px; flex: none; }
.channel h3 { font-size: 15.5px; }
.channel .kind { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.channel .stats { font-size: 12px; color: var(--muted); margin-top: 4px; }
.channel .acts { display: flex; gap: 7px; flex-wrap: wrap; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 11px; border: 1px solid var(--line-2); border-radius: 20px; padding: 2px 9px; color: var(--ink-2); }

/* 待办 */
.todo-form { display: grid; grid-template-columns: 1fr 146px 128px auto; gap: 8px; margin-bottom: 16px; }
.todo-list { display: flex; flex-direction: column; }
.todo {
  display: grid; grid-template-columns: 26px 1fr auto auto; gap: 10px; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--line);
}
.todo:last-child { border-bottom: none; }
.todo .txt { min-width: 0; overflow-wrap: anywhere; }
.todo.done .txt { color: var(--muted); text-decoration: line-through; }
.check {
  width: 19px; height: 19px; border: 1.6px solid var(--line-2); border-radius: 5px;
  background: #fff; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.check.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.check svg { width: 12px; height: 12px; }
.todo .due { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.todo .due.late { color: var(--danger); }
.todo .ops { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.todo:hover .ops { opacity: 1; }
.icon-btn {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { border-color: var(--ink); color: var(--ink); }
.prio { width: 3px; height: 18px; border-radius: 2px; background: var(--line); }
.prio.p2 { background: var(--ink); }
.prio.p1 { background: #a9a89c; }

/* 弹窗 */
.modal-bg {
  position: fixed; inset: 0; background: rgba(22, 22, 15, .38); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px; z-index: 60; animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--panel); border-radius: 16px; width: min(560px, 100%);
  box-shadow: 0 30px 70px -30px rgba(0,0,0,.55); overflow: hidden;
  animation: pop .18s cubic-bezier(.2,.8,.3,1);
}
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; max-height: 72vh; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--panel-2); }
.code-box {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; text-align: center; margin: 4px 0 16px;
}
.code-box .code {
  font-family: var(--mono); font-size: 38px; letter-spacing: .28em; font-weight: 600; line-height: 1.1;
}
.code-box .hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.steps { counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li { counter-increment: s; position: relative; padding-left: 30px; margin-bottom: 12px; font-size: 13px; color: var(--ink-2); }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 1px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--ink); color: #fff; font-size: 11px;
  display: grid; place-items: center;
}
.steps code { background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.copyable { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-family: var(--mono); font-size: 12.5px; margin-top: 4px; }
.copyable span { flex: 1; overflow: auto; white-space: nowrap; }

/* 编辑表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.rule-row { display: grid; grid-template-columns: 1fr 1fr 1.1fr 1.3fr 32px; gap: 7px; align-items: center; margin-bottom: 7px; }
.rule-row .input { padding: 7px 9px; font-size: 13px; }
.section-title { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.thumb-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; max-height: 260px; overflow: auto; padding: 2px; }
.pick { position: relative; border: 2px solid transparent; border-radius: 9px; overflow: hidden; cursor: pointer; }
.pick img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; filter: grayscale(1); }
.pick.on { border-color: var(--ink); }
.pick.on::after { content: "✓"; position: absolute; top: 3px; right: 3px; background: var(--ink); color: #fff; width: 17px; height: 17px; border-radius: 50%; font-size: 10px; display: grid; place-items: center; }
.sortable { display: flex; flex-direction: column; gap: 6px; }
.sort-item { display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 6px; }
.sort-item img { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; filter: grayscale(1); }

/* toast */
#toast-wrap { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 15px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.6); animation: slip .2s ease;
}
.toast.err { background: var(--danger); }
@keyframes slip { from { transform: translateY(8px); opacity: 0; } }

.tag-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.tag-live i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); display: block; }
.tag-live.on i { background: var(--ok); box-shadow: 0 0 0 3px rgba(47,107,63,.14); }

@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; gap: 14px; overflow-x: auto; padding: 12px 14px; border-right: none; border-bottom: 1px solid var(--line); }
  .side-brand span, .side-foot { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav-item { white-space: nowrap; }
  .nav-item .count { display: none; }
  .main { padding: 20px 16px 60px; }
  .device { grid-template-columns: 1fr; }
  .device-screen { border-right: none; border-bottom: 1px solid var(--line); }
  .screen-frame { max-width: 220px; margin: 0 auto; }
  .todo-form { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .rule-row { grid-template-columns: 1fr 1fr; }
}
