/* Espelho de Liderança — tema "Gabinete"
   Luz âmbar sobre madeira escura. Tipografia editorial.
   Sobriedade executiva com calor humano. */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300..700&family=Karla:wght@300;400;500;600;700&display=swap');

:root {
  /* madeira escura, não azul-tech */
  --ink:       #100E0B;
  --ink-2:     #17140F;
  --ink-3:     #211D17;
  --ink-4:     #2B251E;
  --line:      #352E25;
  --line-soft: #2A241D;

  --paper:      #EFE8DC;
  --paper-mute: #A2988A;
  --paper-dim:  #6E6559;

  --amber:      #E0A82E;
  --amber-soft: #F0C25E;
  --amber-dim:  rgba(224, 168, 46, .14);

  --sage:  #86A077;
  --clay:  #C86B52;
  --rust:  #A9552F;

  --r-sm: 8px;
  --r:    13px;
  --r-lg: 20px;

  --rail-w: 260px;

  --ease: cubic-bezier(.32, .72, 0, 1);

  --serif: 'Fraunces', ui-serif, Georgia, serif;
  --sans:  'Karla', ui-sans-serif, system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --ink:       #F5F0E6;
    --ink-2:     #FCFAF5;
    --ink-3:     #EFE9DC;
    --ink-4:     #E5DDCC;
    --line:      #DDD3C0;
    --line-soft: #E8E0D0;
    --paper:      #221D16;
    --paper-mute: #6B6153;
    --paper-dim:  #8C8274;
    --amber:      #A9752A;
    --amber-soft: #C08D33;
    --amber-dim:  rgba(169, 117, 42, .12);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* luz de luminária + grão */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(120% 80% at 62% -10%, rgba(224,168,46,.055), transparent 60%),
    radial-gradient(90% 60% at 8% 108%, rgba(169,85,47,.045), transparent 65%);
}
body::after {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--amber-soft); }

::selection { background: var(--amber-dim); color: var(--paper); }

/* ─── layout ─── */
.shell { min-height: 100vh; position: relative; z-index: 1; }

/* fixa: previsível em páginas longas (sticky dentro de flex stretch desgruda) */
.rail {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--rail-w);
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  display: flex; flex-direction: column; overflow-y: auto;
  z-index: 20;
}

.rail-head { padding: 26px 22px 18px; border-bottom: 1px solid var(--line-soft); }
.rail-mark {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 40, 'wght' 500, 'SOFT' 0;
  font-size: 21px; line-height: 1.15; letter-spacing: -.015em;
}
.rail-mark em { font-style: italic; color: var(--amber); }
.rail-sub { font-size: 11.5px; color: var(--paper-dim); letter-spacing: .09em; text-transform: uppercase; margin-top: 5px; }

.rail-who { padding: 16px 22px; border-bottom: 1px solid var(--line-soft); }
.rail-who .nome { font-size: 14.5px; font-weight: 600; }
.rail-who .cod {
  font-size: 11.5px; color: var(--paper-dim); letter-spacing: .12em;
  font-variant-numeric: tabular-nums; margin-top: 2px;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.rail-who .cod:hover { color: var(--amber); }
.rail-who .papel {
  display: inline-block; margin-top: 8px; font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 999px;
  background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(224,168,46,.22);
}

.rail-nav { flex: 1; padding: 14px 12px 8px; }
.rail-group {
  font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--paper-dim); padding: 14px 10px 7px;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--paper-mute); font-size: 14px; cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease);
  border: 1px solid transparent; text-decoration: none;
}
/* entrada escalonada só na primeira montagem da sessão */
.rail.entra .nav-item { animation: slideIn .5s var(--ease) backwards; }
.nav-item:hover { background: var(--ink-3); color: var(--paper); text-decoration: none; }
.nav-item.on {
  background: var(--ink-3); color: var(--paper);
  border-color: var(--line); box-shadow: inset 2px 0 0 var(--amber);
}
.nav-item .ic { width: 17px; text-align: center; opacity: .75; flex: 0 0 17px; font-size: 13px; }
.nav-item .tx { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; }
.nav-item .dot.done { background: var(--sage); }
.nav-item .dot.wip  { background: var(--amber); }
.nav-item .dot.todo { background: var(--line); }

