/* The app's own palette (lib/src/core/theme/app_theme.dart): ember on near
   black, and the deeper ember on paper in light mode. System fonts, as in the
   app, until the typeface is chosen (F5). */
:root {
  color-scheme: dark;
  --bg: #0B0B10;
  --surface: #14141B;
  --surface-high: #1C1C25;
  --line: #3A3A47;
  --ink: #F3F2F7;
  --ink-soft: #9E9DAE;
  --accent: #FF4D2E;
  --on-accent: #14141B;
  --ok: #14E8A0;
  --error: #FF6B6B;
  --radius: 14px;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Light when the system is light, unless this browser chose dark; and light
   when it chose light (the switch in the header, common.js). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #FBF9F7;
    --surface: #FFFFFF;
    --surface-high: #F1EDE9;
    --line: #D8D2CC;
    --ink: #16151A;
    --ink-soft: #5F5B66;
    --accent: #C43B1E;
    --on-accent: #FFFFFF;
    --ok: #0E7A55;
    --error: #B3261E;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #FBF9F7;
  --surface: #FFFFFF;
  --surface-high: #F1EDE9;
  --line: #D8D2CC;
  --ink: #16151A;
  --ink-soft: #5F5B66;
  --accent: #C43B1E;
  --on-accent: #FFFFFF;
  --ok: #0E7A55;
  --error: #B3261E;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.bar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 900; font-size: 22px; color: var(--accent); }
.where { color: var(--ink-soft); }
/* What sits on the right of the bar: who, the look, «Salir». */
.bar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.theme-switch button { border: 0; border-radius: 0; padding: 6px 10px; display: inline-flex; color: var(--ink-soft); }
.theme-switch button + button { border-left: 1px solid var(--line); }
.theme-switch button[aria-pressed="true"] { background: var(--surface-high); color: var(--accent); }
.theme-switch svg { width: 18px; height: 18px; }

main {
  max-width: 1040px;
  margin: 0 auto;
  padding-block: 28px 64px;
  padding-inline: 16px;
  display: grid;
  gap: 20px;
}
#app { display: grid; gap: 20px; }
/* Grid items would otherwise grow to their widest content (the table) and
   push the page sideways on a phone. */
main > *, #app > * { min-width: 0; }
.narrow { max-width: 440px; margin: 0 auto; width: 100%; }

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; text-wrap: balance; }
h2 { font-size: 18px; margin: 0 0 6px; }
.lede { color: var(--ink-soft); margin: 0 0 16px; }
.import { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; }
.import label { flex: 1 1 16rem; }
.hint, .note { color: var(--ink-soft); font-size: 14px; margin: 4px 0 14px; }
.error { color: var(--error); min-height: 1.5em; margin: 8px 0 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-soft); }
label.inline { display: inline-flex; align-items: center; gap: 6px; }
input, select {
  font: inherit;
  color: var(--ink);
  background: var(--surface-high);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#login-form { display: grid; gap: 14px; }
#weeks { width: 4.5em; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 8px 16px;
}
button.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  font-weight: 700;
  padding: 11px 22px;
}
button:disabled { opacity: .5; cursor: default; }

