:root {
  --paper: #f3efe6;
  --ink: #1d2430;
  --muted: #5e675f;
  --line: #ddd4c4;
  --card: #fffdf8;
  --green: #1f6b4a;
  --green-dark: #164c35;
  --red: #8d2f2f;
  --gold: #8a5a2b;
  --side: #1d2430;
  --side-text: #f3efe6;
  --shadow: 0 1px 0 rgba(29, 36, 48, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--green-dark); }

button, input, select, textarea { font: inherit; color: inherit; }

img { max-width: 100%; }

.nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.shell { min-height: 100vh; }

.side {
  display: none;
  background: var(--side);
  color: var(--side-text);
  padding: 16px 12px 24px;
}

.nav-toggle:checked ~ .shell .side { display: block; }

.brand { padding: 8px 12px 16px; }
.brand strong { display: block; font-size: 20px; font-weight: 600; }
.brand span { color: #c8c0b2; font-size: 13px; }

.nav-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--side-text);
  text-decoration: none;
  border-radius: 8px;
}

.nav-link.active, .nav-link:hover { background: rgba(255, 253, 248, 0.08); }

.side-form { margin: 12px; }
.side-form button {
  width: 100%;
  min-height: 44px;
  background: transparent;
  color: var(--side-text);
  border: 1px solid rgba(243, 239, 230, 0.35);
  border-radius: 8px;
}

.main {
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.top h1 { margin: 0; font-size: 24px; font-weight: 600; }
.who { margin-left: auto; color: var(--muted); }

.nav-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.flash {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #e7f3ec;
  color: var(--green-dark);
}

.flash.error { background: #f8e8e4; color: var(--red); }

.stats, .split, .form-grid {
  display: grid;
  gap: 12px;
}

.stat, .panel, .login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.stat { padding: 14px 16px; }
.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 4px; font-size: 22px; font-weight: 600; }

.panel { padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 8px; font-size: 18px; }
.muted { color: var(--muted); }
.note { margin: 0 0 12px; color: var(--muted); }

.num { font-variant-numeric: tabular-nums; }

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

.btn.secondary, button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn.danger, button.danger {
  background: transparent;
  color: var(--red);
  border-color: #e4c4c0;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
label.field input, label.field select, label.field textarea, .inline-form input {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

textarea { min-height: 88px; resize: vertical; }

.inline-form, .row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input { width: auto; min-width: 0; flex: 1 1 120px; }

table.responsive { width: 100%; border-collapse: collapse; }
table.responsive th, table.responsive td {
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  word-break: break-word;
}

.choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.choice input { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.choice strong, .choice .muted, .choice .nums { display: block; }
.choice .nums { margin-top: 4px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.login-card { width: 100%; max-width: 440px; padding: 24px 18px; }
.login-card h1 { margin: 0 0 8px; font-size: 28px; }

@media (max-width: 759px) {
  .btn, button.btn, .actions form { width: 100%; }
  .actions form button { width: 100%; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive thead { display: none; }
  table.responsive tr {
    margin: 0 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
  }
  table.responsive td {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 12px;
    border-bottom: 1px solid var(--line);
  }
  table.responsive td:last-child { border-bottom: 0; }
  table.responsive td::before {
    content: attr(data-label);
    flex: 1 1 100%;
    color: var(--muted);
    font-size: 13px;
  }
  table.responsive td.span { display: block; }
  table.responsive td.span::before { content: none; }
  .inline-form, .row-actions { width: 100%; }
}

@media (min-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: 1 / -1; }
}

@media (min-width: 960px) {
  .nav-toggle-btn { display: none; }
  .shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
  .side { display: block; position: sticky; top: 0; height: 100vh; overflow: auto; }
  .main { padding: 28px 32px 48px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .top h1 { font-size: 28px; }
}