@keyframes slideIn { from { opacity: 0; transform: translateX(-7px); } to { opacity: 1; transform: none; } }

.rail-foot { padding: 14px 22px 20px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--paper-dim); }
.rail-foot button {
  background: none; border: none; color: var(--paper-dim); font: inherit;
  cursor: pointer; padding: 0; text-align: left;
}
.rail-foot button:hover { color: var(--paper); }

.stage { margin-left: var(--rail-w); min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.stage-inner { flex: 1; width: 100%; max-width: 820px; margin: 0 auto; padding: 46px 34px 90px; }
.stage-wide .stage-inner { max-width: 1080px; }

/* ─── hero do assistente ─── */
.hero { min-height: calc(100vh - 140px); display: flex; flex-direction: column; justify-content: center; }
.hero-greet {
  font-family: var(--serif);
  font-variation-settings: 'opsz' 120, 'wght' 300, 'SOFT' 20;
  font-size: clamp(34px, 5.4vw, 55px); line-height: 1.06;
  letter-spacing: -.028em; margin: 0 0 14px;
  animation: rise .8s var(--ease) backwards;
}
.hero-greet em { font-style: italic; color: var(--amber); font-variation-settings: 'opsz' 120, 'wght' 300; }
.hero-note {
  font-size: 16px; color: var(--paper-mute); max-width: 52ch; margin: 0 0 34px;
  animation: rise .8s var(--ease) .08s backwards;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.ask {
  position: relative; animation: rise .8s var(--ease) .16s backwards;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--ink-2), var(--ink-3));
  transition: border-color .22s var(--ease), box-shadow .22s var(--ease);
}
.ask:focus-within {
  border-color: rgba(224,168,46,.45);
  box-shadow: 0 0 0 4px var(--amber-dim), 0 22px 50px -28px rgba(0,0,0,.85);
}
.ask textarea {
  width: 100%; background: none; border: none; color: var(--paper);
  font: 400 16.5px/1.6 var(--sans); padding: 20px 22px 8px; resize: none;
  min-height: 82px; max-height: 260px; outline: none;
}
.ask textarea::placeholder { color: var(--paper-dim); }
.ask-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px 13px 22px; gap: 12px; }
.ask-hint { font-size: 11.5px; color: var(--paper-dim); }

.hero-chips { margin-top: 26px; animation: rise .8s var(--ease) .24s backwards; }
.hero-chips .lbl { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--paper-dim); margin-bottom: 11px; }

/* ─── thread ─── */
.thread { display: flex; flex-direction: column; gap: 22px; margin: 12px 0 26px; }
.msg { max-width: 88%; font-size: 15.5px; line-height: 1.72; }
.msg.me {
  align-self: flex-end; background: var(--ink-3); border: 1px solid var(--line);
  padding: 13px 18px; border-radius: var(--r) var(--r) 4px var(--r);
}
.msg.bot { align-self: flex-start; }
.msg.bot::before {
  content: 'assistente'; display: block; font-size: 10.5px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--paper-dim); margin-bottom: 8px;
}
.msg.bot strong { color: var(--amber-soft); font-weight: 600; }
.msg.wait { color: var(--paper-dim); font-style: italic; }
.msg.wait::after { content: '…'; animation: dots 1.3s steps(4) infinite; }
@keyframes dots { 0%{content:''} 25%{content:'.'} 50%{content:'..'} 75%{content:'...'} }

/* ─── tipografia de conteúdo ─── */
h1, h2, h3 { font-family: var(--serif); font-variation-settings: 'opsz' 60, 'wght' 500; letter-spacing: -.018em; }
h1 { font-size: 31px; line-height: 1.16; margin: 0 0 10px; }
h2 { font-size: 25px; line-height: 1.2; margin: 0 0 10px; }
h3 {
  font-family: var(--sans); font-size: 11.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--paper-dim);
  margin: 32px 0 12px; letter-spacing: .14em;
}
.lede { font-size: 16px; color: var(--paper-mute); max-width: 62ch; }
.hint { font-size: 14px; color: var(--paper-mute); max-width: 66ch; }
.mini { font-size: 12.5px; color: var(--paper-dim); }

