/* PCGuard 家长端 —— 米白暖色、扁平、移动优先 */

:root {
  --bg: #f5f0e5;
  --bg-deep: #efe7d7;
  --card: #fffcf5;
  --card-soft: #fbf6ea;
  --ink: #211d16;
  --ink-soft: #3b3529;
  --muted: #7c7261;
  --muted-2: #9c917e;
  --line: #e7dcc7;
  --line-strong: #d8cbb2;
  --accent: #b45309;
  --accent-deep: #8f3f06;
  --accent-soft: #f6e7cc;
  --accent-text: #fffaf0;
  --good: #157f3d;
  --good-soft: #e6f1e4;
  --bad: #a3281b;
  --bad-soft: #f7e6e1;
  --warn: #a16207;
  --warn-soft: #f8ecd2;
  --shadow-sm: 0 1px 2px rgba(33, 29, 22, 0.05);
  --shadow-md: 0 2px 4px rgba(33, 29, 22, 0.04), 0 22px 44px -30px rgba(33, 29, 22, 0.42);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(255, 252, 240, 0.95), transparent 64%),
    radial-gradient(900px 520px at 108% 4%, rgba(240, 222, 188, 0.5), transparent 60%),
    var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

button, input { font-family: inherit; }

.app { min-height: 100dvh; }

.shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px 48px;
}
.shell.shell-narrow { width: min(620px, 100%); }

/* ---------------------------------------------------------------- 顶部 */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--ink);
  color: var(--accent-soft);
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: var(--shadow-sm);
}
.logo-mark svg { width: 21px; height: 21px; }
.brand-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.7);
  color: var(--muted);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--card); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 2px;
  cursor: pointer;
}
.back-btn:hover { color: var(--ink); }
.back-btn svg { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- 登录 */
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
}
.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 34px 28px 26px;
  box-shadow: var(--shadow-md);
}
.login-mark {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: grid;
  place-items: center;
  margin-bottom: 20px;
}
.login-mark svg { width: 30px; height: 30px; }
.login-card h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0.01em;
}
.login-card .sub {
  margin: 8px 0 26px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
}
.login-card .hint {
  margin: 18px 0 0;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.65;
  text-align: center;
}
.login-error {
  min-height: 20px;
  color: var(--bad);
  font-size: 12.5px;
  margin: 10px 2px 0;
}

.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 2px 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.field {
  position: relative;
  display: flex;
  align-items: center;
}
.field input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fffdf8;
  padding: 0 46px 0 15px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(180, 83, 9, 0.12);
}
.field .eye {
  position: absolute;
  right: 6px;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  color: var(--muted-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 10px;
}
.field .eye svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  height: 48px;
  padding: 0 18px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  user-select: none;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn svg { width: 18px; height: 18px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-deep); }
