/* Max Corretora — componentes base (Fase 0) */

/* ── Botões ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--bg-muted); }
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-muted); }

.btn-danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.btn-block { width: 100%; }

/* ── Formulários ──────────────────────────────────────── */
.label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.input,
.select,
.textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-focus);
}

/* ── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
  background: var(--bg-muted);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger  { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-neutral { background: var(--bg-muted); color: var(--text-muted); }

/* ── Toast ──────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--success);
  color: #fff;
  padding: 9px 17px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  z-index: var(--z-toast);
  box-shadow: var(--shadow-md);
  transform: translateY(56px);
  opacity: 0;
  transition: transform var(--motion-fast), opacity var(--motion-fast);
  transition-timing-function: var(--motion-ease);
  pointer-events: none;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.warn { background: var(--warning); }

/* ── Logo agência ─────────────────────────────────────── */
.ag-logo-img {
  display: block;
  max-height: 32px;
  max-width: 120px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  padding: 2px 4px;
}

/* ── Seção parceiros (Fase 4) ───────────────────────────── */
.parc-shell-sticky {
  position: sticky;
  top: var(--header-stack);
  z-index: 200;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}
.secao-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-wrap: wrap;
}
.sec-ic {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  color: var(--accent);
  flex-shrink: 0;
}
.secao-title { font-size: 18px; font-weight: 800; color: var(--text); line-height: 1.2; }
.secao-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.secao-badge {
  background: var(--accent-soft);
  color: var(--accent-on-soft);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  white-space: nowrap;
}
.ag-logo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

/* ── Login (T01) ──────────────────────────────────────── */
#login {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
}
#login.hidden { display: none; }

.login-theme-btn {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s, border-color 0.15s;
}
.login-theme-btn:hover { background: var(--bg-muted); }
.login-theme-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.login-theme-ic { display: inline-flex; line-height: 0; }

