@font-face {
  font-family: "WG Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: local("Segoe UI"), local("PingFang SC"), local("Hiragino Sans GB"), local("Microsoft YaHei"), local("Noto Sans SC");
}

@font-face {
  font-family: "WG Display";
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: local("Bahnschrift"), local("Segoe UI Semibold"), local("PingFang SC"), local("Microsoft YaHei");
}

:root {
  --bg: #e8eef2;
  --bg-2: #dfe7ec;
  --panel: rgba(248, 251, 252, 0.92);
  --panel-solid: #f5f8fa;
  --line: rgba(40, 70, 90, 0.1);
  --line-strong: rgba(40, 70, 90, 0.18);
  --text: #1a2b36;
  --muted: #5f7382;
  --accent: #0d9f8a;
  --accent-2: #0b8573;
  --accent-soft: rgba(13, 159, 138, 0.12);
  --danger: #d94a4a;
  --danger-soft: rgba(217, 74, 74, 0.1);
  --ok: #1a9f6a;
  --warn: #c48912;
  --shadow: 0 12px 40px rgba(30, 55, 70, 0.08);
  --shadow-sm: 0 4px 16px rgba(30, 55, 70, 0.06);
  --radius: 18px;
  --radius-sm: 12px;
  --pad: clamp(14px, 2.5vw, 28px);
  --topbar-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "WG Sans", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.bg-grid, .bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.bg-grid {
  background-image:
    linear-gradient(rgba(13, 159, 138, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 159, 138, 0.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 30%, black 15%, transparent 72%);
  animation: gridDrift 32s linear infinite;
}
.bg-glow {
  background:
    radial-gradient(900px 520px at 8% -10%, rgba(13, 159, 138, 0.16), transparent 55%),
    radial-gradient(720px 440px at 100% 0%, rgba(90, 140, 180, 0.14), transparent 50%),
    radial-gradient(640px 420px at 60% 110%, rgba(200, 170, 120, 0.1), transparent 55%);
  animation: glowPulse 12s ease-in-out infinite alternate;
}

@keyframes gridDrift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 44px 44px, 44px 44px; }
}
@keyframes glowPulse {
  from { opacity: 0.9; }
  to { opacity: 1; }
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#app { position: relative; z-index: 1; min-height: 100vh; }
.hidden { display: none !important; }
.muted, .hint, .sub { color: var(--muted); }
.hint, .sub { font-size: 0.86rem; margin: 4px 0 0; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 0.9rem; }
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.35);
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-family: "WG Display", sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(145deg, #2ec4a8, var(--accent) 48%, var(--accent-2));
  box-shadow: 0 10px 24px rgba(13, 159, 138, 0.28);
}
.brand-mark.sm { width: 40px; height: 40px; border-radius: 12px; font-size: 0.85rem; }

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--pad);
  gap: 22px;
  animation: riseIn 0.55s var(--ease) both;
}
.login-brand {
  text-align: center;
  display: grid;
  gap: 10px;
  justify-items: center;
}
.login-brand h1 {
  margin: 0;
  font-family: "WG Display", sans-serif;
  font-size: clamp(1.85rem, 4vw, 2.45rem);
  letter-spacing: -0.03em;
  color: var(--text);
}
.login-brand h1 span {
  display: block;
  font-size: 0.52em;
  font-weight: 650;
  color: var(--accent);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 6px;
}
.login-brand p { margin: 0; color: var(--muted); }
.login-form {
  width: min(400px, 100%);
  padding: 26px;
  border-radius: calc(var(--radius) + 2px);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  display: grid;
  gap: 14px;
}

