/* Mari Gabaritos — papel claro, tinta azul, lousa verde */
:root {
  --bg: #f8f0ee; --card: #ffffff; --ink: #1d3f7a; --text: #2b3445; --muted: #6b7486; --line: #e8dcd6;
  --brand: #1f5fbf; --brand-ink: #ffffff; --ok: #1e8a4c; --bad: #c8362b; --warn: #c27a06;
  --ok-bg: #e5f4ea; --bad-bg: #fbe7e4; --warn-bg: #fdf1dc; --chip: #f4e6dc; --beige: #f3e3d3;
  --board: #2f5d46; --board-dark: #234836; --wood: #a0703f; --chalk: #f4f1e8;
  --radius: 14px; --shadow: 0 1px 2px rgba(90,60,40,.06), 0 4px 14px rgba(90,60,40,.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.55 "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { color: var(--ink); }
.serif { font-family: "Cinzel", Georgia, serif; letter-spacing: .02em; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
small, .small { font-size: .85rem; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem clamp(16px, 4vw, 40px); background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { font-family: "Cinzel", Georgia, serif; font-weight: 700; font-size: 1.25rem; color: var(--ink); display: flex; align-items: center; gap: .6rem; letter-spacing: .03em; }
.brand img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid var(--beige); }
nav { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; }
nav a:not(.btn) { color: var(--muted); padding: .35rem .6rem; border-radius: 8px; }
nav a.active:not(.btn) { color: var(--ink); background: var(--chip); }
body:not(.authed) [data-auth] { display: none !important; }
body.authed [data-guest] { display: none !important; }

main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.5rem clamp(16px, 4vw, 40px) 3rem; flex: 1; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.kpi b { display: block; font-size: 1.6rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .82rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }

.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); padding: .55rem 1rem; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn.sm { padding: .3rem .7rem; font-size: .85rem; }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }

label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .25rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; width: 100%; }
textarea { min-height: 80px; resize: vertical; font-family: ui-monospace, Consolas, monospace; letter-spacing: .05em; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.field { margin-bottom: .75rem; }
.inline { display: flex; gap: .5rem; }

.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; cursor: pointer; transition: .15s; background: var(--card); }
.drop.over, .drop:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, var(--card)); }
.drop b { display: block; font-size: 1.05rem; margin-bottom: .25rem; }
.steps { display: flex; gap: .5rem; margin: .5rem 0 1.25rem; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .9rem; }
.step i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--chip); font-size: .75rem; font-weight: 700; }
.step.on { color: var(--ink); } .step.on i { background: var(--brand); color: #fff; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--chip); }
.tablewrap { overflow-x: auto; }
td input { padding: .3rem .45rem; min-width: 110px; }
.num { text-align: right; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--chip); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.score { font-weight: 700; }
.bar { height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--brand); }

.thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.header-crop { max-width: 300px; height: 46px; object-fit: cover; object-position: left center; border-radius: 6px; border: 1px solid var(--line); display: block; background: #fff; }

.anskey { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .25rem .75rem; }
.ans { display: flex; align-items: center; gap: .3rem; font-size: .85rem; }
.ans b { width: 24px; text-align: right; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.opt { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--muted); display: inline-grid; place-items: center; font-size: .65rem; cursor: pointer; user-select: none; color: var(--muted); background: transparent; padding: 0; }
.opt.on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.opt.right { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.wrong { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.key { box-shadow: 0 0 0 2px var(--ok); }
.ans.flag b { color: var(--warn); }

.review { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 820px) { .review { grid-template-columns: 1fr; } }
.review canvas { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); background: #fff; }

.modal { position: fixed; inset: 0; background: rgba(10, 14, 20, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--card); border-radius: var(--radius); width: min(1100px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 1.25rem; position: relative; }
.modal-x { position: absolute; right: .6rem; top: .4rem; border: 0; background: none; font-size: 1.6rem; color: var(--muted); cursor: pointer; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: .6rem 1rem; border-radius: 9px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.progress { height: 6px; background: var(--chip); border-radius: 99px; overflow: hidden; margin: .5rem 0; }
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

.heat { border-collapse: separate; border-spacing: 2px; font-size: .7rem; }
.heat td, .heat th { padding: 0; border: 0; width: 20px; height: 20px; text-align: center; }
.heat th { font-weight: 500; text-transform: none; letter-spacing: 0; }
.heat td.r { background: var(--ok); color: #fff; border-radius: 3px; }
.heat td.w { background: var(--bad); color: #fff; border-radius: 3px; opacity: .85; }
.heat td.b { background: var(--chip); border-radius: 3px; }
.heat td.name { text-align: left; width: auto; white-space: nowrap; padding-right: .5rem; font-size: .78rem; }
.chart-box { position: relative; height: 260px; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: .55rem .8rem; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
/* lousa */
.board { position: relative; background: radial-gradient(ellipse at 30% 20%, #3a6e55 0%, var(--board) 45%, var(--board-dark) 100%); border: 12px solid var(--wood); border-radius: 10px; box-shadow: inset 0 0 40px rgba(0,0,0,.35), 0 6px 18px rgba(90,60,40,.18); color: var(--chalk); display: grid; grid-template-columns: 1fr 240px; gap: 1rem; align-items: end; padding: 1.6rem 1.8rem 0; margin-bottom: 1.5rem; overflow: hidden; }
.board::after { content: ""; position: absolute; left: 18%; right: 18%; bottom: -12px; height: 10px; background: #8a5d33; border-radius: 3px; }
.board h1 { font-family: "Cinzel", Georgia, serif; color: var(--chalk); font-size: clamp(1.6rem, 3.6vw, 2.4rem); text-shadow: 0 0 1px rgba(255,255,255,.4); margin-bottom: .4rem; }
.board p { color: #dfe9e2; font-size: 1rem; max-width: 560px; }
.board .chalk { list-style: none; padding: 0; margin: .5rem 0 1.4rem; display: grid; gap: .3rem; font-size: .92rem; color: #eef3ec; }
.board .chalk li::before { content: "✓ "; color: #ffe79a; font-weight: 700; }
.board .chalk a { color: #ffe79a; text-decoration: underline; }
.board img { width: 240px; height: 240px; object-fit: cover; object-position: center top; border-radius: 50% 50% 0 0; display: block; }
@media (max-width: 720px) { .board { grid-template-columns: 1fr; padding: 1.2rem 1.2rem 0; } .board img { width: 170px; height: 170px; margin: 0 auto; } }
.title-rule { font-family: "Cinzel", Georgia, serif; color: var(--ink); font-size: 1.05rem; display: flex; align-items: center; gap: .6rem; margin: 0 0 .8rem; }
.title-rule .n { width: 30px; height: 30px; border-radius: 50%; background: var(--beige); display: inline-grid; place-items: center; font-family: "Montserrat", sans-serif; font-weight: 700; font-size: .85rem; color: var(--ink); }
.dashed { border: 1.5px dashed #d9c9bf; border-radius: 10px; padding: .75rem; }
.rejected { background: var(--bad-bg); border: 1px solid #efc4bd; border-radius: 10px; padding: .6rem .8rem; margin-top: .75rem; font-size: .85rem; }
.rejected summary { cursor: pointer; font-weight: 600; color: var(--bad); }
.xl-tabs { display: flex; gap: 2px; border-bottom: 2px solid #1e7145; margin-top: .5rem; }
.xl-tabs button { border: 1px solid var(--line); border-bottom: 0; background: #f3f3f3; padding: .35rem .8rem; font: inherit; font-size: .82rem; cursor: pointer; border-radius: 6px 6px 0 0; }
.xl-tabs button.on { background: #fff; color: #1e7145; font-weight: 700; border-color: #1e7145; }
.xl { overflow: auto; max-height: 60vh; border: 1px solid #d0d7de; border-top: 0; background: #fff; }
.xl table { border-collapse: collapse; font: 12px/1.3 Calibri, "Segoe UI", sans-serif; color: #222; }
.xl th, .xl td { border: 1px solid #d9d9d9; padding: 3px 6px; white-space: nowrap; text-transform: none; letter-spacing: 0; }
.xl thead th { position: sticky; top: 0; background: #1f5fbf; color: #fff; font-weight: 700; font-size: 12px; }
.xl td.rh, .xl th.rh { background: #f3f3f3; color: #666; text-align: center; font-weight: 400; }
.xl td.g { background: #c9f0d6; text-align: center; } .xl td.r { background: #fad4d0; text-align: center; } .xl td.c { text-align: center; }
.ocr-tag { font-size: .7rem; color: var(--muted); }
.trend-up { color: var(--ok); font-weight: 700; } .trend-down { color: var(--bad); font-weight: 700; } .trend-flat { color: var(--muted); }
