/* ===== Tokens ===== */
:root {
  --bg: #f4f6fa; --surface: #fff; --line: #e3e8ef; --line-2: #eef2f7;
  --ink: #0e1d31; --ink-2: #44566c; --muted: #75869b;
  --navy: #0a2540; --navy-2: #07203a;
  --accent: #0a7ac4; --accent-d: #075f9b; --accent-soft: #e8f3fc; --accent-line: #b9dcf3;
  --red: #c8283d; --red-soft: #fdeff1; --green: #17824a; --green-soft: #e9f8ef; --amber: #a4640a; --amber-soft: #fff6df; --amber-line: #f0d28c;
  --sel: #dcedfb; --r: 12px; --r-sm: 8px;
  --sh1: 0 1px 2px rgba(14, 29, 49, .06), 0 1px 1px rgba(14, 29, 49, .03);
  --sh2: 0 10px 30px rgba(14, 29, 49, .12);
  --font: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { letter-spacing: -.01em; }
[hidden] { display: none !important; }
#app { height: 100%; }
.ic { display: inline-flex; flex: none; vertical-align: middle; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.row { display: flex; align-items: center; } .gap { gap: 12px; }
.spacer { flex: 1; }
.stack { display: grid; gap: 14px; }
.pad { padding: 40px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Controles ===== */
.btn { border: 1px solid transparent; border-radius: var(--r-sm); padding: 8px 14px; font-weight: 600; cursor: pointer; background: var(--surface); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; }
.btn.sm { padding: 5px 10px; font-size: 13px; gap: 6px; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(10, 122, 196, .35); }
.btn.primary:hover { background: var(--accent-d); }
.btn.light { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: var(--sh1); }
.btn.light:hover { background: #f6f9fc; border-color: #cfd8e3; }
.btn.light.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-d); }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: #e9eef5; }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.icon-btn { border: 0; background: transparent; border-radius: 6px; padding: 5px 7px; cursor: pointer; color: var(--muted); display: inline-flex; }
.icon-btn:hover { background: #e9eef5; color: var(--ink); }
.input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; transition: border-color .12s, box-shadow .12s; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 122, 196, .15); }
.input.sm { padding: 5px 9px; width: 150px; font-size: 13px; }
.search { position: relative; max-width: 320px; flex: 1; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 34px; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.check { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.form-error { color: var(--red); min-height: 18px; font-size: 13px; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: #e9eef5; color: var(--ink-2); }
.pill.admin { background: var(--amber-soft); color: var(--amber); }
.chip { border: 1px solid var(--amber-line); background: var(--amber-soft); color: var(--amber); border-radius: 99px; padding: 3px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.chip:hover { background: #ffefc4; }
.badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 2px 10px; font-size: 11.5px; font-weight: 700; border: 1px solid; }
.badge.amber { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }

/* ===== Login ===== */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, #14518a 0, transparent 60%), linear-gradient(160deg, var(--navy), #0a3a63); }
.login-card { width: 100%; max-width: 390px; background: #fff; border-radius: 18px; padding: 32px; display: grid; gap: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.login-brand { margin-bottom: 6px; } .login-brand b { color: var(--navy); } .login-brand small { color: var(--muted); }

/* ===== Layout / barra lateral ===== */
.layout { display: flex; height: 100%; }
.side { width: 256px; flex: none; background: linear-gradient(180deg, var(--navy), var(--navy-2)); color: #fff; display: flex; flex-direction: column; gap: 6px; padding: 18px 12px 14px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 11px; color: #fff; }
.brand b { display: block; line-height: 1.15; font-size: 15px; }
.brand small { color: #8fb4d4; font-size: 11.5px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #2aa8ee, #0a7ac4); display: grid; place-items: center; box-shadow: 0 4px 12px rgba(10, 122, 196, .45); }
.side .brand { padding: 2px 8px 16px; }
.side-sheet { padding: 0 4px 10px; }
.side-sheet label { display: block; font-size: 10.5px; color: #7fa3c4; margin: 0 4px 6px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.sheet-select { width: 100%; padding: 9px 10px; border-radius: 9px; border: 1px solid #ffffff26; background: #ffffff10; color: #fff; cursor: pointer; }
.sheet-select option { color: #000; }
.nav { display: grid; gap: 2px; }
.nav-label { font-size: 10.5px; color: #6f94b6; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; padding: 14px 12px 6px; }
.nav a { position: relative; display: flex; align-items: center; gap: 11px; color: #bcd2e6; padding: 9px 12px; border-radius: 9px; font-weight: 600; transition: background .12s, color .12s; }
.nav a .ic { color: #7fa3c4; }
.nav a:hover { background: #ffffff0f; color: #fff; }
.nav a.active { background: rgba(56, 170, 240, .16); color: #fff; }
.nav a.active .ic { color: #5cc0ff; }
.nav a.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #5cc0ff; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid #ffffff1c; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #2aa8ee, #0a7ac4); display: grid; place-items: center; font-weight: 700; flex: none; }
.side-user > div { flex: 1; min-width: 0; line-height: 1.2; }
.side-user b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .side-user small { color: #8fb4d4; font-size: 11.5px; }
.side-user .icon-btn { color: #9dbbd6; } .side-user .icon-btn:hover { background: #ffffff1a; color: #fff; }

.content { flex: 1; min-width: 0; overflow: auto; display: flex; flex-direction: column; }
.content.full { overflow: hidden; }
.content.full .editor-host { flex: 1; min-height: 0; display: flex; }
.page-bar { flex: none; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 24px 32px 4px; }
.page-bar h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.page-bar small { display: block; margin-top: 3px; font-size: 13.5px; }
.page-actions { display: flex; align-items: center; gap: 10px; }
.content .page { max-width: 1280px; width: 100%; padding: 18px 32px 56px; }
.toolbar-line { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sheet-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 5px 14px 5px 10px; box-shadow: var(--sh1); font-size: 13px; }
.sheet-pill .ic { color: var(--accent); }

/* ===== Cards, tabelas ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh1); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 11px 16px; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-top: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover td { background: #fafcfe; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.inactive td { color: var(--muted); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * { margin-left: 6px; }
.sheet-link { font-weight: 700; color: var(--ink); } .sheet-link:hover { color: var(--accent); }
.card:has(> .table) { overflow: hidden; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 10px; }
.empty .ic { color: #aebccd; }
.dropzone { display: flex; align-items: center; gap: 18px; padding: 22px 26px; margin-bottom: 18px; border: 1.5px dashed #8cc4e8; border-radius: var(--r); background: linear-gradient(180deg, #f4faff, #eef7fe); cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.over { background: #e4f2fd; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(10, 122, 196, .1); }
.dropzone.busy { opacity: .6; pointer-events: none; }
.dropzone b { font-size: 15px; } .dropzone p { margin: 3px 0 0; color: var(--ink-2); }
.dz-icon { width: 48px; height: 48px; border-radius: 12px; background: #fff; display: grid; place-items: center; color: var(--accent); box-shadow: var(--sh1); flex: none; }

/* ===== Modal / menu / toasts ===== */
.modal-back { position: fixed; inset: 0; background: rgba(7, 27, 44, .55); backdrop-filter: blur(2px); z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: 16px; width: min(460px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--sh2); }
.modal.wide { width: min(920px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 0; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 16px 22px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 4px 22px 20px; }
.menu { position: fixed; z-index: 200; min-width: 220px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh2); padding: 6px; max-height: calc(100vh - 16px); overflow: auto; }
.menu-item { display: flex; justify-content: space-between; align-items: center; gap: 18px; width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.menu-item:hover:not(:disabled) { background: var(--accent-soft); }
.menu-item:disabled { color: #a9b6c5; cursor: default; }
.menu-item.danger { color: var(--red); } .menu-item.danger:hover:not(:disabled) { background: var(--red-soft); }
.menu-item.checked span::before { content: '✓ '; color: var(--accent); font-weight: 700; }
.menu-item kbd { color: var(--muted); font: inherit; font-size: 12px; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 2px; }
.menu-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-swatches { display: flex; gap: 6px; padding: 4px 10px 8px; }
.swatch { width: 24px; height: 24px; border-radius: 7px; border: 1px solid rgba(0, 0, 0, .18); cursor: pointer; } .swatch:hover { transform: scale(1.1); }
#toasts { position: fixed; right: 20px; bottom: 46px; z-index: 300; display: grid; gap: 8px; }
.toast { background: #12263b; color: #fff; padding: 11px 16px; border-radius: 11px; box-shadow: var(--sh2); max-width: 380px; transition: opacity .4s; animation: pop .18s ease-out; }
.toast.ok { background: #135a37; } .toast.err { background: #8f1d2c; } .toast.out { opacity: 0; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ===== Dashboard ===== */
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric { padding: 16px 16px 14px; display: grid; gap: 4px; position: relative; }
.metric .m-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.metric label { font-size: 12px; font-weight: 600; color: var(--muted); }
.metric strong { font-size: 28px; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric.amber .m-ic { background: var(--amber-soft); color: var(--amber); } .metric.amber strong { color: var(--amber); }
.metric-link { color: inherit; display: block; } .metric-link .metric { height: 100%; border-color: var(--amber-line); transition: .15s; }
.metric-link:hover .metric { box-shadow: var(--sh2); transform: translateY(-1px); }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.charts.one { grid-template-columns: 1fr; max-width: 820px; }
.chart-card { padding: 18px 20px 14px; } .chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 { margin: 0 0 12px; font-size: 14.5px; }
.bar-row { display: grid; grid-template-columns: 22px minmax(90px, 36%) 1fr 44px; gap: 10px; align-items: center; margin: 3px 0; font-size: 13px; min-height: 26px; }
.bar-rank { color: #a3b1c2; font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
a.bar-label:hover { color: var(--accent); text-decoration: underline; }
.bar { background: #edf2f8; height: 10px; border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #35a4e8, var(--accent)); }
.bar-row:nth-child(n+3) .bar i { opacity: .82; }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; }
.daily { display: flex; gap: 5px; align-items: flex-end; overflow-x: auto; padding: 4px 2px; min-height: 170px; }
.day { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 32px; font-size: 10.5px; color: var(--muted); }
.day i { display: block; width: 20px; background: linear-gradient(180deg, #35a4e8, var(--accent)); border-radius: 5px 5px 2px 2px; } .day b { color: var(--ink); font-weight: 600; }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.agent-card { padding: 16px 18px; color: var(--ink); display: grid; gap: 4px; transition: .15s; }
.agent-card:hover { transform: translateY(-2px); border-color: var(--accent-line); box-shadow: var(--sh2); }
.agent-top { display: flex; justify-content: space-between; align-items: center; }
.agent-card h3 { margin: 4px 0 2px; font-size: 20px; font-variant-numeric: tabular-nums; }
.rank { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 99px; padding: 2px 9px; }
.agent-card .badge { justify-self: start; margin: 4px 0; }

/* ===== Duplicados ===== */
.note { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); border: 1px solid var(--accent-line); color: #0b4d7a; padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; }
.note .ic { margin-top: 1px; }
.dup-card { padding: 16px 18px; margin-bottom: 14px; }
.dup-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.dup-pnr { font: 700 15px ui-monospace, Consolas, monospace; background: #eef3f9; border: 1px solid var(--line); padding: 3px 10px; border-radius: 7px; letter-spacing: .06em; margin-right: 10px; }
.dup-table { overflow: auto; margin-top: 10px; border: 1px solid var(--line-2); border-radius: 10px; }
.table.compact th, .table.compact td { padding: 7px 12px; font-size: 12.5px; white-space: nowrap; }
.table.compact th { background: #f3f7fb; }
.last-edit { padding: 18px 22px; margin-bottom: 16px; border-left: 4px solid var(--accent); } .last-edit h3 { margin: 6px 0 4px; font-size: 18px; }
.pad-card { padding: 24px; max-width: 540px; } .pad-card h3 { margin-top: 0; }

/* ===== Editor ===== */
.editor { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; background: var(--surface); }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: nowrap; }
.toolbar > * { flex: none; }
@media (max-width: 1180px) { .toolbar { flex-wrap: wrap; } }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.name-input { border: 1px solid transparent; border-radius: 8px; padding: 5px 9px; font-size: 17px; font-weight: 700; flex: 1 1 140px !important; min-width: 60px; max-width: 260px; width: auto; background: transparent; letter-spacing: -.01em; }
.name-input:hover { border-color: var(--line); background: #fafcfe; } .name-input:focus { border-color: var(--accent); outline: none; background: #fff; box-shadow: 0 0 0 3px rgba(10, 122, 196, .15); }
.save-status { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; min-width: 70px; }
.save-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #b7c3d1; }
.save-status.ok { color: var(--green); } .save-status.ok::before { background: var(--green); }
.save-status.err { color: var(--red); font-weight: 600; } .save-status.err::before { background: var(--red); }
.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--red-soft); color: #8f1d2c; padding: 9px 16px; border-bottom: 1px solid #f7c5cc; }
.grid-wrap { flex: 1; min-height: 0; overflow: auto; position: relative; outline: none; background: #fff; }
.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; position: relative; font-size: 13px; }
.grid th, .grid td { border-right: 1px solid #e6ebf2; border-bottom: 1px solid #e6ebf2; }
.grid thead th { position: sticky; z-index: 6; background: #f1f5fa; }
.grid .band-row th { top: 0; height: 26px; font-size: 12px; font-weight: 700; letter-spacing: .02em; text-align: center; border-right: 1px solid #ffffff55; overflow: hidden; white-space: nowrap; }
.grid .band-row th.band-empty { background: #fff; }
.grid .band-row th.gut { left: 0; z-index: 8; background: #fff; }
.grid thead tr:last-child th { top: var(--head-top, 0px); box-shadow: 0 1px 0 #cfd9e6; }
.grid thead tr:last-child th.gut { left: 0; z-index: 8; }
.colhead { height: 54px; padding: 4px 6px; text-align: center; font-size: 12px; font-weight: 700; color: #1d3550; vertical-align: middle; position: sticky; overflow: hidden; cursor: pointer; user-select: none; }
.colhead:hover { filter: brightness(.97); }
.colhead .cn { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.15; }
.colhead .cl { position: absolute; left: 4px; top: 1px; font-size: 9px; color: #6b829a; font-weight: 600; }
.colhead .caret { position: absolute; right: 2px; top: 2px; border: 0; background: rgba(255, 255, 255, .85); cursor: pointer; font-size: 11px; color: #365374; padding: 1px 5px; border-radius: 5px; opacity: 0; transition: opacity .1s; }
.colhead:hover .caret, .colhead .caret:focus-visible, .colhead.filtered .caret { opacity: 1; }
.colhead .caret:hover { background: #fff; }
.colhead.filtered .caret { color: var(--accent); }
.colhead.filtered::after { content: ''; position: absolute; left: 5px; bottom: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.colhead .resizer { position: absolute; right: 0; top: 0; bottom: 0; width: 5px; cursor: col-resize; } .colhead .resizer:hover { background: var(--accent); }
.colhead.stk, .cell.stk { position: sticky; left: 52px; z-index: 5; }
.colhead.stk { z-index: 7; }
.cell.stk { box-shadow: 1px 0 0 #d7e0eb; }
.grid tbody tr { height: 28px; }
.grid tbody tr.spacer td { padding: 0; border: 0; }
.grid td.none { text-align: center; color: var(--muted); padding: 48px; height: auto; }
.gut { position: sticky; left: 0; z-index: 4; background: #f1f5fa; color: #7b8fa6; font-size: 11px; text-align: center; cursor: pointer; user-select: none; font-variant-numeric: tabular-nums; }
.gut:hover { background: #e3ebf5; }
.gut.sel { background: #c4def3; color: #0b3a5d; font-weight: 700; }
.corner { cursor: pointer; }
.cell { padding: 0 8px; height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #fff; cursor: cell; }
.cell.alt { background: #fafcfe; }
.cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell.sel { background: var(--sel); }
.cell.act { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
.cell.sel.act { background: #fff; }
.cell.dup { box-shadow: inset 3px 0 0 #e0a431; }
.cell.stk.dup { box-shadow: inset 3px 0 0 #e0a431, 1px 0 0 #d7e0eb; }
.cell-edit { position: absolute; z-index: 9; border: 2px solid var(--accent); padding: 0 7px; background: #fff; outline: none; box-shadow: 0 6px 18px rgba(14, 29, 49, .22); border-radius: 2px; }
.statusbar { display: flex; gap: 14px; padding: 6px 16px; border-top: 1px solid var(--line); background: #f8fafc; font-size: 12px; align-items: center; color: var(--ink-2); }
.hint { display: none; }
@media (min-width: 1200px) { .hint { display: inline; } }
.find { position: absolute; top: 62px; right: 18px; z-index: 20; display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); padding: 9px 11px; border-radius: 12px; box-shadow: var(--sh2); flex-wrap: wrap; max-width: calc(100% - 36px); }

/* ===== Resumo (modal) ===== */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { background: #f6f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; min-width: 130px; }
.stat b { display: block; font-size: 22px; } .stat span { color: var(--muted); font-size: 12px; }
.sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.sum-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.sum-card h3 { margin: 0 0 8px; font-size: 13px; }
.sum-card .bar-row, .fill-grid .bar-row { grid-template-columns: minmax(80px, 38%) 1fr 42px; font-size: 12px; }
.fill-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }

@media (max-width: 1250px) { .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .layout { flex-direction: column; height: auto; min-height: 100%; }
  .side { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .side .brand { padding: 0 8px 0 0; } .side-sheet { padding: 0; } .side-sheet label, .nav-label { display: none; }
  .nav { grid-auto-flow: column; overflow-x: auto; flex: 1 1 100%; } .nav a.active::before { display: none; }
  .side-user { margin: 0 0 0 auto; border: 0; padding: 0; } .side-user small { display: none; }
  .content, .content.full { overflow: visible; } .content.full .editor-host { height: 85vh; }
  .charts, .sum-grid, .fill-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-bar, .content .page { padding-left: 16px; padding-right: 16px; }
}

/* ===== E-mail de aderência ===== */
.mail-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px; align-items: start; }
.mail-picker { overflow: hidden; display: flex; flex-direction: column; max-height: calc(100vh - 230px); min-height: 360px; }
.mail-picker-head { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mail-picker-head .search { flex: 1 1 170px; max-width: none; }
.mail-table { overflow: auto; flex: 1; }
.mail-table th { position: sticky; top: 0; z-index: 1; }
.mail-table tbody tr { cursor: pointer; }
.mail-table tbody tr.picked td { background: var(--accent-soft); }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; }
.trunc { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-composer { padding: 18px; display: grid; gap: 14px; position: sticky; top: 12px; }
.mail-strip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; background: #f6f9fc; border: 1px solid var(--line); border-radius: 10px; }
.mail-count { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); }
.badge:not(.amber) { background: #eef3f9; color: var(--ink-2); border-color: var(--line); }
.mail-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mail-fields .full { grid-column: 1 / -1; }
.mail-body, .mail-locs { font: 13.5px/1.55 var(--font); resize: vertical; }
.mail-locs { background: #fffdf5; border-color: var(--amber-line); }
.field > .row { margin-bottom: 4px; } .field > .row > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
@media (max-width: 1500px) { .mail-layout { grid-template-columns: 1fr; } .mail-composer { position: static; } .mail-picker { max-height: 340px; min-height: 0; } }

/* ===== Mesclar / grupos x conexões ===== */
.metrics.three { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 820px; }
.badge.ok { background: var(--green-soft); color: var(--green); border-color: #b9e6cb; }
.merge-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.merge-head h3 { margin: 0; font-size: 15px; }
.merge-table { overflow: auto; max-height: 520px; }
.merge-block { padding: 16px 18px; margin-top: 16px; } .merge-block h3 { margin: 0 0 4px; font-size: 15px; }
.merge-block .merge-table { margin: 8px -18px -16px; border-top: 1px solid var(--line-2); }
.card:has(> .merge-table) { margin-bottom: 0; }
.merge-table tbody tr.picked td { background: var(--accent-soft); }
.merge-table th { position: sticky; top: 0; z-index: 1; }
.leg { white-space: nowrap; }
.seg { display: inline-flex; background: #e9eef5; border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg-btn.on { background: #fff; color: var(--ink); box-shadow: var(--sh1); }
.flight-nums { display: flex; gap: 10px; margin: 10px 0 2px; flex-wrap: wrap; }
.flight-nums > div { background: #f6f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; min-width: 120px; }
.flight-nums b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; } .flight-nums span { font-size: 12px; color: var(--muted); }
.flight-nums .ok { background: var(--green-soft); border-color: #b9e6cb; } .flight-nums .ok b { color: var(--green); }
.flight-nums .warn { background: var(--amber-soft); border-color: var(--amber-line); } .flight-nums .warn b { color: var(--amber); }
@media (max-width: 900px) { .metrics.three { grid-template-columns: 1fr; } }

/* ===== Preencher com a base ===== */
.enrich-step { padding: 18px 20px; } .enrich-step h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 10px; font-size: 15px; }
.step-n { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-grid; place-items: center; font-size: 13px; }
.map-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.enrich-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.enrich-stats > div { background: #f6f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; min-width: 120px; }
.enrich-stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; } .enrich-stats span { font-size: 12px; color: var(--muted); }
.enrich-stats .warn { background: var(--amber-soft); border-color: var(--amber-line); } .enrich-stats .warn b { color: var(--amber); }
@media (max-width: 900px) { .map-grid { grid-template-columns: 1fr; } }

/* ===== ajustes: dashboard, histórico de mesclagem, consulta ===== */
.metrics.three { max-width: none; }
.metric-sub { color: var(--green); font-weight: 600; font-size: 12px; margin-top: 2px; }
.daily-card { padding: 22px 26px 18px; margin-bottom: 18px; }
.daily-head { text-align: center; margin-bottom: 14px; } .daily-head h3 { margin: 0; font-size: 17px; } .daily-head p { margin: 4px 0 0; }
.daily { display: flex; justify-content: center; align-items: flex-end; gap: 8px; min-height: 250px; overflow-x: auto; padding: 10px 6px 6px;
  background: repeating-linear-gradient(to top, transparent 0, transparent 47px, #eef2f7 47px, #eef2f7 48px); }
.daily .day { flex: 1 1 0; max-width: 46px; min-width: 22px; gap: 5px; font-size: 11px; }
.daily .day i { width: 100%; max-width: 34px; border-radius: 7px 7px 3px 3px; transition: filter .15s; }
.daily .day:hover i { filter: brightness(1.12); }
.daily .day.peak i { background: linear-gradient(180deg, #f2b24a, var(--amber)); }
.daily .day b { font-size: 12px; }
.merged-card { margin-top: 16px; }
.merge-hist { display: grid; gap: 8px; margin-top: 8px; }
.merge-run { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: #fbfdff; }
.merge-run summary { cursor: pointer; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.sql-block { background: #0f1d2e; color: #d6e6f5; border-radius: 10px; padding: 14px 16px; overflow: auto; max-height: 340px; font: 12.5px/1.55 ui-monospace, Consolas, monospace; margin: 0; white-space: pre; }
