/* 应用外壳与通用组件。四个端共享这一层：
   顶栏、按钮、卡片、表单、表格、弹层、提示、空状态。
   各端自己的排布在 views/*.css 里，不在这里加。 */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.boot {
  margin: auto; color: var(--muted); font-size: 15px; padding: 40px;
}

/* ── 顶栏 ── */
.topbar {
  background: var(--ink); color: var(--frame-text);
  border-bottom: 2px solid var(--clay);
  padding: 0 22px; min-height: 56px;
  display: flex; align-items: center; gap: 18px; flex: none;
  position: sticky; top: 0; z-index: 30;
}
.topbar .brand {
  color: #FBF6EC; font-size: 20px; font-weight: 700; letter-spacing: 3px;
  text-decoration: none; display: flex; align-items: baseline; gap: 10px;
}
.topbar .brand small { font-size: 12px; font-weight: 400; letter-spacing: 0; opacity: .55; }
.topbar .nav { display: flex; gap: 4px; }
.topbar .nav a {
  color: var(--frame-text); text-decoration: none; font-size: 14px;
  padding: 6px 12px; border-radius: 6px;
}
.topbar .nav a:hover { background: var(--frame-chip); color: #FFF8EF; }
.topbar .nav a[data-on="1"] { background: var(--paper); color: var(--ink); font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; opacity: .8; text-align: right; line-height: 1.3; }
.topbar .who b { color: #FBF6EC; font-size: 14px; font-weight: 600; }
.topbar .clock {
  font-variant-numeric: tabular-nums; background: var(--frame-chip);
  padding: 4px 10px; border-radius: 6px; font-size: 13px; color: var(--frame-text);
}
.topbar .tbtn {
  background: transparent; color: var(--frame-text); border: 1px solid var(--frame-line);
  padding: 5px 12px; border-radius: 6px; font-size: 13px;
}
.topbar .tbtn:hover { color: #FFF8EF; border-color: #A99B88; }

/* ── 通用排版 ── */
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wrap { width: min(1180px, 100%); margin: 0 auto; padding: 22px 20px 48px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: .5px; }
.page-head .sub { color: var(--muted); font-size: 14px; }
.page-head .right { margin-left: auto; display: flex; gap: 8px; }

.section { margin-bottom: 22px; }
.section > h2 {
  font-size: 15px; letter-spacing: 1px; color: var(--muted);
  margin: 0 0 10px; font-weight: 600; text-transform: none;
  display: flex; align-items: baseline; gap: 10px;
}
.section > h2 .hint { font-size: 13px; color: var(--faint); letter-spacing: 0; font-weight: 400; }

/* ── 按钮 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--clay); color: #FFF6EE; border: 1px solid var(--clay);
  border-radius: var(--radius-sm); padding: 9px 18px; font-size: 15px; line-height: 1.2;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:hover { background: var(--clay-deep); border-color: var(--clay-deep); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); background: var(--card); }
.btn.danger { background: var(--card); color: var(--red); border-color: #E9BEB6; }
.btn.danger:hover { background: var(--red-s); }
.btn.primary-ghost { background: transparent; color: var(--clay-deep); border-color: #D9BEAC; }
.btn.sm { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn.lg { padding: 13px 26px; font-size: 17px; }
.btn.block { width: 100%; }
.btn.link { background: none; border: 0; color: var(--blue); padding: 0; font-size: 14px; text-decoration: underline; }

/* ── 卡片 / 面板 ── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 2px 0 rgba(42,35,29,.02);
}
.card.pad { padding: 18px 20px; }
.card h3 { margin: 0 0 10px; font-size: 17px; }
.card h3 .sub { font-weight: 400; font-size: 13px; color: var(--muted); margin-left: 8px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

/* ── 状态标签 ── */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.7; white-space: nowrap;
  background: var(--line-2); color: var(--muted);
}
.pill.red { background: var(--red-s); color: var(--red); }
.pill.amber { background: var(--amber-s); color: var(--amber); }
.pill.green { background: var(--green-s); color: var(--green); }
.pill.blue { background: var(--blue-s); color: var(--blue); }
.pill.clay { background: var(--clay-soft); color: var(--clay-deep); }
.pill.lg { font-size: 14px; padding: 3px 12px; }

/* ── 表单 ── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 15px; outline: none; width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.field textarea { resize: vertical; min-height: 70px; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--clay); box-shadow: 0 0 0 3px rgba(158, 91, 55, .12);
}
.field .help { font-size: 12px; color: var(--faint); }
.field .err { font-size: 12px; color: var(--red); }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .form-row, .form-row.three { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ── 表格 ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px;
  letter-spacing: .5px; padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--paper-2); white-space: nowrap;
}
table.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: #FFFBF3; }
table.tbl td.actions { text-align: right; white-space: nowrap; }
table.tbl td.actions .btn { margin-left: 6px; }
table.tbl .muted { color: var(--muted); }
table.tbl .num { font-variant-numeric: tabular-nums; }

/* ── 提示 / 空状态 ── */
.empty {
  padding: 30px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius); background: rgba(255,253,248,.5);
}
.empty b { display: block; color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }
.note { font-size: 13px; color: var(--muted); }
.errline {
  background: var(--red-s); color: var(--red); border: 1px solid #E9BEB6;
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px;
}
.okline {
  background: var(--green-s); color: var(--green); border: 1px solid #B6D2C0;
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px;
}

/* ── 页签 ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 9px 14px; font-size: 15px; color: var(--muted); margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[data-on="1"] { color: var(--ink); border-bottom-color: var(--clay); font-weight: 600; }

/* ── 弹层 ── */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(42, 35, 29, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  animation: fade .12s ease-out;
}
.modal {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: min(86vh, 760px); display: flex; flex-direction: column;
  animation: rise .16s ease-out;
}
.modal.wide { width: min(820px, 100%); }
.modal header { padding: 18px 22px 10px; }
.modal header h3 { margin: 0; font-size: 19px; }
.modal header .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.modal .body { padding: 4px 22px 8px; overflow: auto; }
.modal footer { padding: 14px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { transform: translateY(8px); opacity: .4 } to { transform: none; opacity: 1 } }

/* ── Toast ── */
.toasts { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--ink); color: #FBF6EC; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); animation: rise .16s ease-out; max-width: 90vw;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* ── 登录 / 初始化 ── */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 28px 18px;
  background:
    radial-gradient(900px 500px at 15% -10%, #FFF7E8 0%, transparent 60%),
    radial-gradient(700px 400px at 110% 110%, #F0E4D2 0%, transparent 60%),
    var(--page);
}
.auth-card {
  width: min(460px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow-lg); padding: 30px 30px 26px;
}
.auth-card.wide { width: min(640px, 100%); }
.auth-brand { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.auth-brand b { font-size: 26px; letter-spacing: 4px; }
.auth-brand span { color: var(--muted); font-size: 13px; }
.auth-lead { color: var(--muted); font-size: 14px; margin: 6px 0 22px; }
.auth-alt { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.auth-alt a { color: var(--blue); text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

/* 登录卡片底部的说明：第一次部署从这里去初始化 */
.auth-foot { margin-top: 18px; font-size: 12px; color: var(--faint); text-align: center; }

/* ── 演示账号（仅 DEMO_MODE）── */
.demo-box { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.demo-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.demo-head b { font-size: 13px; color: var(--ink-2); }
.demo-list { display: grid; gap: 6px; }
.demo-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 11px; font-size: 14px;
}
.demo-btn:hover { border-color: var(--clay); background: var(--card); }
.demo-btn:disabled { opacity: .6; cursor: default; }
.demo-btn b { display: block; font-size: 14px; font-weight: 600; }
.demo-btn small { display: block; color: var(--faint); font-size: 12px; margin-top: 1px; }
.demo-go { color: var(--clay-deep); font-size: 13px; white-space: nowrap; }
.demo-note { margin: 8px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--faint); }

/* ── 通用小件 ── */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 8px; font-size: 13px; user-select: all;
}
.copyline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
