:root {
  color-scheme: light;
  --bg: #eeeee8;
  --surface: #f9f8f3;
  --surface-strong: #ffffff;
  --ink: #1d2420;
  --muted: #68716b;
  --line: #d8dcd5;
  --line-strong: #c5cbc3;
  --accent: #2f6f58;
  --accent-dark: #245845;
  --accent-soft: #e2eee8;
  --danger: #9b433d;
  --danger-soft: #f5e8e6;
  --warn: #8d641f;
  --warn-soft: #f4eddd;
  --shadow: 0 28px 80px -52px rgba(28, 52, 41, .58);
  font-family: "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); }
body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 12% 8%, rgba(47, 111, 88, .12), transparent 27rem),
    radial-gradient(circle at 92% 82%, rgba(113, 127, 106, .11), transparent 32rem),
    repeating-linear-gradient(90deg, rgba(32, 44, 37, .018) 0 1px, transparent 1px 7px);
  content: "";
  pointer-events: none;
}
button, input { font: inherit; }
button { transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, opacity 180ms ease; }
button:not(:disabled) { cursor: pointer; }
button:not(:disabled):hover { transform: translateY(-1px); }
button:not(:disabled):active { transform: translateY(1px) scale(.99); }
button:disabled { cursor: wait; opacity: .66; }
input { transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease; }
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(47, 111, 88, .22);
  outline-offset: 2px;
}
a { color: inherit; }
.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }
.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font: 700 .68rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1, h2 { text-wrap: balance; }
p { color: var(--muted); line-height: 1.65; }
.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px 13px 13px 5px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 13px 26px -17px rgba(47, 111, 88, .95);
  font: 800 1rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* Login */
