/* ============================================================
   Atlas CRM — visual SaaS moderno (claro, indigo)
   ============================================================ */
:root {
  --bg:        #f5f6fa;
  --surface:   #ffffff;
  --surface-2: #fbfbfe;
  --border:    #e6e8ef;
  --text:      #1e2334;
  --muted:     #6b7280;
  --muted-2:   #9aa1b0;
  --primary:   #6366f1;
  --primary-d: #4f46e5;
  --primary-soft:#eef0ff;
  --shadow:    0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --radius:    14px;
  --radius-sm: 10px;

  --slate-bg:#eef1f6; --slate-fg:#475569;
  --amber-bg:#fff4e0; --amber-fg:#b45309;
  --green-bg:#e6f7ee; --green-fg:#15803d;
  --red-bg:  #fdeaea; --red-fg:  #b91c1c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

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

.sidebar {
  width: 248px; flex-shrink: 0;
  background: linear-gradient(180deg, #1e1b3a 0%, #211c44 100%);
  color: #c9cce0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 22px 16px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 6px 16px rgba(99,102,241,.45);
}
.brand b { color: #fff; font-size: 16px; letter-spacing: -.02em; }
.brand span { display: block; font-size: 11px; color: #8a8fb5; font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: #b9bcd6; font-weight: 540; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(129,140,248,.18); color: #fff; }
.nav a.active svg { opacity: 1; }
.nav .sep { margin: 14px 12px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f74a0; }

.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.07); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.side-user .av { background: linear-gradient(135deg,#a5b4fc,#6366f1); }
.side-user small { display: block; color: #8a8fb5; font-size: 11.5px; }
.side-user b { color: #fff; font-size: 13px; font-weight: 600; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; }
.topbar .spacer { flex: 1; }
.content { padding: 26px 28px 48px; max-width: 1180px; width: 100%; }

/* ---------- Avatar ---------- */
.av {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg,#c7d2fe,#818cf8);
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
}
.av.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 15px; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: 1.3fr .9fr; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.stats { grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; }

/* ---------- Stat card ---------- */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat .lbl { color: var(--muted); font-size: 12.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; display:flex; align-items:center; gap:8px; }
.stat .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }
.stat .val { font-size: 27px; font-weight: 740; margin-top: 10px; letter-spacing: -.02em; }
.stat .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 640;
}
.badge.slate { background: var(--slate-bg); color: var(--slate-fg); }
.badge.amber { background: var(--amber-bg); color: var(--amber-fg); }
.badge.green { background: var(--green-bg); color: var(--green-fg); }
.badge.red   { background: var(--red-bg);   color: var(--red-fg); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 650; padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .cli { display: flex; align-items: center; gap: 11px; }
.table .cli b { font-weight: 600; }
.table .cli small { color: var(--muted); display: block; font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: all .15s; line-height: 1;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); border-color: #d6d9e4; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,.28); }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary-d); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-danger { color: var(--red-fg); }

/* ---------- Forms ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; color: var(--text); background: var(--surface); transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { resize: vertical; min-height: 90px; }
.row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 540; color: var(--text); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- Timeline / anotacoes ---------- */
.notes { display: flex; flex-direction: column; gap: 14px; }
.note {
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  padding: 14px 16px; position: relative;
}
.note.imp { border-color: #f4c97a; background: #fffdf6; box-shadow: inset 3px 0 0 #f59e0b; }
.note.pin { box-shadow: inset 3px 0 0 var(--primary); }
.note.pin.imp { box-shadow: inset 3px 0 0 var(--primary), inset 6px 0 0 #f59e0b; }
.note-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
  padding-bottom: 8px; border-bottom: 1px dashed var(--border);
}
.note-head .who { font-weight: 650; font-size: 13px; }
.note-head .when { color: var(--muted); font-size: 12px; }
.note-head .tags { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.note-body { white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px; color: #2b3043; }
.note-foot { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.note-foot .lock { color: var(--muted); font-size: 11.5px; display: inline-flex; align-items: center; gap: 5px; margin-left: auto; }
.chip { display:inline-flex; align-items:center; gap:5px; font-size:11px; font-weight:650; padding:2px 8px; border-radius:999px; }
.chip.pin { background: var(--primary-soft); color: var(--primary-d); }
.chip.imp { background: var(--amber-bg); color: var(--amber-fg); }
.chip.edit { background: var(--slate-bg); color: var(--slate-fg); }

/* ---------- Flash ---------- */
.flashes { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.flash {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow); font-weight: 540; min-width: 240px;
  animation: slidein .25s ease;
}
.flash.ok  { border-left-color: #15803d; }
.flash.err { border-left-color: #b91c1c; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 70% -10%, #2a2456 0%, #16142e 55%, #100f24 100%); padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4); padding: 36px 34px; }
.login-card .brand { justify-content: center; padding-bottom: 8px; }
.login-card h2 { text-align: center; font-size: 19px; margin-bottom: 4px; }
.login-card .lead { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 13.5px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; margin-top: 4px; }
.login-hint { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); }
.login-err { background: var(--red-bg); color: var(--red-fg); padding: 10px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 540; margin-bottom: 16px; text-align: center; }

/* ---------- Utils ---------- */
.muted { color: var(--muted); }
.right { text-align: right; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex.between { justify-content: space-between; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.page-head h2 { font-size: 21px; }
.page-head .spacer { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty svg { width: 40px; height: 40px; opacity: .4; margin-bottom: 10px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
.toolbar .search input { padding-left: 38px; }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.ver { font-size: 11px; color: var(--muted-2); padding: 12px 28px; }
.dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 13.5px; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .grid.cols-2, .grid.stats, .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .row, .row.three { grid-template-columns: 1fr; }
}
