/* Alinhavo Flow — demonstração. Mesma identidade visual do site ALINHAVO. */
:root {
  --navy-950: #040915; --navy-900: #071127; --navy-800: #0E1F45; --navy-700: #16295A;
  --blue-500: #2E6BFF; --blue-400: #4F8BFF; --blue-300: #8DB4FF; --blue-100: #E6EEFF;
  --silver-200: #DCE2EB; --silver-300: #C3CBD8; --silver-400: #9AA6B8; --silver-500: #6B7891;
  --bg: #F4F6FA; --surface: #FFFFFF; --text: #0B1430; --muted: #4F5B73; --line: #E1E6EE;
  --ok: #0E8A5F; --ok-bg: #E7F7EF; --warn: #9A6200; --warn-bg: #FFF4DE; --bad: #B4232F; --bad-bg: #FDECEE;
  --info: #1D4FD8; --info-bg: #E8EFFF;
  --font-head: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --radius: 14px; --shadow: 0 1px 2px rgba(7,17,39,.05), 0 6px 20px -10px rgba(7,17,39,.15);
  --ease: cubic-bezier(.22,.8,.24,1);
  --side: 248px;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font-body); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-head); letter-spacing: -.02em; margin: 0; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue-500); }
:focus-visible { outline: 2px solid var(--blue-400); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Faixa de demonstração */
.demo-banner { background: var(--navy-950); color: var(--silver-300); font-size: .8rem; text-align: center; padding: 7px 16px; border-bottom: 1px solid rgba(195,203,216,.12); }
.demo-banner strong { color: #fff; font-weight: 600; }
.demo-banner a { color: var(--blue-300); }

/* Layout */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: calc(100vh - 34px); }
.side { background: var(--navy-900); color: var(--silver-300); padding: 22px 16px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: calc(100vh - 34px); }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 0 8px; }
.logo svg { width: 30px; height: 30px; flex: none; }
.logo b { font-family: var(--font-head); font-size: 1.02rem; letter-spacing: .02em; display: block; line-height: 1.1; }
.logo small { font-size: .68rem; color: var(--silver-400); letter-spacing: .12em; text-transform: uppercase; }
.menu { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--silver-300); text-decoration: none; font-weight: 500; font-size: .92rem; transition: background-color .2s var(--ease), color .2s var(--ease); }
.menu a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.menu a:hover { background: rgba(255,255,255,.05); color: #fff; }
.menu a[aria-current="page"] { background: rgba(46,107,255,.18); color: #fff; }
.menu a[aria-current="page"] svg { color: var(--blue-300); opacity: 1; }
.menu .label-short { display: none; }
.menu .count { margin-left: auto; font-size: .72rem; background: var(--blue-500); color: #fff; border-radius: 999px; padding: 1px 8px; font-weight: 600; }
.side__foot { margin-top: auto; font-size: .78rem; color: var(--silver-400); padding: 0 8px; }
.side__foot a { color: var(--blue-300); text-decoration: none; }

.main { min-width: 0; padding: 26px clamp(16px, 3vw, 36px) 48px; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 24px; }
.topbar h1 { font-size: 1.5rem; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.topbar__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Botões */
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .88rem; font-family: var(--font-head); cursor: pointer; transition: background-color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease); }
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--silver-300); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--blue-500); border-color: var(--blue-500); color: #fff; }
.btn--primary:hover { background: #1D5BFF; border-color: #1D5BFF; }
.btn--live[aria-pressed="true"] { background: var(--ok-bg); border-color: #A9E2C8; color: var(--ok); }
.btn--live[aria-pressed="true"] .dot { animation: blink 1.2s infinite; }
.btn--sm { min-height: 32px; padding: 4px 12px; font-size: .8rem; }
.btn--ok { color: var(--ok); } .btn--ok:hover { background: var(--ok-bg); border-color: #A9E2C8; }
.btn--bad { color: var(--bad); } .btn--bad:hover { background: var(--bad-bg); border-color: #F3B9C0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
@keyframes blink { 50% { opacity: .25; } }

/* Cards / KPIs */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.panel__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.panel__head h2 { font-size: 1rem; }
.panel__head span { font-size: .8rem; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 18px 20px; }
.kpi__label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.kpi__value { font-family: var(--font-head); font-size: 1.75rem; font-weight: 600; letter-spacing: -.03em; margin-top: 4px; line-height: 1.2; }
.kpi__hint { font-size: .78rem; color: var(--silver-500); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Gráficos */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--silver-500); font-size: 11px; font-family: var(--font-body); }
.chart .line { fill: none; stroke: var(--blue-500); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#areaGrad); }
.chart .pt { fill: var(--blue-500); stroke: var(--surface); stroke-width: 2; opacity: 0; transition: opacity .15s; }
.chart .pt.on { opacity: 1; }
.chart .cross { stroke: var(--silver-300); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.chart .cross.on { opacity: 1; }
.chart .bar { fill: var(--blue-500); transition: fill .15s; }
.chart .bar-row:hover .bar, .chart .bar-row:focus .bar { fill: #1D5BFF; }
.chart .bar-row { cursor: default; outline: none; }
.chart .bar-label { fill: var(--text); font-size: 12px; font-family: var(--font-body); }
.chart .bar-value { fill: var(--muted); font-size: 12px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.tooltip { position: absolute; pointer-events: none; background: var(--navy-900); color: #fff; font-size: .78rem; padding: 7px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .12s; z-index: 5; box-shadow: 0 8px 20px -8px rgba(0,0,0,.4); }
.tooltip.on { opacity: 1; }
.tooltip b { font-family: var(--font-head); }

/* Feed de atividades */
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 360px; overflow: auto; }
.feed li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: .86rem; }
.feed li:last-child { border-bottom: 0; }
.feed .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.feed .ico svg { width: 15px; height: 15px; }
.feed .ico--regra { background: var(--info-bg); color: var(--info); }
.feed .ico--integracao { background: #EEF0F4; color: var(--navy-700); }
.feed .ico--usuario { background: var(--ok-bg); color: var(--ok); }
.feed .ico--notificacao { background: var(--warn-bg); color: var(--warn); }
.feed time { display: block; font-size: .74rem; color: var(--silver-500); }
.feed li.new { animation: flash 1.6s var(--ease); }
@keyframes flash { from { background: var(--blue-100); } to { background: transparent; } }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge svg { width: 12px; height: 12px; }
.badge--aprovada { background: var(--ok-bg); color: var(--ok); }
.badge--pendente { background: var(--warn-bg); color: var(--warn); }
.badge--em_analise { background: var(--info-bg); color: var(--info); }
.badge--rejeitada { background: var(--bad-bg); color: var(--bad); }
.tag-auto { font-size: .7rem; font-weight: 600; color: var(--blue-500); background: var(--blue-100); padding: 2px 7px; border-radius: 6px; margin-left: 6px; }

/* Filtros & tabela */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.filters input, .filters select, .field input, .field select, .field textarea {
  min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.filters input { flex: 1 1 220px; }
.filters input:focus, .filters select:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(46,107,255,.15); }
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFBFD; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FAFBFD; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .sub { display: block; font-size: .78rem; color: var(--muted); }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
tr.new { animation: flash 1.6s var(--ease); }

/* Formulário */
.form-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field--full { grid-column: 1 / -1; }
.field label { font-size: .82rem; font-weight: 600; }
.field textarea { min-height: 90px; resize: vertical; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.presets span { font-size: .8rem; color: var(--muted); align-self: center; }
.result-empty { color: var(--muted); font-size: .9rem; display: grid; place-items: center; text-align: center; min-height: 260px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; opacity: 0; transform: translateY(6px); animation: stepIn .45s var(--ease) forwards; }
.steps li .n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-100); color: var(--blue-500); font-weight: 700; font-size: .8rem; font-family: var(--font-head); }
.steps li strong { display: block; font-size: .9rem; }
.steps li span { font-size: .84rem; color: var(--muted); }
.steps li.skip { background: #FAFBFD; } .steps li.skip .n { background: #EEF0F4; color: var(--silver-500); }
@keyframes stepIn { to { opacity: 1; transform: none; } }

/* Regras */
.rules { display: grid; gap: 12px; }
.rule { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.rule h3 { font-size: .98rem; margin-bottom: 4px; }
.rule p { margin: 0; color: var(--muted); font-size: .88rem; }
.rule code { font-size: .8rem; background: #F1F4F9; padding: 2px 6px; border-radius: 6px; color: var(--navy-700); }
.rule__meta { font-size: .78rem; color: var(--silver-500); margin-top: 8px !important; }
.switch { position: relative; width: 46px; height: 26px; border-radius: 999px; background: var(--silver-300); border: 0; cursor: pointer; transition: background-color .2s var(--ease); flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s var(--ease); }
.switch[aria-checked="true"] { background: var(--blue-500); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* Integrações */
.int-cards { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; margin-bottom: 16px; }
.int-card { display: flex; gap: 14px; align-items: center; }
.int-card .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--info-bg); color: var(--info); display: grid; place-items: center; flex: none; }
.int-card .ico svg { width: 20px; height: 20px; }
.int-card b { display: block; font-family: var(--font-head); font-size: .92rem; }
.int-card span { font-size: .8rem; color: var(--muted); }
pre.payload { margin: 0; background: var(--navy-900); color: #CFE0FF; font-size: .76rem; padding: 12px 14px; border-radius: 10px; overflow: auto; max-height: 220px; }
details.log summary { cursor: pointer; color: var(--blue-500); font-size: .8rem; font-weight: 600; }
details.log[open] summary { margin-bottom: 8px; }

/* Toast */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; max-width: min(360px, calc(100vw - 32px)); }
.toast { background: var(--navy-900); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: .86rem; box-shadow: 0 12px 30px -10px rgba(0,0,0,.45); animation: toastIn .3s var(--ease); }
.toast b { color: var(--blue-300); font-family: var(--font-head); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* Responsivo */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-2, .grid-2b, .form-layout { grid-template-columns: 1fr; }
  .int-cards { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 12px; min-width: 0; }
  .side nav { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .side nav::-webkit-scrollbar { display: none; }
  .logo small, .side__foot { display: none; }
  .menu { display: flex; gap: 4px; }
  .menu a { padding: 8px 10px; white-space: nowrap; font-size: .85rem; }
  .menu a .label-long { display: none; }
  .menu a .label-short { display: inline; }
}
@media (max-width: 560px) {
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi__value { font-size: 1.35rem; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar__actions .btn { flex: 1 1 auto; justify-content: center; }
  .menu a svg { display: none; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .steps li { opacity: 1; transform: none; } }
