/* Norte CRM — design system */
:root {
  --ink: #0E1525;
  --ink-2: #3A4356;
  --muted: #8A93A6;
  --bg: #F7F8FB;
  --card: #FFFFFF;
  --border: #E8ECF3;
  --accent: #2453FF;
  --accent-soft: #EDF1FF;
  --green: #0FA968;
  --green-soft: #E7F7F0;
  --amber: #E8A23D;
  --amber-soft: #FDF4E4;
  --red: #E5484D;
  --red-soft: #FDECEC;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(14,21,37,.05);
  --shadow-lg: 0 12px 40px rgba(14,21,37,.14);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }

/* ---------- login ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #FBFCFE 40%, #EDF1FF 100%); }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 48px; width: 400px; box-shadow: var(--shadow-lg); }
.login-logo { font-size: 30px; font-weight: 800; letter-spacing: -.04em; }
.login-logo span, .logo span { color: var(--accent); }
.login-sub { color: var(--muted); margin: 8px 0 32px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.login-card input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; outline: none; transition: border .15s; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error { background: var(--red-soft); color: var(--red); padding: 10px 14px; border-radius: 10px; margin-top: 16px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 24px; padding: 13px !important; font-size: 15px !important; }

/* ---------- shell ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 224px; background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.logo { font-size: 21px; font-weight: 800; letter-spacing: -.04em; padding: 24px 24px 28px; }
.sidebar nav { flex: 1; padding: 0 12px; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: var(--ink-2); font-weight: 500; margin-bottom: 2px; transition: all .12s; }
.sidebar nav a svg { width: 17px; height: 17px; fill: currentColor; opacity: .75; }
.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-info { font-size: 13px; font-weight: 600; line-height: 1.3; }
.user-info a { font-size: 11px; color: var(--muted); font-weight: 500; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 28px; background: var(--card); border-bottom: 1px solid var(--border); }
.company-tabs { display: flex; gap: 6px; }
.company-tab { padding: 8px 16px; border-radius: 100px; border: 1px solid var(--border); background: var(--card); font-weight: 600; font-size: 13px; color: var(--ink-2); transition: all .12s; display: flex; align-items: center; gap: 8px; }
.company-tab .dot { width: 8px; height: 8px; border-radius: 50%; }
.company-tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 13.5px; transition: all .12s; }
.btn-primary:hover { background: #1B41D8; }
.btn-ghost { background: var(--card); border: 1px solid var(--border); color: var(--ink-2); padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--red-soft); color: var(--red); border: none; padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; }
.btn-success { background: var(--green); color: #fff; border: none; padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; }

main#view { flex: 1; overflow: auto; padding: 28px; }

.page-title { font-size: 21px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.page-head .page-sub { margin-bottom: 0; }

/* ---------- dashboard ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; }
.kpi .delta { font-size: 12px; margin-top: 4px; color: var(--muted); }
.kpi.hero .value { color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 16px; }
.chart-wrap { position: relative; height: 260px; }

/* heatmap */
.heatmap { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 3px; font-size: 10px; color: var(--muted); }
.heatmap .hm-cell { aspect-ratio: 1; border-radius: 3px; background: var(--bg); }
.heatmap .hm-label { display: flex; align-items: center; font-weight: 600; }
.heatmap .hm-hour { text-align: center; }

