/* ===================== Tema ===================== */
:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --surface-3: #eef0f3;
  --border: #e2e4e9;
  --border-strong: #cdd0d6;
  --text: #15171c;
  --text-2: #4f525a;
  --muted: #868993;
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-ink: #ffffff;
  --accent-soft: #e7f0fc;
  --series-1: #2a78d6;
  --grid: #e8e9ec;
  --good: #0ca30c;
  --good-text: #067306;
  --good-soft: #e5f6e5;
  --warn: #fab219;
  --warn-text: #8a5a00;
  --warn-soft: #fff4d9;
  --crit: #d03b3b;
  --crit-text: #b42c2c;
  --crit-soft: #fdecec;
  --info-soft: #e7f0fc;
  --sidebar: #1d2230;
  --sidebar-text: #b9bdca;
  --sidebar-hover: #283043;
  --sidebar-active: #313a52;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .2);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #181a20;
    --surface-2: #1e2128;
    --surface-3: #262a33;
    --border: #2c3039;
    --border-strong: #3a3f4a;
    --text: #f3f4f6;
    --text-2: #c3c6cf;
    --muted: #8e929c;
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-soft: #1b2b42;
    --series-1: #3987e5;
    --grid: #2a2d35;
    --good-text: #3fc23f;
    --good-soft: #142a16;
    --warn-text: #f5c04f;
    --warn-soft: #2d2410;
    --crit-text: #f07a7a;
    --crit-soft: #331819;
    --info-soft: #1b2b42;
    --sidebar: #12151c;
    --sidebar-hover: #1d2230;
    --sidebar-active: #262d40;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115; --surface: #181a20; --surface-2: #1e2128; --surface-3: #262a33;
  --border: #2c3039; --border-strong: #3a3f4a; --text: #f3f4f6; --text-2: #c3c6cf; --muted: #8e929c;
  --accent: #3987e5; --accent-hover: #5598e7; --accent-soft: #1b2b42; --series-1: #3987e5; --grid: #2a2d35;
  --good-text: #3fc23f; --good-soft: #142a16; --warn-text: #f5c04f; --warn-soft: #2d2410;
  --crit-text: #f07a7a; --crit-soft: #331819; --info-soft: #1b2b42;
  --sidebar: #12151c; --sidebar-hover: #1d2230; --sidebar-active: #262d40;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
}

/* ===================== Base ===================== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

input:not([type="checkbox"]):not([type="color"]), select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  outline: none;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
input[type="color"] { width: 34px; height: 34px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 500;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--crit-text); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .ic { width: 15px; height: 15px; }

/* ===================== Layout ===================== */
.app { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: 210px; flex: none;
  display: flex; flex-direction: column;
  background: var(--sidebar); color: var(--sidebar-text);
  padding: 16px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; font-weight: 700; font-size: 16px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent); }
