/* =========================================================================
   Base
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
#app { min-height: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.stack.loose { gap: 20px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.boot-loading { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* =========================================================================
   Shell (sidebar + topbar)
   ========================================================================= */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); z-index: 40;
  background: var(--sidebar-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transition: transform .2s ease, width .2s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-height); padding: 0 18px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.sidebar-brand img { width: 28px; height: 28px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; color: var(--text); }
.sidebar-org { padding: 12px; border-bottom: 1px solid var(--border); }
.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 10px 10px 24px; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 2px; }
.nav-group-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--subtle); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--sidebar-text); font-weight: 500; cursor: pointer; text-decoration: none !important; user-select: none;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--muted); }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.nav-item.active svg { color: var(--sidebar-active-text); }
.nav-sub { margin: 2px 0 4px 28px; border-left: 1px solid var(--border); padding-left: 6px; }
.nav-sub .nav-item { padding: 5px 10px; font-size: 13.5px; }
.sidebar-footer { padding: 10px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--subtle); }

.main { flex: 1 1 auto; min-width: 0; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-height);
  display: flex; align-items: center; gap: 10px; padding: 0 24px;
  background: color-mix(in srgb, var(--background) 86%, transparent); backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .menu-btn { display: none; }
.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.sidebar-backdrop { display: none; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header .subtitle { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* =========================================================================
   Componentes
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 550; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, color .12s;
}
.btn > svg { width: 16px; height: 16px; flex: 0 0 16px; stroke-width: 2; }
.btn.sm > svg { width: 15px; height: 15px; flex: 0 0 15px; }
/* Botão de adicionar (+ Novo / + Adicionar): mesmo tamanho, ícone e espaço em todas as telas. */
.btn.add { gap: 6px; padding-left: 12px; }
.btn.add > svg { width: 16px; height: 16px; flex: 0 0 16px; stroke-width: 2.4; margin-left: -1px; }
.btn.sm.add { gap: 5px; padding-left: 9px; }
.btn.sm.add > svg { width: 14px; height: 14px; flex: 0 0 14px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-width: 0; height: 38px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.select { padding-right: 32px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667085' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); }
.input::placeholder, .textarea::placeholder { color: var(--subtle); }
.input-group { position: relative; }
.input-group > svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--subtle); pointer-events: none; }
.input-group > .input { padding-left: 34px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; color: var(--text-2); }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.switch { position: relative; display: inline-flex; width: 38px; height: 22px; flex: 0 0 38px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:disabled + span { opacity: .5; cursor: not-allowed; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 14.5px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.sidebar-layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

.stat { padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.stat-label > svg { width: 15px; height: 15px; }
.stat-value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11.5px; font-weight: 550; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table th.right, .table td.right { text-align: right; }
.cards-list { display: flex; flex-direction: column; }
.list-card { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-card:last-child { border-bottom: none; }
.list-card:active { background: var(--surface-2); }
.list-card .lc-title { font-weight: 600; }
.list-card .lc-meta { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.list-card .lc-side { margin-left: auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar .search { flex: 1 1 240px; max-width: 360px; }
.toolbar .select { width: auto; min-width: 150px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty > svg { width: 40px; height: 40px; color: var(--subtle); margin-bottom: 10px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13.5px; }
.alert > svg { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; }
.alert.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert.warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.alert.info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.alert.success { background: var(--success-soft); border-color: transparent; color: var(--success); }

.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.loading-block { display: grid; place-items: center; padding: 48px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: 18px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 9px 12px; font-weight: 550; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; background: none; border-top: 0; border-left: 0; border-right: 0; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented button { flex: 0 0 auto; white-space: nowrap; }
.segmented button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-weight: 550; color: var(--muted); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 650; background: var(--primary-soft); color: var(--primary); flex: 0 0 30px; }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; flex-basis: 44px; }

/* Modal / drawer */
.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .12s ease; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; border: 1px solid var(--border); }
.modal.lg { max-width: 820px; }
.modal.xl { max-width: 1080px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.drawer-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 90; animation: fade .12s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 91; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slidein .18s ease; border-left: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } }

/* Menu suspenso */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; }
.menu.left { right: auto; left: 0; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer; text-align: left; color: var(--text); font-weight: 500; }
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item > svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--muted); }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-label { font-size: 11.5px; color: var(--subtle); padding: 6px 10px 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

/* Combobox */
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; z-index: 70; padding: 4px; }
.combo-opt { padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.combo-opt:hover, .combo-opt.active { background: var(--surface-2); }
.combo-opt .muted { font-size: 12px; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--text); color: var(--surface); padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: fade .15s; }
.toast.error { background: var(--danger); color: #fff; }
.toast > svg { width: 18px; height: 18px; flex: 0 0 18px; }

/* =========================================================================
   Autenticação / onboarding
   ========================================================================= */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-aside { background: linear-gradient(160deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 55%, #0E0F12) 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside h2 { color: #fff; font-size: 30px; line-height: 1.2; max-width: 420px; letter-spacing: -0.02em; }
.auth-aside p { color: rgba(255,255,255,.82); max-width: 420px; margin-top: 12px; font-size: 15px; }
.auth-aside ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.auth-aside li { display: flex; gap: 10px; align-items: center; color: rgba(255,255,255,.9); }
.auth-aside li svg { width: 18px; height: 18px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 24px; }
.onboarding { max-width: 760px; margin: 0 auto; padding: 40px 20px 64px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.choice { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 12px; padding: 14px; cursor: pointer; text-align: left; transition: border-color .12s, box-shadow .12s; }
.choice:hover { border-color: var(--primary); }
.choice.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.choice strong { display: block; }
.choice small { color: var(--muted); }
.progress { height: 4px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); transition: width .25s; }

/* =========================================================================
   CRM Kanban
   ========================================================================= */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; scroll-snap-type: x proximity; }
.board-col { flex: 0 0 290px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 220px); scroll-snap-align: start; }
.board-col.drop-target { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.board-col-head { padding: 10px 12px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.board-col-head .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.board-col-body { padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.opp-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow-sm); }
.opp-card:hover { border-color: var(--border-strong); }
.opp-card.dragging { opacity: .45; }
.opp-card .t { font-weight: 600; line-height: 1.35; }
.opp-card .m { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.opp-card .f { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 6px; }
.stage-pills { display: none; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .tl-title { font-weight: 600; }
.timeline .tl-body { white-space: pre-wrap; color: var(--text-2); margin-top: 2px; }
.timeline .tl-meta { font-size: 12px; color: var(--muted); }

/* Gráfico simples */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar > div { width: 100%; max-width: 44px; background: var(--primary); border-radius: 6px 6px 3px 3px; min-height: 2px; opacity: .85; }
.bars .bar.current > div { opacity: 1; }
.bars .bar span { font-size: 11.5px; color: var(--muted); }

.attention-item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.attention-item:last-child { border-bottom: none; }
/* Atalhos do Início (grade de ações rápidas) */
.shortcut-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.shortcut { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font-weight: 550; text-decoration: none !important; }
.shortcut:hover { background: var(--surface-2); }
.shortcut-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.shortcut-icon > svg { width: 17px; height: 17px; }
.shortcut-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.mobile-search { display: flex; align-items: center; gap: 10px; width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--muted); font: inherit; text-align: left; cursor: pointer; box-shadow: var(--shadow-sm); }
.mobile-search > svg { width: 18px; height: 18px; flex: 0 0 18px; }
.attention-item:hover { background: var(--surface-2); }
.attention-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 34px; }
.attention-icon > svg { width: 17px; height: 17px; }
.attention-icon.critical { background: var(--danger-soft); color: var(--danger); }
.attention-icon.warning { background: var(--warning-soft); color: var(--warning); }
.attention-icon.info { background: var(--info-soft); color: var(--info); }

.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 12px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; }
.doc-lines .line { display: grid; grid-template-columns: minmax(0, 3fr) 90px 120px 110px 120px 36px; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.doc-lines .head { font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.totals { margin-left: auto; width: min(340px, 100%); display: grid; gap: 6px; }
.totals .row { justify-content: space-between; }
.totals .grand { font-size: 17px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 8px; }
.perm-table td, .perm-table th { padding: 8px 10px; }
.perm-table td.c, .perm-table th.c { text-align: center; }

/* =========================================================================
   Responsividade
   ========================================================================= */
@media (max-width: 1180px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.sidebar-layout { grid-template-columns: minmax(0, 1fr); }
}
/* Tablet: sidebar vira gaveta */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .shell.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 35; }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-flex; }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .doc-lines .line { grid-template-columns: minmax(0, 1fr) 80px 100px 36px; }
  .doc-lines .line .c-disc, .doc-lines .line .c-total { display: none; }
}
/* Celular */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .content { padding: 16px 14px 80px; }
  .topbar { padding: 0 12px; }
  .page-header { margin-bottom: 14px; }
  .page-header h1 { font-size: 20px; }
  .page-actions { width: 100%; }
  .page-actions .btn, .page-actions .select { flex: 1 1 auto; min-width: 0; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .grid.stats-mobile-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .toolbar { padding: 10px; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .toolbar .select { flex: 1 1 140px; min-width: 0; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.lg, .modal.xl { max-width: none; max-height: 94vh; border-radius: 16px 16px 0 0; }
  .modal-footer .btn { flex: 1 1 auto; }
  .drawer { width: 100vw; }
  .stat-value { font-size: 19px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .board { flex-direction: column; overflow-x: visible; }
  .board-col { flex-basis: auto; width: 100%; max-height: none; display: none; }
  .board-col.mobile-active { display: flex; }
  .stage-pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
  .stage-pills button { flex: 0 0 auto; }
  .opp-card { cursor: pointer; }
  .doc-lines .head { display: none; }
  .doc-lines .line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--surface-2); border-radius: 10px; padding: 10px; border: 0; margin-bottom: 8px; }
  .doc-lines .line .c-item { grid-column: 1 / -1; }
  .doc-lines .line .c-disc, .doc-lines .line .c-total { display: block; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 641px) { .only-mobile { display: none !important; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  .sidebar, .topbar, .page-actions, .no-print { display: none !important; }
  .main { margin: 0; }
  .card { box-shadow: none; }
}

/* Papéis e permissões */
.grid.roles-layout { grid-template-columns: minmax(0, 260px) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .grid.roles-layout { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------ precificação */
.pricing-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.pricing-result { position: sticky; top: calc(var(--topbar-height) + 16px); }
.price-hero { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.price-hero.unviable { color: var(--danger); font-size: 22px; }
.price-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.price-kpis > div { background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; }
.price-kpis .k { font-size: 12px; color: var(--muted); }
.price-kpis .v { font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.comp-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.comp-bar > span { display: block; height: 100%; }
.comp-legend { display: grid; gap: 6px; font-size: 13px; }
.comp-legend .row { justify-content: space-between; }
.comp-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.price-lines { display: grid; gap: 8px; }
.price-line { display: grid; grid-template-columns: minmax(0, 3fr) 96px 78px 118px 36px; gap: 8px; align-items: center; }
.price-line.labor { grid-template-columns: minmax(0, 3fr) 96px 118px 130px 36px; }
.price-line.other { grid-template-columns: minmax(0, 3fr) 140px 36px; }
.price-line.head { font-size: 12px; color: var(--muted); font-weight: 600; }
.price-line .catalog-cost { font-size: 11.5px; color: var(--muted); }
.price-mobile-bar { display: none; }
@media (max-width: 1180px) {
  .pricing-layout { grid-template-columns: minmax(0, 1fr); }
  .pricing-result { position: static; }
}
@media (max-width: 640px) {
  .price-line, .price-line.labor, .price-line.other { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--surface-2); border-radius: 10px; padding: 10px; }
  .price-line > :first-child { grid-column: 1 / -1; }
  .price-line.head { display: none; }
  .price-hero { font-size: 28px; }
  .price-mobile-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--border);
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); justify-content: space-between; align-items: center; box-shadow: var(--shadow-lg); }
}

/* =========================================================================
   Busca global (Ctrl+K)
   ========================================================================= */
.topbar-center { display: flex; justify-content: center; min-width: 0; }
.topbar-search { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 440px; height: 38px; padding: 0 10px 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--muted); font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
.topbar-search:hover { border-color: var(--border-strong); }
.topbar-search > svg { width: 16px; height: 16px; flex: 0 0 16px; }
.kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; margin: 0 2px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--muted); font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.palette-backdrop { align-items: flex-start; padding-top: 10vh; }
.palette { width: min(640px, calc(100vw - 32px)); max-height: 72vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg, 0 20px 50px rgba(0,0,0,.25)); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.palette-input > svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--muted); }
.palette-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-group { padding: 10px 10px 4px; font-size: 11.5px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase; color: var(--subtle); }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.palette-item.active { background: var(--primary-soft); }
.palette-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.palette-item.active .palette-icon { color: var(--primary); background: var(--surface); }
.palette-icon > svg { width: 16px; height: 16px; }
.palette-empty { padding: 18px 12px; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (max-width: 640px) {
  .topbar-center { justify-content: flex-end; flex: 0 0 auto; margin-left: auto; }
  .topbar-search { width: 38px; padding: 0; justify-content: center; background: transparent; border-color: transparent; }
  .palette-backdrop { padding-top: 0; }
  .palette { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .palette-foot { display: none; }
}

/* Precificação — blocos de custo (modo básico) */
.cost-block .card-header { padding-top: 10px; padding-bottom: 10px; }
.cost-block-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.cost-block-icon > svg { width: 15px; height: 15px; }
.cost-add { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; border: 1.5px dashed var(--border-strong); border-radius: 12px; }
.cost-add .menu { min-width: 280px; }
.cost-add .menu-item { align-items: flex-start; }
