/* ════════════════════════════════════════════════════════════════════
   Dashboard Marcelo Serviços Digitais — tema claro premium
   ════════════════════════════════════════════════════════════════════ */
:root {
  --bg: #F8F9FA;
  --bg-sidebar: #FFFFFF;
  --bg-card: #FFFFFF;
  --border: #E5E7EB;
  --border-soft: #F1F2F4;
  --text: #111827;
  --text-muted: #6B7280;
  --text-dim: #9CA3AF;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-soft: #DBEAFE;
  --success: #16A34A;
  --success-soft: #DCFCE7;
  --warn: #D97706;
  --warn-soft: #FEF3C7;
  --danger: #DC2626;
  --danger-soft: #FEE2E2;
  --info: #0891B2;
  --info-soft: #CFFAFE;
  --purple: #7C3AED;
  --purple-soft: #EDE9FE;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 6px -1px rgba(16, 24, 40, .06), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 15px -3px rgba(16, 24, 40, .08), 0 4px 6px -4px rgba(16, 24, 40, .04);
  --radius: 12px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }

/* ═════════ LOGIN ═════════ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #F8F9FA 0%, #E8EDF4 100%);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563EB 0%, #4F46E5 100%);
  display: grid; place-items: center;
  color: #fff;
  margin: 0 auto 20px;
}
.login-card h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; text-align: center; }
.login-card p.sub { color: var(--text-muted); text-align: center; margin: 0 0 24px; font-size: 13px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.login-card input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff; font-size: 14px; color: var(--text);
  outline: none; transition: border .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-card .field { margin-bottom: 16px; }
.btn-login {
  width: 100%; padding: 12px; border: 0; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; font-weight: 600; cursor: pointer;
  margin-top: 8px; transition: background .15s;
}
.btn-login:hover { background: var(--primary-hover); }
.login-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px; }

/* ═════════ APP LAYOUT ═════════ */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand .logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563EB 0%, #4F46E5 100%);
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
}
.sidebar-brand .name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.sidebar-brand .tagline { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-section { margin-bottom: 8px; }
.nav-label {
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 8px 12px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer;
  font-weight: 500; font-size: 13px;
  margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: #F3F4F6; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item.active svg { stroke: var(--primary); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  color: #fff; display: grid; place-items: center; font-weight: 700;
  font-size: 13px; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout {
  border: 0; background: transparent; color: var(--text-muted);
  padding: 6px; border-radius: 6px; cursor: pointer;
}
.btn-logout:hover { background: #F3F4F6; color: var(--danger); }

/* ═════════ CONTENT ═════════ */
.content { padding: 28px 32px; max-width: 1400px; }
.content-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.content-header h1 { font-size: 22px; font-weight: 700; margin: 0; }
.content-header .breadcrumb { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.content-header .actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff;
  color: var(--text); font-weight: 500; cursor: pointer;
  font-size: 13px; transition: all .12s;
}
.btn:hover { background: #F9FAFB; border-color: #D1D5DB; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { border: 0; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: #F3F4F6; }
.btn-danger { background: #FEF2F2; color: var(--danger); border-color: #FECACA; }
.btn-danger:hover { background: #FEE2E2; }

.refresh-meta { font-size: 12px; color: var(--text-muted); }
.refresh-meta .live-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--success); margin-right: 4px;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

/* ═════════ STAT CARDS ═════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card.tinted-success { background: linear-gradient(180deg, var(--success-soft) 0%, #fff 80%); border-color: #BBF7D0; }
.stat-card.tinted-info { background: linear-gradient(180deg, var(--info-soft) 0%, #fff 80%); border-color: #A5F3FC; }
.stat-card.tinted-warn { background: linear-gradient(180deg, var(--warn-soft) 0%, #fff 80%); border-color: #FDE68A; }
.stat-card.tinted-danger { background: linear-gradient(180deg, var(--danger-soft) 0%, #fff 80%); border-color: #FECACA; }
.stat-card.tinted-purple { background: linear-gradient(180deg, var(--purple-soft) 0%, #fff 80%); border-color: #DDD6FE; }
.stat-card.tinted-primary { background: linear-gradient(180deg, var(--primary-soft) 0%, #fff 80%); border-color: #BFDBFE; }

.stat-card .icon-box {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.6);
}
.stat-card .icon-box svg { width: 18px; height: 18px; }
.stat-card .label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; margin-bottom: 6px; word-break: break-word; }
.stat-card .delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
}
.stat-card .delta.up { background: var(--success-soft); color: var(--success); }
.stat-card .delta.down { background: var(--danger-soft); color: var(--danger); }
.stat-card .delta.neutral { background: #F3F4F6; color: var(--text-muted); }
.stat-card .delta-context { font-size: 11px; color: var(--text-dim); margin-left: 6px; }

/* ═════════ CARDS / SECTIONS ═════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; align-items: center;
}
.card-header h3 { font-size: 14px; font-weight: 600; margin: 0; }
.card-header .card-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 20px; }

.row-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; margin-bottom: 24px; }
.row-2-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 1024px) {
  .row-2, .row-2-eq, .row-3 { grid-template-columns: 1fr; }
}

/* ═════════ TABELAS ═════════ */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  background: #FAFBFC;
}
.tbl td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #FAFBFC; }
.tbl .cell-strong { font-weight: 600; color: var(--text); }
.tbl .cell-muted { color: var(--text-muted); font-size: 12px; }

/* ═════════ BADGES ═════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-mute { background: #F3F4F6; color: var(--text-muted); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }

.badge-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  margin-right: 4px;
}

/* ═════════ FUNIL ═════════ */
.funil { display: flex; flex-direction: column; gap: 8px; }
.funil-bar {
  background: var(--border-soft);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center;
  position: relative;
  overflow: hidden;
}
.funil-bar::before {
  content: ''; position: absolute; inset: 0;
  background: var(--bar-color, #2563EB);
  opacity: .12;
  width: var(--bar-width, 0%);
}
.funil-bar > * { position: relative; z-index: 1; }
.funil-bar .funil-name { font-weight: 500; font-size: 13px; }
.funil-bar .funil-qtd { font-weight: 700; font-size: 14px; color: var(--text); }
.funil-bar .funil-qtd small { font-weight: 500; color: var(--text-muted); margin-left: 4px; font-size: 11px; }

/* ═════════ PROGRESS BARS ═════════ */
.progress-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.progress-row:last-child { border-bottom: 0; }
.progress-row .top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.progress-row .name { font-weight: 600; font-size: 13px; }
.progress-row .pct { font-weight: 700; font-size: 13px; color: var(--primary); }
.progress-row .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.progress-bar {
  height: 6px; background: var(--border-soft); border-radius: 3px;
  overflow: hidden;
}
.progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #2563EB, #4F46E5);
  border-radius: 3px;
  transition: width .3s;
}

/* ═════════ KANBAN ═════════ */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.kanban-col {
  background: #F1F2F4;
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
}
.kanban-col-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 6px 10px;
}
.kanban-col-name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kanban-col-count { background: #fff; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--text-muted); }
.kanban-card {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--primary);
  font-size: 13px;
}
.kanban-card .name { font-weight: 600; }
.kanban-card .meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ═════════ MISC ═════════ */
.input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; font-size: 13px; color: var(--text); outline: none;
  transition: border .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { min-height: 70px; resize: vertical; }
select.input { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.field-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }

.empty {
  padding: 32px 20px; text-align: center;
  color: var(--text-muted); font-size: 13px;
}

/* ═════════ TOAST ═════════ */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--text); color: #fff;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px); opacity: 0;
  transition: all .25s; z-index: 200;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { background: var(--success); }
#toast.error { background: var(--danger); }

/* ═════════ MODAL ═════════ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, .55);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-bg.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%; max-width: 720px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 8px; }

/* ═════════ PRE / LOG ═════════ */
.pre {
  background: #1F2937; color: #E5E7EB;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  padding: 14px; border-radius: 8px;
  white-space: pre-wrap; word-break: break-all;
  max-height: 50vh; overflow-y: auto;
}

/* ═════════ SCROLLBAR ═════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* ═════════ RESPONSIVE ═════════ */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -240px; transition: left .25s; z-index: 90; width: 240px; }
  .sidebar.open { left: 0; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .value { font-size: 22px; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
