:root {
  --ink: #172521;
  --muted: #68736e;
  --paper: #f4f0e6;
  --paper-deep: #e8e1d2;
  --card: rgba(255, 253, 247, 0.91);
  --line: rgba(23, 37, 33, 0.13);
  --forest: #174e3b;
  --forest-bright: #236d52;
  --moss: #8aa66e;
  --amber: #d69b3d;
  --danger: #a84436;
  --shadow: 0 24px 70px rgba(42, 50, 42, 0.12);
  --radius: 26px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: clip; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 6%, rgba(138, 166, 110, 0.24), transparent 29rem),
    radial-gradient(circle at 4% 36%, rgba(214, 155, 61, 0.13), transparent 26rem),
    linear-gradient(135deg, var(--paper), #f9f6ef 55%, var(--paper-deep));
  font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(23, 37, 33, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 37, 33, 0.06) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid rgba(214, 155, 61, 0.55);
  outline-offset: 3px;
}

.page-shell {
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 34px;
  position: relative;
}

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  margin-bottom: 34px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 39px;
  height: 39px;
  border-radius: 50% 50% 46% 54%;
  background: var(--forest);
  display: grid;
  place-items: center;
  transform: rotate(-8deg);
  box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.1);
}

.brand-mark span {
  width: 8px;
  height: 16px;
  border-radius: 50% 0 50% 50%;
  background: #e9d38a;
  transform: rotate(30deg);
}

.brand strong {
  display: block;
  font: 700 21px/1 "Songti SC", "Noto Serif CJK SC", serif;
  letter-spacing: 0.08em;
}

.brand small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; letter-spacing: 0.12em; }

.text-button, .small-button, .icon-button, .primary-button, .secondary-button {
  border: 0;
  cursor: pointer;
}

.text-button { background: transparent; color: var(--muted); padding: 10px 4px; }
.text-button:hover { color: var(--forest); }

.hero {
  min-height: 315px;
  padding: clamp(34px, 6vw, 72px);
  border-radius: 36px 36px 110px 36px;
  color: #f5f1e8;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.055), transparent 50%),
    var(--forest);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 40px;
  position: relative;
  overflow: hidden;
}

.hero > div:first-child,
.dashboard-grid > *,
.side-stack {
  min-width: 0;
}

.hero::after {
  content: "守";
  position: absolute;
  right: 15%;
  bottom: -76px;
  font: 700 240px/1 "STKaiti", "KaiTi", serif;
  color: rgba(255, 255, 255, 0.035);
  transform: rotate(-7deg);
}

.eyebrow, .section-kicker {
  margin: 0 0 14px;
  color: var(--amber);
  font: 700 11px/1.3 ui-monospace, "Cascadia Mono", monospace;
  letter-spacing: 0.18em;
}

.hero h1 {
  margin: 0;
  max-width: 720px;
  font: 650 clamp(36px, 5.2vw, 68px)/1.14 "Songti SC", "Noto Serif CJK SC", serif;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.hero h1 em { color: #dbe7c9; font-style: normal; }
.hero-copy { max-width: 620px; margin: 24px 0 0; color: rgba(255, 255, 255, 0.7); line-height: 1.8; }

.watch-seal {
  flex: 0 0 158px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.watch-seal::before, .watch-seal::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: inherit;
  border: 1px dashed rgba(255, 255, 255, 0.2);
}

.watch-seal::after { inset: -8px; border-style: solid; border-color: rgba(138, 166, 110, 0.35); }
.watch-seal strong { margin-top: 10px; font: 650 18px "Songti SC", serif; }
.watch-seal small { margin-top: 5px; color: rgba(255, 255, 255, 0.56); }

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b8db89;
  box-shadow: 0 0 0 0 rgba(184, 219, 137, 0.55);
  animation: pulse 2.2s infinite;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 16px 0 36px;
}

.stat-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.68);
  padding: 25px 28px;
  border-radius: 20px;
  min-height: 158px;
  position: relative;
  box-shadow: 0 13px 34px rgba(42, 50, 42, 0.07);
}

.stat-card::after {
  content: "";
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 17px;
  height: 3px;
  background: linear-gradient(90deg, var(--moss) 36%, var(--line) 36%);
}

.stat-card strong { font: 700 43px/1 ui-monospace, "Cascadia Mono", monospace; color: var(--forest); }
.stat-card sup { font-size: 14px; margin-left: 3px; }
.stat-card p { margin: 9px 0 2px; font-weight: 700; }
.stat-card small { color: var(--muted); }
.stat-index { position: absolute; right: 22px; top: 22px; color: #9ca49e; font: 11px ui-monospace, monospace; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr); gap: 18px; align-items: start; }
.side-stack { display: grid; gap: 18px; }

.panel {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius);
  box-shadow: 0 18px 46px rgba(42, 50, 42, 0.08);
  padding: 30px;
  backdrop-filter: blur(18px);
}