/* ─── formulários ─── */
label { display: block; margin: 20px 0 7px; font-size: 13px; color: var(--paper-mute); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], textarea, select {
  width: 100%; padding: 11px 14px; background: var(--ink-2); color: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font: 400 15px/1.5 var(--sans); transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
textarea { min-height: 92px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: rgba(224,168,46,.5); box-shadow: 0 0 0 3px var(--amber-dim);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--paper-dim) 50%), linear-gradient(135deg, var(--paper-dim) 50%, transparent 50%); background-position: right 16px center, right 11px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

button {
  font: 500 14.5px var(--sans); padding: 11px 20px; border-radius: var(--r-sm);
  border: 1px solid var(--amber); background: var(--amber); color: #14110C;
  cursor: pointer; transition: all .18s var(--ease);
}
button:hover { background: var(--amber-soft); border-color: var(--amber-soft); transform: translateY(-1px); }
button:active { transform: none; }
button.ghost { background: transparent; color: var(--paper); border-color: var(--line); }
button.ghost:hover { background: var(--ink-3); border-color: var(--paper-dim); }
button.bare { background: none; border: none; color: var(--paper-dim); padding: 0; }
button.bare:hover { color: var(--paper); background: none; transform: none; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px; }

/* ─── chips ─── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 15px; border-radius: 999px; cursor: pointer; user-select: none;
  background: var(--ink-2); border: 1px solid var(--line); color: var(--paper-mute);
  font-size: 13.5px; transition: all .16s var(--ease);
}
.chip:hover { border-color: var(--amber); color: var(--paper); }
.chip.on { background: var(--amber); border-color: var(--amber); color: #14110C; font-weight: 500; }
.chip.static { cursor: default; }
.chip.static:hover { border-color: var(--line); color: var(--paper-mute); }

/* ─── cartões e métricas ─── */
.card { background: var(--ink-2); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 26px; margin-bottom: 18px; }
.panel { background: var(--ink-2); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 20px; margin: 14px 0; }
.panel.accent { border-left: 2px solid var(--amber); }
.panel.warn   { border-left: 2px solid var(--clay); }
.panel.good   { border-left: 2px solid var(--sage); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin: 16px 0; }
.metric { background: var(--ink-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 15px; }
.metric .k { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--paper-dim); }
.metric .v {
  font-family: var(--serif); font-variation-settings: 'opsz' 40, 'wght' 500;
  font-size: 27px; color: var(--amber); margin: 5px 0 2px; font-variant-numeric: tabular-nums;
}
.metric .s { font-size: 12px; color: var(--paper-dim); }

.bar { height: 3px; background: var(--ink-4); border-radius: 2px; overflow: hidden; margin: 12px 0; }
.bar > i { display: block; height: 100%; background: var(--amber); transition: width .5s var(--ease); }

/* escala 1-5 */
.scale { display: flex; gap: 6px; margin-top: 8px; }
.scale button {
  flex: 1; padding: 9px 0; background: var(--ink-2); color: var(--paper-mute);
  border: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.scale button:hover { border-color: var(--amber); color: var(--paper); transform: none; }
.scale button.on { background: var(--amber); border-color: var(--amber); color: #14110C; font-weight: 600; }

input[type=range] { -webkit-appearance: none; width: 100%; height: 3px; background: var(--ink-4); border-radius: 2px; outline: none; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--amber); cursor: pointer; border: 3px solid var(--ink);
}

/* grade de módulos / equipe */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 14px; }
.tile {
  padding: 20px; background: var(--ink-2); border: 1px solid var(--line-soft);
  border-radius: var(--r); cursor: pointer; text-decoration: none; color: inherit;
  transition: transform .2s var(--ease), border-color .2s var(--ease);
}
.tile:hover { border-color: var(--amber); transform: translateY(-2px); text-decoration: none; }
.tile .st { font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase; color: var(--paper-dim); }
.tile .st.done { color: var(--sage); }
.tile h4 { font-family: var(--serif); font-variation-settings: 'opsz' 40, 'wght' 500; font-size: 17.5px; margin: 7px 0 5px; letter-spacing: -.01em; }
.tile p { margin: 0; font-size: 13px; color: var(--paper-mute); }

