:root {
  color-scheme: light;
  --ink: #15263a;
  --muted: #4c6077;
  --line: #d8e2ed;
  --paper: #fff;
  --canvas: #f3f6fa;
  --navy: #122233;
  --blue: #175bd5;
  --blue-light: #eaf2ff;
  --teal: #b3f8e9;
  --radius: 20px;
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { opacity: .56; cursor: wait; }
button, input, select, textarea { border-radius: 11px; }
:focus-visible { outline: 3px solid #5e9cff; outline-offset: 3px; }
h1, h2, p, dl { margin: 0; }
h1 { font-size: clamp(1.5rem, 4.5vw, 2rem); line-height: 1.28; letter-spacing: -.035em; }
h2 { font-size: 1.1rem; font-weight: 700; }
.shell { width: min(100% - 32px, 960px); margin-inline: auto; }
.topbar { background: var(--navy); color: white; }
.topbar-inner { display: flex; gap: 12px; min-height: 65px; align-items: center; }
.brand { font-size: 1.04rem; letter-spacing: .035em; }
.brand-icon { width: 34px; height: 34px; background: #2b6be1 url("/icon-192.png") center / cover; border-radius: 9px; flex: none; }
.role { margin-inline-start: auto; color: #ccdef2; font-size: .875rem; white-space: nowrap; }
main.shell { margin-block: 26px 55px; }
.surface { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 23px #172f4b08; }
.tabs { display: inline-flex; background: #e4ebf5; padding: 4px; border-radius: 13px; gap: 3px; margin-bottom: 16px; }
.tabs button { border: 0; background: transparent; color: var(--muted); font-weight: 700; min-height: 43px; padding: 7px 19px; }
.tabs button[aria-pressed="true"] { background: white; color: #174d9e; box-shadow: 0 2px 5px #20334c14; }
.sales-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); align-items: start; }
.entry, .result, .admin-heading, .edit-section, .setup { padding: clamp(18px, 3.8vw, 30px); }
.intro { margin: 8px 0 22px; color: var(--muted); }
.control { display: grid; gap: 6px; align-content: start; min-width: 0; }
.control > span { color: #3b5069; font-size: .92rem; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #becdde; background: #fbfcff; padding: 11px 12px; min-height: 48px; }
input::placeholder, textarea::placeholder { color: #62758c; opacity: 1; }
textarea { display: block; min-height: 76px; resize: vertical; }
select {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, #4c6077 50%), linear-gradient(135deg, #4c6077 50%, transparent 50%);
  background-position: calc(100% - 19px) 53%, calc(100% - 13px) 53%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-block: 18px 23px; }
.control .with-unit { position: relative; display: block; color: var(--ink); }
.with-unit input { padding-right: 66px; }
.unit-label { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .84rem; max-width: 58px; overflow-wrap: anywhere; pointer-events: none; }
.primary, .secondary, .subtle { min-height: 44px; padding: 9px 15px; font-weight: 700; border: 1px solid transparent; }
.primary { background: var(--blue); color: #fff; }
.primary:hover { background: #1249af; }
.secondary { background: var(--blue-light); color: #174d9e; border-color: #cfddf2; }
.secondary:hover { background: #dceaff; }
.subtle { color: #4c6077; background: white; border-color: var(--line); }
.demo-note { margin-top: 10px; padding: 8px 11px; border-radius: 9px; background: #fff2d9; color: #6f4806; font-size: .9rem; }
.result { min-height: 320px; background: var(--navy); color: white; border-color: var(--navy); }
.result h2 { color: #e5eef8; }
.result-placeholder { min-height: 214px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 13px; color: #c2d1e2; }
.result-mark { display: grid; place-items: center; width: 53px; height: 53px; border-radius: 14px; border: 1px solid #43617d; background: #1f354d; font-size: 1.3rem; }
.result-focus { padding: 21px 0 15px; color: var(--teal); }
.result-focus dt { color: #cadced; }
.result-focus dd { font-size: clamp(2.1rem, 6.5vw, 3rem); font-weight: 750; letter-spacing: -.04em; line-height: 1.2; margin: 5px 0 0; overflow-wrap: anywhere; }
.result-focus small { font-size: 1rem; font-weight: 650; margin-left: 7px; letter-spacing: normal; }
.result-parts > div { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 10px 0; border-top: 1px solid #39516a; }
.result-parts dt { color: #d2e0ef; overflow-wrap: anywhere; }
.result-parts dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result .demo-note { background: #263b50; color: #e4eefe; margin: 2px 0 12px; }
.setup { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.setup p { color: var(--muted); font-size: .92rem; }
.setup button { flex-shrink: 0; }
.message { background: #e9f2ff; color: #164880; padding: 10px 13px; border-radius: 10px; margin-block: 12px; overflow-wrap: anywhere; }
.message[data-error="true"] { color: #792329; background: #fce7e7; }
.message.compact { font-size: .92rem; }
.admin-heading { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 14px; }
.admin-heading .intro { margin-bottom: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.link-settings { margin-top: 16px; padding: clamp(16px, 3vw, 24px); }
.link-settings summary { font-weight: 700; cursor: pointer; }
.link-settings .intro { margin-bottom: 12px; }
.link-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.link-form .control { flex: 1 1 170px; }
.link-form button { min-height: 48px; }
.created-link { margin-top: 14px; }
.mobile-link-list { margin: 12px 0 0; padding: 0; list-style: none; }
.mobile-link-list:empty { display: none; }
.mobile-link-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.mobile-link-row button { flex: none; }
.link-inactive { color: var(--muted); white-space: nowrap; }
#manage-picker { flex: 1 0 100%; max-width: 440px; }
#editor { display: grid; gap: 14px; margin-top: 16px; }
.edit-section > p { color: var(--muted); margin: 4px 0 14px; }
.edit-section > .actions { margin-top: 15px; }
.edit-row { display: grid; align-items: end; gap: 10px; grid-template-columns: minmax(0, 1.4fr) minmax(0, .72fr) minmax(0, 1fr) auto; margin-top: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; }
.edit-row.two { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; }
.edit-row.input-row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; }
.field-settings { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.edit-row.formula { grid-template-columns: minmax(0, 1.4fr) minmax(0, .65fr) minmax(12rem, 1fr) auto; }
.formula-expression, .formula-tools { grid-column: 1 / -1; }
.formula-tools { display: grid; align-items: end; gap: 10px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.formula-tools button { justify-self: start; }
.toggle { display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: .92rem; min-height: 40px; }
.toggle input { width: 19px; height: 19px; min-height: 0; accent-color: var(--blue); }
.formula-help { margin-top: 12px; color: var(--muted); }
.formula-help summary { cursor: pointer; font-weight: 650; }
.formula-help p { margin-top: 7px; overflow-wrap: anywhere; }
#editor .result { min-height: 0; }
.edit-footer .actions { margin-bottom: 8px; }
.edit-footer .primary { min-width: 105px; }
@media (max-width: 690px) {
  main.shell { margin-top: 16px; }
  .sales-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .result { min-height: 216px; }
  .result-placeholder { min-height: 145px; }
  .edit-row, .edit-row.formula { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .edit-row.formula > .control:first-child, .result-format { grid-column: 1 / -1; }
  .edit-row.formula > .subtle { grid-column: 2; grid-row: 2; }
  .edit-row.two, .edit-row.input-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .edit-row .subtle { justify-self: end; }
}
@media (max-width: 355px) {
  .shell { width: calc(100% - 24px); }
  .setup { align-items: start; flex-direction: column; }
  .edit-row, .edit-row.formula, .edit-row.two, .edit-row.input-row, .field-settings, .formula-tools { grid-template-columns: minmax(0, 1fr); }
  .edit-row.formula > .subtle { grid-column: auto; grid-row: auto; }
}