.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-heading h2, .dialog-heading h2 { margin: 0; font: 700 28px/1.2 "Songti SC", "Noto Serif CJK SC", serif; }
.compact-heading h2 { font-size: 24px; }
.section-kicker { color: var(--forest-bright); margin-bottom: 7px; }
.panel-intro { color: var(--muted); line-height: 1.65; margin: 15px 0 24px; font-size: 13px; }

.primary-button, .secondary-button {
  min-height: 43px;
  padding: 0 18px;
  border-radius: 13px;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button { color: white; background: var(--forest); box-shadow: 0 9px 22px rgba(23, 78, 59, 0.2); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-2px); }
.primary-button:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }
.secondary-button { color: var(--forest); background: #e4ead9; }
.full-button { width: 100%; }
.link-button { display: inline-flex; align-items: center; text-decoration: none; }

.user-list { border-top: 1px solid var(--line); }
.user-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.user-number { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: var(--forest); background: #e9ecdf; font: 700 12px ui-monospace, monospace; }
.name-line { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.name-line h3 { margin: 0; font-size: 17px; }
.status-chip { border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 700; }
.status-active { color: #246344; background: #dcebd7; }
.status-paused { color: #68716d; background: #e6e7e3; }
.status-warning { color: #80551b; background: #f5e5bf; }
.credential-flags { display: flex; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.credential-flag { color: #8b8f8c; background: #eeece5; padding: 4px 8px; border-radius: 7px; font-size: 11px; }
.credential-flag.is-set { color: var(--forest-bright); background: #e4ecdd; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.small-button { color: var(--forest); background: transparent; padding: 7px 8px; border-radius: 8px; font-size: 12px; }
.small-button:hover { background: #e7ebdf; }
.danger-button { color: var(--danger); }
.danger-button:hover { background: #f5e3df; }

.count-badge { display: grid; place-items: center; min-width: 42px; height: 42px; border-radius: 50%; color: #f9f6ef; background: var(--forest); font: 700 16px ui-monospace, monospace; }
.upload-form { margin-top: 22px; }
.drop-zone { min-height: 150px; border: 1px dashed rgba(23, 78, 59, 0.35); border-radius: 18px; background: rgba(232, 237, 221, 0.7); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; cursor: pointer; margin-bottom: 10px; transition: border-color 160ms ease, background 160ms ease; }
.drop-zone:hover { border-color: var(--forest); background: #e4ead9; }
.drop-zone input { position: absolute; opacity: 0; pointer-events: none; }
.upload-glyph { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 9px; color: white; background: var(--forest); font-size: 23px; }
.drop-zone strong { font-size: 14px; }
.drop-zone small { color: var(--muted); margin-top: 5px; font-size: 11px; }
.photo-list { margin-top: 20px; max-height: 310px; overflow: auto; padding-right: 4px; }
.photo-item { display: grid; grid-template-columns: 27px minmax(0, 1fr) 32px; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.photo-swatch { width: 24px; height: 30px; border-radius: 4px 11px 4px 4px; background: linear-gradient(145deg, #4f715d, #d6b267); }
.photo-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 11px ui-monospace, monospace; }
.photo-item small { display: block; color: var(--muted); margin-top: 3px; font-size: 10px; }
.icon-button { width: 32px; height: 32px; border-radius: 50%; color: var(--muted); background: transparent; font-size: 19px; }
.icon-button:hover { color: var(--danger); background: #f5e3df; }
.refresh-button:hover { color: var(--forest); background: #e7ebdf; }

.activity-list { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 14px; }
.activity-list li { display: grid; grid-template-columns: 9px 1fr; gap: 11px; }
.activity-dot { width: 7px; height: 7px; margin-top: 7px; border-radius: 50%; background: var(--moss); }
.level-error, .level-critical { background: var(--danger); }
.level-warning { background: var(--amber); }
.activity-list p { margin: 0; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.activity-list time { color: #949a96; font: 10px ui-monospace, monospace; }
.empty-inline { color: var(--muted); background: rgba(236, 233, 224, 0.8); border-radius: 14px; padding: 16px; font-size: 12px; line-height: 1.6; }

.empty-state { min-height: 230px; display: flex; flex-direction: column; justify-content: center; align-items: center; color: var(--muted); }
.empty-state > span { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; color: var(--forest); background: #e4ead9; font-size: 28px; }
.empty-state h3 { margin: 16px 0 4px; color: var(--ink); }
.empty-state p { margin: 0; font-size: 13px; }

.flash-stack { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100; width: min(540px, calc(100% - 32px)); display: grid; gap: 8px; }
.flash { display: grid; grid-template-columns: 10px 1fr; gap: 11px; align-items: start; padding: 14px 16px; border-radius: 14px; color: #f9f6ef; background: #243b34; box-shadow: 0 16px 42px rgba(0, 0, 0, 0.22); }
.flash > span { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: #a9ce7d; }
.flash p { margin: 0; font-size: 13px; line-height: 1.55; }
.flash-error { background: #703b35; }
.flash-error > span { background: #ffc0a8; }

.admin-dialog { width: min(560px, calc(100% - 28px)); border: 0; border-radius: 28px; color: var(--ink); background: #fbf8f0; padding: 0; box-shadow: 0 34px 100px rgba(18, 32, 27, 0.32); }
.admin-dialog::backdrop { background: rgba(12, 27, 22, 0.68); backdrop-filter: blur(7px); }
.dialog-form { padding: 30px; display: grid; gap: 10px; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 10px; }
.dialog-form > label, .stack-form > label { font-size: 12px; font-weight: 700; margin-top: 6px; }
.dialog-form label span { color: var(--muted); font-weight: 400; }
.dialog-form > input, .secret-field input, .stack-form > input {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(23, 37, 33, 0.18);
  border-radius: 12px;
  color: var(--ink);
  background: #fffefa;
  padding: 0 13px;
}
.dialog-form input::placeholder, .stack-form input::placeholder { color: #a7aaa6; }
.secret-field { position: relative; }
.secret-field input { padding-right: 66px; }
.reveal-secret { position: absolute; right: 7px; top: 6px; bottom: 6px; border: 0; border-radius: 8px; padding: 0 10px; color: var(--forest); background: #e8ecdf; cursor: pointer; font-size: 11px; }
.check-line { display: flex; gap: 9px; align-items: center; cursor: pointer; padding: 7px 0; }
.check-line input { width: 17px; height: 17px; accent-color: var(--forest); }
.subtle-check { color: var(--muted); font-weight: 400 !important; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 19px; }

.login-stage { min-height: calc(100vh - 180px); display: grid; place-items: center; position: relative; }
.login-card { width: min(470px, 100%); position: relative; z-index: 1; padding: clamp(30px, 6vw, 54px); border-radius: 34px 34px 82px 34px; background: var(--card); box-shadow: var(--shadow); border: 1px solid rgba(255, 255, 255, 0.8); }
.login-card h1, .error-stage h1 { margin: 0; font: 700 clamp(34px, 6vw, 52px)/1.1 "Songti SC", "Noto Serif CJK SC", serif; }
.login-copy { color: var(--muted); line-height: 1.8; margin: 17px 0 28px; }
.stack-form { display: grid; gap: 11px; }
.quiet-line { display: flex; align-items: center; gap: 9px; color: #8c918d; font-size: 11px; margin-top: 20px; }
.quiet-line span { width: 22px; height: 1px; background: var(--amber); }
.login-orbit { position: absolute; width: min(690px, 95vw); aspect-ratio: 1; border: 1px solid rgba(23, 78, 59, 0.1); border-radius: 50%; animation: orbit 36s linear infinite; }
.login-orbit::before, .login-orbit::after { content: ""; position: absolute; inset: 12%; border: inherit; border-radius: inherit; }
.login-orbit::after { inset: 30%; }
.login-orbit span { position: absolute; width: 13px; height: 13px; border-radius: 50%; background: var(--forest); }
.login-orbit span:nth-child(1) { top: 7%; left: 28%; }
.login-orbit span:nth-child(2) { bottom: 17%; right: 12%; background: var(--amber); }
.login-orbit span:nth-child(3) { top: 50%; left: -6px; background: var(--moss); }

.error-stage { margin: 10vh auto; max-width: 720px; padding: 60px; border-radius: 34px; background: var(--card); box-shadow: var(--shadow); }
.error-stage p:not(.eyebrow) { color: var(--muted); line-height: 1.8; margin: 20px 0 28px; }
.footer-note { text-align: center; color: #89908b; font-size: 11px; margin-top: 30px; letter-spacing: 0.08em; }

.reveal-card { animation: reveal 500ms cubic-bezier(.2,.8,.2,1) both; }
.delay-1 { animation-delay: 60ms; }
.delay-2 { animation-delay: 120ms; }
.delay-3 { animation-delay: 180ms; }
.delay-4 { animation-delay: 240ms; }

@keyframes reveal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 70% { box-shadow: 0 0 0 14px rgba(184, 219, 137, 0); } 100% { box-shadow: 0 0 0 0 rgba(184, 219, 137, 0); } }
@keyframes orbit { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .hero { border-radius: 30px 30px 76px 30px; }
  .watch-seal { flex-basis: 132px; }
}

@media (max-width: 680px) {
  .page-shell { width: calc(100% - 24px); max-width: 1220px; padding-top: 10px; }
  .topbar { margin-bottom: 18px; }
  .brand small { display: none; }
  .hero { padding: 34px 26px 52px; min-height: auto; align-items: flex-start; }
  .hero h1 { font-size: clamp(30px, 9vw, 42px); word-break: break-all; }
  .hero-copy { overflow-wrap: anywhere; }
  .watch-seal { display: none; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 136px; }
  .panel { padding: 22px 18px; border-radius: 21px; }
  .panel-heading { align-items: flex-start; }
  .user-row { grid-template-columns: 38px 1fr; }
  .row-actions { grid-column: 2; justify-content: flex-start; }
  .admin-dialog { border-radius: 22px; }
  .dialog-form { padding: 23px 18px; }
  .login-stage { min-height: calc(100vh - 130px); }
  .login-card { border-radius: 26px 26px 60px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
