@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --sidebar-bg: #0B1220;
  --sidebar-bg-2: #0E1729;
  --blue-600: #2563EB;
  --blue-500: #3B82F6;
  --blue-400: #60A5FA;
  --cyan-400: #22D3EE;
  --ink-900: #0F172A;
  --ink-700: #334155;
  --ink-500: #64748B;
  --ink-300: #CBD5E1;
  --bg-app: #F3F5FA;
  --card-bg: #FFFFFF;
  --border-soft: rgba(15, 23, 42, 0.08);

  --green: #16A34A; --green-soft: #DCFCE7; --green-text: #15803D;
  --orange: #F59E0B; --orange-soft: #FEF3E2; --orange-text: #B45309;
  --red: #EF4444; --red-soft: #FEE2E2; --red-text: #B91C1C;
  --blue-soft: #DBEAFE; --blue-text: #1D4ED8;

  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(15,23,42,0.04), 0 8px 24px rgba(15,23,42,0.06);
  --shadow-card-hover: 0 4px 10px rgba(15,23,42,0.06), 0 16px 32px rgba(15,23,42,0.10);
  --shadow-drawer: -8px 0 40px rgba(15,23,42,0.18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-app);
  color: var(--ink-900);
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

/* ================= LAYOUT SHELL ================= */
.app-shell { display: flex; min-height: 100vh; }

