/* ─── App-specific tokens (shared tokens, fonts and reset live in /base.css) ──── */
:root {
  --radius:      8px;
  --shadow-md:   0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --panel-width: 340px;
  --color-vat:   #f59e0b;
  --accent-tint: rgba(67,97,238,.08);
  --accent-ring: rgba(67,97,238,.12);
}

html { height: 100%; }

body {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

/* ─── Layout ───────────────────────────────────────────────────────────────── */
main {
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ─── Form panel ───────────────────────────────────────────────────────────── */
.form-panel {
  width: var(--panel-width);
  min-width: var(--panel-width);
  background: var(--color-panel);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding-bottom: 40px;
}

.form-panel::-webkit-scrollbar { width: 5px; }
.form-panel::-webkit-scrollbar-track { background: transparent; }
.form-panel::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.form-section { border-bottom: 1px solid var(--color-border); }

.section-title {
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--color-muted);
  padding: 14px 20px;
  user-select: none;
}

.section-body { padding: 0 20px 20px; }

.hint {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-top: 12px;
  line-height: 1.5;
}
.hint a { color: var(--color-accent); }

/* Visually hidden radios that stay keyboard-focusable */
.segmented input,
.rate-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

/* ─── Mode toggle ──────────────────────────────────────────────────────────── */
.segmented {
  display: flex;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
}

.seg-option { flex: 1; position: relative; }

.seg-option span {
  display: block;
  text-align: center;
  padding: 8px 10px;
  border-radius: 6px;
  font-family: var(--font-head);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}

.seg-option span:hover { color: var(--color-text); }

.seg-option input:checked + span {
  background: var(--color-panel);
  color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.seg-option input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-ring); }

/* ─── Money input ──────────────────────────────────────────────────────────── */
.money-input-wrap,
.pct-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.money-input-wrap input,
.pct-input-wrap input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--color-text);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.money-input-wrap input {
  padding: 10px 12px 10px 30px;
  font-size: 1.375rem;
}

.money-input-wrap input:focus,
.pct-input-wrap input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.money-input-wrap input[aria-invalid="true"],
.pct-input-wrap input[aria-invalid="true"] { border-color: #dc2626; }

.money-symbol {
  position: absolute;
  left: 12px;
  font-family: var(--font-head);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-muted);
  pointer-events: none;
}

.field-error {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #dc2626;
}

/* ─── Rate options ─────────────────────────────────────────────────────────── */
.rate-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.rate-option { position: relative; }

.rate-option > span { display: block; text-align: center; cursor: pointer; }

.rate-option .rate-pct {
  padding: 9px 4px 2px;
  border: 1px solid var(--color-border);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  font-family: var(--font-head);
  font-size: 0.9375rem;
  font-weight: 700;
  background: #fff;
  transition: background .15s, border-color .15s, color .15s;
}

.rate-option .rate-name {
  padding: 0 4px 8px;
  border: 1px solid var(--color-border);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-muted);
  background: #fff;
  transition: background .15s, border-color .15s;
}

.rate-option:hover .rate-pct,
.rate-option:hover .rate-name { border-color: #c4c8d2; }

.rate-option input:checked ~ .rate-pct,
.rate-option input:checked ~ .rate-name {
  background: var(--accent-tint);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.rate-option input:focus-visible ~ .rate-pct { box-shadow: 0 -3px 0 3px var(--accent-ring); }

.custom-rate {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-rate[hidden] { display: none; }

.custom-rate label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
}

.pct-input-wrap { width: 110px; }

.pct-input-wrap input {
  padding: 8px 28px 8px 10px;
  font-size: 0.9375rem;
}

.pct-symbol {
  position: absolute;
  right: 10px;
  font-weight: 700;
  color: var(--color-muted);
  pointer-events: none;
}

/* ─── Results panel ────────────────────────────────────────────────────────── */
.preview-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.results {
  width: 100%;
  max-width: 44rem;
  position: relative;
}

.result-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.result-card {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 18px 18px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.result-card--gross {
  background: var(--color-header);
  border-color: var(--color-header);
  color: #fff;
}

.result-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--color-muted);
}

.result-label small {
  font-size: inherit;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  opacity: .8;
}

.result-card--gross .result-label { color: rgba(255,255,255,.65); }

.result-value {
  font-family: var(--font-head);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.5px;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.result-card--vat .result-value { color: #b45309; }

.copy-btn {
  align-self: flex-start;
  margin-top: 4px;
  padding: 4px 12px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: transparent;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-accent);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.copy-btn:hover { background: var(--accent-tint); border-color: var(--color-accent); }
.copy-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

.result-card--gross .copy-btn { color: #fff; border-color: rgba(255,255,255,.3); }
.result-card--gross .copy-btn:hover { background: rgba(255,255,255,.1); border-color: #fff; }

/* ─── Split bar ────────────────────────────────────────────────────────────── */
.split { margin-top: 28px; }

.split-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--color-border);
}

.split-net { background: var(--color-accent); transition: width .25s ease; }
.split-vat { background: var(--color-vat);    transition: width .25s ease; }

.split-legend {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.split-legend b { color: var(--color-text); font-weight: 700; margin-left: 4px; }

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 0;
}
.dot-net { background: var(--color-accent); }
.dot-vat { background: var(--color-vat); }

/* ─── Working ──────────────────────────────────────────────────────────────── */
.working {
  margin-top: 28px;
  padding: 16px 18px;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.working-title {
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--color-muted);
  margin-bottom: 6px;
}

.working p {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.8;
  font-variant-numeric: tabular-nums;
}

.copy-note {
  margin-top: 14px;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.copy-note code { font-family: var(--font-mono); font-size: 0.75rem; }

/* ─── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--color-header);
  color: #fff;
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 200;
}

.toast[hidden] { display: none; }

/* ─── Narrower desktops ────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .result-value { font-size: 1.375rem; }
}

/* ─── Mobile (≤768px) ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  html, body { height: auto; min-height: 100%; display: block; overflow: visible; }

  main {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .form-panel {
    width: 100%;
    min-width: 0;
    overflow-y: visible;
    padding-bottom: 20px;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .preview-panel {
    overflow-y: visible;
    padding: 24px 16px 32px;
  }

  .result-cards { grid-template-columns: 1fr; gap: 10px; }

  .result-card {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "label copy" "value copy";
    align-items: center;
    column-gap: 12px;
    row-gap: 2px;
    padding: 14px 16px;
  }
  .result-label { grid-area: label; }
  .result-value { grid-area: value; font-size: 1.5rem; }
  .copy-btn     { grid-area: copy; align-self: center; margin-top: 0; }
}