/* export */
pre.export {
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 15px; overflow: auto; max-height: 250px; font-size: 11.5px;
  color: var(--paper-dim); font-family: ui-monospace, 'SF Mono', monospace;
}

.row-grid { display: grid; gap: 9px; margin: 9px 0; align-items: end; }
.row-grid.acoes  { grid-template-columns: 1.5fr 1.5fr 1fr 1.5fr auto; }
.row-grid.agenda { grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; }

/* ─── compatibilidade com os módulos (classes da v1) ─── */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin: 16px 0; }
.eixo { background: var(--ink-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 15px; }
.eixo .name { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--paper-dim); }
.eixo .val {
  font-family: var(--serif); font-variation-settings: 'opsz' 40, 'wght' 500;
  font-size: 26px; color: var(--amber); margin: 5px 0 2px; font-variant-numeric: tabular-nums;
}
.eixo .lvl { font-size: 12px; color: var(--paper-dim); }
.progress { height: 3px; background: var(--ink-4); border-radius: 2px; overflow: hidden; margin: 12px 0; }
.progress > div { height: 100%; background: var(--amber); transition: width .5s var(--ease); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 14px; }
.tile .status { font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase; color: var(--paper-dim); }
.tile .status.done { color: var(--sage); }
.tile h3 {
  font-family: var(--serif); font-variation-settings: 'opsz' 40, 'wght' 500;
  font-size: 17.5px; margin: 7px 0 5px; letter-spacing: -.01em;
  text-transform: none; color: var(--paper);
}
.tile p { margin: 0; font-size: 13px; color: var(--paper-mute); }
.footer { text-align: center; padding: 34px 16px; color: var(--paper-dim); font-size: 12.5px; }
.footer p { margin: 4px 0; }
details summary { cursor: pointer; }
iframe { border: 0; border-radius: var(--r-sm); }

/* toast de sync */
.toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 60;
  padding: 8px 15px; border-radius: 999px; font-size: 12px;
  background: var(--ink-3); border: 1px solid var(--line); color: var(--paper-mute);
  transition: opacity .35s var(--ease); pointer-events: none;
}

/* topo mobile */
.topbar { display: none; }

@media (max-width: 900px) {
  .rail {
    z-index: 50; transform: translateX(-100%);
    transition: transform .32s var(--ease); box-shadow: 30px 0 60px -30px rgba(0,0,0,.9);
  }
  .rail.open { transform: none; }
  .stage { margin-left: 0; }
  .topbar {
    display: flex; align-items: center; gap: 13px; padding: 13px 18px;
    border-bottom: 1px solid var(--line-soft); background: var(--ink-2);
    position: sticky; top: 0; z-index: 30;
  }
  .topbar .burger { background: none; border: none; color: var(--paper); font-size: 19px; padding: 0; cursor: pointer; }
  .topbar .ttl { font-family: var(--serif); font-variation-settings: 'opsz' 40, 'wght' 500; font-size: 16.5px; }
  .stage-inner { padding: 28px 20px 80px; }
  .hero { min-height: auto; padding-top: 22px; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; }
  .row-grid.acoes, .row-grid.agenda {
    grid-template-columns: 1fr; padding: 14px; background: var(--ink-2);
    border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  }
  .row-grid button { width: 100%; }
  .msg { max-width: 96%; }
}

@media print {
  .rail, .topbar, .actions, button, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  body::before, body::after { display: none; }
  .card, .panel { border: 1px solid #ccc; page-break-inside: avoid; }
}