.btn-dark { background: var(--ink); color: #fff7e8; }
.btn-dark:hover { background: #332d23; }
.btn-outline {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink-soft);
}
.btn-outline:hover { background: var(--card-soft); border-color: var(--muted-2); }
.btn-danger { background: var(--bad-soft); color: var(--bad); border-color: #eccdc4; }
.btn-danger:hover { background: #f3d9d2; }
.btn-soft { background: var(--accent-soft); color: var(--accent-deep); }
.btn-soft:hover { background: #f1ddb8; }
.btn-sm { height: 38px; border-radius: 11px; font-size: 13px; padding: 0 13px; }
.btn-sm svg { width: 15px; height: 15px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title svg { width: 17px; height: 17px; color: var(--muted); }
.card-sub { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- 设备列表 */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 4px 2px 18px;
}
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: 0.01em; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.device-list { display: grid; gap: 12px; }
.device-card {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.device-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.device-card:active { transform: scale(0.995); }
.device-icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  flex: none;
}
.device-icon svg { width: 23px; height: 23px; }
.device-main { flex: 1; min-width: 0; }
.device-name {
  font-size: 15.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.device-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.device-card .chev { color: var(--muted-2); flex: none; }
.device-card .chev svg { width: 18px; height: 18px; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}
.dot-online { background: var(--good); box-shadow: 0 0 0 3px rgba(21, 127, 61, 0.13); }
.dot-offline { background: var(--muted-2); box-shadow: 0 0 0 3px rgba(124, 114, 97, 0.12); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 25px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-neutral { background: var(--card-soft); color: var(--muted); border: 1px solid var(--line); }

/* ---------------------------------------------------------------- 详情 Hero */
.hero {
  padding: 22px;
  background:
    radial-gradient(620px 260px at 100% 0%, rgba(246, 231, 204, 0.6), transparent 62%),
    var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
}
.hero.is-locked {
  background:
    radial-gradient(620px 260px at 100% 0%, rgba(240, 210, 200, 0.55), transparent 62%),
    var(--card);
}
.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.hero h2 {
  margin: 14px 0 0;
  font-size: 27px;
  line-height: 1.25;
  letter-spacing: 0.01em;
}
.hero .reason {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}
.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}
.metric {
  background: rgba(255, 253, 248, 0.7);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 12px 11px;
  min-width: 0;
}
.metric span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.usage-block { margin-top: 18px; }
.usage-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.usage-bar {
  height: 9px;
  border-radius: 999px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  overflow: hidden;
}
.usage-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #d19a45, var(--accent));
  transition: width 0.5s ease;
  min-width: 0;
}
.usage-fill.is-full { background: linear-gradient(90deg, #cf7a62, var(--bad)); }

/* ---------------------------------------------------------------- 操作区 */
.actions-card { margin-top: 14px; }
.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.actions-grid .btn { width: 100%; }
.actions-grid .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.action-note {
  margin: 12px 2px 0;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.6;
}

/* ---------------------------------------------------------------- 规则 / 记录 */
.section { margin-top: 14px; }
.schedule-summary { display: grid; gap: 7px; }
.schedule-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
}
.schedule-row:last-child { border-bottom: none; }
.schedule-row .day {
  width: 44px;
  flex: none;
  color: var(--muted);
  font-size: 12.5px;
}
.schedule-row .times { color: var(--ink-soft); line-height: 1.7; }
.schedule-row .times .off { color: var(--muted-2); }
.quota-line {
  margin-top: 12px;
  padding: 11px 13px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.quota-line strong { color: var(--accent-deep); }

.recent-list { display: grid; gap: 4px; }
.recent-item {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 12.5px;
}
.recent-item:last-child { border-bottom: none; }
.recent-item .when { color: var(--muted-2); flex: none; font-variant-numeric: tabular-nums; }
.recent-item .what { color: var(--ink-soft); line-height: 1.55; }
.empty-note { color: var(--muted-2); font-size: 12.5px; padding: 8px 0; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.info-item {
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  min-width: 0;
}
.info-item span { display: block; font-size: 11.5px; color: var(--muted); }
.info-item strong {
  display: block;
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  word-break: break-all;
}
.lan-line {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.lan-line code {
  font-family: "Cascadia Mono", Consolas, monospace;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  color: var(--ink-soft);
  font-size: 12px;
}

/* ---------------------------------------------------------------- 空状态 */
.empty-card {
  padding: 40px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 22px;
  background: rgba(255, 252, 245, 0.55);
}
.empty-card .icon-wrap {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}
.empty-card .icon-wrap svg { width: 27px; height: 27px; }
.empty-card h3 { margin: 0 0 8px; font-size: 17px; }
.empty-card p { margin: 0 auto 18px; color: var(--muted); font-size: 13px; line-height: 1.7; max-width: 340px; }

/* ---------------------------------------------------------------- 弹层 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(33, 29, 22, 0.38);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  padding: 0;
  animation: fade-in 0.18s ease;
}
.modal {
  width: min(620px, 100%);
  max-height: 92dvh;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -20px 60px -30px rgba(33, 29, 22, 0.5);
  animation: sheet-up 0.22s cubic-bezier(0.22, 0.8, 0.3, 1);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body {
  padding: 18px 20px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-foot {
  display: flex;
  gap: 10px;
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  flex: none;
}
.modal-foot .btn { flex: 1; }
.modal-close {
  border: none;
  background: var(--card-soft);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.modal-close svg { width: 17px; height: 17px; }
@media (min-width: 720px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal {
    border-radius: 24px;
    border-bottom: 1px solid var(--line);
    max-height: 86dvh;
  }
}

/* ---------------------------------------------------------------- 规则编辑器 */
.sheet-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
}
.day-editor { display: grid; gap: 12px; }
.day-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: var(--card-soft);
}
.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.day-name { font-size: 13px; font-weight: 700; }
.window-rows { display: grid; gap: 7px; }
.window-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: 7px;
}
.window-row .dash { color: var(--muted-2); font-size: 12px; }
.time-input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fffdf8;
  padding: 0 8px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
.time-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.1); }
.remove-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.remove-btn:hover { background: var(--bad-soft); color: var(--bad); }
.remove-btn svg { width: 15px; height: 15px; }
.add-window {
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  height: 34px;
  border-radius: 9px;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  margin-top: 7px;
}
.add-window:hover { border-color: var(--accent); color: var(--accent-deep); background: rgba(246, 231, 204, 0.4); }
.quota-editor {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.quota-editor label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 8px; }
.quota-input-row { display: flex; align-items: center; gap: 9px; }
.quota-input-row input {
  width: 110px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 10px;
  font-size: 14px;
  background: #fffdf8;
  color: var(--ink);
  outline: none;
}
.quota-input-row span { color: var(--muted); font-size: 12px; }
.quota-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.quota-chips button {
  border: 1px solid var(--line);
  background: var(--card-soft);
  color: var(--muted);
  border-radius: 999px;
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
  cursor: pointer;
}
.quota-chips button:hover { border-color: var(--accent); color: var(--accent-deep); }

/* ---------------------------------------------------------------- 配对 */
.pair-code {
  margin: 6px auto 18px;
  width: max-content;
  max-width: 100%;
  padding: 16px 24px;
  border-radius: 16px;
  background: var(--accent-soft);
  border: 1px dashed #d9b982;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 34px;
  letter-spacing: 0.28em;
  font-weight: 700;
  color: var(--accent-deep);
  text-align: center;
  padding-right: calc(24px - 0.28em);
}
.pair-steps {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}
.pair-steps li::marker { color: var(--accent); }

/* ---------------------------------------------------------------- 杂项 */
.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}
.boot-mark {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff7e8;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: min(86vw, 480px);
  text-align: center;
  z-index: 60;
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); }

.fade-in { animation: fade-in 0.25s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(26px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .shell { padding-left: 14px; padding-right: 14px; }
  .hero { padding: 18px; border-radius: 20px; }
  .hero h2 { font-size: 23px; }
  .hero-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-metrics .metric:last-child { grid-column: span 2; }
  .actions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head h1 { font-size: 21px; }
  .pair-code { font-size: 30px; }
  .info-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