.brand-mark .ic { width: 17px; height: 17px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 0; border-radius: 8px;
  background: transparent; color: inherit; text-align: left;
  font-weight: 500;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-label { flex: 1; }
.nav-badge { min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--crit); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.sync-status { margin-top: auto; padding: 10px 8px 0; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.sync-dot.ok { background: var(--good); }
.sync-dot.saving { background: var(--warn); }
.sync-dot.error { background: var(--crit); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 650; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.view { flex: 1; min-height: 0; overflow: auto; padding: 20px 24px 32px; }
.view.board-view { display: flex; flex-direction: column; padding-bottom: 12px; }

.badge { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--crit); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; }

/* Notificações */
.bell-wrap { position: relative; }
.dropdown {
  position: absolute; right: 0; top: 44px; z-index: 40;
  width: 340px; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.dropdown-head { padding: 12px 14px; font-weight: 600; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dropdown-empty { padding: 22px 14px; color: var(--muted); text-align: center; }
.dropdown-foot { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.notif-item { display: block; width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; }
.notif-item:hover { background: var(--surface-2); }
.notif-item:last-child { border-bottom: 0; }
.notif-title { font-weight: 500; }
.notif-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===================== Funil (kanban) ===================== */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.toolbar select { width: auto; min-width: 150px; }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-left: 34px !important; }
.empty-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 14px 16px; margin-bottom: 14px;
  background: var(--accent-soft); border-radius: var(--radius);
}
.empty-banner p { margin: 0; flex: 1 1 260px; }

.board { flex: 1; min-height: 0; display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: stretch; }
.col {
  flex: 0 0 280px;
  display: flex; flex-direction: column;
  background: var(--surface-3);
  border-radius: var(--radius);
  min-height: 0;
}
.col-head { padding: 12px 12px 10px; border-top: 4px solid var(--c); border-radius: var(--radius) var(--radius) 0 0; }
.col-title { display: flex; align-items: center; gap: 6px; font-weight: 650; text-transform: uppercase; font-size: 12.5px; letter-spacing: .03em; }
.col-type { font-size: 10.5px; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 1px 6px; border-radius: 8px; background: var(--surface); color: var(--text-2); }
.col-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.col-body { flex: 1; overflow-y: auto; padding: 2px 8px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; border-radius: 0 0 var(--radius) var(--radius); }
.col-body.drop-over { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -4px; }
.col-add { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border: 1px dashed var(--border-strong); border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; }
.col-add:hover { color: var(--accent); border-color: var(--accent); background: var(--surface); }
.col-add .ic { width: 15px; height: 15px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--c);
  border-radius: 8px;
  padding: 10px 11px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
}
.card:hover { border-color: var(--border-strong); border-left-color: var(--c); }
.card.dragging { opacity: .45; }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card-name { font-weight: 600; overflow-wrap: anywhere; }
.card-value { font-weight: 600; color: var(--good-text); white-space: nowrap; font-size: 13px; }
.card-contact { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 10px;
  font-size: 11.5px; font-weight: 500;
  background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
}
.pill .ic { width: 12px; height: 12px; }
.pill.src { background: var(--accent-soft); color: var(--accent); }
.pill.tag { background: transparent; border: 1px solid var(--border-strong); }
.pill.crit { background: var(--crit-soft); color: var(--crit-text); }
.pill.warn { background: var(--warn-soft); color: var(--warn-text); }
.pill.good { background: var(--good-soft); color: var(--good-text); }
.pill.conv-andamento { background: var(--info-soft); color: var(--accent); }
.pill.conv-aguardando { background: var(--warn-soft); color: var(--warn-text); }
.pill.conv-respondida { background: var(--good-soft); color: var(--good-text); }
.card-task { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); padding-top: 6px; border-top: 1px solid var(--border); }
.card-task span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-task .ic { width: 13px; height: 13px; }
.card-task.is-overdue { color: var(--crit-text); font-weight: 500; }
.card-task.is-today { color: var(--accent); font-weight: 500; }
.card-task.is-none { color: var(--warn-text); }

/* ===================== Drawer do lead ===================== */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop, .modal-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 18, .45); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(620px, 100%);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideIn .18s ease-out;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 16px 18px 4px; }
.lead-name-input { font-size: 20px !important; font-weight: 650; border-color: transparent !important; padding: 6px 8px !important; margin-left: -8px; }
.lead-name-input:hover { border-color: var(--border) !important; }
.lead-name-input:focus { border-color: var(--accent) !important; }
.drawer-meta { padding: 0 18px 10px; color: var(--text-2); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.drawer-meta strong { color: var(--good-text); font-size: 15px; }
.stage-track { display: flex; gap: 4px; padding: 0 18px 12px; overflow-x: auto; }
.stage-step {
  flex: 1 0 auto;
  padding: 7px 10px;
  border: 0; border-radius: 6px;
  background: var(--surface-3); color: var(--text-2);
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.stage-step:hover { background: var(--border); }
.stage-step.passed { border-bottom-color: var(--c); }
.stage-step.current { background: var(--c); color: #fff; }
.tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: 10px 12px;
  border: 0; border-bottom: 2px solid transparent;
  background: transparent; color: var(--text-2); font-weight: 500;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { font-size: 11px; padding: 0 6px; border-radius: 8px; background: var(--surface-3); margin-left: 4px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .field > .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input-row { display: flex; gap: 6px; }
.input-row .icon-btn { flex: none; width: 38px; height: 38px; border: 1px solid var(--border-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong); border-radius: 18px;
  background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 500;
}
.chip .ic { width: 14px; height: 14px; }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tags-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--border-strong); border-radius: 8px; }
.tags-edit input { border: 0 !important; box-shadow: none !important; flex: 1 1 140px; width: auto; padding: 4px 6px !important; }
.tag-chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 9px; border-radius: 14px; background: var(--surface-3); font-size: 12.5px; }
.tag-chip button { border: 0; background: transparent; padding: 0 3px; color: var(--muted); display: grid; place-items: center; }
.tag-chip button .ic { width: 13px; height: 13px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; }

/* Serviços */
.svc-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.svc-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--border); }
.svc-table td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.svc-table input { padding: 6px 8px !important; }
.svc-table .w-price { width: 120px; }
.svc-table .w-qty { width: 70px; }
.svc-add { display: flex; gap: 8px; margin-bottom: 10px; }
.svc-add select { flex: 1; }
details.svc-new { margin-bottom: 18px; }
details.svc-new summary { cursor: pointer; color: var(--accent); font-weight: 500; font-size: 13px; }
.svc-new-row { display: flex; gap: 8px; margin-top: 8px; }
.svc-new-row input:first-child { flex: 2; }
.svc-new-row input:nth-child(2) { flex: 1; }
.totals { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 6px; }
.totals-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.totals-row.total { font-size: 17px; font-weight: 700; padding-top: 8px; border-top: 1px solid var(--border); }
.totals-row.total span:last-child { color: var(--good-text); }
.disc-input { display: flex; align-items: center; gap: 6px; }
.disc-input input { width: 80px !important; }

