:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --line: #dcdad4;
  --line-strong: #111111;
  --ink: #111111;
  --muted: #6b6b6b;
  --tax: #ef4444;
  --margin: #f59e0b;
  --product: #22c55e;
  --tax-text: #b91c1c;
  --margin-text: #92400e;
  --product-text: #15803d;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.banner {
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 48px 20px 60px;
}

header.top {
  margin-bottom: 32px;
}

.meta {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
}

h1 {
  font-family: var(--font-sans);
  font-size: 34px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--muted);
  font-size: 16.5px;
  margin: 0;
  max-width: 46ch;
}

.urdu {
  font-family: "Noto Nastaliq Urdu", var(--font-sans);
  line-height: 1.9;
}

h1.urdu {
  font-size: 32px;
  font-weight: 700;
}

.subtitle.urdu {
  font-size: 18px;
}

.panel {
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
  margin-bottom: -1px;
}

.panel + .panel {
  border-top: none;
}

.panel h2 {
  font-size: 13.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 16px;
}

.field label {
  display: none;
}

.mode-toggle {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.mode-btn {
  flex: 1;
  border: none;
  background: var(--panel);
  color: var(--muted);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 15px;
  padding: 10px 10px;
  cursor: pointer;
}

.mode-btn + .mode-btn {
  border-left: 1px solid var(--line-strong);
}

.mode-btn.active {
  background: var(--ink);
  color: #fff;
}

#quantityInput {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  padding: 14px 14px;
  margin-bottom: 12px;
}

#quantityInput:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--ink);
}

.chips {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14.5px;
  padding: 9px 6px;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--ink);
}

.btn-row {
  display: flex;
  gap: 8px;
}

.calculate-btn {
  flex: 1;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 600;
  padding: 14px;
  cursor: pointer;
  letter-spacing: 0.01em;
}

.calculate-btn:hover { background: #000; }

.calculate-btn:disabled {
  background: var(--muted);
  border-color: var(--muted);
  cursor: default;
}

.clear-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 600;
  padding: 14px 18px;
  cursor: pointer;
}

.clear-btn:hover {
  border-color: var(--ink);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
}

.result-label {
  font-size: 15px;
  color: var(--muted);
}

.result-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
}

.result-value.small {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

.muted-row {
  border-top: 1px dashed var(--line);
  margin-top: 4px;
  padding-top: 10px;
}

.split-bar {
  display: flex;
  height: 20px;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.split-seg { height: 100%; }
.split-product { background: var(--product); }
.split-tax { background: var(--tax); }
.split-margin { background: var(--margin); }
.split-seg + .split-seg { border-left: 2px solid #fff; }

.answer-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  font-size: 16px;
}

.answer-table tr {
  font-weight: 600;
}

.answer-table td {
  padding: 14px 14px;
  vertical-align: middle;
}

.answer-table td:first-child {
  border-radius: 10px 0 0 10px;
  border-left: 5px solid transparent;
}

.answer-table td:last-child {
  border-radius: 0 10px 10px 0;
}

.row-product td { background: color-mix(in srgb, var(--product) 14%, white); }
.row-product td:first-child { border-left-color: var(--product); }

.row-tax td { background: color-mix(in srgb, var(--tax) 10%, white); }
.row-tax td:first-child { border-left-color: var(--tax); }

.row-margin td { background: color-mix(in srgb, var(--margin) 14%, white); }
.row-margin td:first-child { border-left-color: var(--margin); }

.answer-table .num {
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
  padding-left: 10px;
  color: var(--ink);
}

.answer-label {
  font-weight: 700;
}

.answer-subtext {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.answer-table .num.strong {
  color: var(--product-text);
  font-weight: 800;
  font-size: 19px;
}

.row-tax .num { color: var(--tax-text); font-weight: 800; font-size: 17px; }
.row-margin .num { color: var(--margin-text); font-weight: 800; font-size: 17px; }

.answer-row.emphasis td {
  font-weight: 700;
}

.pct-badge {
  display: inline-block;
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  text-align: center;
}

.pct-product { background: var(--product); }
.pct-tax { background: var(--tax); }
.pct-margin { background: var(--margin); }

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
}

.breakdown-table td {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 15px;
}

.breakdown-table tr:last-child td {
  border-bottom: none;
}

.breakdown-table .label-cell {
  padding-right: 12px;
}

.breakdown-table .name {
  font-weight: 600;
  font-size: 15.5px;
}

.breakdown-table .desc {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 2px;
}

.breakdown-table .nested .name {
  color: var(--muted);
  font-weight: 500;
}

.breakdown-table .val {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  white-space: nowrap;
}

.breakdown-table .nested .val {
  color: var(--muted);
  font-weight: 500;
}

footer {
  color: var(--muted);
  font-size: 12px;
  margin-top: 24px;
  padding-top: 16px;
}

footer p { margin: 0; }