/* ================= SIDEBAR ================= */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: #E2E8F0;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.sidebar-logo .mark {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--blue-500), var(--cyan-400));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: .85rem;
  box-shadow: 0 4px 14px rgba(59,130,246,0.4);
}
.sidebar-logo .brand-name { font-weight: 700; font-size: .98rem; color: #fff; line-height: 1.2; }
.sidebar-logo .brand-tag { font-size: .68rem; color: #64748B; margin-top: 1px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; margin-bottom: 20px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  font-size: .87rem; font-weight: 500; color: #94A3B8;
  transition: background .15s ease, color .15s ease;
}
.sidebar-nav a .ic { width: 18px; text-align: center; font-size: .95rem; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.05); color: #E2E8F0; }
.sidebar-nav a.active {
  background: linear-gradient(135deg, var(--blue-600), #1D4ED8);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}

.sidebar-mission {
  margin-top: auto;
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  background: radial-gradient(120% 120% at 20% 0%, #1E3A8A 0%, #0B1220 70%);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}
.sidebar-mission::before {
  content: '';
  position: absolute; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(96,165,250,0.35), transparent 70%);
  top: -60px; right: -60px; filter: blur(4px);
}
.sidebar-mission .eyebrow { font-size: .64rem; letter-spacing: .08em; color: #7DD3FC; font-weight: 700; margin-bottom: 8px; }
.sidebar-mission h4 { margin: 0; font-size: 1.15rem; color: #fff; font-weight: 800; line-height: 1.25; }
.sidebar-mission h4 span { background: linear-gradient(90deg, var(--blue-400), var(--cyan-400)); -webkit-background-clip: text; background-clip: text; color: transparent; display: block; }
.sidebar-mission p { font-size: .74rem; color: #94A3B8; margin: 10px 0 0; line-height: 1.5; position: relative; }

.sidebar-user {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px; padding-left: 8px;
}
.sidebar-user .avatar-circle { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }
.sidebar-user .name { font-size: .82rem; font-weight: 600; color: #fff; }
.sidebar-user .role { font-size: .7rem; color: #64748B; }

/* ================= MAIN / TOPBAR ================= */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--border-soft);
  padding: 14px 28px; display: flex; align-items: center; gap: 18px;
  position: sticky; top: 0; z-index: 20;
}
.search-box {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 9px;
  background: #F1F5F9; border-radius: 999px; padding: 9px 14px; color: var(--ink-500);
}
.search-box input { border: none; background: transparent; outline: none; font-size: .85rem; flex: 1; color: var(--ink-900); font-family: inherit; }
.search-box .kbd { font-size: .68rem; background: #fff; border: 1px solid var(--border-soft); border-radius: 5px; padding: 2px 6px; color: var(--ink-500); }

.topbar-integrations { display: flex; gap: 6px; }
.topbar-integrations a {
  display: flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 500;
  color: var(--ink-700); padding: 7px 12px; border-radius: 999px; transition: background .15s ease;
}
.topbar-integrations a:hover { background: #F1F5F9; }

.topbar-spacer { flex: 1; }

.topbar-bell { position: relative; font-size: 1.05rem; color: var(--ink-500); cursor: pointer; }
.topbar-bell .dot { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }

.topbar-avatars { display: flex; }
.topbar-avatars .avatar-circle { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; margin-left: -8px; }
.topbar-avatars .avatar-circle:first-child { margin-left: 0; }

.topbar-tagline { font-size: .75rem; color: var(--ink-500); text-align: right; max-width: 150px; line-height: 1.3; }

.avatar-circle {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--blue-500), var(--cyan-400));
}

/* ================= CONTENT ================= */
.content { padding: 30px 28px 60px; flex: 1; }

.content-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.content-header .eyebrow { font-size: .72rem; letter-spacing: .1em; font-weight: 700; color: var(--blue-600); margin-bottom: 6px; }
.content-header h1 { font-size: 1.9rem; margin: 0 0 6px; font-weight: 800; color: var(--ink-900); letter-spacing: -0.02em; }
.content-header p { margin: 0; color: var(--ink-500); font-size: .92rem; }
.content-header .decor { font-family: 'Inter', cursive; font-style: italic; color: var(--blue-400); font-size: .85rem; text-align: right; opacity: .8; line-height: 1.4; }

.filters-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px; font-size: .81rem; font-weight: 600;
  background: #fff; border: 1px solid var(--border-soft); color: var(--ink-700);
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.chip .count { opacity: .55; font-weight: 600; }
.chip.active { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }
.chip.active .count { opacity: .7; }
.chip .status-dot { width: 8px; height: 8px; border-radius: 50%; }
.chip[data-filter="on_track"] .status-dot { background: var(--green); }
.chip[data-filter="approaching"] .status-dot { background: var(--orange); }
.chip[data-filter="overdue"] .status-dot { background: var(--red); }
.filters-spacer { flex: 1; }
.sort-select {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-soft);
  background: #fff; font-size: .81rem; font-weight: 600; color: var(--ink-700); font-family: inherit;
}

/* ================= CARDS GRID ================= */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }

.client-card {
  background: var(--card-bg); border-radius: var(--radius-xl); padding: 18px;
  box-shadow: var(--shadow-card); border: 1px solid var(--border-soft);
  cursor: pointer; transition: transform .16s ease, box-shadow .16s ease;
  display: flex; flex-direction: column; gap: 12px;
}
.client-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }

.card-head { display: flex; align-items: flex-start; gap: 12px; }
.card-icon {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
}
.card-title-block { flex: 1; min-width: 0; }
.card-title-block h3 { margin: 0; font-size: .98rem; font-weight: 700; color: var(--ink-900); }
.card-title-block .stage-line { font-size: .78rem; color: var(--ink-500); margin-top: 2px; }
.card-title-block .time-line { font-size: .76rem; color: var(--ink-500); margin-top: 1px; }

.status-pill { flex-shrink: 0; font-size: .7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.status-pill .status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* dot-timeline (6 etapas fixas) */
.dot-timeline { display: flex; align-items: center; }
.dot-timeline .seg { display: flex; align-items: center; flex: 1; }
.dot-timeline .node {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: .68rem; font-weight: 700;
  background: #E2E8F0; color: #94A3B8; border: 2px solid #E2E8F0;
}
.dot-timeline .node.done { background: var(--blue-500); color: #fff; border-color: var(--blue-500); }
.dot-timeline .node.current { background: #fff; color: var(--blue-600); border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59,130,246,0.18); }
.dot-timeline .line { flex: 1; height: 2px; background: #E2E8F0; }
.dot-timeline .line.done { background: var(--blue-500); }

/* barra de progresso da Gestão Contínua (3 fases) */
.phase-progress-labels { display: flex; justify-content: space-between; font-size: .68rem; color: var(--ink-500); font-weight: 600; margin-bottom: 5px; }
.phase-progress-track { height: 6px; border-radius: 999px; background: #E2E8F0; overflow: hidden; }
.phase-progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue-500), var(--cyan-400)); }

.card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.avatar-stack { display: flex; align-items: center; }
.avatar-stack .avatar-circle { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; margin-left: -8px; font-size: .62rem; }
.avatar-stack .avatar-circle:first-child { margin-left: 0; }
.avatar-stack .plus { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; margin-left: -8px; background: #E2E8F0; color: var(--ink-500); font-size: .62rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.view-details-link { font-size: .8rem; font-weight: 700; color: var(--blue-600); white-space: nowrap; }

.upsell-hint {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; border-radius: var(--radius-md);
  background: var(--orange-soft); border: 1px solid rgba(245,158,11,0.25);
}
.upsell-hint .ic { font-size: 1rem; flex-shrink: 0; }
.upsell-hint .txt strong { display: block; font-size: .8rem; color: var(--orange-text); font-weight: 700; }
.upsell-hint .txt span { display: block; font-size: .73rem; color: var(--ink-500); margin-top: 1px; }
.upsell-hint .arrow { margin-left: auto; color: var(--orange-text); font-weight: 700; align-self: center; }

.empty-state { text-align: center; padding: 80px 20px; color: var(--ink-500); }

/* ================= DRAWER ================= */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.4);
  opacity: 0; pointer-events: none; transition: opacity .25s ease; z-index: 40;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(520px, 96vw);
  background: #fff; box-shadow: var(--shadow-drawer);
  transform: translateX(100%); transition: transform .3s cubic-bezier(.4,0,.2,1);
  z-index: 41; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-header { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--border-soft); }
.drawer-header .card-icon { width: 46px; height: 46px; font-size: 1.35rem; }
.drawer-header .title-block { flex: 1; min-width: 0; }
.drawer-header .title-block h2 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.drawer-header .title-block .sub { font-size: .8rem; color: var(--ink-500); margin-top: 1px; }
.drawer-header .drawer-actions { display: flex; align-items: center; gap: 10px; }
.drawer-close { font-size: 1.1rem; color: var(--ink-500); cursor: pointer; padding: 4px; line-height: 1; }
.drawer-close:hover { color: var(--ink-900); }

.drawer-tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--border-soft); }
.drawer-tabs .tab-btn {
  padding: 12px 6px; margin-right: 18px; font-size: .84rem; font-weight: 600; color: var(--ink-500);
  background: none; border: none; border-bottom: 2.5px solid transparent; cursor: pointer; margin-bottom: -1px;
}
.drawer-tabs .tab-btn.active { color: var(--blue-600); border-bottom-color: var(--blue-600); }

.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px 30px; }
.drawer-panel { display: none; flex-direction: column; gap: 18px; }
.drawer-panel.active { display: flex; }

.box { background: #F8FAFC; border: 1px solid var(--border-soft); border-radius: var(--radius-lg); padding: 18px 18px; }
.box-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.box-eyebrow { font-size: .68rem; font-weight: 700; letter-spacing: .07em; color: var(--ink-500); }
.box .day-badge { font-size: .74rem; font-weight: 700; color: var(--ink-500); }
.box h3.stage-name { margin: 4px 0 2px; font-size: 1.2rem; font-weight: 800; color: var(--ink-900); }
.box .stage-days { font-size: .8rem; color: var(--ink-500); margin: 0 0 16px; }

/* timeline horizontal no drawer */
.h-timeline { display: flex; align-items: flex-start; }
.h-timeline .h-node-wrap { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.h-timeline .h-line { flex: 1; height: 2px; background: #E2E8F0; margin-top: 15px; }
.h-timeline .h-line.done { background: var(--blue-500); }
.h-timeline .h-node {
  width: 30px; height: 30px; border-radius: 50%; background: #E2E8F0; color: #94A3B8;
  display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; border: 2px solid #E2E8F0;
}
.h-timeline .h-node.done { background: var(--blue-500); border-color: var(--blue-500); color: #fff; }
.h-timeline .h-node.current { background: #fff; border-color: var(--blue-500); color: var(--blue-600); box-shadow: 0 0 0 4px rgba(59,130,246,0.18); }
.h-timeline .h-label { margin-top: 8px; font-size: .68rem; font-weight: 700; color: var(--ink-700); text-align: center; white-space: nowrap; }
.h-timeline .h-sub { font-size: .64rem; color: var(--ink-500); text-align: center; }

.connected-pill { font-size: .68rem; font-weight: 700; color: var(--green-text); background: var(--green-soft); padding: 3px 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px; }

.events-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.event-row { display: flex; align-items: flex-start; gap: 9px; font-size: .82rem; }
.event-row .check { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .62rem; margin-top: 1px; }
.event-row .check.done { background: var(--green); color: #fff; }
.event-row .check.pending { border: 2px solid #CBD5E1; }
.event-row strong { color: var(--ink-900); font-weight: 700; }
.event-row .sep { color: var(--ink-500); margin: 0 3px; }
.event-row .detail { color: var(--ink-500); }
.event-row .date { color: var(--ink-500); }

.action-row { display: flex; gap: 10px; }
.action-row .btn { flex: 1; justify-content: center; }

.detail-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.info-list { display: flex; flex-direction: column; gap: 11px; }
.info-list .info-row { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.info-list .info-row .ic { color: var(--ink-500); width: 16px; text-align: center; }
.info-list .info-row .lbl { color: var(--ink-500); flex-shrink: 0; }
.info-list .info-row .val { color: var(--ink-900); font-weight: 600; margin-left: auto; text-align: right; }
.info-list .info-row.link .val { color: var(--blue-600); }
.quick-links-list { display: flex; flex-direction: column; gap: 12px; }
.quick-links-list a { display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 700; color: var(--blue-600); }

.footer-notice {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  background: #F1F5F9; border-radius: var(--radius-md); font-size: .78rem; color: var(--ink-500);
}
.footer-notice .ic { font-size: 1.1rem; flex-shrink: 0; }
.footer-notice .spacer { flex: 1; }

/* Vertical timeline (aba Histórico) */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-line { position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--border-soft); }
.timeline-item:last-child .timeline-line { display: none; }
.timeline-dot {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: #E2E8F0; color: #94A3B8; font-size: .7rem; font-weight: 700; z-index: 1;
}
.timeline-item.done .timeline-dot { background: var(--green); color: #fff; }
.timeline-item.current .timeline-dot { background: var(--blue-500); color: #fff; box-shadow: 0 0 0 4px rgba(59,130,246,0.18); }
.timeline-item.pending .timeline-content { opacity: .45; }
.timeline-content h4 { margin: 0 0 2px; font-size: .88rem; font-weight: 700; }
.timeline-content .date { font-size: .76rem; color: var(--ink-500); }

/* Notas */
.note-form textarea {
  width: 100%; min-height: 80px; border-radius: var(--radius-md); border: 1.5px solid var(--border-soft);
  padding: 11px 13px; font-family: inherit; font-size: .85rem; resize: vertical;
}
.note-form input[type=text] { width: 100%; padding: 9px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-soft); font-family: inherit; margin-bottom: 8px; font-size: .85rem; }
.note-item { padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.note-item:last-child { border-bottom: none; }
.note-item .note-meta { font-size: .72rem; color: var(--ink-500); margin-bottom: 3px; }
.note-item .note-text { font-size: .85rem; color: var(--ink-900); white-space: pre-wrap; }

/* Formulário (Integrações / Novo cliente) */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .76rem; font-weight: 700; color: var(--ink-700); }
.field input[type=text], .field input[type=date], .field select {
  padding: 9px 11px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-soft); font-family: inherit; font-size: .85rem;
}
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: .84rem; margin-bottom: 4px; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 11px; font-weight: 700; font-size: .85rem;
  border: none; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--blue-600), var(--blue-500)); color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,0.3); }
.btn-outline { background: #fff; border: 1.5px solid var(--border-soft); color: var(--ink-700); }
.btn-ghost { background: #F1F5F9; color: var(--ink-700); }
.btn-sm { padding: 8px 14px; font-size: .8rem; border-radius: 9px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--ink-900); color: #fff;
  padding: 12px 20px; border-radius: var(--radius-md); font-size: .85rem; box-shadow: var(--shadow-card-hover);
  opacity: 0; transform: translateY(10px); transition: all .25s ease; pointer-events: none; z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-app); }
.login-box { background: #fff; padding: 38px 34px; border-radius: var(--radius-xl); box-shadow: var(--shadow-card); width: 340px; }
.login-box .sidebar-logo { padding: 0 0 20px; }
.login-box input { width: 100%; padding: 11px 13px; margin-bottom: 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border-soft); font-family: inherit; font-size: .88rem; }
.login-box .btn { width: 100%; }
.error-msg { color: var(--red); font-size: .82rem; margin-bottom: 10px; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .content-header .decor { display: none; }
  .topbar-tagline { display: none; }
  .detail-cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .settings-grid { grid-template-columns: 1fr; }
  .action-row { flex-direction: column; }
}