/* App shell */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px var(--pad);
  background: rgba(232, 238, 242, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand-inline { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-inline strong {
  font-family: "WG Display", sans-serif;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.top-actions { display: flex; gap: 8px; flex-shrink: 0; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 14px var(--pad) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabs a {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: 0.2s var(--ease);
}
.tabs a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
}
.tabs a.active {
  color: var(--accent-2);
  background: #fff;
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.brand-inline {
  text-decoration: none;
  color: inherit;
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.quick-links .item-card {
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s var(--ease), box-shadow 0.2s;
}
.quick-links .item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.home-stats { margin-bottom: 4px; }

@media (max-width: 900px) {
  .quick-links { grid-template-columns: 1fr; }
}

main {
  flex: 1;
  padding: 18px var(--pad) 48px;
  animation: riseIn 0.4s var(--ease) both;
}
.tab-panel { display: grid; gap: 14px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-head.compact { align-items: center; }
.panel-head h2 {
  margin: 0;
  font-family: "WG Display", sans-serif;
  font-size: clamp(1.22rem, 2.4vw, 1.5rem);
  letter-spacing: -0.02em;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(120px, 0.7fr));
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--line);
}
.search-wrap { min-width: 0; }
.search-wrap input,
.toolbar select,
label input,
label select,
label textarea {
  width: 100%;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}
label span { font-weight: 650; color: #4a6070; }

input, select, textarea, button { font: inherit; }
input, select, textarea {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: #fbfcfd;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
}
input:hover, select:hover, textarea:hover { background: #fff; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #fff;
}
textarea { resize: vertical; min-height: 72px; }
input[readonly] {
  background: #eef3f6;
  color: var(--muted);
}

button {
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 650;
  transition: transform 0.15s var(--ease), filter 0.15s, box-shadow 0.2s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #1cbc9f, var(--accent) 42%, var(--accent-2));
  box-shadow: 0 8px 18px rgba(13, 159, 138, 0.22);
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-secondary {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: #f7fafb; }
.btn-ghost {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover {
  color: var(--text);
  background: rgba(255,255,255,0.65);
}
.btn-danger {
  color: #fff;
  background: linear-gradient(180deg, #e86a6a, var(--danger));
  box-shadow: 0 6px 14px rgba(217, 74, 74, 0.2);
}
.btn-danger:hover { filter: brightness(1.03); }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 0.84rem; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.92rem;
  vertical-align: middle;
}
th {
  position: sticky;
  top: 0;
  color: var(--muted);
  font-weight: 700;
  background: #f0f5f8;
  z-index: 1;
}
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: rgba(13, 159, 138, 0.05); }
.mono {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.88em;
}
.ops { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.badge.ok {
  color: var(--ok);
  background: rgba(26, 159, 106, 0.1);
  border-color: rgba(26, 159, 106, 0.18);
}
.badge.warn {
  color: #9a6a0a;
  background: rgba(196, 137, 18, 0.12);
  border-color: rgba(196, 137, 18, 0.2);
}
.badge.muted {
  color: var(--muted);
  background: rgba(95, 115, 130, 0.08);
  border-color: var(--line);
}

.card-list { display: grid; gap: 10px; }
.item-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-sm);
  padding: 15px;
  display: grid;
  gap: 10px;
  animation: riseIn 0.35s var(--ease) both;
}
.item-card .title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}
.item-card h3 { margin: 0; font-size: 1.02rem; }
.item-meta {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--muted);
}
.item-meta strong { color: var(--text); font-weight: 650; }

.system-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(236, 246, 244, 0.85));
  box-shadow: var(--shadow-sm);
}
.sys-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  gap: 6px;
  min-width: 0;
}
.stat span { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.stat strong {
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}
.sys-log {
  margin: 12px 0 0;
  max-height: 220px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #eef3f6;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 920px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-sm);
}
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; }

dialog {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  color: var(--text);
  padding: 0;
  width: min(460px, 94vw);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: rgba(40, 60, 75, 0.28);
  backdrop-filter: blur(5px);
}
.dialog-form { padding: 22px; margin: 0; display: grid; gap: 12px; }
.dialog-form h3 {
  margin: 0 0 4px;
  font-family: "WG Display", sans-serif;
  letter-spacing: -0.02em;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

#toast {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  z-index: 80;
  width: min(320px, calc(100vw - 24px));
}
.toast-item {
  background: #fff;
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: riseIn 0.25s var(--ease) both;
}
.toast-item.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.toast-item.err { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.desktop-only { display: block; }
.mobile-only { display: none; }

@media (max-width: 960px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-wrap { grid-column: 1 / -1; }
  .sys-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .desktop-only { display: none; }
  .mobile-only { display: grid; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .tabs { padding-top: 8px; }
  .panel-head { flex-direction: column; align-items: stretch; }
  .panel-head .btn-primary, .panel-head .btn-secondary { width: 100%; }
  .top-actions { width: 100%; }
  .top-actions button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
