/* ARP CMS. Palette from app/lib/core/theme/app_colors.dart. */
:root {
  --green: #58C069;
  --green-strong: #46A956;
  --green-dark: #2F7D3D;
  --green-deep: #173D1F;
  --green-soft: #D8EFDC;
  --green-softer: #EEF8EF;
  --ink: #141714;
  --ink-2: #262A26;
  --muted: #7D827C;
  --card: #FFFFFF;
  --sand: #EEE9E5;
  --sand-light: #F6F3F0;
  --divider: #E7E3DE;
  --clay: #E0734A;
  --gold: #C9A227;
  --danger: #B5402A;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 23, 20, .06), 0 4px 16px rgba(20, 23, 20, .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--sand-light);
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--sand-light); }
a { color: var(--green-dark); }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--sand); padding: .05em .35em; border-radius: 6px; }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }
.big { font-size: 1.15rem; font-weight: 600; margin: .25rem 0; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--green-deep); color: #fff; padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none; font-weight: 600; }
.brand .logo { background: var(--green); color: var(--green-deep); font-weight: 800; padding: .2rem .5rem; border-radius: 8px; letter-spacing: .04em; }
.brand.big { font-size: 1.2rem; margin-bottom: 1rem; color: var(--ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: #DDE9DF; text-decoration: none; padding: .45rem .7rem; border-radius: 10px; font-size: .95rem; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.on { background: var(--green); color: var(--green-deep); font-weight: 600; }
.nav-group { margin: .8rem .7rem .2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8FB59A; }
.topbar { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; margin-bottom: 1rem; }
.who { display: flex; flex-direction: column; align-items: flex-end; font-size: .9rem; line-height: 1.25; }
.who small { color: var(--muted); }
.main { padding: 1.5rem 2rem 3rem; max-width: 1200px; width: 100%; }
.bare { min-height: 100vh; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: .75rem 1rem; gap: .5rem; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: .25rem; }
  .nav a { white-space: nowrap; }
  .nav-group { display: none; }
  .main { padding: 1rem 1rem 3rem; }
}

/* Building blocks */
.page-head { margin-bottom: 1rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 520px; margin: 3rem auto; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
.grid2 > .card, .grid3 > .card { margin-bottom: 1rem; }
@media (max-width: 700px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
td.actions { white-space: nowrap; }
.inline { display: inline; margin: 0; }
.stack { display: flex; flex-direction: column; gap: .25rem; }

.flash { background: var(--green-soft); color: var(--green-deep); padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.alert { background: #FBE5DD; color: #7A2A16; padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.saved { color: var(--green-dark); font-size: .85rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font: inherit; font-size: .92rem; font-weight: 600; padding: .5rem .95rem; border-radius: 999px; border: 1px solid var(--divider); background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--green-dark); }
.btn.primary { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.btn.primary:hover { background: var(--green-deep); }
.btn.danger { color: var(--danger); border-color: #EBC3B6; }
.btn.danger:hover { background: #FBE5DD; }
.btn.sm { padding: .25rem .65rem; font-size: .82rem; }
.btn.wide { width: 100%; padding: .7rem; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--green-dark); text-decoration: underline; cursor: pointer; }

/* Forms */
.form .actions { margin-top: .75rem; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; min-width: 0; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea, .text-row textarea, .alt-form input {
  font: inherit; font-size: .95rem; padding: .55rem .7rem; border: 1px solid var(--divider); border-radius: var(--radius-sm); background: #fff; color: var(--ink); width: 100%;
}
.field textarea, .text-row textarea { resize: vertical; min-height: 4.5rem; }
.field input:focus, .field select:focus, .field textarea:focus, .text-row textarea:focus, .code-input:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }
.field small { color: var(--muted); }
.field.compact { margin-bottom: 0; }
.field.grow { flex: 1; }
.invalid input, .invalid select, .invalid textarea { border-color: var(--danger); background: #FFF8F6; }
.err { color: var(--danger); font-style: normal; font-size: .85rem; }
.check { display: flex; align-items: center; gap: .5rem; margin: .4rem 0; flex-wrap: wrap; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--green-dark); }
.image-field .thumb { width: 160px; height: 100px; object-fit: cover; border-radius: var(--radius-sm); background: var(--sand); }
.filters { display: flex; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; flex-wrap: wrap; }
.refs { margin: .5rem 0 1rem; font-size: .88rem; }
.refs summary { cursor: pointer; color: var(--green-dark); font-weight: 600; }
.refs ul { margin: .3rem 0; padding-left: 1rem; max-height: 220px; overflow: auto; }
.danger-zone { margin: 0 0 1.5rem; display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.danger-zone p { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--divider); }
td { padding: .6rem; border-bottom: 1px solid var(--divider); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mini { width: 52px; height: 40px; object-fit: cover; border-radius: 8px; background: var(--sand); display: block; }
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .55rem; border-radius: 999px; background: var(--sand); color: var(--ink-2); }
.pill.ok, .pill.active { background: var(--green-soft); color: var(--green-deep); }
.pill.off, .pill.expired { background: var(--sand); color: var(--muted); }
.pill.used { background: #DCE6F5; color: #23406B; }
.pill.clay { background: #FBE1D6; color: #8A3517; }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; vertical-align: middle; background: var(--green); }
.dot.clay { background: var(--clay); } .dot.ink { background: var(--ink); } .dot.gold { background: var(--gold); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .5rem 0; border-bottom: 1px solid var(--divider); }
.list li:last-child { border-bottom: 0; }
.pager { display: flex; gap: .5rem; margin: 1rem 0; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .15rem; color: inherit; text-decoration: none; }
.kpi span { font-size: .82rem; color: var(--muted); }
.kpi strong { font-size: 1.7rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
a.kpi:hover { outline: 2px solid var(--green-soft); }

/* Segmented control */
.segmented { display: inline-flex; background: var(--sand); border-radius: 999px; padding: 3px; gap: 2px; margin-bottom: 1rem; flex-wrap: wrap; }
.segmented a { padding: .4rem 1rem; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .9rem; }
.segmented a.on { background: #fff; color: var(--green-deep); box-shadow: var(--shadow); }
.segmented.small { margin-bottom: .5rem; }
.segmented.small a { padding: .25rem .7rem; font-size: .82rem; }

/* Merchant panel */
.validate { border: 2px solid var(--green-soft); }
.code-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.code-input { font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.3rem; letter-spacing: .08em; text-transform: uppercase; padding: .55rem .8rem; border: 1px solid var(--divider); border-radius: var(--radius-sm); flex: 1; min-width: 0; max-width: 320px; }
.result { margin-top: 1rem; padding: 1rem 1.1rem; border-radius: var(--radius-sm); background: var(--sand-light); border-left: 5px solid var(--muted); }
.result > strong { font-size: 1.1rem; }
.result p { margin: .3rem 0; }
.result.valido { background: var(--green-softer); border-color: var(--green); }
.result.confirmado { background: var(--green-soft); border-color: var(--green-dark); }
.result.usado { background: #EEF2F8; border-color: #5A7BB0; }
.result.expirado, .result.nao-encontrado, .result.invalido { background: #FDF0EA; border-color: var(--clay); }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; margin: .6rem 0 .9rem; font-size: .92rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; }
.bars { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; align-items: end; height: 160px; padding-bottom: 1.2rem; position: relative; }
.bar { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.bar i { display: block; background: var(--green); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar span { position: absolute; bottom: -1.2rem; left: 0; font-size: .7rem; color: var(--muted); }
.stock { padding: .6rem 0 .9rem; border-bottom: 1px solid var(--divider); }
.stock:last-child { border-bottom: 0; }
.stock-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.squares { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.sq { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: var(--sand); border: 1px solid var(--divider); vertical-align: middle; }
.sq.used { background: var(--green-dark); border-color: var(--green-dark); }
.sq.held { background: var(--clay); border-color: var(--clay); }
.sq.free { background: #fff; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: .5rem; }

/* Texts and images */
.text-row { display: grid; grid-template-columns: 260px 1fr auto; gap: .75rem; align-items: start; padding: .75rem 0; border-bottom: 1px solid var(--divider); margin: 0; }
.text-row:last-child { border-bottom: 0; }
.text-key { display: flex; flex-direction: column; gap: .3rem; }
.text-key code { align-self: flex-start; }
.plain { font: inherit; font-size: .82rem; color: var(--muted); border: 0; border-bottom: 1px dashed var(--divider); background: transparent; padding: .1rem 0; }
.text-actions { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; }
@media (max-width: 700px) { .text-row { grid-template-columns: 1fr; } }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.slot-item { margin: 0; background: var(--sand-light); border-radius: var(--radius-sm); padding: .5rem; }
.slot-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; background: var(--sand); }
.slot-item figcaption { font-size: .8rem; margin: .4rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.media-item { margin: 0; padding: .6rem; display: flex; flex-direction: column; }
.media-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--sand); display: block; }
.media-item figcaption { display: flex; flex-direction: column; gap: .3rem; padding-top: .5rem; font-size: .88rem; }
.media-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alt-form { display: flex; gap: .3rem; align-items: center; margin: 0; }
.alt-form input { padding: .3rem .5rem; font-size: .85rem; }

/* Map editor */
.map-layout { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .map-layout { grid-template-columns: 1fr; } }
.map-card { position: sticky; top: 1rem; }
.map { width: 100%; height: auto; display: block; cursor: crosshair; border-radius: var(--radius-sm); user-select: none; }
.map-bg { fill: #F1EEE6; }
.area rect { fill: #E4DED3; stroke: #CFC7B8; stroke-width: 2; }
.area.square rect { fill: var(--green-soft); stroke: #B7DDBF; }
.area.parking rect { fill: #DDE3EA; stroke: #C3CCD6; }
.area.editing rect { stroke: var(--clay); stroke-width: 4; }
.area text { font-size: 22px; fill: var(--ink-2); font-weight: 600; pointer-events: none; }
.place circle { fill: var(--green-dark); stroke: #fff; stroke-width: 4; }
.place.landmark circle { fill: var(--ink); }
.place.editing circle { fill: var(--clay); }
.place text { font-size: 18px; fill: var(--ink); pointer-events: none; paint-order: stroke; stroke: #F1EEE6; stroke-width: 4px; }
.ghost { fill: rgba(224, 115, 74, .15); stroke: var(--clay); stroke-width: 3; stroke-dasharray: 8 6; pointer-events: none; }
.marker { fill: none; stroke: var(--clay); stroke-width: 5; pointer-events: none; }
.map-side .card { margin-bottom: 1rem; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--green-softer), var(--sand-light)); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 24px; box-shadow: var(--shadow); padding: 2rem 1.75rem; }

/* Printable QR */
body.print { background: #fff; }
.qr-sheet { max-width: 560px; margin: 2rem auto; text-align: center; padding: 1rem; }
.qr-sheet .eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .8rem; color: var(--green-dark); font-weight: 700; margin: 0; }
.qr-sheet h1 { font-size: 2.2rem; margin: .3rem 0; }
.qr-sheet .lead { font-size: 1.2rem; margin: 0 0 1rem; }
.qr-box { width: min(100%, 420px); margin: 0 auto 1rem; border: 3px solid var(--green-deep); border-radius: 24px; padding: 12px; }
.qr-box svg { width: 100%; height: auto; display: block; }
@media print {
  .no-print { display: none; }
  .qr-sheet { margin: 0 auto; }
}

/* API keys */
.key-box { display: flex; gap: .5rem; align-items: center; margin: .75rem 0 1.25rem; flex-wrap: wrap; }
.key-input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem; padding: .6rem .75rem; border: 1px solid var(--divider); border-radius: var(--radius-sm); background: var(--sand-light); color: var(--ink); }
.snippet { background: var(--ink); color: #E8F2EA; padding: .8rem 1rem; border-radius: var(--radius-sm); overflow-x: auto; font-size: .85rem; }
.snippet code { background: none; padding: 0; color: inherit; white-space: pre; }

/* API docs (Redoc) */
body.docs { background: #fff; }
.docs-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .6rem 1.25rem; background: var(--green-deep); color: #fff; }
.docs-bar .actions a { color: #DDE9DF; text-decoration: none; font-size: .9rem; padding: .3rem .6rem; border-radius: 8px; }
.docs-bar .actions a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.docs-fallback { padding: 1.5rem; }
