/* Mesa Quant — one brand (SPEC_GOVERNING.md, W2 rules).
 *
 * navy #0b2545 · teal #0f9d84 · white cards · system font stack — the same tokens as
 * mesaquant.com and the Keycloak login page. Mobile first: everything below is written for a
 * 390 px viewport and only widens from there, so no screen can scroll sideways (GAP 9 AC3).
 *
 * This is the ONLY stylesheet. Templates carry layout classes, never a colour. */

:root {
  --navy: #0b2545;
  --navy-soft: #1c3a5e;
  --teal: #0f9d84;
  --teal-dark: #0b7a67;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #dde3ec;
  --text: #0b2545;
  --muted: #5a6b82;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #0f9d84;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}

/* Nothing may exceed its column — the structural half of AC3. */
img, svg, video, canvas, iframe, table, pre { max-width: 100%; }
img, svg, video, canvas { height: auto; }

.container { width: 100%; max-width: 860px; margin: 0 auto; padding: 1.5rem 1rem; }

h1 { font-size: 1.9rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: .6rem; }
h3 { font-size: 1rem; font-weight: 600; }
p { color: var(--muted); }
strong { color: var(--text); }
a { color: var(--teal-dark); }

.lead { font-size: 1.05rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.xsmall { font-size: .75rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }
.mt { margin-top: 1.5rem; }
.mb { margin-bottom: 1.5rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }

/* --- surfaces ----------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(11, 37, 69, .05);
}
.card + .card { margin-top: 1rem; }
.card-danger { border-color: var(--danger); }
.card-warn { border-color: var(--warn); }
.card-teal { border-color: var(--teal); }

.hero { padding: 2rem 0 1.5rem; text-align: center; }
.hero p { max-width: 46ch; margin-inline: auto; }

/* auto-fit grid whose track floor never exceeds the viewport: min() keeps a 220 px card from
 * forcing a 220 px column inside a 390 px - padding column. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 1rem;
}

.stat-label { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--navy); line-height: 1.2; }
.stat-value-danger { color: var(--danger); }
.stat-value-warn { color: var(--warn); }
.stat-value-ok { color: var(--ok); }

/* --- controls ----------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: .8rem 1.6rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--card);
  color: var(--navy);
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { background: var(--card); color: var(--navy); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--navy-soft); }
.btn-block { display: block; width: 100%; }
.btn:focus-visible, a:focus-visible, input:focus-visible, button:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

label { display: block; font-weight: 500; margin-bottom: .35rem; }
input[type="text"], input[type="email"], input[type="file"], textarea, select {
  width: 100%;
  max-width: 100%;
  padding: .65rem .75rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.checkline { display: flex; align-items: flex-start; gap: .5rem; font-weight: 400; }
.checkline input { width: auto; margin-top: .2rem; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
}

/* GAP 13 mode 1 — the desktop drag-and-drop target has to SAY it is a target while a file is
   held over it, otherwise "arraste o arquivo até aqui" is a claim the screen never confirms. */
.dropzone.dragover { border-color: var(--teal); background: #e6f6f2; }

/* Client-side preview: the captured photo, big enough to judge legibility, capped so a
   portrait screenshot cannot push the submit button off a 390 px viewport. */
.file-preview { margin-top: 1rem; }
.file-preview img {
  display: block; max-width: 100%; max-height: 15rem; margin: 0 auto .5rem;
  border: 1px solid var(--border); border-radius: 8px;
}
.file-preview .preview-doc {
  display: inline-block; margin-bottom: .5rem; padding: .75rem 1.25rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--muted); font-weight: 700; letter-spacing: .05em;
}
.file-preview figcaption { color: var(--muted); word-break: break-word; }
.file-preview .btn-remove-row { margin-top: .5rem; }

.broker-guide summary { cursor: pointer; color: var(--navy-soft); font-weight: 600; }
.broker-guide ul { margin: .5rem 0 .5rem 1.1rem; }
.broker-guide li { margin-bottom: .25rem; }

.badge { display: inline-block; padding: .2em .6em; border-radius: 4px; font-size: .75rem; font-weight: 700; }
.badge-warn { background: #fff4e5; color: var(--warn); }
.badge-ok { background: #e6f6f2; color: var(--teal-dark); }

.notice { padding: .75rem 1rem; border-radius: 8px; background: #eef2f7; color: var(--muted); font-size: .9rem; }

/* --- GAP 13: Colar texto / Digitar ---------------------------------------- */

textarea.paste-area {
  width: 100%; min-height: 9rem; padding: .75rem; border: 1px solid var(--border);
  border-radius: 8px; font-family: inherit; font-size: .95rem; resize: vertical;
}

.manual-row { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .75rem; position: relative; }
.manual-row .manual-fields { display: flex; gap: .5rem; }
.manual-row input[name="names"] { flex: 2 1 auto; min-width: 0; }
.manual-row input[name="amounts"] { flex: 1 1 auto; min-width: 0; }
.manual-row .btn-remove-row {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: .8rem;
  align-self: flex-end; padding: .2rem 0;
}

.fund-suggestions {
  list-style: none; border: 1px solid var(--border); border-radius: 8px; background: #fff;
  max-height: 10rem; overflow-y: auto; display: none;
}
.fund-suggestions.open { display: block; }
.fund-suggestions li { padding: .5rem .75rem; font-size: .88rem; cursor: pointer; }
.fund-suggestions li:hover, .fund-suggestions li:focus { background: var(--bg); }

.btn-add-row { background: none; border: 1px dashed var(--border); color: var(--navy); }

/* --- tables ------------------------------------------------------------- */

/* The paid breakdown is 16 columns wide by design; it scrolls *inside* this box so the page
 * itself never does (AC3). */
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; max-width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
.highlight { background: #fdf2f0; }

/* NOTE: the paywall's blur stays an INLINE style on report.html, not a class here. Existing
 * tests (test_report.py, test_freemium_funnel.py) assert `opacity:0.4` / `blur(3px)` appear in
 * the free HTML and are absent from the paid HTML — the check only sees the markup. */

/* --- chrome ------------------------------------------------------------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .7rem 1rem;
  font-size: .9rem;
  background: var(--navy);
  color: #fff;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.brand { font-weight: 600; }

footer { margin-top: 2.5rem; padding: 1.5rem 1rem 2rem; border-top: 1px solid var(--border); }
footer p { color: var(--muted); font-size: .8rem; text-align: center; max-width: 60ch; margin-inline: auto; }

/* --- 390 px first: one column below 480 px ------------------------------ */

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
  .container { padding: 1rem .9rem; }
  h1 { font-size: 1.55rem; }
  .btn { display: block; width: 100%; }
  .topbar { font-size: .85rem; }
}