/* Tarefas (linhas) */
.quick-task { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; }
.quick-task .full { grid-column: 1 / -1; }
.quick-task .row { display: flex; gap: 8px; }
.quick-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-presets .chip { padding: 4px 10px; font-size: 12px; }
.task-list { display: flex; flex-direction: column; }
.task-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: 0; }
.check {
  flex: none; width: 20px; height: 20px; margin-top: 1px;
  display: grid; place-items: center;
  border: 2px solid var(--border-strong); border-radius: 6px;
  background: var(--surface); padding: 0; color: #fff;
}
.check:hover { border-color: var(--good); }
.check.on { background: var(--good); border-color: var(--good); }
.check .ic { width: 13px; height: 13px; stroke-width: 3; }
.task-main { flex: 1; min-width: 0; cursor: pointer; }
.task-title { font-weight: 500; overflow-wrap: anywhere; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-meta { font-size: 12.5px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 2px; }
.task-row.overdue .task-when { color: var(--crit-text); font-weight: 600; }
.task-lead { color: var(--accent); cursor: pointer; }
.task-lead:hover { text-decoration: underline; }

/* Histórico */
.note-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.note-form .btn { align-self: flex-end; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--border); margin-left: 5px; }
.tl-item::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.tl-item.note::before { background: var(--accent); }
.tl-when { font-size: 12px; color: var(--muted); }
.tl-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-item.note .tl-text { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-top: 3px; }

