/* Build v2 — interface administrativa. Tema claro por padrão. */
@font-face { font-family: geomanist; font-weight: 400; font-style: normal; font-display: swap;
  src: url(fonts/geomanist-regular-webfont.woff2) format("woff2"), url(fonts/geomanist-regular-webfont.woff) format("woff"); }
@font-face { font-family: geomanist; font-weight: 600; font-style: normal; font-display: swap;
  src: url(fonts/geomanist-medium-webfont.woff2) format("woff2"), url(fonts/geomanist-medium-webfont.woff) format("woff"); }
@font-face { font-family: geomanist; font-weight: 700; font-style: normal; font-display: swap;
  src: url(fonts/geomanist-bold-webfont.woff2) format("woff2"), url(fonts/geomanist-bold-webfont.woff) format("woff"); }

:root {
  /* Paleta: coral #fa5a50, grafite #26282d, cinza #707378, fundos #f7f9fa / #f3f4f5 */
  --bg: #f7f9fa;
  --surface: #ffffff;
  --surface-2: #f3f4f5;
  --border: #e6e8ea;
  --text: #26282d;
  --muted: #707378;
  --primary: #fa5a50;
  --primary-strong: #d63d33;
  --primary-ink: #ffffff;
  --primary-soft: #fff0ef;
  --green: #12805c;
  --green-soft: #e6f4ee;
  --red: #b42318;
  --red-soft: #fdecea;
  --amber: #a15c00;
  --amber-soft: #fff4e2;
  --blue: #26282d;
  --blue-soft: #eceef0;
  --focus: 0 0 0 3px rgba(250, 90, 80, .35);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(38, 40, 45, .05), 0 1px 3px rgba(54, 57, 73, .09);
  --sidebar: 264px;
  --topbar: 60px;
  color-scheme: light;
}
/* Tema escuro só quando escolhido no botão do topo */
:root[data-theme="dark"] {
  --bg: #1b1d21; --surface: #26282d; --surface-2: #2f3237; --border: #3a3d43; --text: #f3f4f5; --muted: #aeb0b3;
  --primary: #fa5a50; --primary-strong: #ff7a70; --primary-ink: #ffffff; --primary-soft: #3a2422; --green: #3fc596; --green-soft: #173229;
  --red: #ff7a70; --red-soft: #3a1f1d; --amber: #f2b45c; --amber-soft: #3a2c15; --blue: #e6e8ea; --blue-soft: #34373d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 geomanist, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
a { color: var(--primary-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; }
h2 { font-size: 1.1rem; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.w-100 { width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- topo e menu ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 6px; border-radius: 10px; white-space: nowrap;
  background: var(--primary); color: var(--primary-ink); font-size: .8rem; font-weight: 800; letter-spacing: -.02em;
}
.brand-mark.lg { min-width: 52px; height: 52px; padding: 0 10px; font-size: 1rem; border-radius: 14px; }
.topbar-spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.nav-toggle { display: none; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 10px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-2); }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-strong); font-weight: 700; }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 6px); width: 240px; padding: 12px; display: grid; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - var(--topbar)); }
.sidebar {
  position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow-y: auto; padding: 12px 10px 24px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.nav-link, .nav-group > summary {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--text); cursor: pointer; font-weight: 550;
}
.nav-group > summary { list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-link:hover, .nav-group > summary:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary-strong); }
.nav-group > summary span { flex: 1; }
.chev { width: 16px; height: 16px; transition: transform .15s; color: var(--muted); }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-group ul { list-style: none; margin: 2px 0 6px; padding: 0 0 0 28px; }
.nav-sub { display: block; padding: 7px 10px; border-radius: 8px; color: var(--muted); }
.nav-sub:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-sub.active { color: var(--primary-strong); background: var(--primary-soft); font-weight: 600; }
.nav-backdrop { display: none; }