/* ---------- kanban ---------- */
.kanban-wrap { height: 100%; display: flex; flex-direction: column; }
.kanban-filters { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; }
.kanban { display: flex; gap: 14px; overflow-x: auto; flex: 1; padding-bottom: 12px; align-items: flex-start; }
.kcol { min-width: 292px; width: 292px; background: #F1F3F8; border-radius: 14px; padding: 10px; flex-shrink: 0; max-height: 100%; display: flex; flex-direction: column; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 12px; }
.kcol-head .kname { font-weight: 700; font-size: 13.5px; }
.kcol-head .kmeta { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.kcol-cards { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; flex: 1; border-radius: 10px; }
.kcol-cards.dragover { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.kcard { background: var(--card); border: 1px solid var(--border); border-radius: 11px; padding: 13px 14px; cursor: grab; box-shadow: var(--shadow); transition: box-shadow .12s, transform .12s; }
.kcard:hover { box-shadow: 0 4px 14px rgba(14,21,37,.1); transform: translateY(-1px); }
.kcard.dragging { opacity: .45; }
.kcard .ktitle { font-weight: 600; font-size: 13.5px; line-height: 1.35; margin-bottom: 4px; }
.kcard .kcontact { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.kcard .kfoot { display: flex; align-items: center; justify-content: space-between; }
.kcard .kvalue { font-weight: 700; font-size: 13px; }
.kcard .kright { display: flex; align-items: center; gap: 7px; }
.kcard .avatar { width: 22px; height: 22px; font-size: 9.5px; }
.chip { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 100px; background: var(--accent-soft); color: var(--accent); }
.sla-dot { width: 8px; height: 8px; border-radius: 50%; }
.sla-ok { background: var(--green); } .sla-warn { background: var(--amber); } .sla-late { background: var(--red); }

/* ---------- drawer ---------- */
.drawer-overlay, .modal-overlay { position: fixed; inset: 0; background: rgba(14,21,37,.4); z-index: 40; backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; background: var(--card); z-index: 50; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slideIn .18s ease; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 24px 26px 18px; border-bottom: 1px solid var(--border); }
.drawer-head .d-title { font-size: 17px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 2px; }
.drawer-head .d-sub { color: var(--muted); font-size: 13px; }
.drawer-close { position: absolute; top: 18px; right: 20px; background: none; border: none; font-size: 22px; color: var(--muted); line-height: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 26px; }
.drawer-actions { display: flex; gap: 8px; padding: 16px 26px; border-top: 1px solid var(--border); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 22px; }
.field label { display: block; font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.field .fval { font-weight: 600; font-size: 13.5px; }
.field input, .field select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; outline: none; }
.timeline { margin-top: 6px; }
.timeline h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 12px; }
.tl-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item::before { content: ''; position: absolute; left: 5px; top: 18px; bottom: 0; width: 1.5px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent-soft); border: 2.5px solid var(--accent); flex-shrink: 0; margin-top: 3px; }
.tl-item.sys .tl-dot { border-color: var(--muted); background: var(--bg); }
.tl-content { flex: 1; }
.tl-content .tl-text { font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.tl-content .tl-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.note-box { display: flex; gap: 8px; margin-bottom: 20px; }
.note-box textarea { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; resize: none; height: 42px; outline: none; }
.note-box textarea:focus { border-color: var(--accent); }

/* ---------- modal ---------- */
.modal-overlay { display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal { background: var(--card); border-radius: 18px; width: 480px; max-width: 92vw; padding: 30px; box-shadow: var(--shadow-lg); max-height: 88vh; overflow-y: auto; }
.modal h2 { font-size: 18px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 20px; }
.modal .field { margin-bottom: 14px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; }

/* ---------- tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* funil de conversão */
.fbar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.fbar-label { width: 140px; font-size: 12.5px; font-weight: 600; text-align: right; color: var(--ink-2); }
.fbar-track { flex: 1; }
.fbar { height: 30px; background: linear-gradient(90deg, var(--accent), #5B7FFF); border-radius: 7px; display: flex; align-items: center; padding: 0 12px; color: #fff; font-weight: 700; font-size: 12.5px; min-width: 44px; transition: width .4s ease; }
.fbar-conv { width: 70px; font-size: 11.5px; color: var(--muted); font-weight: 600; }

/* filtros */
.filters { display: flex; gap: 10px; margin-bottom: 22px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input { padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); outline: none; font-weight: 500; }
.search-input { min-width: 260px; }

/* ---------- IA ---------- */
.ai-hero { background: linear-gradient(135deg, var(--ink) 0%, #1B2A4E 100%); border-radius: 18px; padding: 36px; color: #fff; margin-bottom: 20px; }
.ai-hero h2 { font-size: 22px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 6px; }
.ai-hero p { color: rgba(255,255,255,.65); margin-bottom: 22px; max-width: 560px; line-height: 1.5; }
.ai-hero .ai-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.ai-hero input { flex: 1; min-width: 280px; padding: 12px 16px; border-radius: 10px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff; outline: none; }
.ai-hero input::placeholder { color: rgba(255,255,255,.4); }
.ai-result { line-height: 1.65; font-size: 14.5px; }
.ai-result h1, .ai-result h2, .ai-result h3 { margin: 20px 0 10px; letter-spacing: -.02em; }
.ai-result h2 { font-size: 17px; } .ai-result h3 { font-size: 15px; }
.ai-result ul, .ai-result ol { padding-left: 22px; margin: 8px 0; }
.ai-result li { margin-bottom: 5px; }
.ai-result strong { color: var(--accent); }
.ai-result table { border-collapse: collapse; margin: 12px 0; }
.ai-result th, .ai-result td { border: 1px solid var(--border); padding: 7px 12px; font-size: 13px; }
.ai-loading { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 30px 0; justify-content: center; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* config */
.code-block { background: var(--ink); color: #A9C1FF; padding: 16px 18px; border-radius: 10px; font-family: 'SF Mono', Menlo, monospace; font-size: 12px; overflow-x: auto; white-space: pre; line-height: 1.6; margin-top: 10px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: 11px; font-weight: 700; }
.pill.on { background: var(--green-soft); color: var(--green); }
.pill.off { background: var(--red-soft); color: var(--red); }

/* drawer tabs */
.dtabs { display: flex; gap: 2px; padding: 0 26px; border-bottom: 1px solid var(--border); background: var(--card); }
.dtab { background: none; border: none; padding: 11px 14px; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.dtab.active { color: var(--accent); border-bottom-color: var(--accent); }
.dtab .cnt { background: var(--bg); border-radius: 100px; padding: 1px 7px; font-size: 10.5px; margin-left: 4px; color: var(--ink-2); }

/* temperatura */
.temp-group { display: flex; gap: 6px; }
.temp-btn { flex: 1; padding: 7px 0; border-radius: 8px; border: 1px solid var(--border); background: var(--card); font-weight: 600; font-size: 12px; color: var(--muted); }
.temp-btn.active[data-t="frio"] { background: #EDF4FD; color: #2176C7; border-color: #B9D9F5; }
.temp-btn.active[data-t="morno"] { background: var(--amber-soft); color: #B77B1E; border-color: #F2D9AC; }
.temp-btn.active[data-t="quente"] { background: var(--red-soft); color: var(--red); border-color: #F5BDBF; }

/* arquivos */
.file-drop { border: 1.5px dashed var(--border); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; transition: all .15s; margin-bottom: 14px; }
.file-drop:hover, .file-drop.dragover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.file-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.file-icon { width: 36px; height: 36px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; flex-shrink: 0; text-transform: uppercase; }
.file-info { flex: 1; min-width: 0; }
.file-info .fname { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info .fmeta { font-size: 11px; color: var(--muted); }
.file-actions { display: flex; gap: 4px; }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 15px; padding: 5px 7px; border-radius: 7px; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }

/* tarefas */
.task-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.task-item.overdue { border-color: #F5BDBF; background: #FFFAFA; }
.task-item.done-task { opacity: .5; }
.task-item.done-task .task-text { text-decoration: line-through; }
.task-check { width: 18px; height: 18px; accent-color: var(--green); margin-top: 1px; cursor: pointer; }
.task-text { font-size: 13px; font-weight: 500; flex: 1; }
.task-due { font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.task-item.overdue .task-due { color: var(--red); }
.task-add { display: flex; gap: 8px; margin-bottom: 14px; }
.task-add input[type=text] { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; outline: none; }
.task-add input[type=date] { padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; outline: none; }

.field textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; outline: none; resize: vertical; min-height: 64px; font-size: 13px; }
.link-row { color: var(--accent); font-weight: 600; font-size: 12.5px; cursor: pointer; }
.tag-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 100px; background: var(--bg); color: var(--ink-2); border: 1px solid var(--border); margin: 0 4px 4px 0; }
.tbl tr.clickable { cursor: pointer; }

/* radios (modal de perda etc) */
label.radio-row, .field label.radio-row { display: flex; align-items: center; justify-content: flex-start; gap: 10px; text-align: left;
  font-size: 13.5px; font-weight: 500; color: var(--ink); text-transform: none; letter-spacing: 0;
  margin: 8px 0; cursor: pointer; padding: 10px 13px; border: 1px solid var(--border); border-radius: 10px; transition: all .12s; }
label.radio-row:hover { border-color: var(--accent); background: var(--accent-soft); }
label.radio-row input { accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; margin: 0; }

/* toast */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 100px; font-weight: 600; font-size: 13.5px; z-index: 100; box-shadow: var(--shadow-lg); animation: slideUp .2s ease; }
@keyframes slideUp { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #D3D9E4; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
