/* HNC Margin & Markup Calculator — mobile-first, Galaxy S26 Ultra ~412×915 */
:root {
  --green-950: #082019;
  --green-900: #0B2E24;
  --green-800: #0F3D2E;
  --green-700: #165A43;
  --green-600: #1B7A4A;
  --green-100: #E7F0EC;
  --bg: #F3F5F4;
  --card: #FFFFFF;
  --line: #E2E7E5;
  --text: #12241D;
  --muted: #5C6E67;
  --orange: #C56A14;
  --orange-bg: #FBF0E4;
  --red: #B42318;
  --red-bg: #FDECEC;
  --green-bg: #E6F5EC;
  --shadow: 0 1px 2px rgba(15, 61, 46, 0.06), 0 6px 18px rgba(15, 61, 46, 0.06);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Noto Sans SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  min-height: 100%;
}

body {
  min-height: 100dvh;
}

.page {
  max-width: 430px;
  margin: 0 auto;
  padding-bottom: calc(20px + var(--safe-bottom));
}

.header {
  background: var(--green-800);
  color: #fff;
  padding: calc(12px + var(--safe-top)) 20px 12px;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex: 0 0 44px;
  background: #fff;
}

.header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.header .zh {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0.92;
  margin-top: 1px;
}

.header .company {
  margin: 6px 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.78;
  font-weight: 600;
}

main {
  padding: 8px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px 10px;
  border: 1px solid rgba(15, 61, 46, 0.04);
}

.card-title {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green-700);
}

.card-title span {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  margin-left: 6px;
  color: var(--muted);
}

.field {
  margin-bottom: 8px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.field label .zh {
  color: var(--muted);
  font-weight: 500;
  margin-left: 6px;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  min-height: 44px;
}

.input-wrap:focus-within {
  border-color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(22, 90, 67, 0.15);
  background: #fff;
}

.affix {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 650;
  padding-right: 8px;
}

.affix.suffix {
  padding-right: 0;
  padding-left: 8px;
}

.input-wrap input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 1.35rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
  width: 100%;
  min-width: 0;
  padding: 8px 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}

.input-wrap input::placeholder {
  color: #B0BAB6;
  font-weight: 500;
}

.results .gp-block {
  padding: 2px 0 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.metric-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.metric-label .zh {
  font-weight: 500;
  margin-left: 6px;
}

.metric-value {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--green-800);
  line-height: 1.1;
}

.gp-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.gp-value {
  font-size: 2.05rem;
}

.gp-unit {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--muted);
  margin-left: 4px;
}

.gp-block.is-loss .gp-value,
.gp-block.is-low .gp-value {
  color: var(--red);
}

.gp-block.is-mid .gp-value {
  color: var(--orange);
}

.gp-block.is-ok .gp-value {
  color: var(--green-600);
}

.tier-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  max-width: 46%;
  white-space: nowrap;
}

.tier-badge .tier-zh {
  font-weight: 600;
  opacity: 0.92;
}

.tier-badge.tier-green {
  background: var(--green-bg);
  color: var(--green-600);
}

.tier-badge.tier-orange {
  background: var(--orange-bg);
  color: var(--orange);
}

.tier-badge.tier-red {
  background: var(--red-bg);
  color: var(--red);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.metric {
  background: var(--bg);
  border-radius: 10px;
  padding: 8px 10px;
}

.metric .metric-value {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
}

.total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.total-row .metric-value {
  font-size: 1.55rem;
}

.rm-prefix {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
  margin-right: 3px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.price-col {
  background: var(--bg);
  border-radius: 12px;
  padding: 8px 10px 10px;
  min-width: 0;
}

.price-col h3 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--green-800);
  line-height: 1.3;
}

.price-col h3 .zh {
  display: block;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.72rem;
}

.price-col .target-field label {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.price-col .input-wrap {
  min-height: 40px;
  padding: 0 8px;
  background: #fff;
}

.price-col .input-wrap input {
  font-size: 1.05rem;
}

.suggested {
  margin-top: 8px;
}

.suggested .metric-label {
  font-size: 0.68rem;
}

.suggested .metric-value {
  font-size: 1.55rem;
  margin-top: 2px;
  display: block;
}

.rates {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rates b {
  color: var(--text);
  font-weight: 750;
}

.actions {
  padding: 2px 0 4px;
}

.btn-reset {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--green-800);
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
}

.btn-reset:active {
  background: var(--green-100);
}

.privacy {
  margin: 6px 16px 0;
  text-align: center;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Confirm dialog */
.confirm[hidden] {
  display: none;
}

.confirm {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 32, 25, 0.45);
}

.confirm-sheet {
  position: relative;
  background: #fff;
  width: min(430px, 100%);
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  box-shadow: 0 -8px 32px rgba(8, 32, 25, 0.18);
}

.confirm-sheet h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.confirm-sheet p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.confirm-actions button {
  min-height: 46px;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.btn-danger {
  border: 0;
  background: var(--green-800);
  color: #fff;
}

@media (min-height: 860px) {
  .gp-value { font-size: 2.35rem; }
}

.metric-value.is-empty {
  font-weight: 500;
  color: #B0BAB6;
}

.gp-value .metric-value.is-empty,
.gp-value.is-empty,
#out-gp.is-empty {
  font-weight: 500;
  color: #B0BAB6;
}

span.is-empty,
.is-empty {
  font-weight: 500 !important;
  color: #B0BAB6 !important;
}
