/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f5f0;
  --surface: #ffffff;
  --surface-2: #f0efe8;
  --ink: #15201b;
  --ink-2: #4b5a53;
  --muted: #7a877f;
  --line: #e2e0d6;
  --accent: #0b6b4f;
  --accent-2: #e5f3ec;
  --green: #12924f;
  --yellow: #c98a00;
  --red: #cf3b2e;
  --c-tax: #9aa6a0;
  --c-prod: #3a5a8c;
  --c-ship: #6f8fc4;
  --c-fee: #a879c9;
  --c-other: #c9a279;
  --c-ads: #e07a4a;
  --c-profit: #12924f;
  --radius: 18px;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", "Manrope", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 1px 2px rgba(21, 32, 27, .04), 0 12px 32px -12px rgba(21, 32, 27, .12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #1e2723;
    --ink: #eef2ef;
    --ink-2: #b6c2bc;
    --muted: #8a9890;
    --line: #2a3530;
    --accent: #3ccf93;
    --accent-2: #183a2c;
    --green: #3ccf93;
    --yellow: #f2b632;
    --red: #ff6b5c;
    --c-profit: #3ccf93;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -12px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0f1412;
  --surface: #171e1b;
  --surface-2: #1e2723;
  --ink: #eef2ef;
  --ink-2: #b6c2bc;
  --muted: #8a9890;
  --line: #2a3530;
  --accent: #3ccf93;
  --accent-2: #183a2c;
  --green: #3ccf93;
  --yellow: #f2b632;
  --red: #ff6b5c;
  --c-profit: #3ccf93;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -12px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.1; letter-spacing: -0.02em; }
fieldset { border: 0; padding: 0; min-width: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1080px; margin-inline: auto; padding-inline: 16px; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 99;
  padding: .6rem 1rem; background: var(--ink); color: var(--bg); border-radius: 8px;
}
.skip-link:focus { top: 1rem; }
.muted { color: var(--muted); font-weight: 500; }

/* =============================================================
   4. Header / hero
   ============================================================= */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 1.25rem; color: var(--accent); }
.logo span { color: var(--ink); }
.header-link { font-size: .9rem; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.header-link:hover { color: var(--accent); }

.hero { padding-top: 24px; padding-bottom: 16px; }
.hero h1 { font-family: var(--display); font-weight: 800; font-size: clamp(1.7rem, 5vw, 2.8rem); }
.subtitle { margin-top: 8px; color: var(--ink-2); max-width: 60ch; font-size: 1rem; }

/* =============================================================
   5. Tool card
   ============================================================= */
.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr;
}
.noscript { padding: 20px; color: var(--red); font-weight: 600; }

.tool-form { padding: 18px; display: grid; gap: 18px; }
legend {
  font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
fieldset { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field label, .target label { font-size: .9rem; font-weight: 600; }
.field small, .hint { font-size: .78rem; color: var(--muted); line-height: 1.4; }
.hint { margin-top: -4px; }

.input-wrap {
  display: flex; align-items: center;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: 12px;
  transition: border-color .2s var(--ease-out), background .2s var(--ease-out);
}
.input-wrap:focus-within { border-color: var(--accent); background: var(--surface); }
.input-wrap input {
  flex: 1; min-width: 0; width: 100%;
  border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 1.05rem; font-weight: 600;
  padding: 11px 4px 11px 14px;
  outline: none;
}
.input-wrap .unit { padding-right: 14px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.input-wrap:has(input.is-invalid) { border-color: var(--red); }
.input-wrap.small { max-width: 160px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: .8rem; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-2);
  transition: border-color .2s var(--ease-out), color .2s var(--ease-out);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* Results */
.results {
  padding: 18px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--accent-2), transparent 140px);
  border-radius: 0 0 var(--radius) var(--radius);
  display: grid; align-content: start; gap: 6px;
}
.verdict {
  display: inline-flex; align-items: center; gap: 8px; justify-self: start;
  padding: 6px 12px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--line); font-weight: 700; font-size: .88rem;
}
.verdict-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.verdict[data-level="green"] .verdict-dot { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 20%, transparent); }
.verdict[data-level="yellow"] .verdict-dot { background: var(--yellow); box-shadow: 0 0 0 4px color-mix(in srgb, var(--yellow) 20%, transparent); }
.verdict[data-level="red"] .verdict-dot { background: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 20%, transparent); }

