/*
 * One hand-written stylesheet, system font stack, no build step. A deliberate aesthetic
 * for an internal fiscal tool, not a placeholder waiting for a designer. It began as the
 * register of the hand-written CSV-import page that used to hang off sqladmin, which is
 * the only part of that panel worth having kept.
 */

:root {
  --ink: #1a2733;
  --muted: #5b6672;
  --rule: #dfe4e9;
  --band: #f6f8fa;
  --accent: #003049;
  --warn: #9a3412;
  --ok: #2f7d4f;
  --page: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--band);
}

a { color: var(--accent); }

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  flex-wrap: wrap;
}
.nav a { color: #e8eef2; text-decoration: none; font-size: 0.92rem; }
.nav a:hover { text-decoration: underline; }
.nav .brand { font-weight: 700; color: #fff; margin-right: 0.5rem; }
.nav-end { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.nav .who { color: #b9c6d0; font-size: 0.85rem; }

.page { max-width: 62rem; margin: 1.5rem auto; padding: 0 1.25rem 3rem; }

h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 0.5rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.warn { color: var(--warn); font-weight: 600; }
.strong td { font-weight: 700; }

.flash { padding: 0.75rem 1rem; border-radius: 4px; margin-bottom: 1rem; background: #e7f0f6; }
.flash.error { background: #fdecea; color: var(--warn); }
/* Terminal, not incidental: "we have everything" must not look like "saved". */
.flash.ok { background: #e8f5ec; border-left: 3px solid var(--ok); }
.flash.ok strong { display: block; margin-bottom: 0.35rem; }

.card { background: var(--page); border: 1px solid var(--rule); border-radius: 4px; padding: 1.25rem; }
.card.narrow { max-width: 24rem; margin: 3rem auto; }

label { display: block; margin-bottom: 0.85rem; font-size: 0.9rem; color: var(--muted); }
input, select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: #fff;
}

button {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button.link { background: none; color: var(--accent); padding: 0; text-decoration: underline; }
.nav button.link { color: #e8eef2; }
.button-ghost {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: #fff;
  text-decoration: none;
}

.grid { width: 100%; border-collapse: collapse; background: var(--page); }
.grid th, .grid td { padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--rule); text-align: left; }
.grid th { background: var(--band); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.grid .num, .num { text-align: right; white-space: nowrap; }

.tiles { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0; }
.tile { background: var(--page); border: 1px solid var(--rule); border-radius: 4px; padding: 0.85rem 1.1rem; min-width: 7rem; }
.tile-n { font-size: 1.6rem; font-weight: 700; }
.tile-l { font-size: 0.8rem; color: var(--muted); }

.filters { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters label { margin-bottom: 0; }
.filters input, .filters select { min-width: 11rem; }
.truncated { margin: -0.5rem 0 0.75rem; }

.cols { display: flex; gap: 2rem; flex-wrap: wrap; }
.cols > div { flex: 1 1 18rem; }

.line { display: flex; gap: 0.5rem; flex-wrap: wrap; border-bottom: 1px solid var(--rule); padding: 0.5rem 0; }
.line label { flex: 1 1 8rem; margin-bottom: 0.35rem; }

.confirm { margin-top: 1.5rem; }
fieldset { border: 1px solid var(--rule); border-radius: 4px; margin: 0 0 1rem; }
legend { padding: 0 0.4rem; color: var(--muted); font-size: 0.85rem; }

/* ── /alta, the prospect's onboarding page ──────────────────────────────────── */

/*
 * The generic rule above makes every input `display:block; width:100%`, which on a
 * checkbox is a full-width grey slab. Undo it for the two input types that are glyphs.
 */
input[type="checkbox"], input[type="radio"] {
  width: auto;
  display: inline-block;
  margin: 0 0.4rem 0 0;
  vertical-align: middle;
}

label.inline { display: inline; color: var(--ink); }

/*
 * "Ya soy emisor electrónico" hides the portal password field, with no JavaScript.
 *
 * This only works because the input is a *sibling* of `.portal-password` rather than
 * wrapped in its own label — see the comment in alta.html. It shipped wrapped once, the
 * selector matched nothing, and the field stayed visible. `test_onboarding.py` renders
 * the page in Chromium now, because no server-side test can see this.
 */
#ya-emisor:checked ~ .portal-password { display: none; }

/*
 * The way back from a finished page. Once everything is in, the two forms live inside a
 * closed `<details>`: a page still showing a `required` file input does not read as done,
 * but a prospect who uploaded the wrong certificate needs to fix it without waiting for
 * an operator to re-mint their link. Native element, no JavaScript.
 */
details.amend { margin-top: 1.5rem; }
details.amend > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.35rem 0;
}
details.amend > summary:hover { color: var(--accent); }
details[open].amend > summary { margin-bottom: 0.5rem; font-weight: 600; }

h3 { font-size: 0.98rem; margin: 1.25rem 0 0.5rem; }

/* ── The DGII steps, shared by `/` and `/alta` ──────────────────────────────── */

/*
 * One line per step, the detail behind a native `<details>`: a prospect scanning for "what
 * do I do next" reads five sentences, not five paragraphs. Same register as
 * `details.amend` above.
 */
ol.pasos { background: var(--page); border: 1px solid var(--rule); border-radius: 4px; padding: 1rem 1.25rem 1rem 2.5rem; margin: 0 0 0.75rem; }
ol.pasos > li { margin-bottom: 0.65rem; }
ol.pasos > li:last-child { margin-bottom: 0; }
ol.pasos p, ol.pasos ul { margin: 0.35rem 0 0; }
ol.pasos details > summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; padding: 0.15rem 0; }
ol.pasos details > summary:hover { color: var(--accent); }

/* ── `/`, the public home page ──────────────────────────────────────────────── */

.lead { font-size: 1.1rem; color: var(--muted); margin-top: 0; }
a.button {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.55rem 1.1rem;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}
a.button:hover { opacity: 0.9; }
.card > p:first-child { margin-top: 0; }
/* A card that opens with a heading; in a form the hidden CSRF input comes first. */
.card > h3:first-child, .card > input[type="hidden"]:first-child + h3 { margin-top: 0; }
