/* MarginMint - one stylesheet, no build step. A tool opened next to the seller centre tab:
   dense, quiet, numbers first. Palette tokens follow Renewal Radar's. */

:root {
  color-scheme: light dark;
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f4f3ef;
  --border: #e3e1dc;
  --text: #17191b;
  --muted: #646a70;
  --accent: #0e7c66;
  --accent-text: #0a5c4c;
  --good: #0e7c66;
  --warn: #a35a06;
  --warn-soft: #fdf1e0;
  --danger: #b02a21;
  --danger-soft: #fdeceb;
  --ok-soft: #e2f2ee;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic",
          "Apple SD Gothic Neo", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f11;
    --surface: #16191d;
    --surface-2: #1c2025;
    --border: #2a2f36;
    --text: #eceef0;
    --muted: #9aa1a9;
    --accent: #35c9a5;
    --accent-text: #6fe0c2;
    --good: #35c9a5;
    --warn: #e0a04a;
    --warn-soft: #2c2113;
    --danger: #f0776c;
    --danger-soft: #2e1715;
    --ok-soft: #0f2b26;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans);
       /* Sellers read alerts on phones: long URLs and product names wrap instead of widening
          the page, and Korean breaks between words, not inside them. */
       overflow-wrap: break-word; word-break: keep-all; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
a { color: var(--accent-text); }
pre { white-space: pre-wrap; font: .85rem/1.5 var(--mono); background: var(--surface-2);
      padding: .8rem; border-radius: 6px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 1.5rem; padding-bottom: 2rem; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 8px; top: 8px; background: var(--surface); padding: .4rem; z-index: 9; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 1rem; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.nav { display: flex; gap: .9rem; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a.active, .nav a:hover { color: var(--text); }
.inline { display: inline; }

.row { display: flex; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; gap: .8rem; }
.gap { gap: .4rem 1rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; }
.lead { font-size: 1.05rem; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.narrow { max-width: 460px; margin: 1rem auto; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
         gap: 1rem; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
         gap: 1rem;
         align-items: start; }

.btn { display: inline-block; padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--border);
       background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
       text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: .3rem .7rem; font-size: .88rem; }
.btn-lg { padding: .7rem 1.2rem; font-size: 1.05rem; }
.btn-block { display: block; width: 100%; text-align: center; }

.notice { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; background: var(--surface-2); }
.notice.ok { background: var(--ok-soft); }
.notice.err { background: var(--danger-soft); color: var(--danger); }

fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend { font-weight: 650; margin-bottom: .4rem; }
.field { margin-bottom: .8rem; }
.field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .2rem; }
.input-row { display: flex; align-items: center; gap: .4rem; }
input:not([type=checkbox]), select { width: 100%; padding: .5rem .6rem; border-radius: 6px;
       border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.suffix { color: var(--muted); min-width: 1.4rem; }
.has-error input, .has-error select { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .85rem; margin: .2rem 0 0; }
.field .hint { margin: .2rem 0 0; }
.check { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .8rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
         gap: .8rem;
         margin-bottom: .8rem; }
.stat { background: var(--surface-2); border-radius: 8px; padding: .8rem .9rem; display: flex;
        flex-direction: column; gap: .15rem; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .85rem; color: var(--muted); }
.stat.good .stat-value { color: var(--good); }
.stat.bad .stat-value, .headroom.bad { color: var(--danger); }
.stat.warn .stat-value { color: var(--warn); }
.headroom { font-weight: 650; }

.kv { border-collapse: collapse; margin: .4rem 0 1rem; }
.kv th { text-align: left; font-weight: 400; color: var(--muted); padding: .2rem 1.5rem .2rem 0; }
.kv td { text-align: right; font-variant-numeric: tabular-nums; }
.kv .total th, .kv .total td { font-weight: 700; color: var(--text); border-top: 1px solid var(--border); }
.assumptions { padding-left: 1.2rem; font-size: .88rem; color: var(--muted); }

.split > *, .grid3 > *, .stats > * { min-width: 0; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.alert-item a, .row a { overflow-wrap: anywhere; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data th, .data td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); text-align: left;
                     white-space: nowrap; }
.data th { color: var(--muted); font-weight: 600; }
.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.data tr.neg td.num { color: var(--danger); }
.data tr.paused { opacity: .6; }

.alerts { list-style: none; padding: 0; margin: 0; }
.alert-item { display: flex; flex-wrap: wrap; gap: .3rem .8rem; padding: .5rem 0;
              border-bottom: 1px solid var(--border); }
.alert-item.unread { font-weight: 600; }
.badge { font-size: .78rem; padding: .05rem .5rem; border-radius: 99px; background: var(--surface-2); }
.badge.kind-negative_margin, .badge.kind-sold_out { background: var(--danger-soft); color: var(--danger); }
.badge.kind-below_floor, .badge.kind-price_up { background: var(--warn-soft); color: var(--warn); }
.badge.kind-recovered { background: var(--ok-soft); color: var(--good); }

.hero { padding: 1.5rem 0 1rem; }
.hero h1 { font-size: 2rem; max-width: 22em; }
@media (max-width: 480px) {
  .hero h1 { font-size: 1.5rem; }
  .card { padding: .9rem; }
  .stat-value { font-size: 1.25rem; }
  .topbar-inner { gap: .5rem; padding-top: .4rem; padding-bottom: .4rem; }
}
.price { font-size: 1.3rem; font-weight: 700; }
.danger-zone { border-color: var(--danger-soft); }

footer.site { border-top: 1px solid var(--border); padding: 1.2rem 0 2rem; font-size: .85rem;
              color: var(--muted); }
footer.site a { color: var(--muted); }
.disclaimer { color: var(--text); }
.business { font-size: .78rem; }
.brand-tag { font-weight: 400; font-size: .8rem; color: var(--muted); margin-left: .3rem; }
@media (max-width: 480px) { .brand-tag { display: none; } }
/* On a phone the form is long: once there is an answer, show it above the form instead of
   making the seller scroll past every input to find it. */
@media (max-width: 720px) { .split > .has-result { order: -1; } }

/* --- phase 2a: sourcing choice, overseas fields, notices, landing ledger, legal pages ----- */
.choice legend { font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }
.radio { display: inline-flex; align-items: center; gap: .35rem; font-weight: 400; }
.radio input { width: auto; margin: 0; }
.sub-legend { font-weight: 650; margin: .4rem 0 .4rem; }
.sourcing-overseas { border-left: 3px solid var(--border); padding-left: .8rem; margin-bottom: .8rem; }
/* Show only the block for the chosen sourcing mode. No script: :has() does it, and a browser
   without :has() shows both (the server ignores the block not chosen). */
@supports selector(:has(*)) {
  form:has(input[name=sourcing][value=domestic]:checked) .sourcing-overseas { display: none; }
  form:has(input[name=sourcing][value=overseas]:checked) .sourcing-domestic { display: none; }
}
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.source-line { font-size: .9rem; font-variant-numeric: tabular-nums; }

.eyebrow { color: var(--accent-text); font-weight: 650; margin-bottom: .4rem; }
.ledger { width: 100%; max-width: 560px; }
.ledger th { padding-right: .8rem; }
.ledger .naive th, .ledger .naive td { color: var(--muted); font-weight: 600; }
.ledger td.pos { color: var(--good); }
.ledger td.neg { color: var(--danger); }
.tag { font-size: .72rem; padding: 0 .4rem; border-radius: 99px; background: var(--surface-2);
       color: var(--muted); white-space: nowrap; }
ul.plain { padding-left: 1.2rem; margin: 0; }
ul.plain li { margin-bottom: .3rem; }

.legal { max-width: 760px; }
.legal h2 { margin-top: 1.6rem; }
.legal li { margin-bottom: .35rem; }
