/* Plataforma Ovation. Layout: barra de topo com abas; cada aba é uma tela. */
:root {
  --bg: #FFF7EA;
  --surface: #FFFDF8;
  --col: #FBEAD6;
  --ink: #4A1A0C;
  --muted: #8A5A45;
  --line: #EBD2B6;
  --accent: #F2440C;
  --accent-ink: #FFFFFF;
  --late: #B3261E;
  --late-bg: #FBE1DC;
  --done: #1F7A4D;
  --done-bg: #DDF0E4;
  --shadow: 0 1px 2px rgba(74, 26, 12, .08), 0 4px 12px rgba(74, 26, 12, .06);
  --font-display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A110D;
    --surface: #2B1C16;
    --col: #221510;
    --ink: #F7E8D8;
    --muted: #C29C86;
    --line: #47291E;
    --accent: #FF6B36;
    --accent-ink: #1A110D;
    --late: #FF8F84;
    --late-bg: #4A1D19;
    --done: #7FD3A4;
    --done-bg: #173626;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 12px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; margin: 0; text-wrap: balance; }

/* Topo */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { font-size: 22px; line-height: 1; color: var(--accent); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.tab:hover { color: var(--ink); border-color: var(--line); }
.tab[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.top .sair { margin-left: auto; }

.field {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 38px;
}
.btn {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 38px;
  font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger { color: var(--late); }
.btn-small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.is-on { border-color: var(--accent); color: var(--accent); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.aviso { margin: 0; padding: 8px 20px; font-size: 13px; background: var(--late-bg); color: var(--late); border-bottom: 1px solid var(--line); }
.view { flex: 1; min-height: 0; overflow: auto; }
.page { max-width: 1120px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.page-head h2 { font-size: 22px; margin-right: auto; }
.nota { margin: 0; font-size: 12px; color: var(--muted); }

/* Login */
.login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login-box h1 { color: var(--accent); font-size: 26px; }

/* Período */
.periodo { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.periodo .sep { color: var(--muted); font-size: 13px; }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .val { font-family: var(--font-display); font-weight: 800; font-size: 24px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.neg .val { color: var(--late); }
.kpi.pos .val { color: var(--done); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.panel-head h3 { font-size: 16px; margin-right: auto; text-transform: uppercase; letter-spacing: .04em; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 600; border-top: 2px solid var(--line); border-bottom: 0; }
td .mut { color: var(--muted); font-size: 12px; }
.tag { display: inline-block; font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; background: var(--bg); white-space: nowrap; }
.tag-late { background: var(--late-bg); color: var(--late); border-color: var(--late); font-weight: 600; }
.vazio-t { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; border: 1px dashed var(--line); border-radius: 8px; margin: 0; }

/* Gráfico de barras */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }

/* DRE */
.dre td { padding: 9px 10px; }
.dre tr.sub td { font-weight: 600; background: var(--col); }
.dre tr.res td { font-weight: 800; font-family: var(--font-display); font-size: 16px; background: var(--col); }
.dre tr.det td:first-child { padding-left: 28px; color: var(--muted); }
.dre .negv { color: var(--late); }
.dre .posv { color: var(--done); }

/* Quadro kanban */
.board-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px 0; align-items: center; }
.board-tools .resumo { margin-right: auto; color: var(--muted); font-size: 13px; }
#busca { width: 190px; }
.board { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 12px 20px 20px; overflow-x: auto; scroll-snap-type: x proximity; }
.esteira { display: flex; flex-direction: column; height: 100%; }
.col { flex: 1 0 264px; max-width: 360px; min-width: 0; display: flex; flex-direction: column; background: var(--col); border: 1px solid var(--line); border-radius: 12px; scroll-snap-align: start; min-height: 0; }
.col-head { display: flex; align-items: baseline; gap: 8px; padding: 12px 12px 4px; }
.col-step { font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; color: var(--muted); }
.col-head h3 { font-size: 15px; letter-spacing: .04em; text-transform: uppercase; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.col-count { font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.col-hint { margin: 0; padding: 0 12px 8px; font-size: 12px; color: var(--muted); }
.col.is-last .col-head h3 { color: var(--done); }
.list { flex: 1; min-height: 60px; overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 8px; }
.list.is-over { background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 8px; }
.drop-line { height: 3px; border-radius: 3px; background: var(--accent); flex: none; }
.vazio { margin: 4px; padding: 12px; font-size: 13px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; text-align: center; }
.col-add { margin: 0 8px 8px; border: 1px dashed var(--line); background: transparent; border-radius: 8px; padding: 8px; color: var(--muted); font-weight: 600; }
.col-add:hover { color: var(--accent); border-color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 10px 8px; display: flex; flex-direction: column; gap: 8px; flex: none; cursor: grab; }
.card.is-dragging { opacity: .4; }
.card-thumb { width: 100%; height: 120px; object-fit: contain; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.card-title { all: unset; cursor: pointer; font-weight: 600; font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.card-title:hover { color: var(--accent); }
.card-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.card-notes { margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; background: var(--bg); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.chip-colecao { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip-preco { font-weight: 600; }
.chip-late { background: var(--late-bg); color: var(--late); border-color: var(--late); font-weight: 600; }
.chip-done { background: var(--done-bg); color: var(--done); border-color: var(--done); font-weight: 600; }
.card-foot { display: flex; align-items: center; gap: 6px; }
.card-foot a { font-size: 12px; color: var(--accent); font-weight: 600; margin-right: auto; }
.card-foot .spacer { margin-right: auto; }
.mini { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; min-width: 30px; min-height: 28px; padding: 2px 8px; font-size: 13px; font-weight: 600; }
.mini:hover { border-color: var(--accent); color: var(--accent); }
.mini[disabled] { opacity: .35; cursor: not-allowed; }

/* Diálogos */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 0; width: min(620px, calc(100vw - 32px)); max-height: calc(100% - 32px); box-shadow: var(--shadow); overflow: auto; }
dialog::backdrop { background: rgba(26, 17, 13, .55); }
.dlg-form { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.dlg-form h3 { font-size: 20px; }
.sec { margin: 4px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-family: var(--font-display); font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.row label, .row .lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.row input, .row select, .row textarea { width: 100%; }
.row textarea { resize: vertical; min-height: 72px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.sizes { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 8px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.margem { display: flex; align-items: center; min-height: 38px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; font-variant-numeric: tabular-nums; font-weight: 600; }
.margem.neg { color: var(--late); border-color: var(--late); }
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.file-thumb, .file-tag { width: 64px; height: 64px; flex: none; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.file-thumb { object-fit: contain; }
.file-tag { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.file-info { flex: 1; min-width: 140px; display: flex; flex-direction: column; }
.file-name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.file-size { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.file a { font-size: 13px; font-weight: 600; color: var(--accent); }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; bottom: -20px; background: var(--surface); padding: 12px 0; border-top: 1px solid var(--line); }
.dlg-actions .push { margin-left: auto; }
.erro { margin: 0; font-size: 13px; color: var(--late); }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 13px; max-width: calc(100vw - 32px); box-shadow: var(--shadow); z-index: 10; }

@media (max-width: 720px) {
  .top { padding: 10px 16px; }
  .page { padding: 16px; }
  .two { grid-template-columns: 1fr; }
  .board, .board-tools { padding-left: 16px; padding-right: 16px; }
  .board { scroll-snap-type: x mandatory; }
  .col { flex-basis: 84%; max-width: none; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  #busca { flex: 1; width: auto; min-width: 0; }
}

/* Painel */
.dash { display: flex; flex-direction: column; gap: 20px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.delta { font-size: 12px; font-weight: 600; color: var(--muted); }
.delta.up { color: var(--done); }
.delta.down { color: var(--late); }
.alertas { margin: 0; padding: 12px 16px 12px 32px; background: var(--late-bg); color: var(--late); border: 1px solid var(--line); border-radius: 12px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(96px, 36%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar-nome { overflow-wrap: anywhere; }
.hbar-trilho { height: 10px; background: var(--col); border-radius: 6px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.hbar-fill.res { background: var(--done); }
.hbar-fill.neg { background: var(--late); }
.hbar-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.mini-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-kpis div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mini-kpis .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.mini-kpis strong { font-family: var(--font-display); font-size: 18px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sub-t { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.lista-curta { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.lista-curta li { display: flex; justify-content: space-between; gap: 8px; }
.link-tela { font-size: 13px; font-weight: 600; color: var(--accent); margin-top: auto; }
.file-thumb-link { flex: none; display: block; border-radius: 6px; }
@media (max-width: 960px) { .three { grid-template-columns: 1fr; } }
