:root {
  --cream: #F6EAD0;
  --paper: #FBF6EA;
  --card: #FFFFFF;
  --brown: #41291A;
  --gold: #DFA800;
  --olive: #6F7D4C;
  --taupe: #B4A99A;
  --line: #E4DACB;
  --muted: #7A6A58;
  --alert: #9A3B1F;
  --ok: #4F5E35;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper:#1F160F; --card:#2A1F16; --brown:#F6EAD0; --line:#4A3B2C; --muted:#B4A99A; --cream:#2A1F16; }
}
:root[data-theme="dark"] { --paper:#1F160F; --card:#2A1F16; --brown:#F6EAD0; --line:#4A3B2C; --muted:#B4A99A; --cream:#2A1F16; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--brown); font-family: Raleway, "Segoe UI", Arial, sans-serif; font-size: 14px; line-height: 1.4; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; margin-bottom: 4px; }
.sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.vazio { color: var(--muted); font-size: 13px; margin: 6px 0; }
.erro { color: var(--alert); font-size: 13px; min-height: 1em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }

/* Botões e campos */
button.btn, label.btn { background: var(--olive); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; cursor: pointer; display: inline-block; }
button.btn.ghost, label.btn.ghost { background: transparent; color: var(--brown); border: 1px solid var(--taupe); }
button.btn.danger { background: transparent; color: var(--alert); border: 1px solid var(--alert); }
button.btn.sm, label.btn.sm { padding: 4px 9px; font-size: 12px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .dia:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
input, select, textarea { font: inherit; color: var(--brown); background: var(--card); border: 1px solid var(--taupe); border-radius: 6px; padding: 7px 9px; max-width: 100%; }
textarea { width: 100%; min-height: 64px; resize: vertical; }
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.esq { margin-right: auto; }

/* Casca */
/* Tela de login: imagem de fundo opcional (configurada pelo super-admin); o cartão fica à direita e com 75% de opacidade */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: flex-end; padding: 16px 8vw; background: var(--paper) url("/api/fundo-login") center / cover no-repeat; }
.cartao-login { background: rgba(65, 41, 26, .75); color: #F6EAD0; border: 1px solid rgba(92, 68, 49, .8); border-radius: 10px; padding: 22px; width: min(360px, 100%); display: grid; gap: 12px; }
.cartao-login label, .cartao-login .sub { color: #DCCDB0; }
.cartao-login input { background: #2E1E13; color: #F6EAD0; border-color: #6B5240; }
.cartao-login .btn { background: #6F7D4C; color: #fff; }
.topo { background: #41291A; color: #F6EAD0; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
/* Logo: fundo branco original vira um disco, legível no topo claro e no escuro */
/* Logo transparente (dourado): fica sobre a barra marrom fixa, nos dois temas */
.logo-login { width: 200px; height: auto; justify-self: center; }
.logo-topo { height: 36px; width: auto; flex: none; }
.marca-topo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.marca { font-family: Georgia, serif; font-weight: 400; font-size: 18px; letter-spacing: .3px; white-space: nowrap; }
.topo .btn.ghost { color: #F6EAD0; border-color: #8C7A66; }
.grupo-topo { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.campo-autor { color: #DCCDB0; font-size: 12px; display: flex; gap: 6px; align-items: center; }
.campo-autor input { width: 150px; padding: 4px 8px; background: #3A2A1E; color: var(--cream); border-color: #8C7A66; }
.corpo { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 52px); }
.menu { background: var(--cream); border-right: 1px solid var(--line); padding: 12px 8px; display: grid; align-content: start; gap: 2px; }
.menu a { color: var(--muted); text-decoration: none; padding: 9px 10px; border-radius: 6px; border-left: 3px solid transparent; }
.menu a:hover { background: var(--paper); color: var(--brown); }
.menu a[aria-current="page"] { color: var(--brown); font-weight: 700; border-left-color: var(--gold); background: var(--paper); }
main#conteudo { padding: 18px; min-width: 0; outline: none; }
.status { position: fixed; bottom: 10px; left: 12px; font-size: 12px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; max-width: calc(100vw - 24px); }
.status:empty { display: none; }

.barra { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.grupo { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Visão geral */
.cards-inicio { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.item { border-top: 1px solid var(--line); padding: 8px 0; display: grid; gap: 3px; }
.item:first-child { border-top: 0; padding-top: 0; }
.item .meta { font-size: 12px; color: var(--muted); }
.destaque { font-family: Georgia, serif; font-size: 22px; margin: 6px 0 2px; }
.atalhos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Rótulos e tipos */
.t-campanha { --c: #41291A; --tx: #fff; }
.t-previa { --c: #6F7D4C; --tx: #fff; }
.t-bazar { --c: #DFA800; --tx: #41291A; }
.t-botafora { --c: #9A3B1F; --tx: #fff; }
.t-data { --c: #B5653F; --tx: #fff; }
.t-feriado { --c: #7A6A58; --tx: #fff; }
.t-ferias { --c: #B4A99A; --tx: #41291A; }
.t-conteudo { --c: #3F6E8C; --tx: #fff; }
.t-outro { --c: #4F5E35; --tx: #fff; }
.rotulo { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--c); color: var(--tx); }

/* Calendário */
.filtros { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filtro { border: 1px solid var(--taupe); background: transparent; color: var(--muted); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.filtro::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.filtro[aria-pressed="true"] { color: var(--brown); border-color: var(--brown); font-weight: 700; }
.filtro[aria-pressed="false"]::before { opacity: .25; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.semana, .grade { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.semana div { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; text-transform: uppercase; letter-spacing: .5px; }
.grade { gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.dia { background: var(--card); min-height: 96px; padding: 5px 6px 6px; cursor: pointer; min-width: 0; }
.dia:hover { filter: brightness(.98); }
.dia.fora { background: var(--paper); color: var(--taupe); }
.dia.fora .chip { opacity: .5; }
.dia.estacao { background: color-mix(in srgb, var(--est) 14%, var(--card)); }
.dia.fora.estacao { background: color-mix(in srgb, var(--est) 6%, var(--paper)); }
.dia .num { font-size: 13px; font-weight: 700; display: inline-block; min-width: 24px; }
.dia.hoje .num { background: var(--brown); color: var(--paper); border-radius: 50%; text-align: center; width: 24px; height: 24px; line-height: 24px; min-width: 0; }
.dia.sel { box-shadow: inset 0 0 0 2px var(--gold); }
.dia .evs { min-width: 0; }
.chip { display: block; background: var(--c); color: var(--tx); border-radius: 4px; padding: 2px 5px; font-size: 11px; line-height: 1.25; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; text-align: left; border: 0; width: 100%; font-family: inherit; }
.mais { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; }
.dots { display: none; }
.dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.lista-evento { border-top: 1px solid var(--line); padding: 8px 0; display: grid; gap: 4px; }
.lista-evento:first-child { border-top: 0; padding-top: 0; }
.lista-evento .meta { font-size: 12px; color: var(--muted); }
.roteiro { white-space: pre-wrap; font-size: 12px; background: var(--cream); border-radius: 6px; padding: 8px; color: var(--brown); max-height: 160px; overflow: auto; }
.bloco-periodo { margin-top: 8px; }
.bloco-periodo h4 { margin: 8px 0 2px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 700; }
.estacao-legenda { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 10px; font-size: 12px; color: var(--muted); }
.estacao-legenda span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--est); margin-right: 5px; vertical-align: -1px; }

/* Listas, tabelas e temporadas */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar input[type="search"] { min-width: 220px; flex: 1; }
.tabela-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--card); max-height: 70vh; }
table.lista { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lista th, table.lista td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.lista th { position: sticky; top: 0; background: var(--cream); font-size: 12px; color: var(--muted); z-index: 1; }
table.lista td.acoes { white-space: nowrap; }
.feito { text-decoration: line-through; color: var(--muted); }
.temporadas { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.temporada { border-top: 6px solid var(--est); display: grid; gap: 8px; align-content: start; }
.temporada .linha { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.temporada .info { font-size: 12px; color: var(--muted); }

/* Visão anual */
.gantt-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.gantt { min-width: 900px; display: grid; grid-template-columns: 210px repeat(var(--n), minmax(46px, 1fr)); position: relative; }
.gantt > div { padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 12px; }
.gantt .cab { font-weight: 700; color: var(--muted); text-align: center; text-transform: capitalize; border-bottom: 1px solid var(--taupe); }
.gantt .cab small { display: block; font-weight: 400; color: var(--taupe); font-size: 10px; }
.gantt .rot { position: sticky; left: 0; background: var(--card); z-index: 1; border-right: 1px solid var(--line); }
.gantt .rot b { display: block; font-size: 13px; }
.gantt .trilha { grid-column: 2 / -1; position: relative; padding: 0; min-height: 46px; }
.gantt .barra { position: absolute; top: 10px; height: 26px; border-radius: 6px; background: var(--est); color: #fff; font-size: 11px; line-height: 26px; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 6px; }
.gantt .hoje-linha { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--alert); z-index: 2; }
.gantt .cont { text-align: center; font-variant-numeric: tabular-nums; border-bottom: 0; }
.gantt .rot-cont { border-bottom: 0; position: sticky; left: 0; background: var(--card); font-weight: 700; color: var(--muted); }
.resumo-tipos { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 14px; }

/* Precificador */
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.abas button { background: transparent; border: 0; border-bottom: 3px solid transparent; padding: 8px 12px; font: inherit; color: var(--muted); cursor: pointer; }
.abas button[aria-selected="true"] { color: var(--brown); border-bottom-color: var(--gold); font-weight: 700; }
.grade-tabela { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
table.prec { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13px; }
table.prec th, table.prec td { padding: 5px 7px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); white-space: nowrap; text-align: right; vertical-align: middle; }
table.prec th { position: sticky; top: 0; background: var(--cream); font-size: 12px; color: var(--muted); z-index: 2; font-weight: 700; }
table.prec td input { width: 92px; text-align: right; padding: 4px 6px; }
table.prec td.texto input { width: 140px; text-align: left; }
table.prec td.calc { background: var(--paper); color: var(--brown); }
table.prec td.situacao { text-align: left; white-space: normal; min-width: 210px; font-size: 12px; }
table.prec th.grupo-site { background: #E9DFC9; }
table.prec th.grupo-tt { background: #DCE5CB; }
.sticky1 { position: sticky; left: 0; background: var(--card); z-index: 1; }
.sticky2 { position: sticky; left: 130px; background: var(--card); z-index: 1; }
table.prec th.sticky1, table.prec th.sticky2 { z-index: 3; background: var(--cream); }
.neg { color: var(--alert); }
.pos { color: var(--ok); }
table.premissas { border-collapse: collapse; font-size: 13px; }
table.premissas th, table.premissas td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.premissas input { width: 110px; }
.aviso-prov { background: var(--cream); border-left: 4px solid var(--gold); padding: 10px 12px; border-radius: 4px; font-size: 13px; margin-bottom: 12px; }

/* Usuários */
.grade-usuario { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; align-items: end; }
.grade-usuario label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.modulos-campo { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; display: flex; gap: 12px; flex-wrap: wrap; margin: 0; }
.modulos-campo legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.check, .grade-usuario label.check, .modulos-campo label.check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--brown); }
.modulos-linha { white-space: normal; min-width: 260px; }
.modulos-linha .check { margin-right: 10px; }
.nome-usuario { color: var(--cream); opacity: .85; font-size: 13px; }
.historico { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
.historico li { margin: 2px 0; }
.fundo-linha { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-top: 8px; }
.fundo-previa { width: 220px; height: 110px; border: 1px dashed var(--taupe); border-radius: 8px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px; background: var(--paper) center / cover no-repeat; }
.fundo-previa.vazio-previa { background-image: none; }

/* Diálogo */
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--brown); padding: 18px; width: min(520px, calc(100vw - 32px)); max-height: 90vh; }
dialog::backdrop { background: rgba(31, 22, 15, .45); }
dialog form { display: grid; gap: 10px; }
dialog .grade-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog .botoes { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }

/* Celular */
@media (max-width: 860px) {
  .corpo { grid-template-columns: 1fr; }
  .menu { grid-auto-flow: column; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; }
  .menu a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; border-radius: 0; }
  .menu a[aria-current="page"] { border-bottom-color: var(--gold); border-left-color: transparent; }
  .cal-layout { grid-template-columns: 1fr; }
  .temporada .linha { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main#conteudo { padding: 12px; }
  .topo { padding: 10px 12px; }
  .marca { white-space: nowrap; font-size: 16px; }
  .rotulo-autor { display: none; }
  .login { justify-content: center; padding: 16px; }
  .campo-autor input { width: 120px; }
  .dia { min-height: 56px; padding: 4px 3px; }
  .chip, .mais { display: none; }
  .dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 3px; }
  .dot { display: inline-block; }
  .dia .num { font-size: 12px; min-width: 20px; }
  .dia.hoje .num { width: 20px; height: 20px; line-height: 20px; }
  .toolbar input[type="search"] { min-width: 0; width: 100%; }
  dialog .grade-form { grid-template-columns: 1fr; }
}
