:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e4e7ec;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0d9488;
  --primary-strong: #0f766e;
  --primary-soft: #ccfbf1;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn-soft: #fef3c7;
  --side-bg: #0b1324;
  --side-text: #9fb0c8;
  --side-active: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--primary-strong); }
h1, h2, h3 { margin: 0; line-height: 1.25; }

/* ---------- controles ---------- */
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; background: var(--primary); color: #fff; white-space: nowrap; transition: background .15s, box-shadow .15s; }
.btn:hover { background: var(--primary-strong); }
.btn:focus-visible, .input:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .pick:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 1px; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); }
.btn.lg { height: 48px; font-size: 15px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: #344054; }
.field > span b { color: var(--danger); }
.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--surface); color: var(--text); }
select.input { padding-right: 8px; }
.input:focus { border-color: var(--primary); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--danger-soft); color: #991b1b; font-weight: 500; }
.alert:empty { display: none; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef2f6; color: #475467; }
.badge.ok { background: var(--primary-soft); color: var(--primary-strong); }
.badge.warn { background: var(--warn-soft); color: #92400e; }
.muted { color: var(--muted); }

/* ---------- login ---------- */
.auth { min-height: 100%; display: grid; grid-template-columns: 1fr; }
.auth-brand { display: none; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 32px; display: grid; gap: 18px; }
.auth-card header { display: grid; gap: 6px; }
.auth-card h1 { font-size: 22px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.logo-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff; }
.logo-mark svg.i { width: 20px; height: 20px; }
@media (min-width: 900px) {
  .auth { grid-template-columns: 1.1fr 1fr; }
  .auth-brand { display: flex; flex-direction: column; justify-content: space-between; padding: 48px; color: #e2e8f0; position: relative; overflow: hidden;
    background: radial-gradient(1200px 600px at -10% 120%, #0f766e 0%, transparent 60%), linear-gradient(160deg, #0b1324 0%, #10213b 100%); }
  .auth-brand .logo { color: #fff; }
  .auth-brand h2 { font-size: 40px; font-weight: 800; letter-spacing: -.02em; color: #fff; max-width: 12ch; }
  .auth-brand p { color: #9fb0c8; max-width: 40ch; font-size: 16px; }
  .auth-brand > :not(.serra) { position: relative; z-index: 1; }
  .auth-brand .serra { position: absolute; inset: auto 0 0 0; width: 100%; height: 38%; opacity: .45; }
}

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100%; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; transform: translateX(-100%); transition: transform .2s; z-index: 40; }
.shell.menu-aberto .sidebar { transform: none; }
.backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 30; }
.sidebar .logo { color: #fff; padding: 20px 20px 12px; }
.nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; display: grid; align-content: start; gap: 2px; }
.nav h4 { margin: 18px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5b6b85; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--side-text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .05); color: #e2e8f0; }
.nav a.ativo { background: rgba(20, 184, 166, .14); color: var(--side-active); box-shadow: inset 3px 0 0 #14b8a6; }
.nav a.ativo svg { color: #2dd4bf; }
.side-foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: 12px; color: #5b6b85; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 16px; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 20px 16px 40px; display: grid; gap: 20px; align-content: start; width: 100%; min-width: 0; }
@media (min-width: 1024px) {
  .shell { grid-template-columns: 260px 1fr; }
  .sidebar { position: sticky; top: 0; height: 100vh; transform: none; }
  .backdrop, #abrir-menu { display: none; }
  .topbar { padding: 0 32px; }
  .content { padding: 28px 32px 48px; }
}

/* avatar + menu */
.user { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; color: var(--text); }
.user-btn:hover { background: var(--surface-2); }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff; font-weight: 700; font-size: 13px; }
.user-info { display: none; text-align: left; line-height: 1.2; }
.user-info small { display: block; color: var(--muted); font-size: 12px; text-transform: capitalize; }
@media (min-width: 640px) { .user-info { display: block; } }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; display: grid; }
.dropdown .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown .who small { display: block; color: var(--muted); }
.dropdown button { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 6px; background: none; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.dropdown button:hover { background: var(--surface-2); }
.dropdown button.sair { color: var(--danger); }

/* ---------- cards / páginas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; font-weight: 700; flex: 1; }
.card-body { padding: 20px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head > div { flex: 1; min-width: 200px; }
.page-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 34px; width: 260px; max-width: 100%; }
@media (max-width: 560px) { .card-head .search { flex: 1 1 100%; order: 3; } .card-head .search .input { width: 100%; } }

.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat { padding: 18px 20px; display: flex; align-items: center; gap: 14px; }
.stat .ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-strong); }
.stat strong { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }

/* tabela */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid td { padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: #fafbfc; }
.grid td.acoes { text-align: right; width: 1%; }
.vazio { padding: 40px 20px; text-align: center; color: var(--muted); }

/* dialog */
dialog { border: 0; padding: 0; border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
dialog .d-head { display: flex; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
dialog .d-head h3 { flex: 1; font-size: 16px; }
dialog .d-body { padding: 20px; overflow-y: auto; display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
dialog .d-body > .full, dialog .d-body > .alert { grid-column: 1 / -1; }
dialog .d-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
@media (max-width: 560px) { dialog .d-body { grid-template-columns: 1fr; } }

/* toast */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; background: #0f172a; color: #fff; box-shadow: var(--shadow-lg); font-weight: 500; animation: entra .2s ease-out; }
.toast svg { color: #2dd4bf; }
.toast.erro svg { color: #f87171; }
@keyframes entra { from { transform: translateY(8px); opacity: 0; } }

/* ---------- lançamento ---------- */
.lancar { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1100px) { .lancar { grid-template-columns: minmax(0, 1fr) 380px; } }
.steps { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); font-weight: 600; }
.steps .n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #eef2f6; margin-right: 6px; font-size: 12px; }
.steps .on { color: var(--text); }
.steps .on .n { background: var(--primary); color: #fff; }
.steps .sep { flex: 0 0 24px; height: 1px; background: var(--border); }
.picker { border: 1px solid var(--border); border-radius: 10px; max-height: 300px; overflow-y: auto; }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--border); background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.pick:last-child { border-bottom: 0; }
.pick:hover { background: var(--surface-2); }
.pick.sel { background: #f0fdfa; box-shadow: inset 3px 0 0 var(--primary); }
.pick .avatar { width: 30px; height: 30px; font-size: 12px; background: #e2e8f0; color: #334155; }
.pick.sel .avatar { background: var(--primary); color: #fff; }
.pick small { display: block; color: var(--muted); }
.chips { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); max-height: 260px; overflow-y: auto; padding: 2px; }
.chip { height: 56px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; color: var(--text); display: grid; place-content: center; line-height: 1.15; }
.chip small { font-weight: 500; font-size: 11px; color: var(--muted); }
.chip:hover { border-color: var(--primary); }
.chip.sel { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.sel small { color: #ccfbf1; }
.resumo { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.resumo div { background: var(--surface-2); padding: 12px 14px; }
.resumo dt { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 560px) { .resumo { grid-template-columns: repeat(2, 1fr); } }
.resumo dd { margin: 2px 0 0; font-weight: 700; font-size: 15px; }
.decide { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.decide .btn { height: 72px; font-size: 16px; flex-direction: column; gap: 2px; }
.decide .btn small { font-weight: 500; opacity: .85; font-size: 12px; }
.stepper { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; height: 52px; }
.stepper button { width: 52px; border: 0; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; color: var(--text); }
.stepper button:hover { background: #eef2f6; }
.stepper input { flex: 1; min-width: 0; border: 0; text-align: center; font: inherit; font-size: 20px; font-weight: 700; color: var(--text); }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed .meta { flex: 1; min-width: 0; }
.feed .meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .meta small { color: var(--muted); }
