:root {
  color-scheme: light;
  --ink: #1d1d1d;
  --muted: #70665f;
  --line: #e4dad2;
  --line-strong: #cfc1b7;
  --canvas: #f4efea;
  --paper: #fffdfa;
  --navy: #1d1d1d;
  --navy-soft: #2d2927;
  --green: #cd6530;
  --green-bright: #e48a5c;
  --green-pale: #fae9df;
  --orange: #ee6338;
  --yellow: #f4d448;
  --blue: #cd6530;
  --danger: #ca3c45;
  --warning: #9a6411;
  --shadow: 0 18px 50px rgba(71, 49, 36, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 0%, rgba(205, 101, 48, 0.11), transparent 28rem),
    var(--canvas);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

button, input, select { font: inherit; }

button { cursor: pointer; }

.app-header {
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: #f9f5f2;
  color: var(--ink);
}

.brand { display: flex; align-items: center; gap: 17px; min-width: 0; }
.brand-logo-frame { position: relative; width: 143px; height: 44px; flex: 0 0 143px; overflow: hidden; }
.brand-logo-frame img { position: absolute; width: 188px; max-width: none; height: auto; left: -22px; top: -74px; }
.brand-product { padding-left: 16px; border-left: 2px solid var(--green); color: #665c56; font-size: 0.82rem; font-weight: 750; line-height: 1.25; }

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #796f68;
  font-size: 0.82rem;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(205, 101, 48, 0.12); }

.app-shell { width: min(1480px, 100%); margin: 0 auto; padding: 34px clamp(16px, 3.5vw, 48px) 64px; }

.intro-row { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 5px; color: #a94a22; font-weight: 800; font-size: 0.76rem; letter-spacing: 0.14em; text-transform: uppercase; }
h1 { margin: 0; max-width: 760px; font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.05; letter-spacing: -0.045em; }
.intro-copy { margin: 10px 0 0; color: var(--muted); font-size: 1rem; }

.button { min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 750; }
.button-secondary { border-color: var(--line-strong); background: rgba(255,255,255,0.72); color: var(--ink); }
.button-secondary:hover { background: #fff; border-color: var(--green); }

.market-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 7px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.68);
  scrollbar-width: thin;
}

.market-tab {
  flex: 1 0 max-content;
  min-height: 48px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #655b55;
  font-weight: 800;
}

.market-tab:hover { background: #fff; color: var(--ink); }
.market-tab.is-active { background: var(--navy); color: #fff; box-shadow: 0 7px 18px rgba(7, 21, 33, 0.17); }
.market-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; font-size: 0.72rem; font-weight: 900; }
.shopee-icon { background: #fee9e2; color: #c4421c; }
.ml-icon { background: #fff7bd; color: #6f5c00; }
.amazon-icon { background: #e9eef4; color: #182739; font-family: Georgia, serif; font-size: 1.05rem; }
.compare-symbol { font-size: 1.35rem; line-height: 1; color: var(--green-bright); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.16fr) minmax(360px, 0.84fr); gap: 18px; align-items: start; }
.input-column { display: grid; gap: 16px; }

.panel, .result-panel, .comparison-panel, .source-note {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.panel { padding: clamp(20px, 3vw, 28px); }
.panel-heading, .result-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.panel-heading > div, .result-heading > div { display: flex; align-items: center; gap: 12px; }
.panel h2, .result-panel h2, .comparison-panel h2 { margin: 0; font-size: 1.12rem; letter-spacing: -0.015em; }
.step-number { min-width: 34px; color: #71909f; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.09em; }
.panel-hint { color: #78909c; font-size: 0.75rem; font-weight: 700; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.field-grid.three-columns { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field-full { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; min-width: 0; }
.field label { color: #38515f; font-size: 0.86rem; font-weight: 750; }
.required-field label::after { content: " •"; color: var(--green); }
.field small { color: #7a8e99; font-size: 0.72rem; line-height: 1.35; }

input, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fffcf9;
  color: var(--ink);
  outline: none;
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
}

input { padding: 10px 12px; }
select { padding: 10px 38px 10px 12px; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(205,101,48,0.14); background: #fff; }
input:disabled { color: #6c625c; background: #f2ebe6; cursor: not-allowed; }

.money-input, .percent-input { position: relative; display: flex; align-items: center; }
.money-input > span, .percent-input > span { position: absolute; color: #69808c; font-size: 0.82rem; font-weight: 800; pointer-events: none; }
.money-input > span { left: 12px; }
.money-input input { padding-left: 39px; text-align: right; font-variant-numeric: tabular-nums; }
.percent-input > span { right: 13px; }
.percent-input input { padding-right: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.target-field { padding-left: 15px; border-left: 1px solid var(--line); }

.market-settings { border-top: 4px solid var(--green); }
.market-badge { padding: 6px 10px; border-radius: 999px; background: var(--green-pale); color: #9b431d; font-size: 0.75rem; font-weight: 850; }
.market-panel { display: none; }
.market-panel.is-active { display: block; }

.setting-callout { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 14px 16px; margin-bottom: 12px; border: 1px solid #edc6b1; border-radius: 12px; background: #fff7f2; }
.setting-callout div { display: grid; gap: 2px; }
.setting-callout strong { font-size: 0.88rem; }
.setting-callout span { color: #74665e; font-size: 0.75rem; }
.switch { position: relative; flex: 0 0 auto; width: 48px; height: 28px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span { position: absolute; inset: 0; border-radius: 999px; background: #b8c7cd; transition: background 150ms; }
.switch > span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.2); transition: transform 150ms; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid rgba(205,101,48,.25); outline-offset: 2px; }

.rule-preview { padding: 10px 13px; margin-bottom: 18px; border-radius: 9px; background: #f3f6f8; color: #526a76; font-size: 0.8rem; font-weight: 650; }
.check-row { display: flex; align-items: flex-start; gap: 11px; margin-top: 18px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.check-row input { width: 19px; min-height: 19px; margin-top: 2px; accent-color: var(--green); }
.check-row span { display: grid; }
.check-row strong { font-size: 0.86rem; }
.check-row small { color: var(--muted); font-size: 0.73rem; }
.comparison-intro { padding: 4px 0 2px; }
.comparison-intro p { margin: 6px 0 0; color: var(--muted); font-size: 0.85rem; }

.projection-settings { border-top: 4px solid var(--blue); }
.estimate-badge { padding: 6px 10px; border-radius: 999px; background: var(--green-pale); color: #9b431d; font-size: 0.75rem; font-weight: 850; }
.projection-copy { margin: -5px 0 18px; color: var(--muted); font-size: 0.83rem; }
.scenario-input-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.scenario-input { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fffcf9; }
.scenario-input > span { display: inline-flex; padding: 4px 7px; margin-bottom: 10px; border-radius: 7px; font-size: 0.7rem; font-weight: 900; }
.scenario-input.conservative > span { background: #edf1f3; color: #506671; }
.scenario-input.probable { border-color: #e5b89f; background: #fff8f3; }
.scenario-input.probable > span { background: var(--green-pale); color: #9b431d; }
.scenario-input.optimistic > span { background: #f2e8e1; color: #7c4a32; }
.scenario-input label { display: block; margin-bottom: 6px; color: #526873; font-size: 0.74rem; font-weight: 750; }
.scenario-input input { text-align: right; font-variant-numeric: tabular-nums; }
.fixed-cost-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, .75fr); align-items: end; gap: 16px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.break-even-box { min-height: 93px; display: grid; align-content: center; gap: 3px; padding: 13px 15px; border-radius: 11px; background: #f3ece7; }
.break-even-box span { color: #637985; font-size: 0.72rem; }
.break-even-box strong { color: #1e3b4a; font-size: 0.92rem; }
.break-even-box small { color: #788d97; font-size: 0.66rem; }

.result-column { display: grid; gap: 16px; position: sticky; top: 18px; }
.result-panel, .comparison-panel, .projection-result-panel { overflow: hidden; }
.result-heading { padding: 22px 24px; margin: 0; border-bottom: 1px solid rgba(255,255,255,.12); background: var(--navy); color: #fff; }
.result-step { color: #ef9a70; }
.result-state { padding: 5px 9px; border-radius: 999px; background: rgba(46,216,163,.13); color: #70edc5; font-size: 0.7rem; font-weight: 850; }
.result-state.waiting { background: rgba(255,255,255,.09); color: #b8cad3; }
.result-state.negative { background: rgba(255,116,124,.14); color: #ffabb1; }

.empty-result { min-height: 330px; display: grid; align-content: center; justify-items: center; padding: 38px; text-align: center; }
.empty-symbol { width: 74px; height: 74px; display: grid; place-items: center; margin-bottom: 16px; border-radius: 24px; background: var(--green-pale); color: #9b431d; font-weight: 900; font-size: 1.35rem; transform: rotate(-4deg); }
.empty-result strong { font-size: 1.02rem; }
.empty-result p { max-width: 330px; margin: 7px 0 0; color: var(--muted); font-size: 0.87rem; }

.result-content { padding: 24px; }
.hero-result { padding: 21px; border-radius: 14px; background: linear-gradient(135deg, #d97845 0%, #b64e21 72%, #963c18 100%); color: #fff; box-shadow: 0 16px 32px rgba(182, 78, 33, .24), inset 0 1px 0 rgba(255,255,255,.18); }
.hero-result > span { color: #fff2e9; font-size: 0.78rem; font-weight: 700; }
.hero-result > strong { display: block; margin: 6px 0 13px; font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1; letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.hero-result.negative { background: linear-gradient(135deg, #7b3038, #a23842); box-shadow: 0 16px 32px rgba(162, 56, 66, .2), inset 0 1px 0 rgba(255,255,255,.14); }
.margin-line { display: flex; justify-content: space-between; gap: 18px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.24); color: #fff2e9; font-size: 0.8rem; }
.margin-line b { color: #d5f7e9; font-size: 0.9rem; }
.hero-result.negative .margin-line b { color: #ffc1c5; }

.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin: 18px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.metric { display: grid; gap: 5px; padding: 14px; background: #fff; }
.metric span { color: var(--muted); font-size: 0.72rem; }
.metric strong { font-size: 1rem; font-variant-numeric: tabular-nums; }

.price-guidance { display: grid; gap: 0; overflow: hidden; border: 1px solid #ddb49e; border-radius: 12px; background: #fff9f5; box-shadow: 0 10px 24px rgba(91, 61, 44, .08); }
.price-guidance div { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 14px 16px; }
.price-guidance div + div { background: #255f63; }
.price-guidance span { color: #6f5547; font-size: 0.76rem; }
.price-guidance strong { color: #a9471e; font-size: 0.97rem; text-align: right; }
.price-guidance div + div span { color: #e7f5f3; }
.price-guidance div + div strong { color: #fff; }

.pending-alert { margin-top: 16px; padding: 13px 14px; border: 1px solid #efd79e; border-radius: 11px; background: #fff8e6; }
.pending-alert strong { color: #82520b; font-size: 0.82rem; }
.pending-alert p { margin: 4px 0 0; color: #765f35; font-size: 0.75rem; }

.breakdown { margin-top: 20px; border-top: 1px solid var(--line); }
.breakdown summary { padding: 17px 0 10px; color: #304a58; font-size: 0.82rem; font-weight: 850; cursor: pointer; }
.breakdown-row { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; color: #5f737e; font-size: 0.76rem; }
.breakdown-row strong { color: #2d4654; font-variant-numeric: tabular-nums; }
.breakdown-row.total { margin-top: 6px; padding-top: 11px; border-top: 1px dashed var(--line-strong); font-weight: 800; }

.projection-result-panel { border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); }
.projection-result-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.projection-result-heading > div { display: flex; align-items: center; gap: 10px; }
.projection-result-heading h2 { margin: 0; font-size: 1rem; }
.projection-market { padding: 5px 8px; border-radius: 999px; background: #f2e9e3; color: #6c5d55; font-size: .68rem; font-weight: 850; }
.projection-empty { padding: 25px 20px; color: var(--muted); text-align: center; font-size: .8rem; }
.projection-cards { display: grid; gap: 10px; padding: 16px; }
.projection-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.projection-card.is-probable { border-color: #e2ad90; box-shadow: inset 3px 0 0 var(--green); }
.projection-card-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: #f8f2ed; }
.projection-card-header strong { font-size: .8rem; }
.projection-card-header span { color: #55707d; font-size: .7rem; font-weight: 750; }
.projection-card-body { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; }
.projection-metric { display: grid; gap: 2px; padding: 10px 12px; border-top: 1px solid #edf2f4; }
.projection-metric:nth-child(odd) { border-right: 1px solid #edf2f4; }
.projection-metric span { color: #71858f; font-size: .66rem; }
.projection-metric strong { color: #274553; font-size: .82rem; font-variant-numeric: tabular-nums; }
.projection-metric .positive-text { color: #087552; }
.projection-metric .negative-text { color: var(--danger); }
.projection-warning { margin: 0 16px 16px; padding: 10px 12px; border-radius: 9px; background: #fff8e6; color: #765f35; font-size: .7rem; }

.comparison-panel .result-heading { background: #2d2927; }
.comparison-empty { min-height: 220px; display: grid; place-items: center; padding: 30px; color: var(--muted); text-align: center; }
.comparison-table-wrap { overflow-x: auto; padding: 18px; }
table { width: 100%; border-collapse: collapse; min-width: 650px; font-size: 0.78rem; }
th { padding: 10px; color: #667d88; text-align: right; font-size: 0.68rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
td { padding: 14px 10px; text-align: right; border-bottom: 1px solid #edf1f3; font-variant-numeric: tabular-nums; }
.market-name { display: flex; align-items: center; gap: 8px; font-weight: 850; }
.mini-market { width: 9px; height: 9px; border-radius: 3px; }
.mini-market.shopee { background: var(--orange); }
.mini-market.mercadolivre { background: var(--yellow); }
.mini-market.amazon { background: #27394b; }
.positive-text { color: #087552; font-weight: 850; }
.negative-text { color: var(--danger); font-weight: 850; }
.partial-mark { display: block; color: var(--warning); font-size: 0.65rem; font-weight: 750; }
.table-note { margin: 14px 2px 2px; color: var(--muted); font-size: 0.72rem; }
.monthly-comparison { margin-top: 22px; padding-top: 19px; border-top: 1px solid var(--line); }
.monthly-comparison-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 14px; }
.monthly-comparison-heading > div { display: grid; gap: 2px; }
.monthly-comparison-heading strong { font-size: .86rem; }
.monthly-comparison-heading span { color: var(--muted); font-size: .7rem; }
.monthly-comparison-heading label { display: grid; gap: 4px; color: #607681; font-size: .68rem; font-weight: 750; }
.monthly-comparison-heading select { min-height: 38px; min-width: 145px; padding-block: 6px; font-size: .76rem; }
.monthly-comparison-empty { padding: 18px; border-radius: 10px; background: #f3f6f8; color: var(--muted); text-align: center; font-size: .76rem; }

.source-note { padding: 18px 20px; box-shadow: none; background: rgba(255,255,255,.68); }
.source-note strong { font-size: 0.82rem; }
.source-note p { margin: 5px 0 12px; color: var(--muted); font-size: 0.75rem; }
.source-links { display: flex; flex-wrap: wrap; gap: 8px; }
.source-links a { padding: 6px 9px; border-radius: 8px; background: #fff; color: #a44820; text-decoration: none; font-size: 0.72rem; font-weight: 750; }
.source-links a:hover { text-decoration: underline; }

[hidden] { display: none !important; }

@media (max-width: 1060px) {
  .workspace { grid-template-columns: 1fr; }
  .result-column { position: static; }
  .field-grid.three-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scenario-input-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .target-field { padding-left: 0; border-left: 0; }
}

@media (max-width: 680px) {
  .app-header { align-items: flex-start; }
  .brand { gap: 12px; }
  .brand-logo-frame { width: 132px; flex-basis: 132px; }
  .brand-logo-frame img { width: 174px; left: -20px; top: -68px; }
  .brand-product { padding-left: 12px; font-size: 0.76rem; }
  .header-meta { display: none; }
  .app-shell { padding-top: 24px; }
  .intro-row { align-items: stretch; flex-direction: column; }
  .button-secondary { align-self: flex-start; }
  .field-grid, .field-grid.three-columns { grid-template-columns: 1fr; }
  .scenario-input-grid, .fixed-cost-row { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .panel { padding: 20px 17px; border-radius: 15px; }
  .panel-heading { align-items: flex-start; }
  .panel-hint { max-width: 120px; text-align: right; }
  .result-content { padding: 17px; }
  .metric-grid { grid-template-columns: 1fr; }
  .monthly-comparison-heading { align-items: stretch; flex-direction: column; }
  .price-guidance div { align-items: flex-start; flex-direction: column; gap: 2px; }
  .market-tab { padding-inline: 13px; }
}

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