.login-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-box h1 {
  text-align: center;
  margin: 0 0 var(--space-1);
  line-height: 1;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -2px;
}
.login-box h1 .nr-n { color: var(--text); }
.login-box h1 .nr-r { color: var(--accent); }
.login-box .sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
  margin-bottom: var(--space-6);
}
.login-box label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.login-box input {
  width: 100%;
  margin-bottom: var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-focus);
}
.login-box button {
  width: 100%;
  margin-top: var(--space-2);
  min-height: 44px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.login-box button:hover { background: var(--accent-hover); }
.login-box button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.login-box .err {
  color: var(--danger);
  font-size: var(--text-sm);
  margin-top: var(--space-2);
  text-align: center;
  min-height: 18px;
}

/* ── Loading (T02) — skeleton boot (Fase 9+) ─────────────── */
#carregando {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 900;
  gap: var(--space-4);
  padding: var(--space-4);
}
#carregando.hidden { display: none; }
.mc-boot-inner { width: 100%; display: flex; justify-content: center; }
.mc-boot-err-slot { width: min(480px, 94vw); }
.mc-boot-err-slot.hidden { display: none; }
.loading-text {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
  font-weight: 600;
}
.mc-boot-skeleton { width: min(1040px, 96vw); }
.mc-sk-block {
  position: relative;
  overflow: hidden;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.mc-sk-block::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 8%, transparent), transparent);
  transform: translateX(-100%);
  animation: mc-shimmer 1.4s ease-in-out infinite;
}
@keyframes mc-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Admin shell */
.mc-sk-shell { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-surface); box-shadow: var(--shadow-md); }
.mc-sk-topbar { height: 48px; border-radius: 0; border: none; border-bottom: 1px solid var(--border); }
.mc-sk-body { display: flex; min-height: 420px; }
.mc-sk-sidebar { width: 200px; flex-shrink: 0; border-radius: 0; border: none; border-right: 1px solid var(--border); min-height: 100%; }
.mc-sk-main { flex: 1; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mc-sk-hdr-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mc-sk-title { height: 28px; width: min(220px, 55%); flex-shrink: 0; }
.mc-sk-chip { height: 24px; width: 88px; border-radius: var(--radius-full); }
.mc-sk-chip.sm { width: 64px; }
.mc-sk-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.mc-sk-pill { height: 34px; width: 72px; border-radius: var(--radius-full); flex-shrink: 0; }
.mc-sk-pill.wide { width: 96px; }
.mc-sk-cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.mc-sk-card { height: 64px; }
.mc-sk-filter { height: 44px; }
.mc-sk-table { display: flex; flex-direction: column; gap: 8px; }
.mc-sk-th { height: 28px; width: 100%; }
.mc-sk-lines { display: flex; flex-direction: column; gap: 6px; }
.mc-sk-line { height: 13px; }
.mc-sk-line:nth-child(1) { width: 96%; }
.mc-sk-line:nth-child(2) { width: 88%; }
.mc-sk-line:nth-child(3) { width: 92%; }
.mc-sk-line:nth-child(4) { width: 78%; }
.mc-sk-line:nth-child(5) { width: 85%; }
.mc-sk-line:nth-child(6) { width: 70%; }
.mc-sk-line:nth-child(7) { width: 62%; }

/* Escritório */
.mc-sk-esc-wrap { display: flex; flex-direction: column; gap: 12px; padding: 4px; }
.mc-sk-sec-hdr { height: 52px; }
.mc-sk-pills-esc { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
.mc-sk-cards-esc { grid-template-columns: repeat(4, 1fr); }
.mc-sk-kanban { display: flex; gap: 10px; overflow: hidden; }
.mc-sk-col { flex: 1; min-height: 200px; min-width: 0; }

#carregando.sk-mode-escritorio .mc-sk-admin { display: none; }
#carregando.sk-mode-admin .mc-sk-escritorio { display: none; }

@media (max-width: 1023px) {
  .mc-sk-sidebar { display: none; }
  .mc-sk-cards { grid-template-columns: repeat(3, 1fr); }
  .mc-sk-cards-esc { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767px) {
  .mc-sk-cards { grid-template-columns: repeat(2, 1fr); }
  .mc-sk-pill { width: 64px; }
  .mc-sk-kanban .mc-sk-col:nth-child(3) { display: none; }
  .mc-sk-col { min-height: 160px; }
}
/* legado */
.spin { display: none; }

/* ── Toggle tema (topbar) ─────────────────────────────── */
#topbar-theme-btn .tb-ic { color: var(--text-muted); }

/* ── Bottom nav — escritório mobile (Fase 1) ──────────── */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-topbar);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.08);
}
.bottom-nav {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: var(--bottom-nav-height);
  margin: 0;
  padding: 0;
  list-style: none;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  min-width: 44px;
  padding: 6px 4px 4px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item .bn-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.bottom-nav-item .bn-lbl {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
}
.bottom-nav-item:hover { background: var(--bg-muted); }
.bottom-nav-item.active {
  color: var(--agencia-cor, var(--accent));
  font-weight: 700;
}
.bottom-nav-item.active .bn-ic { color: var(--agencia-cor, var(--accent)); }
.bottom-nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── SPA polish (Fase 7) ───────────────────────────────────── */
.mc-boot-err{text-align:center;padding:20px;color:var(--danger)}
.mc-boot-err h2{color:var(--danger);margin:0 0 8px;font-size:1.25rem}
.mc-boot-err p{font-size:13px;margin-top:10px;color:var(--text-muted)}
.mc-boot-err .btn{margin-top:20px}
.mc-boot-warn{text-align:center;padding:40px 20px;color:var(--text-muted)}
.mc-boot-warn h2{color:var(--danger);margin:0 0 8px}
.mc-boot-warn .btn{margin-top:16px}
.mc-link{display:block;font-size:12px;color:var(--accent);text-decoration:underline;margin-bottom:2px}
.mc-link-miss{display:block;font-size:12px;color:var(--text-muted);margin-bottom:2px}
.mc-link-miss .pv-ic{display:inline-flex;vertical-align:middle;margin-right:3px}
.tag-chip{cursor:pointer}
.tag-chip.is-active{background:var(--accent);color:#fff;border-color:var(--accent)}
.tag-chip-count{background:rgba(0,0,0,.08);border-radius:8px;padding:0 5px;font-size:10px;margin-left:4px}
.tag-chip.is-active .tag-chip-count{background:rgba(255,255,255,.28)}
.tags-empty{color:var(--text-subtle);font-style:italic;font-size:12px}
.cn-sub{font-size:10px;color:var(--text-subtle);margin-top:2px}
.cn-tags{margin-top:3px}
.pill-tag{background:var(--badge-indigo-bg);color:var(--badge-indigo-fg);border:1px solid var(--badge-indigo-border)}
.pill-prod{background:var(--badge-yellow-bg);color:var(--badge-yellow-fg);border:1px solid var(--badge-yellow-border)}
.tbl-chk-col{width:30px}
.tr-click{cursor:pointer}
.tbl-setor{font-size:11px;color:var(--text-muted);max-width:140px}
.tbl-acts{white-space:nowrap}
.btn-xs-inline{display:inline-flex;align-items:center;gap:3px}
.btn-xs-lbl{font-size:10.5px}
.badge.cap{text-transform:capitalize}
.mc-load-msg{color:var(--text-subtle);text-align:center;padding:24px;font-size:13px}
.tpl-preview{font-size:10.5px;color:var(--text-muted);margin-top:3px}
.prod-section-gap{margin-top:24px}
.map-dist{padding:14px 24px}
.map-dist-title{font-size:18px;color:var(--text);margin-bottom:14px;font-weight:800}
.map-dist-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:14px}
.map-reg-card{background:var(--bg-surface);border:1px solid var(--border);border-radius:var(--radius-md);padding:14px}
.map-reg-hdr{display:flex;align-items:center;gap:8px;margin-bottom:10px;padding-bottom:8px;border-bottom:2px solid var(--map-reg-color,var(--accent))}
.map-reg-dot{width:14px;height:14px;background:var(--map-reg-color,var(--accent));border-radius:3px;flex-shrink:0}
.map-reg-name{font-size:13px;color:var(--map-reg-color,var(--accent));text-transform:uppercase;letter-spacing:.5px;flex:1;font-weight:700}
.map-reg-total{font-size:13px;font-weight:700;color:var(--text)}
.map-uf-row{cursor:pointer;padding:6px 4px;border-radius:5px;display:flex;align-items:center;gap:8px;transition:background .15s}
.map-uf-row:hover{background:var(--accent-soft)}
.map-uf-lbl{width:30px;font-weight:700;color:var(--accent);font-size:12px}
.map-uf-track{flex:1;height:14px;background:var(--bg-muted);border-radius:7px;overflow:hidden}
.map-uf-fill{height:100%;background:var(--map-reg-color,var(--accent));border-radius:7px}
.map-uf-n{font-size:12px;color:var(--text-muted);min-width:60px;text-align:right}
.tag-chip-row{display:flex;flex-wrap:wrap;gap:6px}
.tags-none{font-size:11px;color:var(--text-subtle)}
.log-empty{font-size:11px;color:var(--text-subtle);font-style:italic}
.pill-sm{font-size:10px}
.kcard-loc{font-size:10px;color:var(--text-subtle);margin-top:2px}
.map-dist-title{display:flex;align-items:center;gap:8px}
.map-dist-title .pv-ic{line-height:0}
.badge.bpf,.badge.bpj{display:inline-flex;align-items:center;gap:4px}
.badge.bpf .pv-ic,.badge.bpj .pv-ic{line-height:0}

/* ── Motion polish (Fase 9) ─────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  .modal.open > .modal-shell,
  .modal.open > .tc-box,
  .modal.open > .tar-modal-box,
  .modal.open > .mv-box,
  .modal.open > .tl-box,
  .modal.open > .mnl-box,
  .modal.open > .mbe-box,
  .modal.open > .adm-box {
    animation: mc-modal-in var(--motion-fast) var(--motion-ease) both;
  }
}
@keyframes mc-modal-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 639px) {
  .modal.open > .modal-shell,
  .modal.open > .tc-box,
  .modal.open > .tar-modal-box,
  .modal.open > .mv-box,
  .modal.open > .tl-box,
  .modal.open > .mnl-box,
  .modal.open > .mbe-box,
  .modal.open > .adm-box {
    animation-name: mc-modal-sheet;
  }
}
@keyframes mc-modal-sheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .mc-sk-block::after { display: none; }
  #sidebar { transition: none !important; }
  .drawer, #drawer, #drawer-cli { transition: none !important; }
  .drawer-overlay, #drawer-overlay, #overlay { transition: none !important; }
}
