:root {
  --forest-950: #132f2a;
  --forest-900: #183c35;
  --forest-800: #235249;
  --forest-700: #2f695c;
  --mint-100: #e6f2ed;
  --mint-50: #f1f8f5;
  --paper: #f6f7f4;
  --ink: #17231f;
  --muted: #718079;
  --line: #dce5e0;
  --amber: #bd761e;
  --amber-bg: #fff4df;
  --red: #b44e4e;
  --red-bg: #fff0ef;
  --shadow: 0 14px 34px rgba(20, 49, 42, .08);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.auth-screen { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, #e6f2ed 0, var(--paper) 42%); }
.auth-card { width: min(420px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.auth-brand { margin-bottom: 34px; }
.auth-card h1 { margin-top: 7px; font-size: 27px; }
.auth-copy { margin: 10px 0 22px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.login-form { display: grid; gap: 14px; }
.login-option { display: flex; align-items: center; gap: 7px; margin-top: -3px; color: var(--muted); font-size: 11px; cursor: pointer; }
.login-option input { width: 15px; height: 15px; margin: 0; accent-color: var(--forest-700); }
.login-form .primary-button { margin-top: 4px; }
.form-error { min-height: 16px; margin: 0; color: var(--red); font-size: 12px; }
.user-label { max-width: 120px; overflow: hidden; color: #c6ded6; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.logout-button { padding: 5px 0; border: 0; color: #c6ded6; background: transparent; font-size: 11px; }
.app-shell { min-height: 100vh; padding-bottom: 86px; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1180px) / 2)); color: #fff; background: var(--forest-900); }
.brand-lockup, .topbar-actions, .section-heading, .panel-heading, .page-heading { display: flex; align-items: center; }
.brand-lockup { gap: 11px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.32); border-radius: 11px; font-weight: 800; font-size: 12px; letter-spacing: .08em; background: rgba(255,255,255,.1); }
.brand-name { font-size: 17px; font-weight: 760; letter-spacing: .02em; }
.brand-subtitle { margin-top: 2px; color: #b3cec4; font-size: 11px; }
.topbar-actions { gap: 17px; }
.sync-state { display: flex; align-items: center; gap: 7px; color: #c6ded6; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #72d6a0; box-shadow: 0 0 0 4px rgba(114,214,160,.12); }
.avatar-button { width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; color: var(--forest-950); background: #d9eee4; font-weight: 750; }
.main-content { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.page-heading { justify-content: space-between; padding: 38px 0 25px; }
.eyebrow, .section-kicker { margin: 0; color: var(--forest-700); font-size: 10px; font-weight: 780; letter-spacing: .14em; }
h1, h2 { margin: 0; letter-spacing: -.025em; }
h1 { margin-top: 5px; font-size: clamp(27px, 4vw, 34px); }
h2 { margin-top: 5px; font-size: 19px; }
.date-picker { display: flex; align-items: center; gap: 9px; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--forest-800); background: #fff; box-shadow: 0 3px 10px rgba(25, 55, 48, .03); }
.date-picker input { width: 125px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.kpi-card { min-height: 125px; padding: 20px 21px 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.kpi-primary { border-color: var(--forest-800); color: #fff; background: var(--forest-800); }
.kpi-warning { border-color: #f0dfbd; background: #fffdf8; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi-primary .kpi-label { color: #c5ddd4; }
.kpi-value { margin-top: 13px; font-size: 27px; font-weight: 790; letter-spacing: -.04em; }
.kpi-value small { margin-left: 3px; font-size: 11px; font-weight: 650; letter-spacing: 0; }
.kpi-foot { margin-top: 12px; color: #bde1cd; font-size: 11px; }
.kpi-foot.neutral { color: #93a19b; }
.warning-text { color: var(--amber); }
.section-block { padding-top: 38px; }
.section-heading { justify-content: space-between; margin-bottom: 15px; }
.section-caption { color: var(--muted); font-size: 12px; }
.issues-section { padding-top: 30px; }
.issues-list { display: grid; gap: 10px; }
.issue-card { padding: 15px 17px; border: 1px solid #f0d8d4; border-left: 4px solid var(--red); border-radius: 9px; background: #fffafa; }
.issue-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.issue-card-title { color: var(--ink); font-size: 13px; font-weight: 760; }
.issue-card-meta { margin-top: 5px; color: var(--muted); font-size: 11px; }
.issue-card-time { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.issue-card-details { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 12px; padding-top: 10px; border-top: 1px solid #f4e5e2; color: #725d58; font-size: 11px; }
.issue-card-details strong { color: var(--red); font-weight: 720; }
.issues-empty { padding: 16px 18px; border: 1px dashed #d7e3dd; border-radius: 8px; color: var(--muted); background: #fbfdfc; font-size: 12px; }
.line-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.line-card { padding: 17px 18px; border: 1px solid var(--line); border-radius: 10px; background: #fff; transition: border-color .18s, box-shadow .18s, transform .18s; }
.line-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.line-card.selected { border-color: var(--forest-700); box-shadow: 0 0 0 2px rgba(47,105,92,.1), var(--shadow); }
.line-card-head, .line-card-meta, .record-head, .record-metrics { display: flex; align-items: center; justify-content: space-between; }
.line-name { font-size: 17px; font-weight: 790; }
.line-product { margin-top: 7px; color: var(--muted); font-size: 12px; }
.line-status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 5px; color: var(--forest-700); background: var(--mint-100); font-size: 10px; font-weight: 700; }
.line-status.issue { color: var(--red); background: var(--red-bg); }
.line-card-meta { margin-top: 18px; padding-top: 13px; border-top: 1px solid #edf1ef; }
.line-output { font-size: 22px; font-weight: 790; letter-spacing: -.04em; }
.line-output small { margin-left: 3px; color: var(--muted); font-size: 10px; letter-spacing: 0; }
.line-achievement { color: var(--forest-700); font-size: 12px; font-weight: 720; }
.line-achievement.issue { color: var(--red); }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, .98fr); gap: 15px; padding-top: 38px; }
.panel { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.panel-heading { justify-content: space-between; margin-bottom: 20px; }
.line-badge { padding: 6px 9px; border-radius: 5px; color: var(--forest-800); background: var(--mint-100); font-size: 11px; font-weight: 800; }
.form-row { display: grid; gap: 12px; margin-top: 13px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.triple-col { grid-template-columns: 1.15fr .85fr .85fr; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 7px; }
.field > span { color: #53635d; font-size: 11px; font-weight: 670; }
.entry-hint { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.entry-hint span { color: var(--forest-700); font-size: 14px; font-weight: 700; }
.field-note { display: flex; min-height: 43px; flex-direction: column; justify-content: center; gap: 4px; padding: 0 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.field-note strong { color: var(--forest-700); font-size: 11px; }
.memory-tools { margin-top: 12px; padding: 10px 11px; border: 1px dashed #cbded5; border-radius: 7px; background: #fbfdfc; }
.memory-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; color: var(--forest-800); font-size: 11px; font-weight: 720; }
.memory-heading small { color: var(--muted); font-size: 10px; font-weight: 500; text-align: right; }
.memory-presets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.memory-preset { min-height: 31px; padding: 5px 8px; border: 1px solid #d3e4dc; border-radius: 5px; color: var(--forest-800); background: #fff; font-size: 10px; text-align: left; }
.memory-preset:hover { border-color: var(--forest-700); background: var(--mint-100); }
.memory-preset strong { display: block; font-size: 10px; }
.memory-preset span { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.field b { color: #98a49f; font-size: 9px; font-weight: 700; }
.field input, .field select { width: 100%; height: 43px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; outline: none; color: var(--ink); background: #fcfdfc; font-size: 13px; }
.field input:focus, .field select:focus { border-color: var(--forest-700); box-shadow: 0 0 0 3px rgba(47,105,92,.11); }
.field-emphasis input { border-color: #a9c9bc; color: var(--forest-900); background: var(--mint-50); font-size: 18px; font-weight: 760; }
.calc-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; padding: 13px; border: 1px solid #e5efea; border-radius: 8px; background: var(--mint-50); }
.calc-preview div { min-width: 0; }
.calc-preview span { display: block; color: #779087; font-size: 10px; }
.calc-preview strong { display: block; margin-top: 6px; overflow: hidden; color: var(--forest-900); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.issue-details { margin-top: 16px; border-top: 1px solid #eef1ef; }
.issue-details summary { display: flex; align-items: center; gap: 8px; padding: 14px 0 8px; cursor: pointer; list-style: none; color: var(--amber); font-size: 12px; font-weight: 720; }
.issue-details summary::-webkit-details-marker { display: none; }
.summary-icon { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; color: #fff; background: var(--amber); font-size: 11px; font-weight: 800; }
.details-body { padding-bottom: 5px; }
.primary-button { display: flex; width: 100%; height: 47px; align-items: center; justify-content: center; gap: 7px; margin-top: 18px; border: 0; border-radius: 7px; color: #fff; background: var(--forest-800); font-size: 13px; font-weight: 730; transition: background .18s, transform .18s; }
.primary-button:hover { background: var(--forest-900); transform: translateY(-1px); }
.secondary-button { display: flex; width: 100%; height: 42px; align-items: center; justify-content: center; gap: 7px; margin-top: 9px; border: 1px solid #cbded5; border-radius: 7px; color: var(--forest-700); background: #fff; font-size: 12px; font-weight: 730; }
.secondary-button:hover, .add-row-button:hover { border-color: var(--forest-700); background: var(--mint-50); }
.records-heading { margin-bottom: 14px; }
.text-button { display: flex; align-items: center; gap: 5px; padding: 5px 0; border: 0; color: var(--forest-700); background: transparent; font-size: 11px; font-weight: 740; }
.filter-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.filter-chip { flex: 0 0 auto; padding: 7px 11px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: #fff; font-size: 11px; }
.filter-chip.active { border-color: var(--forest-700); color: var(--forest-800); background: var(--mint-100); font-weight: 720; }
.records-list { max-height: 525px; overflow-y: auto; margin-top: 13px; padding-right: 2px; }
.empty-state { display: grid; min-height: 210px; place-items: center; border: 1px dashed #cddad4; border-radius: 8px; color: var(--muted); font-size: 12px; text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 14px; }
.record { padding: 15px 0; border-bottom: 1px solid #edf1ef; }
.record:first-child { padding-top: 5px; }
.record:last-child { border-bottom: 0; }
.record-head { align-items: flex-start; }
.record-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 750; }
.record-head-meta { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 8px; margin-left: 12px; }
.record-time { color: var(--muted); font-size: 10px; }
.record-tag { padding: 4px 6px; border-radius: 4px; color: var(--forest-700); background: var(--mint-100); font-size: 9px; font-weight: 700; }
.record-tag.issue { color: var(--red); background: var(--red-bg); }
.record-subtitle { margin-top: 6px; color: var(--muted); font-size: 11px; }
.record-metrics { justify-content: flex-start; gap: 20px; margin-top: 12px; }
.record-metric span { display: block; color: #87948e; font-size: 9px; }
.record-metric strong { display: block; margin-top: 3px; color: var(--ink); font-size: 13px; }
.record-metric strong.good { color: var(--forest-700); }
.record-metric strong.warn { color: var(--red); }
.record-action { padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; color: var(--forest-700); background: #fff; font-size: 10px; font-weight: 720; }
.record-action:hover { border-color: var(--forest-700); background: var(--mint-50); }
.bottom-nav { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; display: flex; justify-content: center; gap: 8px; height: 72px; padding: 8px max(16px, calc((100vw - 420px) / 2)); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); }
.bottom-nav-item { display: flex; min-width: 90px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 7px; color: #8a9891; background: transparent; font-size: 10px; }
.bottom-nav-item.active { color: var(--forest-800); background: var(--mint-50); font-weight: 720; }
.nav-icon { height: 18px; font-size: 19px; line-height: 18px; }
.toast { position: fixed; z-index: 20; right: 50%; bottom: 88px; transform: translate(50%, 15px); padding: 11px 16px; border-radius: 7px; color: #fff; background: var(--forest-950); box-shadow: var(--shadow); opacity: 0; pointer-events: none; font-size: 12px; transition: opacity .2s, transform .2s; }
.toast.show { transform: translate(50%, 0); opacity: 1; }
.modal { position: fixed; z-index: 30; inset: 0; display: none; align-items: center; justify-content: center; padding: 18px; background: rgba(16, 38, 33, .46); }
.modal.open { display: flex; }
.modal-card { width: min(980px, 100%); max-height: min(760px, calc(100vh - 36px)); overflow-y: auto; padding: 22px; border-radius: 12px; background: #fff; box-shadow: 0 24px 80px rgba(5, 26, 20, .25); }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.close-button { width: 31px; height: 31px; border: 0; border-radius: 50%; color: var(--muted); background: #f0f4f2; font-size: 23px; line-height: 1; }
.modal-context { margin: 12px 0 16px; color: var(--forest-700); font-size: 12px; font-weight: 700; }
.batch-rows { display: grid; gap: 10px; }
.batch-row { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdfc; }
.batch-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 700; }
.batch-remove { border: 0; color: var(--red); background: transparent; font-size: 11px; }
.batch-row-grid { display: grid; grid-template-columns: 1.15fr 1.15fr 1.15fr .8fr .8fr .8fr .8fr; gap: 8px; }
.batch-row label { display: flex; min-width: 0; flex-direction: column; gap: 5px; }
.batch-row label span { color: var(--muted); font-size: 9px; }
.batch-row input { width: 100%; height: 37px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; outline: 0; color: var(--ink); background: #fff; font-size: 12px; }
.batch-row input:focus { border-color: var(--forest-700); box-shadow: 0 0 0 3px rgba(47,105,92,.1); }
.add-row-button { display: flex; width: 100%; height: 39px; align-items: center; justify-content: center; gap: 6px; margin-top: 11px; border: 1px dashed #b8d0c5; border-radius: 7px; color: var(--forest-700); background: #fff; font-size: 11px; font-weight: 730; }
.batch-summary { margin-top: 13px; padding: 11px 12px; border-radius: 7px; color: var(--forest-800); background: var(--mint-50); font-size: 11px; line-height: 1.5; }
.modal-actions { display: grid; grid-template-columns: .7fr 1.3fr; gap: 9px; margin-top: 15px; }
.ghost-button { height: 44px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: #fff; font-size: 12px; font-weight: 700; }
.modal-save { height: 44px; margin-top: 0; }
.edit-modal-card { width: min(900px, 100%); }
.edit-form { display: grid; gap: 0; }
.edit-form .modal-actions { margin-top: 14px; }

@media (max-width: 900px) {
  .main-content { width: min(720px, calc(100% - 32px)); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .batch-row-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .batch-row-grid label:nth-child(-n+3) { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .topbar { height: 68px; padding: 0 16px; }
  .sync-state { display: none; }
  .user-label { max-width: 74px; }
  .logout-button { font-size: 10px; }
  .avatar-button { display: none; }
  .auth-card { padding: 24px 20px; }
  .main-content { width: calc(100% - 28px); }
  .page-heading { align-items: flex-start; padding: 25px 0 19px; }
  .date-picker { height: 38px; padding: 0 8px; }
  .date-picker input { width: 112px; font-size: 12px; }
  .kpi-card { min-height: 111px; padding: 16px; }
  .kpi-value { margin-top: 10px; font-size: 23px; }
  .kpi-foot { margin-top: 9px; font-size: 10px; }
  .section-block, .workspace-grid { padding-top: 29px; }
  .line-grid { grid-template-columns: 1fr; gap: 9px; }
  .line-card { padding: 15px; }
  .record-head-meta { margin-left: 8px; }
  .panel { padding: 17px 15px; }
  .triple-col { grid-template-columns: 1fr 1fr; }
  .triple-col .field-emphasis { grid-column: 1 / -1; }
  .calc-preview { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
  .memory-heading { align-items: flex-start; flex-direction: column; gap: 3px; }
  .memory-heading small { text-align: left; }
  .batch-row-grid { grid-template-columns: 1fr; }
  .batch-row-grid label:nth-child(-n+3) { grid-column: auto; }
  .bottom-nav-item { min-width: 78px; }
  .edit-modal-card { width: min(680px, 100%); }
}
