:root {
  --gold: #c9a45c;
  --gold-light: #ddbf82;
  --wine: #7a1f24;
  --bg: #15110f;
  --bg-alt: #1d1714;
  --surface: #261e1a;
  --surface-2: #2f2520;
  --border: rgba(201, 164, 92, 0.2);
  --text: #f3ead8;
  --muted: #b8ac9c;
  --on-gold: #15110f;
  --ok: #7fbf8a;
  --danger: #e07a7a;
  --radius: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { font-family: var(--font-display); margin: 0 0 .35em; line-height: 1.2; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.15rem; }
a { color: var(--gold-light); }
.sub { color: var(--muted); margin: 0 0 1.2em; }
.mudo { color: var(--muted); }
.erro { color: var(--danger); }

:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: 999px; border: 2px solid transparent;
  font: 600 .95rem var(--font); cursor: pointer; text-decoration: none;
  transition: transform .15s, background .15s, border-color .15s, color .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--gold-light), var(--gold)); color: var(--on-gold); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-light); }
.btn-danger { background: var(--wine); color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: .85rem; }
.btn-bloco { width: 100%; }
.perigo:hover { border-color: var(--danger) !important; color: var(--danger) !important; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 1.6rem; line-height: 1; cursor: pointer; min-width: 44px; min-height: 44px; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; margin-top: 12px; }
.grupo-botoes { display: flex; gap: 10px; flex-wrap: wrap; }
.grupo-botoes.coluna { flex-direction: column; }

/* Formulários */
.campo { display: grid; gap: 6px; font-size: .85rem; font-weight: 600; margin-bottom: 14px; }
.campo input, .campo select, .campo textarea, .ferramentas input[type=search], .ferramentas select {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 8px; font: 400 1rem var(--font);
  color: var(--text); background: var(--bg); border: 2px solid rgba(201, 164, 92, .25);
}
.campo input:focus, .campo select:focus, .campo textarea:focus, .ferramentas input:focus, .ferramentas select:focus { outline: none; border-color: var(--gold); }
.check { display: flex; align-items: center; gap: 10px; font-size: .95rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
.grade { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grade .largo { grid-column: 1 / -1; }

/* Telas de entrada */
.tela-cheia { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 50% -10%, rgba(201, 164, 92, .18), transparent 55%), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px; box-shadow: 0 16px 40px rgba(0, 0, 0, .45); }
.login-logo { height: 90px; margin: 0 auto 12px; }
.login-card h1 { text-align: center; font-size: 1.5rem; }
.login-card .sub { text-align: center; }

/* Estrutura do app */
#app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
#menu { background: var(--bg-alt); border-right: 1px solid var(--border); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.menu-topo { padding: 0 6px 18px; }
.menu-logo { height: 64px; }
#menu-lista { display: grid; gap: 4px; }
#menu-lista a { display: block; padding: 11px 14px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
#menu-lista a:hover { background: var(--surface); }
#menu-lista a.ativo { background: rgba(201, 164, 92, .15); color: var(--gold-light); box-shadow: inset 3px 0 0 var(--gold); }
.menu-titulo { margin: 18px 14px 6px; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.menu-breve { padding: 8px 14px; font-size: .9rem; color: rgba(184, 172, 156, .6); }
.area { min-width: 0; }
.barra-topo { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--bg-alt); position: sticky; top: 0; z-index: 20; }
.titulo-topo { font-family: var(--font-display); font-weight: 700; flex: 1; }
.menu-btn { display: none; }
.usuario { display: flex; align-items: center; gap: 12px; }
.usuario span { display: grid; text-align: right; line-height: 1.25; }
.usuario small { color: var(--muted); }
#conteudo { padding: 28px 24px 100px; max-width: 1100px; outline: none; }

.topo-pagina { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.ferramentas { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0 16px; }
.ferramentas input[type=search] { flex: 1; min-width: 220px; max-width: 380px; }
.ferramentas select { width: auto; min-width: 200px; }

/* Cartões e blocos */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 28px; }
.card-num { display: grid; gap: 4px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.card-num:hover { border-color: var(--gold); transform: translateY(-2px); }
.card-num .n { font: 800 2.2rem var(--font-display); color: var(--gold-light); }
.card-num .l { color: var(--muted); font-size: .9rem; }
.bloco { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.lista-simples { list-style: none; margin: 0; padding: 0; }
.lista-simples li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.lista-simples li:last-child { border-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { padding: 6px 14px; border: 1px dashed var(--border); border-radius: 999px; color: var(--muted); font-size: .88rem; }
.aviso { background: rgba(201, 164, 92, .1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 18px; }
.aviso.erro { background: rgba(224, 122, 122, .12); border-color: rgba(224, 122, 122, .4); color: var(--text); }
.aviso.demo { margin: 0; border-radius: 0; text-align: center; font-size: .9rem; }
.legenda { color: var(--muted); padding-left: 18px; }

/* Tabelas */
.tabela-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tabela { width: 100%; border-collapse: collapse; min-width: 620px; }
.tabela th { text-align: left; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tabela td { padding: 11px 14px; border-bottom: 1px solid rgba(201, 164, 92, .1); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover { background: rgba(255, 255, 255, .02); }
.tabela .inativo { opacity: .55; }
.tabela .acoes { text-align: right; white-space: nowrap; }
.tabela .vazio { text-align: center; padding: 28px; }
.selo { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; background: var(--surface-2); color: var(--muted); }
.selo.ok { background: rgba(127, 191, 138, .15); color: var(--ok); }
.preco-input { width: 110px; min-height: 38px; padding: 6px 10px; text-align: right; border-radius: 8px; font: 500 1rem var(--font); color: var(--text); background: var(--bg); border: 2px solid rgba(201, 164, 92, .25); }
.preco-input.alterado { border-color: var(--gold); background: rgba(201, 164, 92, .1); }
.preco-input.invalido { border-color: var(--danger); }
.sel-papel { min-height: 40px; padding: 6px 10px; border-radius: 8px; font: 1rem var(--font); color: var(--text); background: var(--bg); border: 2px solid rgba(201, 164, 92, .25); }
.chk-ativo { width: 22px; height: 22px; accent-color: var(--gold); }

.barra-salvar { position: fixed; left: 250px; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 24px; background: var(--surface-2); border-top: 2px solid var(--gold); box-shadow: 0 -8px 24px rgba(0, 0, 0, .4); }

/* Janela */
.modal { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); }
.modal::backdrop { background: rgba(0, 0, 0, .65); }
.modal-form header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.modal-form header h3 { margin: 0; }
.modal-body { padding: 20px; max-height: calc(100vh - 190px); overflow-y: auto; }
.modal-form footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* Avisos rápidos */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: grid; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); max-width: 340px; }
.toast.ok { border-color: rgba(127, 191, 138, .6); }
.toast.erro { border-color: rgba(224, 122, 122, .7); }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  #menu { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-105%); transition: transform .2s; }
  #menu.aberto { transform: none; box-shadow: 8px 0 30px rgba(0, 0, 0, .6); }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .barra-topo { padding: 8px 12px; }
  .usuario small, .titulo-topo { display: none; }
  .barra-salvar { left: 0; }
  #conteudo { padding: 20px 14px 110px; }
  .grade { grid-template-columns: 1fr; }
  h1 { font-size: 1.55rem; }
}

@media (max-width: 520px) {
  .usuario .btn { padding: 6px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