.main { padding: 24px; display: grid; gap: 18px; align-content: start; min-width: 0; max-width: 1400px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head p { margin-top: 2px; }
.section-title { font-size: .95rem; margin: 6px 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.section-title .small { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ---------- cartões e indicadores ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-title { margin-bottom: 12px; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.stat { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-ico { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex: none; }
.stat-ico .ico { width: 22px; height: 22px; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; word-break: break-word; }
.tone-green .stat-ico { background: var(--green-soft); color: var(--green); }
.tone-red .stat-ico { background: var(--red-soft); color: var(--red); }
.tone-amber .stat-ico { background: var(--amber-soft); color: var(--amber); }
.tone-blue .stat-ico { background: var(--blue-soft); color: var(--blue); }

/* ---------- gráfico ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .area-credito { fill: var(--green); opacity: .16; }
.chart .area-debito { fill: var(--red); opacity: .14; }
.chart .line { fill: none; stroke-width: 2.2; }
.chart .line-credito { stroke: var(--green); }
.chart .line-debito { stroke: var(--red); }
.chart .pt:hover rect { fill: var(--surface-2); fill-opacity: .6; }
.legend { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.key-credito { background: var(--green); }
.key-debito { background: var(--red); }

/* ---------- formulários ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: .9rem; }
.req { color: var(--red); }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=datetime-local], input[type=time],
input[type=email], input[type=number], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; min-height: 120px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.has-error input, .has-error select, .has-error textarea, [aria-invalid=true] { border-color: var(--red); }
.field-error { color: var(--red); font-size: .85rem; }
.hint { color: var(--muted); font-size: .82rem; }
.input-group { display: flex; align-items: stretch; }
.input-group > input { border-radius: 0 10px 10px 0; }
.input-group > input:first-child { border-radius: 10px 0 0 10px; }
.input-group > .btn { border-radius: 0 10px 10px 0; border-left: 0; }
.addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border); border-right: 0; border-radius: 10px 0 0 10px; background: var(--surface-2); color: var(--muted); }

.form-grid { display: grid; gap: 18px 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.field-wide { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; padding-top: 6px; border-top: 1px solid var(--border); }
.filter, .search { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.filter .field, .search .field { flex: 1 1 180px; }
.filter .grow, .search .grow { flex: 3 1 240px; }
.field-btn { flex: 0 0 auto !important; display: flex !important; gap: 8px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 42px; height: 24px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; flex: none; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .switch-ui { background: var(--primary); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { box-shadow: var(--focus); }
.switch.sm .switch-ui { width: 36px; height: 20px; }
.switch.sm .switch-ui::after { width: 14px; height: 14px; }
.switch.sm input:checked + .switch-ui::after { transform: translateX(16px); }
.field-switch { align-self: end; padding-bottom: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: .85rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* editor de texto */
.editor { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.editor-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.ed-btn { min-width: 34px; height: 32px; border: 0; border-radius: 7px; background: transparent; color: var(--text); cursor: pointer; font: inherit; font-size: .9rem; }
.ed-btn:hover, .ed-btn[aria-pressed=true] { background: var(--surface); }
.editor-sep { flex: 1; }
.editor-area { min-height: 220px; max-height: 70vh; overflow: auto; padding: 12px 14px; outline: none; }
.editor-area img { max-width: 100%; height: auto; }
.editor-source { border: 0 !important; border-radius: 0 !important; font-family: ui-monospace, Menlo, Consolas, monospace !important; font-size: .85rem !important; }
.editor[data-ready] .editor-source { display: none; }
.editor[data-mode=source] .editor-source { display: block; }
.editor[data-mode=source] .editor-area { display: none; }

/* upload */
.upload { display: grid; gap: 8px; }
.upload-row { display: flex; gap: 8px; flex-wrap: wrap; }
.upload-row .upload-name { flex: 1 1 200px; }
.upload-preview { display: grid; place-items: center; min-height: 120px; max-width: 360px; padding: 8px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-2); }
.upload-preview img { max-width: 100%; max-height: 220px; border-radius: 6px; }

/* links do checkout */
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.link-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.link-label { font-weight: 600; min-width: 110px; }
.link-url { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; font-size: .85rem; color: var(--muted); }
.nowrap { flex-wrap: nowrap; }

/* ---------- tabelas ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-card > .card-title { padding: 16px 18px 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.table thead th a { color: inherit; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td { font-weight: 600; background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-act { width: 1%; white-space: nowrap; text-align: center !important; }
.row-pending td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.cell-progress { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.progress { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress-bar { display: block; height: 100%; border-radius: 999px; }
.bar-red { background: var(--red); }
.bar-green { background: var(--green); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 650; }
.pill-on { background: var(--green-soft); color: var(--green); }
.pill-off { background: var(--red-soft); color: var(--red); }
.pill-warn { background: var(--amber-soft); color: var(--amber); }
.pill-info { background: var(--primary-soft); color: var(--primary-strong); }
.del-check { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--muted); }
.del-check input { width: 18px; height: 18px; accent-color: var(--red); }
.del-check:has(input:checked) { color: var(--red); }
tr:has(.del-check input:checked) { background: var(--red-soft) !important; }
.table-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; }
.pager a, .pager .gap { min-width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0 8px; border-radius: 9px; border: 1px solid var(--border); color: var(--text); }
.pager a:hover { background: var(--surface-2); text-decoration: none; }
.pager a.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.pager .gap { border-color: transparent; }
.empty { text-align: center; padding: 36px; }

/* ---------- avisos ---------- */
.alert { position: relative; padding: 12px 40px 12px 14px; border-radius: 10px; border: 1px solid; }
.alert-success { background: var(--green-soft); border-color: transparent; color: var(--green); }
.alert-error { background: var(--red-soft); border-color: transparent; color: var(--red); }
.alert-info { background: var(--blue-soft); border-color: transparent; color: var(--blue); }
.alert-x { position: absolute; right: 8px; top: 6px; border: 0; background: transparent; color: inherit; font-size: 20px; cursor: pointer; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  /* Imagem de fundo da tela de bloqueio do sistema antigo, sem filtro */
  background: url(lock-screen.jpg) center / cover no-repeat fixed, #26282d; }
.login-card { width: min(100%, 400px); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.35); padding: 28px; display: grid; gap: 18px; }
@media (max-width: 900px) { .login-page { background-attachment: scroll; } }
.login-head { display: flex; align-items: center; gap: 14px; }
.login-head h1 { font-size: 1.3rem; }
.stack { display: grid; gap: 14px; }

/* ---------- responsivo ---------- */
@media (max-width: 900px) {
  .nav-toggle { display: inline-grid; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; left: 0; top: var(--topbar); width: min(86vw, var(--sidebar)); transform: translateX(-102%); transition: transform .2s; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--topbar) 0 0 0; z-index: 35; background: rgba(0,0,0,.35); }
  .main { padding: 16px; }
  .user-name { display: none; }
}
@media (max-width: 640px) {
  /* Tabelas viram cartões empilhados no celular */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td, .table tfoot { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table td { border: 0; padding: 6px 16px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; font-weight: 600; }
  .table td:not([data-label])::before { content: none; }
  .table td.col-act { width: 100%; justify-content: flex-end; }
  .table .num { text-align: right; }
  .cell-progress { min-width: 0; }
  .row-pending td:first-child { box-shadow: none; }
  .row-pending { box-shadow: inset 3px 0 0 var(--amber); }
  h1 { font-size: 1.3rem; }
}
@media print {
  .topbar, .sidebar, .filter, .search, .table-foot, .form-actions { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; }
}
