:root {
  --canvas: #f3f2ed;
  --surface: #fffdf9;
  --surface-2: #f8f7f2;
  --ink: #1d2420;
  --muted: #727a74;
  --line: #e4e1d8;
  --line-strong: #cfccc2;
  --accent: #2e5b4e;
  --accent-hover: #24493f;
  --accent-soft: #e7efe9;
  --danger: #9c3d2e;
  --danger-soft: #f7e9e5;
  --warn: #8a5b20;
  --warn-soft: #f6eddc;
  --ok: #2d6a4d;
  --ok-soft: #e4efe7;
  --radius: 10px;
  --font: "Segoe UI", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .token-value { font-family: var(--mono); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 238px;
  flex: 0 0 238px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 10px 22px;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #f4f7f4;
  border-radius: 9px;
  flex: 0 0 38px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; letter-spacing: 0.01em; }
.brand-text small { color: var(--muted); font-size: 11px; margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group {
  color: #9ba29d;
  font-size: 10px;
  letter-spacing: 0.14em;
  padding: 18px 12px 7px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 7px;
  color: #49514c;
  font-size: 13.5px;
  line-height: 1.2;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .icon { flex: 0 0 auto; opacity: 0.9; }

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 15px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-name { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.foot-actions { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 12px; }
.foot-actions a, .link-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-size: 12px;
}
.foot-actions a:hover, .link-button:hover { color: var(--ink); text-decoration: none; }
.foot-actions form { display: inline; }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
  max-width: 1480px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.topbar h1 { font-size: 23px; line-height: 1.25; }
.page-sub { color: var(--muted); font-size: 12.5px; margin-top: 5px; min-height: 20px; }
.topbar-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 20px;
  padding: 5px 12px;
  white-space: nowrap;
}

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: #a9afa9; }
.dot.ok { background: #4c8a68; box-shadow: 0 0 0 3px rgba(76, 138, 104, 0.12); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.card-head h2 { font-size: 15.5px; }
.card-head p { color: var(--muted); font-size: 12px; margin-top: 3px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.alert {
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.alert.success { background: var(--ok-soft); border-color: #c9dfd1; color: #245640; }
.alert.danger { background: var(--danger-soft); border-color: #ebcfc7; color: #793126; }
.alert.warning { background: var(--warn-soft); border-color: #ead9b8; color: #6d4818; }
.alert.info { background: var(--surface-2); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 18px 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label { color: var(--muted); font-size: 11.5px; letter-spacing: 0.03em; }
.stat-value { font-size: 27px; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-note { color: #8a918c; font-size: 11px; }

.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: start;
}
.grid-main > .card { margin-bottom: 18px; }
.memories-grid { grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.5fr); }

.chart-card { overflow: hidden; }
.chart { width: 100%; height: auto; display: block; margin-top: 4px; }
.chart-grid { stroke: #e8e5dd; stroke-width: 1; }
.chart-axis { fill: #8a918c; font-size: 10px; font-family: var(--font); }
.chart-bar { fill: #b9ccc2; }
.chart-bar.is-today { fill: var(--accent); }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.legend-bar { width: 9px; height: 9px; border-radius: 2px; background: var(--accent); display: inline-block; }

.status-list, .meta-list { list-style: none; margin: 0; padding: 0; }
.status-list li, .meta-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.status-list li:last-child, .meta-list li:last-child { border-bottom: 0; }
.status-list li > span:first-child, .meta-list li > span:first-child { color: var(--muted); }
.status-list strong, .meta-list strong { font-weight: 600; text-align: right; }
.status-card .btn { margin-top: 10px; }

.text-link { color: var(--accent); font-size: 12.5px; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  color: #858c87;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfaf6; }
.table .right { text-align: right; }
.clamp {
  max-width: 340px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: #3e4641;
}
.wrap-anywhere { word-break: break-word; max-width: 720px; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11px;
  line-height: 1.7;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #cfe2d6; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: #ecd1ca; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #e9d7b5; }
.badge.neutral { background: var(--surface-2); color: #68716b; border-color: var(--line); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 13px;
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #f8fbf9; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.secondary { border-color: var(--line-strong); background: var(--surface); color: #37413b; }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { border-color: #e3c3bb; background: var(--danger-soft); color: var(--danger); }
.btn.danger:hover { background: #f3dcd6; }
.btn.tiny { padding: 4px 8px; font-size: 11.5px; border-radius: 6px; }
.btn.block { width: 100%; margin-top: 4px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.inline-action { display: inline-flex; align-items: center; gap: 5px; margin-left: 4px; }
.inline-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
.inline-form .grow { flex: 1 1 220px; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.field > span { font-size: 12px; color: #4e5752; font-weight: 600; }
.field small, .field .checkline { color: var(--muted); font-size: 11.5px; }
.field > input, .field > textarea, .field > select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fffefa;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field > input { min-height: 40px; }
.field > textarea { resize: vertical; line-height: 1.65; }
.field > input:focus, .field > textarea:focus, .field > select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 91, 78, 0.12);
}
.checkbox-field { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-field input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }
.checkline { display: inline-flex; align-items: center; gap: 6px; }
.checkline.compact { font-size: 11px; white-space: nowrap; }
.checkline input[type="checkbox"] { accent-color: var(--accent); }
.form-card { padding: 22px; }
.form-card.flat { padding: 0; border: 0; background: transparent; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.sticky-actions {
  position: sticky;
  bottom: 0;
  margin: 0 -4px;
  padding: 14px 4px;
  background: var(--canvas);
  border-top: 1px solid var(--line);
  z-index: 2;
}
.narrow-card { max-width: 560px; }
.settings-form > .card { margin-bottom: 16px; }

.search-form { flex: 1; min-width: 0; }
.search { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-icon { color: var(--muted); margin-right: -26px; padding-left: 9px; position: relative; z-index: 1; display: inline-flex; }
.search input[type="search"] {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fffefa;
  padding: 6px 10px 6px 31px;
  min-width: 220px;
  outline: none;
}
.search select {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fffefa;
  padding: 6px 9px;
  outline: none;
}
.search input:focus, .search select:focus { border-color: var(--accent); }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 18px 0 2px; }
.pager-link { font-size: 12px; color: var(--accent); }
.pager-link.disabled { color: #a8aea9; }
.pager-info { color: var(--muted); font-size: 11.5px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state.compact { padding: 20px; }
.empty-state p { margin-bottom: 12px; }
.empty-state .icon { color: #a9b2ab; margin-bottom: 8px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-top: 1px solid var(--line); padding: 12px 0; }
.timeline li:first-child { border-top: 0; padding-top: 0; }
.timeline-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.timeline p { font-size: 12.5px; color: #3e4641; word-break: break-word; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 8px; margin-bottom: 16px; font-size: 12.5px; }
.notice.warning { background: var(--warn-soft); color: #6d4818; border: 1px solid #ead9b8; }
.notice.danger { background: var(--danger-soft); color: #793126; border: 1px solid #ebcfc7; }
.notice .icon { flex: 0 0 auto; margin-top: 1px; }

.token-card { max-width: 760px; }
.token-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.token-value {
  display: block;
  background: #1f2a25;
  color: #e9f2ec;
  border-radius: 8px;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-all;
  user-select: all;
  margin-bottom: 14px;
}

.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-list li { border-bottom: 1px solid var(--line); }
.contact-list li:last-child { border-bottom: 0; }
.contact-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 8px;
  color: var(--ink);
  border-radius: 6px;
}
.contact-list a:hover { background: var(--surface-2); text-decoration: none; }
.contact-list li.is-active a { background: var(--accent-soft); }
.contact-main { display: flex; flex-direction: column; min-width: 0; }
.contact-main strong { font-size: 13px; font-weight: 600; }
.subhead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; margin-bottom: 10px; }
.subhead h3 { font-size: 13px; }

.transcript { list-style: none; margin: 0; padding: 0; }
.transcript li { padding: 11px 0; border-top: 1px solid var(--line); }
.transcript li:first-child { border-top: 0; }
.transcript-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.transcript p { font-size: 12.5px; margin: 3px 0; word-break: break-word; }
.transcript p strong { display: inline-block; width: 36px; color: var(--muted); font-weight: 500; font-size: 11px; }

.message-block { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 12px; background: var(--surface-2); }
.message-block.reply { background: var(--accent-soft); border-color: #d3e2d9; }
.message-label { color: var(--muted); font-size: 11px; letter-spacing: 0.05em; }
.message-text { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; margin-top: 5px; }

.guide-card h3 { font-size: 12px; margin: 16px 0 7px; color: #4e5752; }
.code-block {
  background: #f1f0ea;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 14px;
  font-size: 11.5px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

.auth-shell { background: #f0efe9; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px;
}
.auth-head { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.auth-head h1 { font-size: 20px; }
.auth-head p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.auth-form .field { margin-bottom: 14px; }
.footnote { color: var(--muted); font-size: 11px; margin-top: 18px; line-height: 1.6; }
.footnote code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.error-card { text-align: center; }
.error-code { font-size: 54px; font-weight: 600; color: var(--accent); line-height: 1.1; margin-bottom: 8px; }
.error-card h1 { font-size: 17px; margin-bottom: 18px; }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .memories-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 14px 10px;
  }
  .brand { padding-bottom: 12px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .nav-group { display: none; }
  .nav-item { white-space: nowrap; padding: 8px 10px; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 16px 50px; }
  .topbar { margin-bottom: 18px; }
  .topbar-state { display: none; }
  .form-grid.two { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 620px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 23px; }
  .card { padding: 16px; }
  .card-head { flex-direction: column; }
  .inline-form { align-items: stretch; }
  .inline-form .btn { align-self: flex-start; }
  .search input[type="search"] { min-width: 0; width: 100%; }
  .search { width: 100%; }
  .clamp { max-width: 220px; }
}
