:root {
  --bg: #f6efe3;
  --card: #fffaf1;
  --line: #e4d6c2;
  --ink: #33241a;
  --muted: #7a634f;
  --head: #4a2e1a;
  --head-2: #5a3418;
  --olive: #6b7a2e;
  --olive-soft: #eef0da;
  --amber: #c9861a;
  --warn-bg: #fbeccf;
  --warn-ink: #7a4b08;
  --red: #a83a22;
  --on-olive: #fffaf1;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1510;
    --card: #271d16;
    --line: #45352a;
    --ink: #efe3d2;
    --muted: #b9a48d;
    --head: #f0d8b6;
    --head-2: #e6c49a;
    --olive: #a9b863;
    --olive-soft: #2d2f1c;
    --amber: #e0a03c;
    --warn-bg: #3a2a12;
    --warn-ink: #f1c97c;
    --red: #e47e66;
    --on-olive: #1c1510;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px 48px; }

h1, h2, .big, .box-label { font-family: Archivo, Inter, system-ui, sans-serif; }

h1 { margin: 0; font-size: 1.9rem; font-weight: 800; color: var(--head); letter-spacing: -0.01em; }
h2 { margin: 0 0 10px; font-size: 1.2rem; font-weight: 700; color: var(--head-2); }
.lede { margin: 4px 0 18px; color: var(--muted); }
.top { margin-bottom: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

/* Plans */
.plans { margin-bottom: 16px; }
.group-h {
  margin: 16px 0 8px; font-size: 0.82rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); font-family: Inter, system-ui, sans-serif;
}
.plan {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px;
  margin-bottom: 8px; padding: 10px 14px; text-align: left;
  font: 500 1rem/1.3 Inter, system-ui, sans-serif; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
}
.plan::before {
  content: ""; flex: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--card);
}
.plan[aria-pressed="true"] {
  border: 2px solid var(--olive); background: var(--olive-soft); font-weight: 600; color: var(--head);
  padding: 9px 13px;
}
.plan[aria-pressed="true"]::before { border-color: var(--olive); background: var(--olive); box-shadow: inset 0 0 0 3px var(--card); }

/* Fields */
label, legend { display: block; margin: 12px 0 6px; font-weight: 600; color: var(--head); }
.field > label:first-child, fieldset + label { margin-top: 0; }
fieldset { border: 0; margin: 0 0 12px; padding: 0; }
legend { margin-top: 0; padding: 0; }

input[type="text"], input[type="search"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font: 400 16px/1.4 Inter, system-ui, sans-serif; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
#amount, #cAmount { font: 700 1.5rem/1.2 Archivo, Inter, sans-serif; }
textarea { resize: vertical; min-height: 72px; }

:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--amber); outline-offset: 1px; border-color: var(--amber); }

.hint { margin: 6px 0 0; font-size: 0.9rem; color: var(--muted); }
.warn {
  margin: 8px 0 0; padding: 8px 12px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; font-size: 0.95rem;
}
.note { color: var(--muted); }

.checks { display: grid; gap: 6px; }
.check {
  display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 0;
  font-weight: 500; color: var(--ink); cursor: pointer;
}
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--olive); }

/* Result boxes */
.box-label { margin: 0; font-size: 1rem; font-weight: 700; color: var(--head-2); }
.big { margin: 2px 0 2px; font-size: 2.2rem; font-weight: 800; line-height: 1.15; color: var(--head); }
.sub { margin: 0; color: var(--muted); font-size: 0.95rem; min-height: 1.4em; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair .card { margin-bottom: 0; }
.pair .big { font-size: 1.9rem; }
@media (max-width: 419px) {
  .pair { grid-template-columns: 1fr; }
}
.summary { margin: 12px 4px 16px; font-weight: 600; color: var(--head); }
.summary span + span::before { content: " · "; color: var(--muted); font-weight: 400; }

.pending { margin: 0 0 8px; font-weight: 600; color: var(--head); }
.entered { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.entered dt { color: var(--muted); }
.entered dd { margin: 0; font-weight: 600; }

/* Buttons */
.btn {
  min-height: 48px; padding: 10px 18px; border-radius: 12px; cursor: pointer;
  font: 600 1rem/1.2 Inter, system-ui, sans-serif; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
}
.btn.primary { width: 100%; margin-top: 16px; background: var(--olive); border-color: var(--olive); color: var(--on-olive); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.danger { border-color: var(--red); color: var(--red); background: transparent; }
.btn.danger-solid { background: var(--red); border-color: var(--red); color: var(--card); }
.btn.small { min-height: 44px; padding: 8px 14px; font-size: 0.95rem; }

.status { margin: 10px 0 0; font-weight: 600; min-height: 1.5em; }
.status.ok { color: var(--olive); }
.status.err { color: var(--red); }

/* History */
.history { margin-top: 28px; }
.tools input[type="search"] { margin-bottom: 10px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button {
  min-height: 44px; border: 0; background: var(--card); color: var(--ink); cursor: pointer;
  font: 500 1rem Inter, system-ui, sans-serif;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--olive); color: var(--on-olive); font-weight: 600; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 0; }
.totals div { min-width: 0; }
.totals dt { font-size: 0.85rem; color: var(--muted); }
.totals dd { margin: 0; font: 700 1.15rem Archivo, Inter, sans-serif; color: var(--head); overflow-wrap: anywhere; }
.count { margin: 8px 0 0; font-size: 0.9rem; color: var(--muted); }

.sales { list-style: none; margin: 0; padding: 0; }
.sale h3 { margin: 0; font: 700 1.1rem/1.3 Archivo, Inter, sans-serif; color: var(--head); overflow-wrap: anywhere; }
.sale .when { margin: 0 0 2px; font-size: 0.85rem; color: var(--muted); }
.sale .plan-name { margin: 2px 0 10px; color: var(--head-2); font-weight: 500; }
.sale dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; }
.sale dt { color: var(--muted); }
.sale dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.sale .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.sale .actions p { margin: 0; width: 100%; font-weight: 600; color: var(--head); }
