:root {
  color-scheme: dark;
  --bg: #08111f;
  --panel: #0f1b2d;
  --panel-2: #11233c;
  --line: rgba(255,255,255,.08);
  --text: #e9eef8;
  --muted: #95a7c4;
  --primary: #35d0a1;
  --warning: #ffcf63;
  --danger: #ff6b6b;
  --ok: #37d67a;
  --shadow: 0 20px 50px rgba(0,0,0,.28);
  --bg-body: radial-gradient(circle at top right, rgba(53,208,161,.12), transparent 25%), radial-gradient(circle at left top, rgba(100,149,237,.14), transparent 25%), var(--bg);
  --input-bg: rgba(255,255,255,.06);
  --input-border: var(--line);
  --input-text: var(--text);
  --placeholder: rgba(233,238,248,.58);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --panel-2: #f8fbff;
  --line: rgba(8,17,31,.10);
  --text: #101828;
  --muted: #5b6472;
  --primary: #0ea47a;
  --warning: #b7791f;
  --danger: #d92d20;
  --ok: #14804a;
  --shadow: 0 20px 40px rgba(16,24,40,.08);
  --bg-body: radial-gradient(circle at top right, rgba(14,164,122,.10), transparent 24%), radial-gradient(circle at left top, rgba(83,194,255,.12), transparent 24%), var(--bg);
  --input-bg: #ffffff;
  --input-border: rgba(16,24,40,.12);
  --input-text: #101828;
  --placeholder: rgba(16,24,40,.42);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, sans-serif;
  background: var(--bg-body);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.app-shell { display: grid; grid-template-columns: 320px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line);
  padding: 28px 22px;
  background: rgba(7,14,25,.72);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand-badge, .eyebrow, .ref, .hero-label, .field-top, .nav-link, .progress-text {
  font-family: "IBM Plex Mono", monospace;
}
.brand-badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(53,208,161,.12);
  border: 1px solid rgba(53,208,161,.22);
  color: var(--primary);
  font-size: 11px;
  margin-bottom: 14px;
}
.brand h1 { margin: 0 0 8px; font-size: 28px; }
.brand p { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.side-nav { display: grid; gap: 8px; margin-bottom: 24px; }
.nav-link {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
}
.nav-link.active, .nav-link:hover {
  color: var(--text);
  border-color: rgba(53,208,161,.32);
  background: rgba(53,208,161,.08);
}
.status-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.status-card h2 { font-size: 16px; margin: 0 0 12px; }
.status-box {
  border-radius: 14px;
  padding: 14px;
  line-height: 1.55;
  border: 1px solid var(--line);
  color: var(--text);
}
.status-box.neutral { background: rgba(255,255,255,.03); }
.status-box.ok { background: rgba(55,214,122,.10); border-color: rgba(55,214,122,.25); }
.status-box.warn { background: rgba(255,207,99,.10); border-color: rgba(255,207,99,.25); }
.status-box.danger { background: rgba(255,107,107,.10); border-color: rgba(255,107,107,.25); }
.mini-metrics { display: grid; gap: 8px; margin-top: 12px; }
.metric { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.metric strong { color: var(--text); }
.compact .stack { display: grid; gap: 10px; }
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, #2dd3a0, #53c2ff); color: #07111f; }
.btn-secondary { background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.main-content { padding: 28px; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 24px;
}
.topbar h2 { margin: 6px 0; font-size: clamp(28px, 4vw, 42px); }
.topbar p, .helper { color: var(--muted); }
.progress-wrap { min-width: 220px; }
.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar span { display: block; height: 100%; width: 14.28%; background: linear-gradient(135deg, #2dd3a0, #53c2ff); }
.step { display: none; }
.step.active { display: block; }
.section-header { margin-bottom: 18px; }
.section-header h3 { margin: 0 0 8px; font-size: 24px; }
.section-header p { margin: 0; color: var(--muted); }
.card-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid.single { grid-template-columns: 1fr; }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.025));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.card.accent { border-color: rgba(53,208,161,.28); }
.card h4 { margin: 0 0 16px; font-size: 18px; }
.field-grid { display: grid; gap: 16px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field-top { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.ref {
  color: #74d7ff;
  font-size: 11px;
  opacity: .9;
}
input, select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--input-text);
  border-radius: 14px;
  padding: 13px 14px;
  font: inherit;
  min-height: 48px;
}
input::placeholder { color: var(--placeholder); }
input:focus, select:focus {
  outline: none;
  border-color: rgba(53,208,161,.45);
  box-shadow: 0 0 0 4px rgba(53,208,161,.12);
  background: color-mix(in srgb, var(--input-bg) 88%, var(--primary) 12%);
}
.money input { padding-left: 26px; }
.money { position: relative; }
.money::after {
  content: "€";
  position: absolute;
  left: 12px;
  bottom: 14px;
  color: var(--primary);
  font-size: 13px;
}
.chip-group { display: flex; gap: 10px; flex-wrap: wrap; }
.chip input { display: none; }
.chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  background: rgba(255,255,255,.03);
}
.chip input:checked + span { border-color: rgba(53,208,161,.34); background: rgba(53,208,161,.1); color: var(--text); }
.hero-result {
  border-radius: 28px;
  padding: 28px;
  background: linear-gradient(145deg, rgba(83,194,255,.12), rgba(53,208,161,.08));
  border: 1px solid rgba(83,194,255,.18);
  margin-bottom: 18px;
}
.hero-amount { font-size: clamp(40px, 7vw, 74px); font-weight: 800; line-height: 1; margin: 8px 0 10px; }
.hero-text { color: var(--muted); font-size: 16px; }
.hero-result.pagar { border-color: rgba(255,107,107,.25); background: linear-gradient(145deg, rgba(255,107,107,.16), rgba(255,107,107,.06)); }
.hero-result.devolver { border-color: rgba(55,214,122,.25); background: linear-gradient(145deg, rgba(55,214,122,.16), rgba(55,214,122,.06)); }
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.result-item {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}
.result-item .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.result-item .v { font-size: 24px; font-weight: 700; margin-top: 8px; }
.table-wrap { overflow-x: auto; }
.result-table { width: 100%; border-collapse: collapse; }
.result-table th, .result-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 12px 10px;
}
.result-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.tips { display: grid; gap: 12px; }
.tip {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}
.tip h5 { margin: 0 0 8px; font-size: 16px; }
.tip p { margin: 0; color: var(--muted); line-height: 1.55; }
.legal { border-color: rgba(255,207,99,.26); }
@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .card-grid, .field-grid.two, .field-grid.three, .result-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
}
@media print {
  .sidebar, .topbar { display: none !important; }
  body { background: white; color: black; }
  .main-content { padding: 0; }
  .step { display: none !important; }
  .step[data-step="6"] { display: block !important; }
  .card, .hero-result, .result-item { box-shadow: none; border-color: #bbb; background: white; }
}


/* ===== V5 responsive + theme ===== */
html, body { min-height: 100%; }
button, input, select { -webkit-tap-highlight-color: transparent; }
.mobile-summary, .mobile-sticky-actions { display: none; }
.compact { padding: 16px; }
.mobile-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.summary-pill { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.summary-k { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.summary-pill strong { font-size: 15px; }
.btn { min-height: 48px; }
#btnTheme { white-space: nowrap; }
input, select { font-size: 16px; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 42px;
}
select option { color: var(--text); background: var(--panel); }
.sidebar { scrollbar-width: thin; }
.result-item .v { word-break: break-word; }
.hero-result { scroll-margin-top: 18px; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 280px 1fr; }
  .main-content { padding: 22px; }
  .card-grid, .field-grid.two, .field-grid.three { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; top: 0; height: auto; border-right: 0; border-bottom: 1px solid var(--line);
    padding: 18px 14px; background: color-mix(in srgb, var(--panel) 82%, transparent);
  }
  .brand h1 { font-size: 24px; }
  .side-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); overflow-x: auto; }
  .nav-link { min-height: 46px; text-align: center; }
  .status-card.compact .stack { grid-template-columns: repeat(2, minmax(0, 1fr)); display: grid; }
  .main-content { padding: 16px 12px 96px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 14px; }
  .topbar h2 { font-size: clamp(24px, 8vw, 34px); }
  .progress-wrap { min-width: 0; }
  .mobile-summary { display: block; margin-bottom: 16px; }
  .card { border-radius: 20px; padding: 16px; }
  .hero-result { padding: 22px 18px; border-radius: 22px; }
  .result-grid { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .result-table { min-width: 520px; }
  .status-card.compact { display: none; }
  .mobile-sticky-actions {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 60; padding: 12px; background: color-mix(in srgb, var(--panel) 88%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(14px);
  }
  .mobile-sticky-actions .btn { width: 100%; }
  .chip-group { display: grid; grid-template-columns: 1fr 1fr; }
  .chip span { min-width: 0; min-height: 48px; width: 100%; }
  .field-top { gap: 6px; }
}

@media (max-width: 560px) {
  .sidebar { padding: 14px 12px; }
  .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-card { padding: 14px; border-radius: 16px; }
  .main-content { padding: 14px 10px 98px; }
  .mobile-summary-grid { grid-template-columns: 1fr; }
  .summary-pill { padding: 10px 12px; }
  .result-item .v { font-size: 20px; }
  .hero-amount { font-size: clamp(34px, 12vw, 54px); }
  .field-grid.three, .field-grid.two, .card-grid { grid-template-columns: 1fr; }
  .money::after { bottom: 16px; }
}

@media print {
  .mobile-sticky-actions, .mobile-summary, #btnTheme, .side-nav, .status-card.compact, .status-card:first-of-type { display: none !important; }
  .app-shell { display: block; }
  .sidebar { height: auto; position: relative; border: 0; background: none; padding: 0 0 16px; }
}
