:root {
  --ink: #242019;
  --muted: #766d61;
  --cream: #fffaf1;
  --paper: #ffffff;
  --line: #e9dfd0;
  --orange: #f26b38;
  --orange-dark: #d84d1d;
  --orange-soft: #fff0e8;
  --green: #21845a;
  --red: #c43e3e;
  --shadow: 0 18px 45px rgba(82, 57, 31, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 5%, rgba(242, 107, 56, 0.12), transparent 22rem),
    linear-gradient(180deg, #fffaf2 0%, #f7f1e8 100%);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 58px 0 80px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.eyebrow { margin: 0 0 8px; color: var(--orange-dark); font-size: 12px; font-weight: 800; letter-spacing: 0.18em; }
h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(36px, 5vw, 64px); line-height: 1.05; letter-spacing: -0.04em; }
.subtitle { margin: 14px 0 0; color: var(--muted); font-size: 16px; }

.ghost-button, .install-button, .add-button, .template-button, .print-button, .remove-button { border: 0; border-radius: 999px; transition: 160ms ease; }
.hero-actions { display: flex; gap: 9px; }
.install-button { padding: 11px 18px; color: #fff; background: var(--ink); font-weight: 700; }
.install-button:hover { background: var(--orange-dark); }
.ghost-button { padding: 11px 18px; border: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.55); }
.ghost-button:hover { color: var(--orange-dark); border-color: var(--orange); }

.summary-grid { display: grid; grid-template-columns: 1.25fr repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.summary-card { min-height: 132px; padding: 22px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.82); box-shadow: var(--shadow); }
.summary-card.primary { color: #fff; border-color: var(--orange); background: linear-gradient(135deg, var(--orange), #e95522); }
.summary-card span, .summary-card small { display: block; }
.summary-card span { font-size: 13px; font-weight: 700; opacity: .75; }
.summary-card strong { display: block; margin: 12px 0 8px; font-family: Georgia, serif; font-size: clamp(25px, 3vw, 34px); letter-spacing: -0.03em; }
.summary-card small { color: var(--muted); font-size: 12px; }
.summary-card.primary small { color: rgba(255,255,255,.78); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .85fr); gap: 18px; align-items: start; }
.input-column { display: grid; gap: 18px; }
.panel { padding: 25px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 22px; }
.panel-heading > div { display: flex; align-items: center; gap: 10px; }
.panel-heading h2 { margin: 0; font-size: 19px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.panel-heading.compact { margin-bottom: 28px; }
.step { display: grid; width: 32px; height: 32px; place-items: center; color: var(--orange-dark); border-radius: 10px; background: var(--orange-soft); font-size: 11px; font-weight: 800; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.basic-grid { grid-template-columns: 1fr 1fr; }
.field-wide { grid-column: 1 / -1; }
.labor-grid { grid-template-columns: repeat(3, 1fr); }
.planning-grid { grid-template-columns: repeat(2, 1fr); }
.field > span { display: block; margin: 0 0 8px 4px; color: var(--muted); font-size: 13px; font-weight: 700; }
.input-wrap { display: flex; align-items: center; min-height: 52px; padding: 0 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--cream); }
.input-wrap:focus-within { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242,107,56,.12); }
.input-wrap i { color: var(--muted); font-style: normal; font-size: 13px; }
.input-wrap input { width: 100%; min-width: 0; padding: 0 8px; border: 0; outline: 0; color: var(--ink); background: transparent; font-weight: 750; }
.input-wrap.small { min-height: 44px; }
.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; right: 16px; top: 50%; color: var(--orange-dark); pointer-events: none; transform: translateY(-55%); }
.select-wrap select { width: 100%; min-height: 52px; padding: 0 42px 0 15px; border: 1px solid var(--line); border-radius: 14px; outline: 0; color: var(--ink); background: var(--cream); appearance: none; font-weight: 750; }
.select-wrap select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242,107,56,.12); }
.select-wrap.small-select select { min-height: 44px; padding-left: 12px; font-size: 12px; }
.category-guide { margin-top: 14px; padding: 14px 16px; border: 1px solid #f2ddca; border-radius: 13px; color: #6d5b48; background: #fff8f1; font-size: 12px; line-height: 1.7; }
.category-guide strong { color: var(--orange-dark); }
.add-button { padding: 9px 13px; color: var(--orange-dark); background: var(--orange-soft); font-size: 12px; font-weight: 700; }
.add-button:hover { background: #ffe1d2; }
.heading-actions { display: flex; gap: 8px; }
.template-button { padding: 9px 13px; color: #fff; background: var(--ink); font-size: 12px; font-weight: 700; }
.template-button:hover { background: #3a342b; }
.cost-list { display: grid; gap: 10px; }
.cost-row { display: grid; grid-template-columns: 1fr 150px 34px; gap: 10px; align-items: center; }
.loss-head, .loss-row { display: grid; grid-template-columns: minmax(150px, 1fr) 150px 120px 34px; gap: 10px; align-items: center; }
.fixed-head, .fixed-row { display: grid; grid-template-columns: minmax(140px, 1fr) 130px 115px 34px; gap: 10px; align-items: center; }
.loss-head, .fixed-head { margin: 0 0 8px; padding: 0 2px; color: var(--muted); font-size: 11px; }
.cost-name { min-width: 0; height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; outline: none; background: #fff; }
.cost-name:focus { border-color: var(--orange); }
.remove-button { width: 32px; height: 32px; color: #9b8f81; background: transparent; font-size: 22px; line-height: 1; }
.remove-button:hover { color: var(--red); background: #fff0f0; }
.panel-total { display: flex; justify-content: space-between; margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 13px; }
.panel-total strong { color: var(--ink); font-size: 16px; }
.panel-note { margin-top: 14px; padding: 11px 13px; border-radius: 11px; color: #786854; background: #fbf6ee; font-size: 12px; line-height: 1.65; }
.allocation-box { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.allocation-box div { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.allocation-box span, .allocation-box strong { display: block; }
.allocation-box span { margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.allocation-box strong { font-size: 15px; }

.sticky-panel { position: sticky; top: 18px; }
.profit-visual { display: grid; place-items: center; gap: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.donut { display: grid; width: 170px; height: 170px; place-content: center; text-align: center; border-radius: 50%; background: conic-gradient(var(--orange) 0deg, #eee5d9 0deg); position: relative; }
.donut::after { content: ""; position: absolute; inset: 17px; border-radius: 50%; background: var(--paper); }
.donut span, .donut small { position: relative; z-index: 1; }
.donut span { font-family: Georgia, serif; font-size: 34px; font-weight: 700; }
.donut small { color: var(--muted); font-size: 12px; }
.legend { width: 100%; display: grid; gap: 9px; }
.legend p { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; margin: 0; color: var(--muted); font-size: 13px; }
.legend strong { color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.revenue-dot { background: var(--orange); }
.cost-dot { background: #d8c8b7; }
.metric-list { display: grid; gap: 2px; margin: 18px 0; }
.metric-list div { display: flex; justify-content: space-between; padding: 12px 2px; color: var(--muted); font-size: 13px; }
.metric-list strong { color: var(--ink); }
.tip { padding: 15px; border-left: 3px solid var(--orange); border-radius: 5px 12px 12px 5px; color: #695844; background: var(--orange-soft); font-size: 13px; line-height: 1.7; }
.print-button { width: 100%; margin-top: 16px; padding: 13px; color: #fff; background: var(--ink); font-weight: 700; }
.print-button:hover { background: #3a342b; transform: translateY(-1px); }
.install-sheet[hidden] { display: none; }
.install-sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; padding: 18px; }
.sheet-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(34, 29, 23, .48); backdrop-filter: blur(5px); }
.sheet-card { position: relative; width: min(520px, 100%); padding: 28px; border-radius: 24px; background: #fff; box-shadow: 0 28px 80px rgba(34,29,23,.28); }
.sheet-card h2 { margin: 0 0 18px; font-size: 24px; }
.sheet-card ol { margin: 0; padding-left: 22px; color: var(--muted); line-height: 1.9; }
.sheet-card p { color: var(--muted); line-height: 1.7; }
.sheet-card strong { color: var(--ink); }
.sheet-close { position: absolute; top: 15px; right: 15px; display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 50%; color: var(--muted); background: var(--cream); font-size: 22px; cursor: pointer; }
.offline-badge { position: fixed; right: 14px; bottom: 14px; z-index: 20; padding: 8px 12px; border-radius: 999px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: 11px; }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .workspace { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
  .profit-visual { grid-template-columns: 180px 1fr; }
  .labor-grid { grid-template-columns: 1fr 1fr 1fr; }
  .allocation-box { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 580px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 28px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .hero-actions { width: 100%; }
  .hero-actions button { flex: 1; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .summary-card { min-height: 118px; padding: 17px; border-radius: 18px; }
  .summary-card strong { font-size: 23px; }
  .panel { padding: 18px; border-radius: 20px; }
  .panel-heading { align-items: flex-start; }
  .panel-heading:has(.heading-actions) { flex-direction: column; }
  .heading-actions { width: 100%; }
  .heading-actions button { flex: 1; }
  .panel-heading p { display: none; }
  .field-grid { grid-template-columns: 1fr; }
  .labor-grid { grid-template-columns: 1fr; }
  .planning-grid { grid-template-columns: 1fr; }
  .allocation-box { grid-template-columns: 1fr; }
  .cost-row { grid-template-columns: 1fr 112px 30px; gap: 6px; }
  .loss-head, .fixed-head { display: none; }
  .loss-row { grid-template-columns: 1fr 1fr 30px; gap: 7px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
  .loss-row .loss-name { grid-column: 1 / 3; }
  .loss-row .remove-button { grid-column: 3; grid-row: 1 / 3; }
  .fixed-row { grid-template-columns: 1fr 1fr 30px; gap: 7px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
  .fixed-row .fixed-name { grid-column: 1 / 3; }
  .fixed-row .remove-button { grid-column: 3; grid-row: 1 / 3; }
  .profit-visual { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .app-shell { width: 100%; padding: 0; }
  .ghost-button, .install-button, .add-button, .template-button, .remove-button, .print-button { display: none; }
  .panel, .summary-card { box-shadow: none; break-inside: avoid; }
  .sticky-panel { position: static; }
}