.rows { display: grid; gap: 12px; margin-bottom: 12px; }
.date-row {
  display: grid;
  grid-template-columns: 9.5em 6.5em minmax(8em, 1fr) minmax(10em, 1.6fr) 11em minmax(8em, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.date-row .remove { padding: 8px 12px; }
.row-status { grid-column: 1 / -1; margin: 0; font-size: 14px; min-height: 0; }
.row-status:empty { display: none; }
.row-status.ok { color: var(--ok); }
.row-status.bad { color: var(--error); }
.date-row.done { opacity: .6; }

.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.weekly { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td .from { display: block; color: var(--ink-soft); font-size: 13px; }

.balance { display: flex; align-items: center; gap: 10px; font-size: 28px; font-weight: 800; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.sprites { position: absolute; width: 0; height: 0; overflow: hidden; }
.coin { width: 1em; height: 1em; flex: none; vertical-align: -0.15em; }
.balance .coin { width: 36px; height: 36px; }
#credits h3 { font-size: 15px; margin: 18px 0 6px; }
.packs { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); max-width: 640px; }
.offer { display: grid; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.offer:hover { border-color: var(--ink-soft); }
#plan { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); align-items: start; padding-top: 12px; }
.founder { display: inline-block; background: #FFB300; color: #3A2400; font-weight: 800; padding: 3px 10px; border-radius: 6px; margin: 0 0 8px; }
.plan .regular { margin: 0; color: var(--ink-soft); text-decoration: line-through; }
.plan .founder-note { margin: 0; font-size: 13px; color: var(--ink-soft); }
.extras { list-style: none; padding: 0; margin: 0 0 8px; color: var(--ink-soft); font-size: 14px; }
.plan .saving { margin: 0; color: var(--ink-soft); font-size: 13px; }
.plan { position: relative; display: grid; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
.plan.highlight { border: 2px solid #FFB300; }
.plan .ribbon { position: absolute; top: -12px; left: 12px; background: #FFB300; color: #3A2400; font-weight: 800; font-style: italic; font-size: 13px; padding: 3px 10px; border-radius: 6px; }
.plan h4 { margin: 4px 0 0; font-size: 17px; letter-spacing: 0.04em; }
.plan.highlight h4 { color: #E08A00; }
.plan h4 small { font-size: 12px; letter-spacing: 0; color: var(--accent); }
.plan .price { margin: 0; color: var(--ink-soft); }
.plan .price b { font-size: 26px; color: var(--ink); font-variant-numeric: tabular-nums; }
.plan .each { margin: 0 0 6px; font-weight: 700; color: var(--accent); }
.plan ul { list-style: none; padding: 0; margin: 4px 0 12px; display: grid; gap: 6px; font-size: 14px; }
.plan li::before { content: "✓ "; color: var(--accent); font-weight: 700; }
.plan li.lacks { color: var(--ink-soft); text-decoration: line-through; opacity: 0.7; }
.plan li.lacks::before { content: "– "; color: var(--ink-soft); }
.offer strong { display: flex; align-items: center; gap: 6px; font-size: 17px; }
.offer b { font-variant-numeric: tabular-nums; }
.offer small { color: var(--ink-soft); }

@media (max-width: 860px) {
  .date-row { grid-template-columns: 1fr 1fr; }
  .date-row .wide { grid-column: 1 / -1; }
  .date-row .remove { justify-self: end; grid-column: 2; }
}

/* --- Shared by both panels (29-09): asking, telling, the second step. --- */

button.danger {
  background: var(--error);
  border-color: var(--error);
  color: var(--bg);
  font-weight: 700;
}
.good { color: var(--ok); }
.bad { color: var(--error); }
.quiet-link { color: var(--ink-soft); font-size: 14px; }

dialog.ask {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 22px;
  width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgb(0 0 0 / .55); }
dialog.ask h2 { font-size: 19px; text-wrap: balance; }
dialog.ask p { color: var(--ink-soft); }
.ask-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--surface-high);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 24px rgb(0 0 0 / .35);
  z-index: 10;
}
.toast.bad { border-color: var(--error); }

.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 12px 0; }
.inline-form label { flex: 1 1 12rem; }
.steps { padding-left: 1.2em; display: grid; gap: 12px; }
.steps small { display: block; margin-top: 8px; word-break: break-all; }
img.qr { display: block; margin-top: 10px; width: 220px; height: 220px; max-width: 100%; border-radius: 10px; background: #fff; }
/* A checkbox is not a text field: its own size, the app's colour. */
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; accent-color: var(--accent); flex: none; }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; }
.plan .terms { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); }

/* The code for «Estoy aquí» (phase 4): read from across the bar. */
.show-code { display: block; margin-top: 6px; font-size: 14px; padding: 4px 10px; }
dialog.code {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 22px;
  width: min(720px, calc(100vw - 32px));
  text-align: center;
}
dialog.code h2 { font-size: 20px; text-wrap: balance; }
dialog.code .code-how, dialog.code .code-note { color: var(--ink-soft); }
.code-digits {
  margin: 18px 0 10px;
  font: 800 clamp(56px, 12vw, 120px)/1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: .04em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
dialog.code progress { width: min(420px, 100%); height: 8px; accent-color: var(--accent); }
dialog.code:fullscreen {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  border: 0;
  border-radius: 0;
  display: grid;
  align-content: center;
  justify-items: center;
}
dialog.code:fullscreen .code-digits { font-size: clamp(96px, 20vw, 320px); }