/* ===================== Modal ===================== */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal-card {
  position: relative;
  width: min(480px, 100%);
  max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.modal-card h2 { margin: 0; font-size: 18px; }
.modal-card p { margin: 0; color: var(--text-2); }
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 4px; }
.modal-foot .spacer { flex: 1; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice-list .btn { justify-content: flex-start; padding: 12px 14px; white-space: normal; text-align: left; }

/* ===================== Toasts & tooltip ===================== */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  max-width: 360px;
  padding: 10px 14px;
  background: #1d2230; color: #fff;
  border-radius: 10px; box-shadow: var(--shadow-lg);
  display: flex; gap: 8px; align-items: flex-start;
  animation: pop .18s ease-out;
}
.toast.error { background: #8f2020; }
.toast.warn { background: #6b4a00; }
.toast.good { background: #0b5e0b; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.tip {
  position: fixed; z-index: 90; pointer-events: none;
  padding: 6px 10px; border-radius: 8px;
  background: #1d2230; color: #fff; font-size: 12.5px;
  box-shadow: var(--shadow-lg); max-width: 260px;
}

/* ===================== Tarefas (calendário) ===================== */
.tasks-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.panel-body { padding: 8px 14px 12px; }
.panel + .panel { margin-top: 14px; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-month { font-weight: 650; font-size: 16px; min-width: 150px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 8px 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; text-align: center; border-bottom: 1px solid var(--border); }
.cal-cell {
  min-height: 96px; padding: 5px;
  border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--surface); text-align: left;
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.out { background: var(--surface-2); }
.cal-cell.out .cal-num { color: var(--muted); }
.cal-cell.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { font-size: 12.5px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-cell.today .cal-num { background: var(--accent); color: #fff; }
.cal-chip { display: block; font-size: 11px; padding: 2px 5px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.overdue { background: var(--crit-soft); color: var(--crit-text); }
.cal-chip.done { background: var(--surface-3); color: var(--muted); text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 4px; }
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal-dot.overdue { background: var(--crit); }
.cal-dot.done { background: var(--border-strong); }
.summary-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.summary-pills .pill { font-size: 13px; padding: 5px 11px; }
.check-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.side-section h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 0 2px; display: flex; align-items: center; gap: 6px; }
.side-section h3 .pill { text-transform: none; letter-spacing: 0; }
.empty-line { color: var(--muted); font-size: 13px; padding: 6px 0; }

/* ===================== Painel ===================== */
.dash-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.dash-filters select { width: auto; }
.dash-section { margin-bottom: 26px; }
.dash-section > h2 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile-label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.tile-label .ic { width: 15px; height: 15px; }
.tile-value { font-size: 26px; font-weight: 700; margin-top: 4px; line-height: 1.15; overflow-wrap: anywhere; }
.tile-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.tile.crit .tile-value { color: var(--crit-text); }
.tile.warn .tile-value { color: var(--warn-text); }
.tile.good .tile-value { color: var(--good-text); }
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { border-color: var(--accent); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.chart-card h3 { margin: 0 0 2px; font-size: 14.5px; font-weight: 650; }
.chart-card .chart-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 130px) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 2px 0; border-radius: 6px; }
.bar-row:hover { background: var(--surface-2); }
.bar-label { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; height: 18px; border-left: 1px solid var(--border-strong); }
.bar-fill { position: absolute; left: 0; top: 2px; bottom: 2px; background: var(--bar, var(--series-1)); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-val { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.bar-val small { font-weight: 400; color: var(--muted); }
.chart-empty { color: var(--muted); font-size: 13px; padding: 14px 0; }
.lead-list { display: flex; flex-direction: column; }
.lead-list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.lead-list-row:last-child { border-bottom: 0; }
.lead-list-row .who { min-width: 0; }
.lead-list-row .who a { font-weight: 500; cursor: pointer; }
.lead-list-row .who div { font-size: 12px; color: var(--muted); }

/* ===================== Ajustes ===================== */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; align-items: start; max-width: 1200px; }
.settings .panel-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.stage-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 110px auto; gap: 6px; align-items: center; }
.stage-row .row-actions { display: flex; }
.cat-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 6px; align-items: center; }
.list-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.add-row { display: flex; gap: 6px; }
.add-row input { flex: 1; }
.settings h4 { margin: 6px 0 0; font-size: 13px; color: var(--text-2); }
.settings code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* ===================== Responsivo ===================== */
@media (max-width: 1000px) {
  .tasks-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { flex-direction: column-reverse; }
  .sidebar { width: 100%; flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); }
  .brand, .sync-status { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 11px; position: relative; }
  .nav-badge { position: absolute; top: 2px; right: 6px; min-width: 16px; font-size: 10px; padding: 0 4px; }
  .topbar { padding: 10px 16px; }
  .topbar h1 { font-size: 17px; }
  .view { padding: 14px 16px 24px; }
  .hide-sm { display: none; }
  .btn.primary { padding: 8px 10px; }
  .toolbar select { flex: 1 1 140px; min-width: 0; }
  .search { max-width: none; flex-basis: 100%; }
  .col { flex-basis: 84vw; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-row { grid-template-columns: 1fr; }
  .cal-cell { min-height: 54px; }
  .cal-chip, .cal-more { display: none; }
  .cal-dots { display: flex; }
  .settings { grid-template-columns: 1fr; }
  .stage-row { grid-template-columns: 34px minmax(0, 1fr) 96px; }
  .stage-row .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .dropdown { position: fixed; left: 12px; right: 12px; top: 56px; width: auto; }
  .toasts { left: 12px; right: 12px; bottom: 76px; align-items: stretch; }
  .bar-row { grid-template-columns: minmax(70px, 100px) minmax(0, 1fr) auto; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px; }
  .tile-value { font-size: 21px; }
  .charts { grid-template-columns: 1fr; }
  .svc-table .w-price { width: 92px; }
  .svc-table .w-qty { width: 56px; }
}
