:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-soft: #f0f2ec;
  --surface-accent: #f4f8dc;
  --text: #20231d;
  --muted: #6b7165;
  --faint: #949a8e;
  --line: #dde1d8;
  --line-strong: #c7ccc1;
  --accent: #9ab62d;
  --accent-strong: #617715;
  --warning: #a56b12;
  --danger: #b63c37;
  --success: #387b4b;
  --shadow: 0 1px 2px rgba(25, 32, 19, 0.05), 0 8px 24px rgba(25, 32, 19, 0.04);
  --radius-input: 6px;
  --radius-card: 8px;
  --radius-modal: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
:focus-visible { outline: 3px solid rgba(154, 182, 45, 0.35); outline-offset: 2px; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--text); color: white; padding: 10px 14px; border-radius: 6px; }
.skip-link:focus { top: 12px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(110deg, #f4f5f1 0 65%, #edf1dc 65%); }
.login-panel { width: min(420px, 100%); background: var(--surface); border: 1px solid rgba(199, 204, 193, 0.8); border-radius: var(--radius-modal); box-shadow: var(--shadow); padding: 32px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 16px; font-weight: 720; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px 7px 7px 3px; background: var(--text); position: relative; }
.brand-mark::after { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #c5dd55; right: 4px; top: 4px; }
.login-panel h1 { margin: 42px 0 8px; font-size: 28px; letter-spacing: 0; }
.login-panel > p { color: var(--muted); margin: 0 0 28px; }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 650; color: #494e45; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: var(--radius-input); background: white; color: var(--text); padding: 10px 12px; }
.field textarea { resize: vertical; min-height: 80px; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #9da595; }
.form-error { min-height: 20px; color: var(--danger); font-size: 13px; margin: 0 0 8px; }
.button { min-height: 44px; border: 1px solid transparent; border-radius: var(--radius-input); padding: 9px 15px; font-weight: 680; color: var(--text); background: var(--surface-soft); }
.button.primary { background: var(--text); color: white; width: 100%; }
.button.secondary { background: white; border-color: var(--line-strong); }
.button.danger { color: var(--danger); background: #fff5f4; border-color: #f0cfcc; }
.button.small { min-height: 36px; padding: 6px 11px; font-size: 13px; }
.button:active { transform: scale(0.98); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: #eef0ea; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; overscroll-behavior: contain; }
.sidebar .brand { padding: 4px 8px 24px; }
.role-label { margin: 8px 10px 6px; font-size: 12px; color: var(--faint); }
.nav { display: grid; gap: 3px; }
.nav button { position: relative; min-height: 44px; border: 0; border-radius: 6px; background: transparent; color: #565c51; padding: 10px 12px 10px 17px; text-align: left; font-weight: 620; }
.nav button[aria-current="page"] { background: rgba(154, 182, 45, 0.13); color: var(--accent-strong); }
.nav button[aria-current="page"]::before { content: ""; position: absolute; left: 6px; top: 13px; bottom: 13px; width: 3px; border-radius: 3px; background: var(--accent); }
.sidebar-user { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 8px 0; }
.sidebar-user strong, .sidebar-user span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user span { font-size: 12px; color: var(--muted); margin-top: 3px; }
.logout { border: 0; background: transparent; color: var(--muted); padding: 12px 0 4px; min-height: 44px; }

.main { min-width: 0; padding: 24px; }
.topbar { min-height: 56px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.topbar h1 { font-size: 25px; margin: 0 0 5px; letter-spacing: 0; }
.topbar p { margin: 0; color: var(--muted); font-size: 13px; }
.sync-state { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); white-space: nowrap; padding-top: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.active { background: var(--success); }
.dot.warning { background: var(--warning); }

.metrics { display: grid; grid-template-columns: minmax(230px, 1.35fr) repeat(3, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { min-height: 128px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 17px; box-shadow: 0 1px 1px rgba(25, 32, 19, 0.02); }
.metric.hero { background: var(--surface-accent); border-color: #dce7aa; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 620; }
.metric-value { margin: 17px 0 7px; font-size: 28px; font-weight: 760; font-variant-numeric: tabular-nums; }
.metric.hero .metric-value { color: var(--accent-strong); font-size: 36px; }
.metric-note { font-size: 12px; color: var(--faint); }
.sparkline { height: 16px; margin-top: 5px; display: flex; align-items: flex-end; gap: 3px; }
.sparkline i { display: block; width: 8px; background: rgba(97, 119, 21, 0.3); border-radius: 2px 2px 0 0; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.75fr); gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: 0 1px 1px rgba(25, 32, 19, 0.02); }
.panel-header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 17px; border-bottom: 1px solid var(--line); }
.panel-header h2 { font-size: 15px; margin: 0; }
.panel-header p { font-size: 12px; color: var(--muted); margin: 3px 0 0; }
.panel-body { padding: 17px; }
.table-wrap { overflow-x: auto; scrollbar-gutter: stable; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th { color: var(--muted); font-size: 12px; font-weight: 620; text-align: left; padding: 11px 14px; background: #fafbf8; border-bottom: 1px solid var(--line); }
td { height: 46px; padding: 9px 14px; border-bottom: 1px solid #eceee9; font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color 120ms ease, box-shadow 120ms ease; }
.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.empty { padding: 40px 20px; color: var(--muted); text-align: center; }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.toolbar button { min-height: 38px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 12px; color: var(--muted); }
.toolbar button[aria-pressed="true"] { color: var(--accent-strong); background: var(--surface-accent); border-color: #dce7aa; }
.section-stack { display: grid; gap: 16px; }
.split-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; grid-column: 1 / -1; }
.form-actions .button.primary { width: auto; }
.notice { border: 1px solid #ead7b2; background: #fffaf0; color: #7b581f; border-radius: 7px; padding: 12px 14px; font-size: 13px; }
.money { font-variant-numeric: tabular-nums; font-weight: 650; }
.tab-actions { display: flex; gap: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 360px; border-radius: 8px; background: var(--text); color: white; padding: 12px 16px; box-shadow: var(--shadow); font-size: 13px; }

@media (hover: hover) and (pointer: fine) {
  .nav button:hover, .toolbar button:hover { background: rgba(255, 255, 255, 0.65); color: var(--text); }
  tbody tr:hover { background: #fafbf8; box-shadow: inset 3px 0 var(--accent); }
  .button:hover { filter: brightness(0.97); }
}

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding: 4px 6px 12px; }
  .role-label, .sidebar-user { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .nav button { padding: 8px 13px; }
  .nav button[aria-current="page"]::before { left: 13px; right: 13px; top: auto; bottom: 3px; width: auto; height: 3px; }
  .main { padding: 18px 14px 28px; }
  .topbar { min-height: auto; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 112px; }
  .split-form { grid-template-columns: 1fr; }
  .form-actions { grid-column: auto; }
}

@media (max-width: 480px) {
  .login-shell { padding: 14px; background: var(--bg); }
  .login-panel { padding: 24px 20px; }
  .metrics { grid-template-columns: 1fr; }
  .topbar { display: block; }
  .sync-state { margin-top: 8px; }
}

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