.login-page { min-height: 100dvh; }
.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 460px);
  width: min(1120px, calc(100% - 48px));
  min-height: 100dvh;
  margin: 0 auto;
  align-items: center;
  gap: clamp(52px, 9vw, 136px);
  padding: 64px 0 78px;
}
.login-intro { max-width: 590px; padding-bottom: 8vh; }
.login-intro .brand-mark { width: 48px; height: 48px; margin-bottom: 42px; }
.login-intro h1 {
  max-width: 12ch;
  margin-bottom: 24px;
  font-size: clamp(2.9rem, 5.9vw, 5.3rem);
  line-height: .98;
  letter-spacing: -.068em;
}
.intro-copy { max-width: 55ch; margin-bottom: 34px; font-size: 1rem; }
.security-list { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border-top: 1px solid var(--line-strong); }
.security-list div { padding: 17px 12px 0 0; }
.security-list dt { color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.security-list dd { margin: 6px 0 0; font: 650 .76rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
.login-card {
  padding: 34px 34px 28px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 28px 28px 28px 10px;
  background: rgba(249, 248, 243, .9);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .9);
  backdrop-filter: blur(18px);
}
.login-card header { margin-bottom: 29px; }
.login-card h2 { margin-bottom: 7px; font-size: 2rem; letter-spacing: -.045em; }
.login-card header p:not(.eyebrow), .login-card footer { margin-bottom: 0; font-size: .78rem; }
.login-card form { display: grid; }
.login-card label { margin: 0 0 7px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.login-card input {
  width: 100%;
  min-height: 48px;
  margin-bottom: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: rgba(255, 255, 255, .82);
  padding: 0 14px;
  color: var(--ink);
  outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(47, 111, 88, .1); background: white; }
.password-field { position: relative; }
.password-field input { padding-right: 68px; }
.password-field .text-button { position: absolute; top: 8px; right: 8px; min-height: 32px; }
.primary-button, .secondary-button, .compact-button, .text-button {
  border-radius: 11px;
  font-weight: 700;
}
.primary-button {
  min-height: 44px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  box-shadow: 0 12px 24px -18px rgba(47, 111, 88, .9);
}
.primary-button:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.secondary-button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .58);
  color: var(--ink);
  padding: 0 14px;
}
.secondary-button:hover:not(:disabled) { border-color: #abb4ac; background: white; }
.text-button { min-height: 34px; border: 0; background: transparent; color: var(--accent); padding: 0 9px; }
.login-card .primary-button { position: relative; width: 100%; min-height: 48px; margin-top: 5px; }
.button-progress {
  position: absolute;
  top: 50%;
  right: 16px;
  width: 13px;
  height: 13px;
  margin-top: -7px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: white;
  border-radius: 50%;
  opacity: 0;
  animation: spin .7s linear infinite;
}
.is-loading .button-progress { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.form-message { min-height: 22px; margin: 10px 0 0; color: var(--danger); font-size: .8rem; }
.login-card footer { margin-top: 15px; padding-top: 17px; border-top: 1px solid var(--line); }

/* Dashboard */
.dashboard-page { min-height: 100dvh; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(197, 203, 195, .78);
  background: rgba(238, 238, 232, .88);
  backdrop-filter: blur(18px);
}
.app-header-inner { display: flex; width: min(1440px, calc(100% - 48px)); min-height: 72px; margin: 0 auto; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand strong { display: block; font-size: .92rem; letter-spacing: -.015em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font: 600 .62rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em; }
.app-header nav { display: flex; align-items: center; gap: 11px; }
.online-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .74rem; font-weight: 650; }
.online-state i { width: 7px; height: 7px; border-radius: 50%; background: #46936f; box-shadow: 0 0 0 4px rgba(70, 147, 111, .12); }
.admin-identity { padding: 0 8px; font-size: .78rem; font-weight: 700; }
.app-shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 54px 0 86px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin-bottom: 8px; font-size: clamp(2.2rem, 4vw, 3.8rem); line-height: 1; letter-spacing: -.065em; }
.page-heading p:last-child { max-width: 58ch; margin-bottom: 0; font-size: .9rem; }
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { min-height: 122px; padding: 17px 17px 18px; border-radius: 18px 18px 18px 7px; background: rgba(249, 248, 243, .82); box-shadow: inset 0 0 0 1px rgba(197, 203, 195, .65); }
.stat span { color: var(--muted); font-size: .71rem; font-weight: 650; }
.stat strong { display: block; margin: 13px 0 8px; font: 780 1.75rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.stat small { color: #879088; font-size: .66rem; }
.skeleton { background: linear-gradient(105deg, rgba(249,248,243,.75) 25%, rgba(255,255,255,.94) 42%, rgba(249,248,243,.75) 60%); background-size: 240% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -220% 0; } }
.panel { margin-top: 18px; padding: 22px; border-radius: 22px 22px 22px 8px; background: rgba(249, 248, 243, .87); box-shadow: var(--shadow), inset 0 0 0 1px rgba(197, 203, 195, .66); }
.panel-heading, .section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 17px; }
.panel-heading.compact { margin-bottom: 13px; }
.panel h2 { margin-bottom: 5px; font-size: 1.22rem; letter-spacing: -.035em; }
.panel-heading p, .section-head p { max-width: 52ch; margin-bottom: 0; font-size: .77rem; }
.create-panel { display: grid; grid-template-columns: minmax(190px, .44fr) minmax(0, 1.56fr); gap: 28px; align-items: end; }
.create-panel .panel-heading { display: block; margin-bottom: 0; align-self: center; }
.create-grid { display: grid; grid-template-columns: 1.15fr .9fr 90px 1.2fr auto; gap: 10px; align-items: end; }
.create-grid label, .search-field, .inline-editor label { display: grid; gap: 6px; color: var(--muted); font-size: .7rem; font-weight: 700; }
.create-grid input, .search-field input, .inline-editor input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255,255,255,.78);
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}
.create-grid input:focus, .search-field input:focus, .inline-editor input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,111,88,.1); background: white; }
.create-actions { display: flex; gap: 8px; white-space: nowrap; }
.search-field { width: min(360px, 42vw); }
.inline-editor { display: grid; grid-template-columns: minmax(240px, 1fr) auto auto; gap: 9px; align-items: end; margin: -2px 0 14px; padding: 13px; border-radius: 14px; background: var(--accent-soft); }
.table-shell { overflow: auto; border-radius: 15px; box-shadow: inset 0 0 0 1px var(--line); }
.table-shell table { width: 100%; min-width: 1060px; border-collapse: collapse; background: rgba(255,255,255,.58); }
th, td { padding: 12px 11px; border-bottom: 1px solid #e5e7e1; text-align: left; vertical-align: middle; font-size: .72rem; }
th { position: sticky; top: 0; z-index: 1; background: #f1f1eb; color: var(--muted); font-size: .67rem; letter-spacing: .02em; }
tbody tr { transition: background 160ms ease; }
tbody tr:hover { background: rgba(255,255,255,.68); }
tbody tr:last-child td { border-bottom: 0; }
td code { font: 680 .67rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
.status-badge { display: inline-block; padding: 5px 7px; border-radius: 7px; font-size: .66rem; font-weight: 750; }
.status-active { background: var(--accent-soft); color: var(--accent-dark); }
.status-disabled, .status-expired { background: var(--danger-soft); color: var(--danger); }
.row-actions { display: flex; flex-wrap: wrap; min-width: 246px; gap: 5px; }
.compact-button { min-height: 29px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.68); color: var(--ink); padding: 0 8px; font-size: .65rem; }
.compact-button:hover:not(:disabled) { border-color: #99a49b; background: white; }
.compact-button.warn { border-color: #ddcfb2; background: var(--warn-soft); color: var(--warn); }
.compact-button.danger { border-color: #e6c4c0; background: var(--danger-soft); color: var(--danger); }
.empty-cell { padding: 34px; color: var(--muted); text-align: center; }
.records-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.compact-table { max-height: 360px; }
.compact-table table { min-width: 680px; }
.log-table { max-height: 460px; }
.result-success { color: var(--accent); font-weight: 750; }
.result-failed { color: var(--danger); font-weight: 750; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 12; max-width: min(460px, calc(100% - 48px)); margin: 0; padding: 12px 16px; border-radius: 12px 12px 12px 4px; background: #27352f; color: white; box-shadow: 0 20px 50px -28px rgba(15,30,22,.72); font-size: .78rem; }
.toast[data-tone="error"] { background: #753833; }

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .create-panel { grid-template-columns: 1fr; }
  .create-grid { grid-template-columns: 1fr 1fr 90px; }
  .remark-field { grid-column: span 2; }
  .create-actions { justify-content: flex-end; }
}

@media (max-width: 800px) {
  .login-shell { grid-template-columns: 1fr; width: min(560px, calc(100% - 32px)); gap: 30px; padding: 42px 0 56px; }
  .login-intro { padding-bottom: 0; }
  .login-intro .brand-mark { margin-bottom: 28px; }
  .login-intro h1 { font-size: clamp(2.6rem, 12vw, 4.2rem); }
  .security-list { gap: 6px; }
  .login-card { padding: 28px 24px 24px; }
  .app-header-inner, .app-shell { width: min(100% - 28px, 1440px); }
  .app-header nav { gap: 6px; }
  .online-state, .admin-identity { display: none; }
  .app-shell { padding-top: 35px; }
  .page-heading { align-items: flex-start; }
  .stats { grid-template-columns: 1fr 1fr; }
  .create-grid { grid-template-columns: 1fr; }
  .remark-field { grid-column: auto; }
  .create-actions { justify-content: stretch; }
  .create-actions button { flex: 1; }
  .section-head { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .records-grid { grid-template-columns: 1fr; }
  .inline-editor { grid-template-columns: 1fr auto; }
  .inline-editor label { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .security-list { grid-template-columns: 1fr; }
  .security-list div { display: flex; align-items: baseline; justify-content: space-between; }
  .login-card { border-radius: 22px 22px 22px 8px; }
  .brand small { display: none; }
  .page-heading { flex-direction: column; }
  .stats { grid-template-columns: 1fr; }
  .panel { padding: 17px; }
}

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