.big-label { margin-top: 12px; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.big-number {
  font-family: var(--display); font-weight: 800; line-height: 1;
  font-size: clamp(2.6rem, 9vw, 3.6rem); letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.big-number[data-level="green"] { color: var(--green); }
.big-number[data-level="yellow"] { color: var(--yellow); }
.big-number[data-level="red"] { color: var(--red); }
.big-sub { color: var(--ink-2); font-size: .95rem; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 2px; }
.stat-label { font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.stat-value { font-family: var(--display); font-weight: 800; font-size: 1.5rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-help { font-size: .72rem; color: var(--muted); line-height: 1.3; }

.breakdown { margin-top: 14px; }
.breakdown-title { font-size: .85rem; font-weight: 700; margin-bottom: 8px; }
.bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.seg { height: 100%; transition: width .35s var(--ease-out); }
.legend { list-style: none; padding: 0; margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }
.legend .loss b { color: var(--red); }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.c-tax { background: var(--c-tax); } .c-prod { background: var(--c-prod); } .c-ship { background: var(--c-ship); }
.c-fee { background: var(--c-fee); } .c-other { background: var(--c-other); } .c-ads { background: var(--c-ads); }
.c-profit { background: var(--c-profit); } .c-loss { background: var(--red); }

.target {
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px;
}
.target-result { grid-column: 1 / -1; font-size: .95rem; color: var(--ink-2); }
.target-result strong { color: var(--ink); font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.btn { padding: 12px 16px; border-radius: 12px; font-weight: 700; font-size: .92rem; transition: transform .2s var(--ease-out), background .2s var(--ease-out); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0b1a14; } }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border: 1px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--ink-2); }

.privacy { margin-top: 12px; font-size: .82rem; color: var(--ink-2); }

/* Sticky result (móvil) */
.sticky-result {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
  transform: translateY(140%); transition: transform .35s var(--ease-out);
  font-size: .9rem; font-weight: 600;
}
.sticky-result strong { font-family: var(--display); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.sticky-result.is-on { transform: translateY(0); }
.sticky-result[data-level="red"] strong { color: #ff8b80; }
.sticky-result[data-level="yellow"] strong { color: #ffc94d; }
.sticky-result[data-level="green"] strong { color: #5fe0a8; }
@media (prefers-color-scheme: dark) {
  .sticky-result[data-level="red"] strong { color: var(--red); }
  .sticky-result[data-level="yellow"] strong { color: #9a6b00; }
  .sticky-result[data-level="green"] strong { color: #0b6b4f; }
}

/* =============================================================
   6. Ads + content
   ============================================================= */
.ad-slot {
  margin: 28px 0; min-height: 100px;
  border: 1.5px dashed var(--line); border-radius: 12px;
  display: grid; place-items: center;
  color: var(--muted); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase;
}
.ad-incontent { min-height: 250px; }

.content { padding-bottom: 48px; }
.content h2 { font-family: var(--display); font-weight: 800; font-size: clamp(1.35rem, 3.5vw, 1.8rem); margin: 32px 0 14px; }
.steps { list-style: none; padding: 0; display: grid; gap: 12px; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.steps svg { width: 26px; height: 26px; color: var(--accent); margin-bottom: 8px; }
.steps h3 { font-size: 1.05rem; margin-bottom: 4px; }
.steps p { color: var(--ink-2); font-size: .95rem; }

.prose { max-width: 70ch; }
.prose p { color: var(--ink-2); margin-bottom: 14px; }

.faq { display: grid; gap: 8px; max-width: 70ch; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; }
.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq details p { padding-bottom: 14px; color: var(--ink-2); }

.site-footer { border-top: 1px solid var(--line); padding: 24px 0 90px; font-size: .85rem; color: var(--muted); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; }
.footer-inner nav { display: flex; gap: 16px; }

/* Legal pages */
.legal { padding: 32px 16px 64px; max-width: 70ch; }
.legal h1 { font-family: var(--display); font-weight: 800; font-size: 2rem; margin-bottom: 16px; }
.legal h2 { font-size: 1.15rem; margin: 24px 0 8px; }
.legal p { color: var(--ink-2); margin-bottom: 10px; }
.legal .todo { background: #fff3c4; color: #5c4400; padding: 2px 6px; border-radius: 4px; font-weight: 600; }

/* =============================================================
   8. Responsive
   ============================================================= */
@media (min-width: 720px) {
  .tool-form, .results { padding: 24px; }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .site-footer { padding-bottom: 24px; }
}
@media (min-width: 960px) {
  .tool-card { grid-template-columns: 1.05fr 1fr; }
  .results {
    border-top: 0; border-left: 1px solid var(--line);
    border-radius: 0 var(--radius) var(--radius) 0;
    position: sticky; top: 0; align-self: start;
  }
  .sticky-result { display: none; }
}
