:root {
  --ink: #17241f;
  --muted: #68766f;
  --paper: #f3f1e9;
  --panel: #fffdf7;
  --line: #dedbd0;
  --green: #174d3b;
  --green-2: #256b51;
  --orange: #e27a36;
  --orange-soft: #fff0df;
  --red: #a94836;
  --shadow: 0 20px 45px rgba(27, 53, 43, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, rgba(226, 122, 54, 0.12), transparent 28rem),
    var(--paper);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 78px;
  padding: 14px clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #fff;
  background: var(--green);
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand, .brand > div, .top-actions, .panel-heading > div, .method-note { display: flex; align-items: center; }
.brand { gap: 13px; }
.brand-mark {
  width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 14px; background: var(--orange); font-weight: 900; font-size: 23px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.brand > div { display: block; }
.brand h1 { margin: 2px 0 0; font-size: 20px; letter-spacing: .03em; }
.eyebrow { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; opacity: .72; }
.top-actions { gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.offline-badge { font-size: 12px; padding: 8px 10px; color: #dcebe4; }
.offline-badge i { width: 7px; height: 7px; display: inline-block; background: #72d3a4; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 0 4px rgba(114,211,164,.12); }
.button { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 750; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--orange); color: #fff; box-shadow: 0 9px 20px rgba(226,122,54,.22); }
.button.ghost { color: inherit; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.16); }
.file-button input { display: none; }
.button.light { color: var(--green); background: #fff; border: 1px solid rgba(23,77,59,.16); }
.button.dark { color: #fff; background: var(--green); }
.button.orange-outline { color: #ad5725; background: #fff8ef; border: 1px solid #edc6a6; }
.button.full { width: 100%; margin-top: 14px; }
.button.dark-text { color: var(--ink); background: #f4f1e8; border: 1px solid var(--line); }

.shell { width: min(1480px, calc(100% - 34px)); margin: 0 auto; }
.hero { padding: 48px 8px 30px; display: grid; grid-template-columns: 1.25fr 1fr; gap: 50px; align-items: end; }
.hero h2 { margin: 8px 0 13px; max-width: 800px; font-family: "STSong", "Songti SC", serif; font-size: clamp(31px, 4vw, 56px); line-height: 1.08; letter-spacing: -.03em; }
.hero-copy { max-width: 780px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.8; }
.hero .eyebrow { color: var(--orange); opacity: 1; }
.hero-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
label { color: var(--muted); font-size: 12px; font-weight: 700; }
input, select {
  width: 100%; margin-top: 7px; padding: 11px 12px; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; outline: none; transition: .15s ease;
}
input:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(37,107,81,.11); }
textarea {
  width: 100%; margin-top: 7px; padding: 11px 12px; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; outline: none; resize: vertical; font: inherit;
}
textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(37,107,81,.11); }

.team-cloud-bar {
  margin-bottom: 18px; padding: 14px 17px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  color: #e9f2ed; background: #2a463b; border: 1px solid rgba(255,255,255,.08); border-radius: 15px;
}
.team-cloud-bar > div, .team-cloud-actions { display: flex; align-items: center; gap: 12px; }
.team-cloud-bar p { margin: 3px 0 0; color: rgba(255,255,255,.62); font-size: 12px; }
.cloud-dot { width: 10px; height: 10px; flex: 0 0 auto; background: #d49a54; border-radius: 50%; box-shadow: 0 0 0 5px rgba(212,154,84,.13); }
.team-cloud-bar.connected .cloud-dot { background: #68d09e; box-shadow: 0 0 0 5px rgba(104,208,158,.13); }

.quarter-center { margin-bottom: 18px; }
.quarter-center-head { padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 22px; border-bottom: 1px solid var(--line); }
.quarter-center-head > div:first-child { display: flex; align-items: center; gap: 12px; }
.quarter-center-head h3 { margin: 0; }
.quarter-center-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.quarter-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.quarter-timeline { padding: 18px 20px 16px; display: grid; grid-template-columns: repeat(12, minmax(52px, 1fr)); gap: 8px; overflow-x: auto; }
.quarter-node { min-width: 54px; padding: 11px 6px 9px; color: var(--muted); background: #f3f1e9; border: 1px solid var(--line); border-radius: 11px; text-align: center; }
.quarter-node strong { display: block; color: var(--ink); font-size: 13px; }
.quarter-node small { display: block; margin-top: 5px; font-size: 10px; white-space: nowrap; }
.quarter-node.active { color: #fff; background: var(--green); border-color: var(--green); box-shadow: 0 8px 18px rgba(23,77,59,.18); }
.quarter-node.active strong { color: #fff; }
.quarter-node.confirmed { border-color: #e7b889; background: #fff4e6; }
.quarter-node.settled { border-color: #9bc5b2; background: #eaf3ee; }
.quarter-node:disabled { opacity: .42; cursor: not-allowed; }
.quarter-history { padding: 0 22px 18px; }
.history-card { padding: 13px 15px; display: grid; grid-template-columns: 1.2fr repeat(4, 1fr); gap: 14px; align-items: center; background: #f8f6ef; border-radius: 12px; font-size: 12px; }
.history-card span { color: var(--muted); }
.history-card strong { display: block; margin-top: 3px; color: var(--ink); }

.result-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.metric { min-height: 132px; padding: 21px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric.accent { color: #fff; background: var(--green); border-color: var(--green); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric.accent span, .metric.accent small { color: rgba(255,255,255,.68); }
.metric span { font-size: 12px; font-weight: 800; letter-spacing: .05em; }
.metric strong { display: block; margin: 13px 0 8px; font-size: clamp(22px, 2.2vw, 31px); line-height: 1.1; }
.metric small { font-size: 12px; }
.decision-center { margin-bottom: 18px; }
.decision-grid { padding: 18px 20px 22px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.decision-card { min-height: 168px; padding: 16px; background: #f8f6ef; border: 1px solid var(--line); border-radius: 13px; }
.decision-card.wide-card { grid-column: span 2; }
.decision-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }
.decision-card-head > span { width: 30px; height: 30px; display: grid; place-items: center; color: #fff; background: var(--green); border-radius: 8px; font-size: 10px; font-weight: 900; }
.decision-card h4 { margin: 0; font-size: 15px; }
.decision-card-head p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.decision-card > p { margin: 0; color: #43534c; font-size: 12px; line-height: 1.75; }
.decision-card table { background: #fff; border: 1px solid var(--line); }
.decision-card th, .decision-card td { padding: 7px 8px; font-size: 11px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.72fr) minmax(340px, .82fr); gap: 18px; align-items: start; }
.inputs-column, .results-column { display: grid; gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { min-height: 75px; padding: 18px 22px; display: flex; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.panel-heading.compact { min-height: 65px; }
.panel-heading > div { gap: 11px; }
.panel-heading h3 { margin: 0; font-size: 18px; }
.panel-heading p { max-width: 430px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: right; }
.step { min-width: 30px; height: 30px; display: inline-grid; place-items: center; color: var(--green); background: #e5eee9; border-radius: 9px; font-size: 11px; font-weight: 900; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 12px; text-align: left; color: var(--muted); background: #f7f5ee; border-bottom: 1px solid var(--line); font-size: 11px; letter-spacing: .03em; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #ece9df; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td input { min-width: 82px; margin: 0; padding: 8px 9px; }
td select { min-width: 104px; margin: 0; padding: 8px 9px; }
td input[type="text"] { min-width: 128px; }
.record-toolbar { padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--muted); background: #faf8f2; border-bottom: 1px solid var(--line); font-size: 12px; }
.record-toolbar .button { flex: 0 0 auto; padding: 8px 11px; }
.row-delete { width: 30px; height: 30px; padding: 0; color: var(--red); background: #f8e8e3; border: 0; border-radius: 8px; font-size: 19px; line-height: 1; }
.row-delete:disabled { opacity: .45; cursor: not-allowed; }
.empty-row { padding: 24px; color: var(--muted); text-align: center; }
.distance-chip { display: inline-block; min-width: 72px; padding: 6px 8px; color: var(--green); background: #e8f0ec; border-radius: 8px; font-size: 11px; font-weight: 800; text-align: center; white-space: nowrap; }
.breed-cell { font-weight: 850; white-space: nowrap; }
.product-tag { display: inline-block; padding: 4px 7px; color: var(--green); background: #e8f0ec; border-radius: 7px; font-size: 11px; font-weight: 800; }
.form-grid { padding: 20px 22px 24px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.advanced summary { padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary span { display: flex; align-items: center; gap: 11px; }
.advanced summary small { color: var(--muted); }
.advanced[open] summary { border-bottom: 1px solid var(--line); }
.advanced-body h4 { margin: 22px 22px 0; }
.note { margin: 0; padding: 15px 22px 22px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.logistics-form { grid-template-columns: repeat(5, minmax(0, 1fr)); padding-bottom: 16px; }
.finance-form { grid-template-columns: repeat(4, minmax(0, 1fr)); padding-bottom: 18px; }
.logistics-advice { border-top: 1px solid var(--line); }
.finance-advice { border-top: 1px solid var(--line); }
.logistics-summary { padding: 18px 22px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.logistics-summary > div { min-height: 108px; padding: 15px; background: #f7f5ee; border: 1px solid var(--line); border-radius: 12px; }
.logistics-summary .recommended-load { color: #fff; background: var(--green); border-color: var(--green); }
.logistics-summary .finance-stop { color: #fff; background: var(--red); border-color: var(--red); }
.logistics-summary span, .logistics-summary small { display: block; color: var(--muted); font-size: 11px; line-height: 1.5; }
.logistics-summary .recommended-load span, .logistics-summary .recommended-load small { color: rgba(255,255,255,.68); }
.logistics-summary .finance-stop span, .logistics-summary .finance-stop small { color: rgba(255,255,255,.72); }
.logistics-summary strong { display: block; margin: 8px 0 6px; font-size: 15px; line-height: 1.4; }
.threshold-note { margin: 0 22px 16px; padding: 12px 14px; color: #76513a; background: var(--orange-soft); border: 1px solid #f1d1b3; border-radius: 10px; font-size: 12px; line-height: 1.65; }
.logistics-table { margin: 0 22px; border: 1px solid var(--line); border-radius: 11px; }
.logistics-table td { white-space: nowrap; }
.finance-grid { margin: 0 22px 4px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.finance-grid > div { padding: 13px 15px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.finance-grid > div:nth-child(3n) { border-right: 0; }
.finance-grid > div:nth-last-child(-n+3) { border-bottom: 0; }
.finance-grid span { display: block; color: var(--muted); font-size: 11px; }
.finance-grid strong { display: block; margin-top: 5px; font-size: 14px; }

.sticky-result { position: sticky; top: 14px; z-index: 2; }
.action-plan { padding: 20px 22px 24px; }
.empty-state { color: var(--muted); line-height: 1.8; }
.plan-lead { padding: 15px; margin-bottom: 16px; background: var(--orange-soft); border: 1px solid #f1d1b3; border-radius: 12px; }
.plan-lead strong { display: block; margin-bottom: 5px; font-size: 17px; }
.plan-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.plan-list li { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.plan-list li:last-child { border: 0; }
.plan-list span { color: var(--muted); }
.plan-list strong { text-align: right; }
.breakdown { padding: 14px 22px 20px; }
.breakdown-row { display: flex; justify-content: space-between; gap: 20px; padding: 9px 0; font-size: 13px; }
.breakdown-row span { color: var(--muted); }
.breakdown-row.total { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); font-weight: 850; }
.warnings { margin: 0; padding: 18px 22px 22px 42px; color: #604e43; }
.warnings li { margin: 0 0 10px; padding-left: 3px; line-height: 1.55; }
.warnings li::marker { color: var(--orange); }
.warnings .safe { color: var(--green); }
.comparison-panel { margin-top: 18px; }
.status { display: inline-block; padding: 4px 7px; border-radius: 7px; font-size: 11px; font-weight: 800; }
.status.ok { color: var(--green); background: #e4efe9; }
.status.no { color: var(--red); background: #f8e8e3; }
.negative { color: var(--red); }
.positive { color: var(--green-2); }
.method-note { margin: 18px 0 30px; padding: 20px 22px; gap: 30px; color: #dce8e2; background: #203c32; border-radius: var(--radius); }
.method-note div { flex: 1; }
.method-note strong { color: #fff; }
.method-note p { margin: 5px 0 0; font-size: 12px; line-height: 1.65; }
.method-note .button { flex: 0 0 auto; }
footer { padding: 0 20px 28px; color: var(--muted); text-align: center; font-size: 11px; }

.modal { width: min(560px, calc(100% - 24px)); max-height: calc(100vh - 30px); padding: 0; color: var(--ink); background: transparent; border: 0; }
.modal.wide, .modal-card.wide { width: min(820px, calc(100vw - 24px)); max-width: 820px; }
.modal::backdrop { background: rgba(13,31,25,.62); backdrop-filter: blur(4px); }
.modal-card { padding: 24px; background: var(--panel); border: 1px solid rgba(255,255,255,.5); border-radius: 20px; box-shadow: 0 30px 80px rgba(6,25,18,.28); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.modal-head h3 { margin: 4px 0 0; font-size: 24px; }
.modal-head .eyebrow { color: var(--orange); opacity: 1; }
.icon-button { width: 34px; height: 34px; padding: 0; color: var(--muted); background: #f0ede4; border: 0; border-radius: 9px; font-size: 23px; }
.tab-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; margin-bottom: 20px; background: #eeece4; border-radius: 11px; }
.tab-switch button { padding: 9px; color: var(--muted); background: transparent; border: 0; border-radius: 8px; font-weight: 800; }
.tab-switch button.active { color: var(--green); background: #fff; box-shadow: 0 4px 12px rgba(31,58,47,.08); }
.team-tab { display: none; }
.team-tab.active { display: grid; gap: 13px; }
.team-tab p { margin: 0 0 2px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.credentials { margin-top: 16px; padding: 14px; color: #ebf3ef; background: var(--green); border-radius: 12px; font-size: 12px; line-height: 1.8; word-break: break-all; }
.credentials strong { color: #fff; }
.modal-message { min-height: 18px; margin: 13px 0 0; color: var(--red); font-size: 12px; }
.settlement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.modal-card h4 { margin: 22px 0 10px; }
.modal-card .table-wrap { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.model-library-modal { width: min(1240px, calc(100vw - 24px)); }
.model-library-card { width: min(1240px, calc(100vw - 24px)); }
.model-toolbar { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 12px; }
.model-meta { padding: 13px 0 6px; }
.model-table-wrap { max-height: 58vh; margin-top: 8px; }
.model-table-wrap th { position: sticky; top: 0; z-index: 1; }
.model-table-wrap td { max-width: 260px; white-space: normal; word-break: break-word; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .sticky-result { position: static; }
  .result-strip { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .decision-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quarter-center-head { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 760px) {
  .topbar, .hero, .panel-heading, .method-note, .team-cloud-bar, .record-toolbar { align-items: stretch; flex-direction: column; }
  .topbar { padding: 14px 17px; }
  .top-actions { justify-content: flex-start; }
  .offline-badge { display: none; }
  .shell { width: min(100% - 20px, 1480px); }
  .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 32px; }
  .hero-controls, .result-strip, .form-grid { grid-template-columns: 1fr; }
  .panel-heading { gap: 8px; }
  .panel-heading p { text-align: left; }
  .metric { min-height: 110px; }
  .team-cloud-actions, .quarter-actions { justify-content: flex-start; }
  .history-card { grid-template-columns: 1fr 1fr; }
  .settlement-grid { grid-template-columns: 1fr; }
  .logistics-form, .finance-form, .logistics-summary, .finance-grid { grid-template-columns: 1fr; }
  .decision-grid, .model-toolbar { grid-template-columns: 1fr; }
  .decision-card.wide-card { grid-column: auto; }
  .finance-grid > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .finance-grid > div:nth-last-child(-n+3) { border-bottom: 1px solid var(--line); }
  .finance-grid > div:last-child { border-bottom: 0; }
}

@media print {
  body { background: #fff; }
  .top-actions, .inputs-column, .method-note button, footer { display: none !important; }
  .workspace { grid-template-columns: 1fr; }
  .sticky-result { position: static; }
  .panel, .metric { box-shadow: none; break-inside: avoid; }
}
