*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surfaces */
  --bg: #F4F0FA;
  --bg-deep: #EDE7F6;
  --card: #FFFFFF;
  --card-hover: #FBFAFE;
  --subtle: #F8F6FC;
  --border: rgba(20, 16, 31, 0.07);
  --border-strong: rgba(20, 16, 31, 0.14);

  /* Text */
  --text: #15101F;
  --text-secondary: #6B6577;
  --text-tertiary: #9C95AD;

  /* Accent */
  --accent: #6E5BC9;
  --accent-soft: #E8E2FA;
  --accent-deep: #5443A3;

  /* Priorities */
  --high-bg: #FFE0EC;
  --high-fg: #B8395E;
  --high-dot: #E27A99;
  --med-bg:  #E8E2FA;
  --med-fg:  #5443A3;
  --med-dot: #8B7DD0;
  --low-bg:  #DCEFE0;
  --low-fg:  #2D7A4D;
  --low-dot: #6FBC8A;

  /* States */
  --state-todo: #9C95AD;
  --state-progress: #6E5BC9;
  --state-review: #C99A3A;
  --state-done: #6FBC8A;

  /* Effects */
  --radius: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 16, 31, 0.04);
  --shadow:    0 2px 6px rgba(20, 16, 31, 0.04), 0 1px 2px rgba(20, 16, 31, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(85, 67, 163, 0.10), 0 4px 8px -4px rgba(20, 16, 31, 0.04);
  --shadow-lg: 0 20px 50px -10px rgba(85, 67, 163, 0.18), 0 8px 16px -8px rgba(20, 16, 31, 0.06);
}

html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--accent-soft); }

.app { display: flex; height: 100dvh; overflow: hidden; }

/* ============== SIDEBAR ============================== */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--border);
  position: fixed;
  height: 100dvh;
  left: 0; top: 0;
  display: flex; flex-direction: column;
  padding: calc(22px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }

/* Project switcher (replaces .brand) */
.project-switcher {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  text-align: left;
  margin-bottom: 18px;
  width: 100%;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: inherit;
}
.project-switcher:hover { background: var(--subtle); border-color: var(--border); }
.project-switcher .brand-text { flex: 1; min-width: 0; }
.project-switcher .brand-name {
  font-size: 13.5px; font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-switcher .brand-sub { font-size: 10.5px; color: var(--text-secondary); font-weight: 500; }
.project-switcher .proj-chev { width: 14px; height: 14px; color: var(--text-tertiary); flex-shrink: 0; }
.project-switcher:hover .proj-chev { color: var(--text-secondary); }

.project-menu {
  position: absolute;
  top: 70px; left: 14px;
  width: 220px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  padding: 6px;
}
.project-menu[hidden] { display: none; }
.project-menu-head {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary); font-weight: 600;
  padding: 6px 10px 4px;
}
.project-menu-list { display: flex; flex-direction: column; gap: 1px; margin-bottom: 4px; max-height: 240px; overflow-y: auto; }
.project-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  border: none; background: transparent;
  font: inherit; font-size: 13px; color: var(--text);
  width: 100%; text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}
.project-menu-item:hover { background: var(--subtle); }
.project-menu-item.active { background: var(--accent-soft); font-weight: 600; color: var(--accent-deep); }
.project-menu-item .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-menu-item .pcount { font-size: 11px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.project-menu-item.active .pcount { color: var(--accent); }
.project-menu-item .pcheck { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; }

.project-menu-foot {
  border-top: 1px solid var(--border);
  padding-top: 4px;
  display: flex; flex-direction: column; gap: 1px;
}
.project-menu-foot button {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  border: none; background: transparent;
  font: inherit; font-size: 13px; color: var(--accent-deep);
  width: 100%; text-align: left;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s ease;
}
.project-menu-foot button:hover { background: var(--accent-soft); }
.project-menu-foot button i { width: 13px; height: 13px; }

/* Undo/Redo */
#undo-btn:disabled, #redo-btn:disabled { opacity: 0.35; cursor: not-allowed; }
#undo-btn:not(:disabled):hover, #redo-btn:not(:disabled):hover { background: var(--accent-soft); border-color: var(--accent); }
#undo-btn:not(:disabled):hover i, #redo-btn:not(:disabled):hover i { color: var(--accent-deep); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent) 0%, #8B7DD0 100%);
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 17px;
  box-shadow: 0 6px 14px -4px rgba(110, 91, 201, 0.45);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.015em; }
.brand-sub { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

.search-mini {
  position: relative;
  margin-bottom: 18px;
}
.search-mini input {
  width: 100%;
  padding: 8px 56px 8px 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--subtle);
  font-size: 12.5px;
  outline: none;
  transition: all 0.15s ease;
}
.search-mini input::placeholder { color: var(--text-tertiary); }
.search-mini input:focus { border-color: var(--accent); background: white; box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.12); }
.search-mini i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-tertiary); pointer-events: none; }
.search-mini kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: inherit; font-size: 10px; font-weight: 500;
  padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--border); color: var(--text-tertiary);
  background: white;
}
.search-mini .search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px;
  border: none; background: var(--border-strong);
  color: white;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.12s ease;
}
.search-mini .search-clear:hover { background: var(--text-secondary); }
.search-mini .search-clear i { width: 11px; height: 11px; color: white; position: static; transform: none; pointer-events: none; }
.search-mini.has-query input { padding-right: 36px; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; padding-right: 2px; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.nav-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); margin: 14px 12px 6px; font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: 9px;
  color: var(--text-secondary); font-weight: 500; font-size: 13px;
  cursor: pointer; transition: all 0.12s ease;
  position: relative;
}
.nav-item:hover { background: var(--subtle); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.nav-item.active i { color: var(--accent); }
.nav-item i { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; }
.nav-item.active i { color: var(--accent); }
.nav-item span:not(.nav-count):not(.dot-badge):not(.nav-badge) { flex: 1; }
.nav-count {
  font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  background: var(--bg-deep); padding: 2px 7px; border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-count { background: white; color: var(--accent); }
.dot-badge { width: 6px; height: 6px; border-radius: 50%; background: var(--high-dot); }

.bloco-list { display: flex; flex-direction: column; gap: 1px; }
.bloco-item {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 12px; border-radius: 9px;
  color: var(--text-secondary); font-weight: 500; font-size: 13px;
  cursor: pointer; transition: all 0.12s ease;
}
.bloco-item:hover { background: var(--subtle); color: var(--text); }
.bloco-item.active { background: var(--subtle); color: var(--text); font-weight: 600; }
.bloco-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.bloco-item span:first-of-type { flex: 1; }
.bloco-count { font-size: 11px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}
.user-meta { flex: 1; min-width: 0; line-height: 1.15; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11.5px; color: var(--text-secondary); }

/* Avatars ---------------------------------------------------- */
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  color: white; font-weight: 600; font-size: 11px;
  flex-shrink: 0;
  background: var(--accent);
}
.avatar.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

/* ============== MAIN / TOPBAR ======================== */
.main { flex: 1; margin-left: 248px; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.topbar {
  height: calc(64px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding-left: 24px;
  padding-right: 24px;
}

.bcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.bcrumb-item.active { color: var(--text); font-weight: 600; }
.bcrumb i { width: 12px; height: 12px; opacity: 0.5; }
.bcrumb-project {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text);
  background: transparent; border: 1px solid transparent;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.12s ease;
  max-width: 280px;
}
.bcrumb-project:hover { background: var(--subtle); border-color: var(--border); }
.bcrumb-project span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 240px;
}
.bcrumb-chev { width: 13px; height: 13px; opacity: 0.6; flex-shrink: 0; }

.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.view-toggle {
  display: flex; gap: 2px; padding: 3px;
  background: var(--subtle); border: 1px solid var(--border);
  border-radius: 10px;
}
.view-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 7px;
  border: none; background: transparent;
  font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
  transition: all 0.15s ease;
}
.view-btn:hover { color: var(--text); }
.view-btn.active { background: white; color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.view-btn i { width: 13px; height: 13px; }

.topbar-divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px; border: 1px solid transparent;
  background: transparent;
  transition: all 0.15s ease;
}
.icon-btn:hover { background: var(--subtle); border-color: var(--border); }
.icon-btn i { width: 16px; height: 16px; color: var(--text-secondary); }
.icon-btn.ghost { border: none; background: transparent; }
.icon-btn.ghost:hover { background: var(--subtle); }

/* Buttons --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: white;
  font-size: 13px; font-weight: 500; color: var(--text);
  transition: all 0.15s ease;
}
.btn:hover { background: var(--subtle); }
.btn i { width: 14px; height: 14px; }
.btn.btn-primary {
  background: var(--accent); color: white; border-color: var(--accent);
  box-shadow: 0 4px 12px -4px rgba(110, 91, 201, 0.45);
}
.btn.btn-primary:hover { background: var(--accent-deep); }
.btn.ghost { border-color: transparent; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--subtle); color: var(--text); border-color: var(--border); }

/* ============== CONTENT LAYOUT ======================= */
/* Tasks area takes the full width — the detail panel is a slide-in
   drawer at all widths, not a permanent split. */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

/* ============== TASKS AREA ============================ */
.tasks-area { flex: 1; min-height: 0; padding: 28px 28px 48px; overflow-y: auto; }

.tasks-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.tasks-title { font-size: 24px; font-weight: 700; letter-spacing: -0.025em; }
.tasks-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: white;
  font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--text); color: white; border-color: var(--text); }
.chip.ghost { border: none; background: transparent; }
.chip.ghost:hover { background: var(--subtle); border: 1px solid var(--border); }
.chip i { width: 13px; height: 13px; }
.filters-spacer { flex: 1; }

/* Project filter dropdown chip */
.chip-dropdown { position: relative; display: inline-block; }
.chip-dropdown .chip { cursor: pointer; }
.chip-dropdown .chip-chev { width: 13px; height: 13px; opacity: 0.7; }
.chip-dropdown .dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 220px; max-width: 320px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 6px;
  z-index: 100;
  max-height: 320px; overflow-y: auto;
}
.chip-dropdown .dropdown-item {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 8px; border: none; background: transparent;
  text-align: left; font-size: 13px; color: var(--text); cursor: pointer;
  transition: background 0.12s ease;
}
.chip-dropdown .dropdown-item:hover { background: var(--subtle); }
.chip-dropdown .dropdown-item.active { background: var(--subtle); font-weight: 600; }
.chip-dropdown .dropdown-count {
  font-size: 11px; color: var(--text-tertiary); font-weight: 500;
  padding: 1px 7px; border-radius: 999px; background: var(--subtle);
}
.chip-dropdown .dropdown-item.active .dropdown-count { background: white; }

/* Empty state when filters yield 0 tasks */
.filters-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: white;
  color: var(--text-secondary);
  text-align: center;
}
.filters-empty i { width: 28px; height: 28px; color: var(--text-tertiary); }
.filters-empty-title { font-size: 15px; font-weight: 600; color: var(--text); }
.filters-empty-sub { font-size: 13px; color: var(--text-secondary); max-width: 380px; }
.filters-empty .btn { margin-top: 4px; }

/* Task sections + cards ------------------------------------ */
.tasks-list { display: flex; flex-direction: column; gap: 28px; }

.section { display: flex; flex-direction: column; gap: 8px; }
.section-head {
  display: flex; align-items: center; gap: 10px;
  padding: 0 4px 6px;
}
.section-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.section-dot.todo { background: var(--state-todo); }
.section-dot.progress { background: var(--state-progress); }
.section-dot.review { background: var(--state-review); }
.section-dot.done { background: var(--state-done); }
.section-title { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }
.section-count {
  font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  background: var(--bg-deep); padding: 2px 8px; border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.section-spacer { flex: 1; }
.section-add {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 6px;
  background: transparent; border: none;
  color: var(--text-tertiary); font-size: 12px; font-weight: 500;
  transition: all 0.15s ease;
}
.section-add:hover { background: var(--subtle); color: var(--text); }
.section-add i { width: 12px; height: 12px; }

.task-card {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.task-card:hover { background: var(--card-hover); border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.task-card.selected { border-color: var(--accent); background: white; box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10), var(--shadow-sm); }

.task-priority-dot { width: 10px; height: 10px; border-radius: 50%; }

.task-body { min-width: 0; }
.task-title-line {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.task-title-text {
  font-size: 13.5px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.task-card.archived .task-title-text { color: var(--text-secondary); text-decoration: line-through; }
.task-meta-line {
  display: flex; align-items: center; gap: 12px;
  font-size: 11.5px; color: var(--text-tertiary);
  flex-wrap: wrap;
}
.task-meta-item { display: inline-flex; align-items: center; gap: 4px; }
.task-meta-item i { width: 11px; height: 11px; }

.bloco-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 6px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.02em;
}
.bloco-pill .bloco-pill-dot { width: 6px; height: 6px; border-radius: 50%; }

.task-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.priority-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.02em;
}
.priority-pill .priority-dot { width: 6px; height: 6px; border-radius: 50%; }
.priority-pill.high {   background: var(--high-bg); color: var(--high-fg); }
.priority-pill.medium { background: var(--med-bg);  color: var(--med-fg);  }
.priority-pill.low {    background: var(--low-bg);  color: var(--low-fg);  }
.priority-pill.high   .priority-dot { background: var(--high-dot); }
.priority-pill.medium .priority-dot { background: var(--med-dot);  }
.priority-pill.low    .priority-dot { background: var(--low-dot);  }

/* ============== DETAIL PANEL ========================= */
/* Always a slide-in drawer from the right, at every breakpoint. The
   list underneath stays interactive but is dimmed by .detail-backdrop. */
.detail-panel {
  background: white;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0;
  top: calc(64px + env(safe-area-inset-top));
  bottom: 0;
  width: 100%;
  max-width: 540px;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 60;
}
.detail-panel.open { transform: translateX(0); }

.detail-backdrop {
  position: fixed;
  inset: calc(64px + env(safe-area-inset-top)) 0 0 0;
  background: rgba(15, 18, 32, 0.32);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.detail-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.detail-empty {
  flex: 1;
  display: grid; place-items: center;
  padding: 32px;
  text-align: center;
  color: var(--text-secondary);
}
.detail-empty i { width: 32px; height: 32px; opacity: 0.3; margin-bottom: 12px; }

.detail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  padding-top: calc(18px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  z-index: 5;
}
.back-btn { display: none; }
.detail-head-left { display: flex; align-items: center; gap: 10px; }
.detail-head-right { display: flex; gap: 4px; }

.detail-content { padding: 22px 24px 36px; display: flex; flex-direction: column; gap: 22px; }
.detail-title { font-size: 22px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.25; }

.meta-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px;
}
.meta-row .meta-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  background: var(--subtle); border: 1px solid var(--border);
  color: var(--text-secondary); font-weight: 500;
}
.meta-row .meta-item i { width: 12px; height: 12px; }
.meta-row .owner-chip { padding: 4px 10px 4px 4px; }

/* Time tracker */
.time-tracker {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--accent-soft) 0%, #F4EFFA 100%);
  border: 1px solid rgba(110, 91, 201, 0.2);
  border-radius: 14px;
  transition: all 0.2s ease;
}
.time-tracker.running {
  background: linear-gradient(135deg, var(--low-bg) 0%, #E5F2EA 100%);
  border-color: rgba(34, 197, 94, 0.28);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.06);
}
.time-tracker .play-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: white;
  border: none;
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px -4px rgba(110, 91, 201, 0.5);
  transition: all 0.15s ease;
}
.time-tracker .play-btn:hover { background: var(--accent-deep); transform: scale(1.05); }
.time-tracker .play-btn:active { transform: scale(0.95); }
.time-tracker .play-btn i { width: 18px; height: 18px; }
.time-tracker.running .play-btn {
  background: var(--low-fg);
  box-shadow: 0 4px 12px -4px rgba(45, 122, 77, 0.5);
}
.time-tracker.running .play-btn:hover { background: #1F5C39; }
.time-tracker-info { flex: 1; min-width: 0; }
.time-tracker-info .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent-deep); font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.time-tracker.running .label { color: var(--low-fg); }
.time-tracker.running .label::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--low-fg);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}
.time-tracker-info .value {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 22px; font-weight: 600; color: var(--text);
  letter-spacing: -0.01em; line-height: 1.1; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.time-tracker.running .value { color: var(--low-fg); }
.time-tracker-info .sub { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }
.time-tracker .reset-btn { color: var(--text-tertiary); }
.time-tracker .reset-btn:hover { color: var(--high-fg); background: rgba(184, 57, 94, 0.08); }

/* Drag and drop ------------------------------------------ */
.task-card[draggable="true"],
.kanban-card[draggable="true"],
.cal-task[draggable="true"] { cursor: grab; }
.task-card[draggable="true"]:active,
.kanban-card[draggable="true"]:active,
.cal-task[draggable="true"]:active { cursor: grabbing; }
.task-card.dragging,
.cal-task.dragging {
  opacity: 0.35;
  cursor: grabbing;
}
/* No kanban escondemos o card original — o placeholder ocupa o espaço
   e empurra os outros cards para mostrar onde vai cair. */
.kanban-card.dragging {
  display: none;
}

.section.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  border-radius: 12px;
}
.kanban-col.drag-over {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
/* Slot vazio que segue o cursor durante drag no kanban — mesma altura do
   card arrastado, borda tracejada azul subtil. Empurra os outros cards.
   Sem margin: a .kanban-col usa flex gap para o espaçamento. */
.kanban-card-placeholder {
  border: 2px dashed var(--accent);
  border-radius: 12px;
  background: var(--accent-soft);
  pointer-events: none;
  box-sizing: border-box;
  flex: 0 0 auto;
}
.calendar-day.drop-target {
  background: var(--accent-soft) !important;
  z-index: 1;
}
.calendar-day.drop-target::after {
  content: ""; position: absolute; inset: 0;
  border: 2px dashed var(--accent);
  pointer-events: none;
}

/* Detail sections */
.detail-section h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary); font-weight: 600;
  margin-bottom: 10px;
}
.detail-section .section-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.detail-section .section-progress {
  font-size: 11px; font-weight: 500; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.detail-desc { font-size: 13.5px; color: var(--text); line-height: 1.6; }

/* Subtasks */
.subtasks { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.subtask {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13px; color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease;
}
.subtask:hover { background: var(--subtle); }
.subtask input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px; border-radius: 5px;
  border: 1.5px solid var(--border-strong); background: white;
  flex-shrink: 0; margin-top: 1px; cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}
.subtask input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.subtask input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 4px; top: 1px;
  width: 5px; height: 9px; border: 2px solid white; border-top: 0; border-left: 0;
  transform: rotate(45deg);
}
.subtask span { flex: 1; line-height: 1.45; }
.subtask.done span { color: var(--text-tertiary); text-decoration: line-through; }

/* Attachments */
.attachments { display: flex; flex-direction: column; gap: 8px; }
.attachment {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--subtle); border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer; transition: all 0.15s ease;
}
.attachment:hover { background: var(--card-hover); border-color: var(--border-strong); }
.attachment-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: white; border: 1px solid var(--border);
  display: grid; place-items: center;
  color: var(--text-secondary);
}
.attachment-icon i { width: 14px; height: 14px; }
.attachment-info { flex: 1; min-width: 0; }
.attachment-name { font-size: 13px; font-weight: 500; }
.attachment-meta { font-size: 11px; color: var(--text-tertiary); }
.attachment-action { color: var(--text-tertiary); }
.attachment-action i { width: 14px; height: 14px; }

/* Resources / dependencies */
.link-list { display: flex; flex-direction: column; gap: 6px; }
.link-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  background: var(--subtle); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text); line-height: 1.45;
  transition: all 0.15s ease;
}
.link-item:hover { border-color: var(--border-strong); background: var(--card-hover); }
.link-item i { width: 13px; height: 13px; color: var(--text-tertiary); flex-shrink: 0; }

/* Tabs */
.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-top: 4px;
}
.tab {
  padding: 10px 14px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary);
  border: none; background: transparent;
  position: relative;
  transition: color 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 2px;
}
.tab-count {
  display: inline-block; margin-left: 5px;
  font-size: 10.5px; font-weight: 600;
  background: var(--bg-deep); color: var(--text-secondary);
  padding: 1px 6px; border-radius: 5px;
}
.tab.active .tab-count { background: var(--accent-soft); color: var(--accent-deep); }

.tab-panel { padding-top: 14px; }

/* Comments */
.comment-input {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--subtle);
  margin-bottom: 14px;
  transition: all 0.15s ease;
}
.comment-input:focus-within { border-color: var(--accent); background: white; }
.comment-input input {
  flex: 1; min-width: 0;
  border: none; background: transparent; outline: none;
  font-size: 13px;
}
.comment-input button {
  border: none; background: var(--accent); color: white;
  padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
}
.comment-input button:disabled { opacity: 0.4; cursor: not-allowed; }

.comments { display: flex; flex-direction: column; gap: 14px; }
.comment {
  display: flex; gap: 10px; align-items: flex-start;
}
.comment-body { flex: 1; min-width: 0; }
.comment-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; margin-bottom: 3px;
}
.comment-author { font-weight: 600; color: var(--text); }
.comment-when { color: var(--text-tertiary); font-size: 11.5px; }
.comment-edited {
  color: var(--text-tertiary);
  font-size: 11px;
  font-style: italic;
  cursor: help;
}
.comment-edit-btn {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.comment-edit-btn i { width: 13px; height: 13px; }
.comment:hover .comment-edit-btn { opacity: 1; }
.comment-edit-btn:hover { color: var(--text); background: var(--subtle); }
.comment-text { font-size: 13px; color: var(--text); line-height: 1.5; overflow-wrap: anywhere; }
.comment-edit { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.comment-edit-input {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 13px; line-height: 1.5;
  color: var(--text); background: white;
  resize: vertical;
  outline: none;
}
.comment-edit-input:focus { border-color: var(--accent); }
.comment-edit-actions { display: flex; gap: 6px; justify-content: flex-end; }
.comment-edit-actions .btn { padding: 4px 10px; font-size: 12px; }

/* Activity */
.activity-list { display: flex; flex-direction: column; gap: 10px; }
.activity-item {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 12.5px; color: var(--text-secondary);
}
.activity-item .avatar { width: 22px; height: 22px; font-size: 10px; }
.activity-item strong { color: var(--text); font-weight: 600; }

/* Empty placeholder */
.empty {
  text-align: center; padding: 28px;
  color: var(--text-tertiary); font-size: 12.5px;
}

/* ============== CALENDAR VIEW ======================== */
.calendar-view { display: flex; flex-direction: column; gap: 14px; }

.calendar-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 4px; gap: 12px; flex-wrap: wrap;
}
.calendar-nav { display: flex; align-items: center; gap: 6px; }
.calendar-nav .icon-btn { width: 32px; height: 32px; border: 1px solid var(--border); background: white; }
.calendar-title {
  font-size: 17px; font-weight: 600;
  min-width: 160px; text-align: center;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  margin: 0 4px;
}
.calendar-meta {
  font-size: 12px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.calendar-nav .btn { padding: 6px 12px; font-size: 12.5px; }
.calendar-nav .btn i { width: 12px; height: 12px; }

.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
}
.calendar-weekdays > div {
  background: var(--subtle);
  padding: 9px 12px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-secondary); font-weight: 600;
}

.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.calendar-day {
  background: white;
  aspect-ratio: 1 / 1;
  min-height: 90px;
  padding: 8px 10px 10px;
  display: flex; flex-direction: column; gap: 5px;
  position: relative;
  overflow: hidden;
}
.calendar-day.outside { background: var(--subtle); opacity: 0.55; }
.calendar-day.outside .day-num { color: var(--text-tertiary); }
.calendar-day.today { background: var(--accent-soft); }
.calendar-day.expanded { aspect-ratio: auto; overflow: visible; }
.calendar-day.weekend { background: #FBFAFC; }
.calendar-day.weekend.outside { background: var(--subtle); }
.calendar-day.weekend.today { background: var(--accent-soft); }
.calendar-day .day-tasks { overflow: hidden; min-width: 0; }

@media (max-width: 768px) {
  .calendar-day { aspect-ratio: auto; min-height: 100px; }
}

.day-num {
  font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 6px;
}
.calendar-day.today .day-num { color: var(--accent-deep); font-weight: 700; }
.today-badge {
  font-size: 9px; font-weight: 700;
  background: var(--accent); color: white;
  padding: 1px 6px; border-radius: 5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.day-tasks { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.cal-task {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 7px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 11px; font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  min-width: 0;
  transition: all 0.15s ease;
}
.cal-task:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.cal-task.selected { box-shadow: 0 0 0 2px rgba(110, 91, 201, 0.32); }
.cal-task-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.cal-task-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}

.cal-more {
  font-size: 10.5px; color: var(--text-secondary);
  background: transparent; border: none;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
  align-self: flex-start;
}
.cal-more:hover { background: var(--subtle); color: var(--text); }

/* ============== KANBAN VIEW ========================== */
/* Trello-style horizontal scroll: cada coluna tem largura fixa, total
   scrolla lateralmente quando excede o viewport. Ninguém fica perdido
   em baixo da página com muitos owners. */
.kanban-view {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 12px;
  /* Improves trackpad scroll feel on macOS */
  overscroll-behavior-x: contain;
}
.kanban-col {
  background: var(--bg-deep);
  border-radius: 14px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  flex: 0 0 280px;          /* fixed width, no shrink, no grow */
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

/* Pill que substitui a dropdown de estado no detail panel */
.meta-state-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
}
.meta-state-pendente  { background: var(--accent-soft); color: var(--accent-deep); border-color: rgba(110,91,201,0.2); }
.meta-state-ongoing   { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.meta-state-arquivada { background: var(--low-bg); color: var(--low-fg); border-color: rgba(45,122,77,0.2); }
.kanban-col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 8px;
}
.kanban-col-head .section-title { font-size: 12.5px; }
.kanban-card {
  position: relative;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  display: flex; flex-direction: column; gap: 8px;
}
/* Badge de menções não lidas no canto sup-direito do card.
   Aparece quando o user actual tem @mentions por ler nesta tarefa.
   Auto-clear ao abrir a tarefa via markTaskMentionsRead(). */
.card-mention-badge {
  position: absolute;
  top: -8px; right: -8px;
  background: #E75B5B;
  color: white;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  min-width: 22px;
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(231, 91, 91, 0.35);
  pointer-events: none;
  z-index: 1;
}
.kanban-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.kanban-card.selected { box-shadow: 0 0 0 2px rgba(110, 91, 201, 0.35); }

/* Top row do card: bloco-pill (esq) + empresa-pill (dir). Cada pill ocupa
   no máximo metade da largura — texto longo trunca com ellipsis. */
.kanban-card-pills {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.kanban-pill-clip {
  max-width: calc(50% - 3px);
  min-width: 0;
  overflow: hidden;
  flex-shrink: 1;
}
.kanban-pill-clip .kanban-pill-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.empresa-pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 6px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.02em;
}

/* Nos cards do kanban, neutralizamos as cores do bloco-pill e priority-pill
   para reduzir ruído visual — só a empresa-pill (direita) e a stripe à
   volta carregam cor. Decisão Tiago 2026-05-09. */
.kanban-card .bloco-pill {
  background: var(--subtle);
  color: var(--text-secondary);
}
.kanban-card .bloco-pill .bloco-pill-dot { background: var(--text-tertiary); }
.kanban-card .priority-pill,
.kanban-card .priority-pill.high,
.kanban-card .priority-pill.medium,
.kanban-card .priority-pill.low {
  background: var(--subtle);
  color: var(--text-secondary);
}
.kanban-card .priority-pill .priority-dot { background: var(--text-tertiary); }
.kanban-card-title { font-size: 13px; font-weight: 500; line-height: 1.35; }
.kanban-card-foot {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  font-size: 11px; color: var(--text-tertiary);
}

/* ============== EDITABLE FIELDS ====================== */
.edit-input,
.edit-textarea {
  font-family: inherit; color: inherit;
  background: transparent; border: 1px solid transparent;
  border-radius: 8px;
  outline: none;
  width: 100%;
  padding: 5px 9px; margin: -5px -9px;
  transition: all 0.12s ease;
}
.edit-input:hover, .edit-textarea:hover { background: var(--subtle); }
.edit-input:focus, .edit-textarea:focus {
  background: white; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10);
}
.edit-textarea { resize: none; line-height: 1.55; min-height: 50px; overflow-wrap: anywhere; }

/* Vista renderizada da descrição (markdown → HTML). Visualmente alinhada
   com o textarea (mesmo padding e font), mas read-only — clica para editar. */
.desc-rendered {
  font-size: 13.5px; line-height: 1.6;
  padding: 5px 9px; margin: -5px -9px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: text;
  min-height: 50px;
  overflow-wrap: anywhere;
  transition: background 0.12s ease;
}
.desc-rendered:hover { background: var(--subtle); }
.desc-rendered ul, .desc-rendered ol { margin: 6px 0; padding-left: 22px; }
.desc-rendered li { margin: 2px 0; }
.desc-rendered strong { font-weight: 600; }
.desc-rendered em { font-style: italic; }
.desc-empty { color: var(--text-tertiary); font-size: 12.5px; }
.desc-empty code {
  background: var(--subtle);
  padding: 1px 5px; border-radius: 4px;
  font-size: 11.5px;
}

/* Bold/italic dentro de comentários */
.comment-text strong { font-weight: 600; }
.comment-text em { font-style: italic; }

.edit-title {
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.025em; line-height: 1.25;
  padding: 6px 10px; margin: -6px -10px;
}

.edit-desc {
  font-size: 13.5px; line-height: 1.6;
  min-height: 180px;
  max-height: 320px;
  overflow-y: scroll;
  resize: vertical;
}
/* Always-visible scrollbar inside the description textarea */
.edit-desc::-webkit-scrollbar { width: 10px; }
.edit-desc::-webkit-scrollbar-track {
  background: var(--subtle);
  border-radius: 0 8px 8px 0;
}
.edit-desc::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 2px solid var(--subtle);
}
.edit-desc::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
/* Firefox always-show */
.edit-desc { scrollbar-width: thin; scrollbar-color: var(--border-strong) var(--subtle); }

.edit-effort {
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  display: inline-block; width: auto; min-width: 60px;
  padding: 0 2px; margin: 0;
}

.edit-notes {
  font-size: 13.5px; line-height: 1.55; font-style: italic;
  background: var(--accent-soft);
  border-radius: 12px; padding: 12px 14px;
  border: 1px solid transparent;
  width: 100%;
}
.edit-notes:hover { background: #E0D9F8; }
.edit-notes:focus { background: white; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10); }

/* Meta selects (state, priority, bloco, assignee) */
.meta-select {
  appearance: none; -webkit-appearance: none;
  font-family: inherit;
  background: var(--subtle) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236B6577' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 8px center;
  background-size: 10px;
  border: 1px solid var(--border);
  padding: 5px 24px 5px 10px;
  border-radius: 8px;
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  transition: all 0.12s ease;
}
.meta-select:hover { background-color: white; border-color: var(--border-strong); color: var(--text); }
.meta-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.12); }

.meta-select.priority-high   { background-color: var(--high-bg); color: var(--high-fg); border-color: transparent; }
.meta-select.priority-medium { background-color: var(--med-bg);  color: var(--med-fg);  border-color: transparent; }
.meta-select.priority-low    { background-color: var(--low-bg);  color: var(--low-fg);  border-color: transparent; }

.meta-input[type="date"] {
  appearance: none; -webkit-appearance: none;
  font-family: inherit;
  background: var(--subtle);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  outline: none;
  transition: all 0.12s ease;
}
.meta-input[type="date"]:hover { background: white; color: var(--text); }
.meta-input[type="date"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.12); }

/* Editable subtasks */
.subtask-edit { flex: 1; }
.subtask .subtask-text-input {
  font-family: inherit; font-size: 13px; color: inherit;
  border: 1px solid transparent; background: transparent;
  border-radius: 6px; outline: none;
  padding: 3px 6px; margin: -3px -6px;
  width: 100%;
}
.subtask .subtask-text-input:hover { background: var(--subtle); }
.subtask .subtask-text-input:focus { background: white; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(110, 91, 201, 0.12); }
.subtask.done .subtask-text-input { color: var(--text-tertiary); text-decoration: line-through; }

.subtask-remove {
  opacity: 0;
  background: transparent; border: none;
  color: var(--text-tertiary);
  padding: 4px;
  border-radius: 6px;
  transition: all 0.12s ease;
  flex-shrink: 0;
}
.subtask:hover .subtask-remove { opacity: 1; }
.subtask-remove:hover { background: var(--high-bg); color: var(--high-fg); }
.subtask-remove i { width: 12px; height: 12px; }

.subtask-add {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  background: transparent;
  border: 1px dashed var(--border-strong);
  margin-top: 4px;
}
.subtask-add input {
  flex: 1;
  border: none; background: transparent;
  font-size: 13px; outline: none;
  color: inherit;
}
.subtask-add i { width: 14px; height: 14px; color: var(--text-tertiary); }

/* Editable list (resources / dependencies) */
.link-list .link-item {
  position: relative;
  padding-right: 36px;
}
.link-list .link-item input {
  flex: 1;
  min-width: 0;
  border: none; background: transparent;
  font-family: inherit; font-size: 12.5px; color: inherit;
  outline: none;
  padding: 3px 4px;
}
.link-list .link-item:hover input { background: white; border-radius: 5px; }
.link-list .link-item input:focus { background: white; box-shadow: 0 0 0 2px rgba(110, 91, 201, 0.12); border-radius: 5px; }
.link-remove {
  position: absolute; right: 8px;
  background: transparent; border: none;
  color: var(--text-tertiary);
  padding: 3px;
  border-radius: 5px;
  opacity: 0;
  transition: all 0.12s ease;
}
.link-list .link-item:hover .link-remove { opacity: 1; }
.link-remove:hover { background: var(--high-bg); color: var(--high-fg); }
.link-remove i { width: 12px; height: 12px; }
.link-list .link-add {
  border: 1px dashed var(--border-strong);
  background: transparent;
}

/* Detail action bar */
.detail-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding-top: 12px; margin-top: 8px;
  border-top: 1px solid var(--border);
}
.btn.danger { color: var(--high-fg); }
.btn.danger:hover { background: var(--high-bg); border-color: var(--high-fg); }

/* ============== MODAL ================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 16, 31, 0.45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: white; border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 600px;
  max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.modal-head h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.015em; }
.modal-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; line-height: 1.5; }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--subtle);
}
.modal-body textarea {
  width: 100%;
  min-height: 220px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px; line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--subtle);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  resize: vertical;
  color: var(--text);
}
.modal-body textarea:focus { border-color: var(--accent); background: white; box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.12); }
.import-preview {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--subtle);
  border: 1px solid var(--border);
  font-size: 12.5px;
}
.import-preview .hint { color: var(--text-tertiary); }
.import-preview.valid { background: var(--low-bg); border-color: rgba(45, 122, 77, 0.2); color: var(--low-fg); }
.import-preview.error { background: var(--high-bg); border-color: rgba(184, 57, 94, 0.2); color: var(--high-fg); }
.import-preview ul { margin: 6px 0 0 16px; }
.import-preview li { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px; line-height: 1.6; }

/* ============== SETTINGS MODAL ======================= */
.modal.modal-large { max-width: 760px; height: 580px; }
.settings-body { display: grid; grid-template-columns: 200px 1fr; flex: 1; min-height: 0; }
.settings-nav {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 10px;
  border-right: 1px solid var(--border);
  background: var(--subtle);
}
.settings-tab {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border: none; background: transparent;
  font: inherit; font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s ease;
}
.settings-tab:hover { background: white; color: var(--text); }
.settings-tab.active { background: white; color: var(--accent-deep); font-weight: 600; box-shadow: var(--shadow-sm); }
.settings-tab i { width: 15px; height: 15px; }

.settings-content { padding: 22px 24px; overflow-y: auto; min-width: 0; }

/* Settings → Custos tab */
.cost-empresa {
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.cost-empresa-head h4 {
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text); margin: 0 0 12px;
}
.cost-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.cost-grid.cost-grid-single { grid-template-columns: 200px; }
.cost-row {
  display: flex; flex-direction: column; gap: 4px;
}
.cost-row > span {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-tertiary); font-weight: 600;
}
.cost-row input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit; font-size: 13px;
  background: white;
}
.cost-row input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10);
}
.cost-skus {
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.cost-skus-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-tertiary); font-weight: 600;
  margin-bottom: 4px;
}
.cost-skus-head-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.cost-skus-head-row .cost-skus-head { margin: 0; }
.cost-skus-empty {
  font-size: 12px; color: var(--text-tertiary); font-style: italic;
  padding: 6px 0;
}
.cost-sku-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px auto;
  gap: 8px;
  align-items: center;
}
.cost-sku-row input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit; font-size: 13px;
  background: white;
}
.shopify-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 8px;
  margin-top: 4px;
}
@media (max-width: 640px) {
  .shopify-row { grid-template-columns: 1fr; }
}
.shopify-field {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-tertiary); font-weight: 600;
}
.shopify-field input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit; font-size: 13px;
  background: white;
  text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 500;
}
.shopify-field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(110,91,201,0.10);
}
.shopify-hint {
  font-size: 11.5px; color: var(--text-tertiary); line-height: 1.5;
  margin-top: 8px;
}
.shopify-hint code {
  background: var(--subtle); padding: 1px 5px; border-radius: 4px;
  font-size: 11px; font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--text);
}
.shopify-test-result {
  margin-top: 8px;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  line-height: 1.5;
  word-break: break-word;
  user-select: text;
}
.shopify-test-result:empty { display: none; }
.shopify-test-result.ok {
  color: var(--state-done, #1f8a4d);
  background: rgba(31,138,77,0.08);
  padding: 8px 10px; border-radius: 8px;
}
.shopify-test-result.fail {
  color: #b32626;
  background: rgba(179,38,38,0.07);
  padding: 8px 10px; border-radius: 8px;
  white-space: pre-wrap;
}
.cost-sku-row input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(110, 91, 201, 0.10);
}

/* ============== WHATSAPP INBOX ============================== */
.whatsapp-page { padding: 4px 0 16px; }

/* Compact stats strip — replaces the old 4-card KPI block. Single thin
   row at top with icon + value + label per stat. Scrolls out of view
   normally, leaving the inbox to fill the viewport when scrolled. */
.wa-stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 12.5px;
  align-items: center;
}
.wa-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}
.wa-stat i { width: 14px; height: 14px; opacity: 0.7; }
.wa-stat-value { font-weight: 600; color: var(--text); }
.wa-stat-label { font-size: 11px; color: var(--text-tertiary); }
.wa-stat-alert .wa-stat-value, .wa-stat-alert i { color: var(--alert); }
.wa-stat-ok { margin-left: auto; }
.wa-stat-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--state-done);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.wa-inbox {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  gap: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  /* Fill the viewport — when user scrolls past the stats strip, the
     inbox occupies the full visible area. The 80px subtracts the
     sticky topbar height. min-height keeps the inbox usable on short
     viewports (laptops with browser chrome eating space). */
  height: calc(100vh - 80px);
  min-height: 560px;
}
/* Back button (mobile-only) + info button (≤1180px) — hidden in full
   desktop where panel is always visible. Both rendered server-side
   and CSS shows them where they apply. */
.wa-thread-back, .wa-thread-info {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  align-items: center; justify-content: center;
  color: var(--text-secondary);
  padding: 0;
}
.wa-thread-back:hover, .wa-thread-info:hover { background: var(--subtle); color: var(--text); }
.wa-thread-back i, .wa-thread-info i { width: 18px; height: 18px; }
.wa-contact-close {
  display: none;
  position: absolute; top: 8px; right: 8px;
  background: white;
  border: 1px solid var(--border);
  width: 28px; height: 28px;
  border-radius: 999px;
  cursor: pointer;
  align-items: center; justify-content: center;
  z-index: 1;
  padding: 0;
}
.wa-contact-close i { width: 16px; height: 16px; }
.wa-contact-panel { position: relative; }

@media (max-width: 1180px) {
  /* Tight desktop / tablet — drop the contact panel column. Info
     button visible to open it as a drawer overlay. */
  .wa-inbox { grid-template-columns: 300px minmax(0, 1fr); }
  .wa-contact-panel { display: none; }
  .wa-thread-info { display: inline-flex; }
  .wa-inbox.wa-mobile-panel-open .wa-contact-panel {
    display: flex;
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(360px, 92vw);
    z-index: 100;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
    animation: wa-slide-in 0.18s ease-out;
  }
  .wa-inbox.wa-mobile-panel-open .wa-contact-close { display: inline-flex; }
  .wa-mobile-panel-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 99;
    animation: wa-fade-in 0.18s ease-out;
  }
}

@media (max-width: 880px) {
  /* Mobile — KPIs landing + 4-level drill-down (folders → conv-list →
     thread). The .wa-inbox layout from desktop is bypassed entirely;
     mobile renders a separate component tree via renderWhatsAppMobileFlow().
     Only the stats strip + open CTA button render at L0. */
  .wa-inbox { display: none; }
  .wa-stats-strip { gap: 12px; padding: 8px 12px; font-size: 12px; }
  .wa-stat { gap: 4px; }
  .wa-stat-ok { margin-left: 0; }

  /* L0 — Big CTA to enter the inbox */
  .wa-mobile-open-cta {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 12px;
    padding: 16px 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
    font: inherit;
  }
  .wa-mobile-open-cta:active { background: var(--subtle); }
  .wa-mobile-open-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    display: grid; place-items: center;
    flex-shrink: 0;
  }
  .wa-mobile-open-icon i { width: 20px; height: 20px; }
  .wa-mobile-open-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
  .wa-mobile-open-title { font-weight: 600; font-size: 15px; color: var(--text); }
  .wa-mobile-open-sub { font-size: 12.5px; color: var(--text-tertiary); }
  .wa-mobile-open-badge {
    background: var(--alert);
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
  }
  .wa-mobile-open-chev { width: 18px; height: 18px; color: var(--text-tertiary); }

  /* L1+ — Fullscreen screens (folders, conv-list, thread) */
  .wa-mobile-screen {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 60;
    display: flex;
    flex-direction: column;
    height: 100dvh;  /* dvh: shrinks when mobile address bar shows */
    /* No entry animation — was triggering on every realtime-driven
       re-render (queued → sent → delivered → read) → visible flicker.
       Drill-down level changes are obvious enough without animation. */
  }
  .wa-mobile-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
    border-bottom: 1px solid var(--border);
    background: white;
    flex-shrink: 0;
  }
  .wa-mobile-icon-btn {
    background: transparent;
    border: none;
    width: 36px; height: 36px;
    border-radius: 10px;
    display: grid; place-items: center;
    cursor: pointer;
    color: var(--text-secondary);
    flex-shrink: 0;
    padding: 0;
  }
  .wa-mobile-icon-btn:active { background: var(--subtle); }
  .wa-mobile-icon-btn i { width: 22px; height: 22px; }
  .wa-mobile-header-title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
  }
  .wa-mobile-header-title span:first-child {
    font-weight: 600; font-size: 15px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .wa-mobile-header-title small {
    font-size: 11.5px;
    color: var(--text-tertiary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .wa-mobile-header-spacer { width: 36px; }

  /* L1 — Folders */
  .wa-mobile-folders { flex: 1; overflow-y: auto; padding: 8px 0; }
  .wa-mobile-folder {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: white;
    border: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-align: left;
    font: inherit;
  }
  .wa-mobile-folder:active { background: var(--subtle); }
  .wa-mobile-folder-icon {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: var(--subtle);
    display: grid; place-items: center;
    color: var(--primary);
    flex-shrink: 0;
  }
  .wa-mobile-folder-icon i { width: 18px; height: 18px; }
  .wa-mobile-folder-name { flex: 1; font-weight: 600; font-size: 15px; }
  .wa-mobile-folder-count {
    background: var(--subtle);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    min-width: 28px;
    text-align: center;
  }
  .wa-mobile-folder-chev { width: 18px; height: 18px; color: var(--text-tertiary); flex-shrink: 0; }

  /* L2 — Conv list */
  .wa-mobile-conv-list { flex: 1; overflow-y: auto; }
  .wa-mobile-conv {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-align: left;
    font: inherit;
  }
  .wa-mobile-conv:active { background: var(--subtle); }
  .wa-mobile-conv-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
  }
  .wa-mobile-conv-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: 14.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .wa-mobile-conv-time { font-size: 11.5px; color: var(--text-tertiary); flex-shrink: 0; }
  .wa-mobile-conv-preview {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .wa-mobile-conv-badge {
    background: var(--primary);
    color: white;
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    min-width: 22px;
    text-align: center;
    flex-shrink: 0;
  }

  /* Sub-bar abaixo do mobile header — controlos AI/Humano + Fechar conv */
  .wa-mobile-thread-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--subtle);
    flex-shrink: 0;
  }
  .wa-mobile-thread-controls .wa-state-badge {
    font-size: 11.5px;
    padding: 4px 10px;
  }
  .wa-mobile-pill-btn {
    margin-left: auto;  /* sticks the close button to the right */
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
  }
  .wa-mobile-pill-btn:active { background: var(--subtle); }
  .wa-mobile-pill-btn i { width: 13px; height: 13px; }
  /* take/handback inline button rendered by the existing badge HTML —
     compactar para o sub-bar mobile */
  .wa-mobile-thread-controls .btn.ghost {
    font-size: 11.5px;
    padding: 4px 10px;
    border-radius: 999px;
  }

  /* Floating toast on mobile — bottom is shorter because reply-hint
     is hidden in mobile view, plus safe-area inset bottom is added
     to the reply itself. ~80px lifts above the visible reply input. */
  .wa-new-msgs-toast { bottom: 80px; }

  /* L3 — Thread fullscreen */
  .wa-mobile-thread-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  /* Hide the desktop thread head since the mobile header replaces it */
  .wa-mobile-thread-body .wa-thread-head { display: none; }
  .wa-mobile-thread-body .wa-thread-msgs {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 12px 8px;
  }
  .wa-mobile-thread-body .wa-msg-wrap { max-width: 100%; }
  .wa-mobile-thread-body .wa-msg {
    max-width: 82%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .wa-mobile-thread-body .wa-reply {
    flex-shrink: 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
  }
  .wa-mobile-thread-body .wa-reply-hint { display: none; }  /* save space */
  /* Prevent iOS Safari auto-zoom — fires whenever an input has
     font-size < 16px. Also disable double-tap zoom (zooming a chat
     thread is annoying — pinch-zoom still works for accessibility). */
  .wa-mobile-thread-body textarea,
  .wa-mobile-thread-body input,
  .wa-mobile-conv,
  .wa-mobile-folder,
  .wa-mobile-icon-btn,
  .wa-mobile-open-cta {
    touch-action: manipulation;
  }
  .wa-mobile-thread-body textarea#wa-reply-input {
    font-size: 16px;
    line-height: 1.4;
  }
  /* Same fix for the contact-panel notes textarea + tag input on mobile */
  .wa-mobile-contact-panel textarea,
  .wa-mobile-contact-panel input {
    font-size: 16px;
  }

  /* Mobile contact panel — slides over the thread screen, full height */
  .wa-mobile-contact-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(360px, 92vw);
    height: 100dvh;
    background: var(--subtle);
    border-left: 1px solid var(--border);
    z-index: 70;
    overflow-y: auto;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
    animation: wa-slide-in 0.18s ease-out;
  }
  .wa-mobile-thread-screen.wa-mobile-panel-open .wa-mobile-contact-panel { display: flex; flex-direction: column; }
  .wa-mobile-thread-screen .wa-mobile-panel-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 65;
    animation: wa-fade-in 0.18s ease-out;
  }
  .wa-mobile-thread-screen .wa-contact-close { display: inline-flex; }

  /* Empty state */
  .wa-mobile-empty {
    flex: 1;
    display: grid; place-items: center; align-content: center;
    padding: 40px;
    text-align: center;
    color: var(--text-tertiary);
    gap: 8px;
    font-size: 14px;
  }
  .wa-mobile-empty i { width: 32px; height: 32px; opacity: 0.4; }
}

@keyframes wa-slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
@keyframes wa-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.wa-conversations {
  border-right: 1px solid var(--border);
  background: var(--subtle);
  display: flex; flex-direction: column;
  min-height: 0;
}
.wa-conversations-list {
  flex: 1; min-height: 0;
  overflow-y: auto;
}
.wa-folders {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: white;
  flex-shrink: 0;
}
.wa-folder {
  flex: 1 1 calc(33% - 4px);
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.wa-folder:hover { background: var(--subtle); }
.wa-folder.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.wa-folder-count {
  font-size: 10px;
  background: rgba(0,0,0,0.08);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
}
.wa-folder.active .wa-folder-count {
  background: rgba(255,255,255,0.25);
}
.wa-conv-cat {
  font-size: 10px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wa-conv-cat-cliente { background: #d4f4d4; color: #1d6f24; }
.wa-conv-cat-carrinho { background: #fef3cd; color: #8a5a13; }
.wa-conv-cat-lead { background: #e2e2ec; color: var(--text-tertiary); }
.wa-conv {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}
.wa-conv:hover { background: rgba(110,91,201,0.05); }
.wa-conv.active { background: white; border-left: 3px solid var(--accent); padding-left: 11px; }
.wa-conv-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 2px;
}
.wa-conv-name { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-conv-time { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }
.wa-conv-preview { font-size: 12.5px; color: var(--text-secondary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-conv-unread {
  background: var(--accent); color: white;
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  min-width: 20px; text-align: center;
}

.wa-thread {
  display: flex; flex-direction: column;
  background: white;
  min-height: 0;
}
.wa-thread-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.wa-thread-name { font-weight: 700; font-size: 15px; }
.wa-thread-phone { font-size: 12px; color: var(--text-tertiary); font-family: 'JetBrains Mono', ui-monospace, monospace; margin-top: 2px; }
.wa-thread-ai-state { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.wa-state-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
}
.wa-state-badge i { width: 13px; height: 13px; }
.wa-state-ai { background: rgba(110,91,201,0.10); color: var(--accent-deep); }
.wa-state-human { background: #fef3cd; color: #8a5a13; }
.wa-thread-msgs {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px;
  background: #fafafd;
}
.wa-msg {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.wa-msg-in {
  align-self: flex-start;
  background: white;
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.wa-msg-out {
  align-self: flex-end;
  background: linear-gradient(135deg, #6E5BC9 0%, #5d4ab5 100%);
  color: white;
  border-bottom-right-radius: 4px;
}
.wa-msg-body { font-size: 13.5px; line-height: 1.45; word-break: break-word; white-space: pre-wrap; }
.wa-msg-meta {
  font-size: 10.5px; opacity: 0.7;
  display: flex; gap: 6px; align-items: center;
}
.wa-msg-out .wa-msg-meta { color: rgba(255,255,255,0.85); }
.wa-msg-in .wa-msg-meta { color: var(--text-tertiary); }
.wa-msg-status {
  display: inline-flex; align-items: center;
  margin-left: 2px;
}
.wa-msg-status i { width: 12px; height: 12px; }
.wa-msg-status-queued i { animation: wa-spin 1.2s linear infinite; opacity: 0.7; }
.wa-msg-status-sent i { opacity: 0.6; }
.wa-msg-status-delivered i { opacity: 0.85; }
.wa-msg-status-read i { color: #38BDF8; opacity: 1; }
.wa-msg-out .wa-msg-status-read i { color: #BAE6FD; }
.wa-msg-status-failed i { color: #FCA5A5; }
.wa-msg-out .wa-msg-status-failed i { color: #FCA5A5; }
@keyframes wa-spin { to { transform: rotate(360deg); } }

.wa-msg-out.wa-msg-failed {
  background: #7F1D1D !important;
  opacity: 0.9;
}
.wa-msg-out.wa-msg-queued {
  opacity: 0.7;
}
.wa-msg-error {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  font-size: 11.5px; color: #991B1B;
  max-width: 70%;
  align-self: flex-end;
}
.wa-msg-error i { width: 14px; height: 14px; flex-shrink: 0; color: #DC2626; }
.wa-msg-error > span { flex: 1; min-width: 0; }
.wa-msg-error .btn { white-space: nowrap; padding: 3px 8px; font-size: 11px; }
.wa-msg-error .btn i { width: 12px; height: 12px; }

.wa-msg-wrap { display: flex; flex-direction: column; gap: 4px; }
.wa-msg-wrap-outbound { align-items: flex-end; }
.wa-msg-wrap-inbound { align-items: flex-start; }
.wa-msg-ai-badge {
  display: inline-flex; align-items: center;
  margin-right: 4px;
  opacity: 0.85;
}
.wa-msg-ai-badge i { width: 11px; height: 11px; }

.wa-msg-rating {
  display: flex; gap: 4px; align-items: flex-start; flex-wrap: wrap;
  max-width: 75%;
}
.wa-rate-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 0;
}
.wa-rate-btn:hover { background: var(--subtle); }
.wa-rate-btn i { width: 13px; height: 13px; }
.wa-rate-btn.active.good { background: rgba(31,138,77,0.12); border-color: var(--state-done); color: var(--state-done); }
.wa-rate-btn.active.bad { background: rgba(179,38,38,0.12); border-color: #b32626; color: #b32626; }
.wa-rate-comment-wrap {
  flex: 1 0 100%;
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 4px;
}
.wa-rate-comment {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit; font-size: 12.5px;
  resize: vertical;
  background: white;
}
.wa-rate-comment:focus { outline: none; border-color: var(--accent); }

.wa-reply {
  position: relative;
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: white;
  align-items: flex-start;
}
.wa-reply-tools { display: flex; align-items: center; }
.wa-reply textarea {
  flex: 1; resize: none;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 13.5px;
}
.wa-reply textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(110,91,201,0.10); }
.wa-reply-locked { padding: 14px 16px; background: #fffaf0; border-top: 1px solid #f3d99f; }
.wa-reply-locked-banner {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: #8a5a08;
  background: #fff5dc; border: 1px solid #f3d99f;
  border-radius: 10px; padding: 10px 12px; line-height: 1.4;
}
.wa-reply-locked-banner i { width: 16px; height: 16px; flex-shrink: 0; }
.wa-reply-locked-banner em { font-style: normal; font-weight: 600; }
.wa-state-other { background: #fff5dc !important; color: #8a5a08 !important; border: 1px solid #f3d99f; }
.wa-emoji-picker {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 12px;
  width: 280px;
  max-height: 240px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15,18,32,0.12);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  z-index: 30;
}
.wa-emoji-picker[hidden] { display: none; }
.wa-emoji {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 5px;
  border-radius: 6px;
  line-height: 1;
}
.wa-emoji:hover { background: var(--subtle); }
.wa-reply-hint {
  font-size: 11.5px; color: var(--text-tertiary);
  padding: 0 16px 12px;
  background: white;
  border-top: none;
}
.wa-thread-empty, .wa-empty {
  flex: 1;
  display: grid; place-items: center; align-content: center;
  padding: 32px;
  text-align: center;
  color: var(--text-tertiary);
  gap: 8px;
}
.wa-thread-empty i, .wa-empty i { width: 28px; height: 28px; opacity: 0.5; }
.wa-empty-hint { font-size: 12px; max-width: 260px; }

/* MCP standalone page (acessível a todos os utilizadores via sidebar) */
.mcp-page {
  display: flex; flex-direction: column;
  gap: 12px;
  max-width: 720px;
}
.mcp-page .settings-data-card { padding: 16px; }
.mcp-page .api-key-row input { font-size: 13px; }

/* "↓ N novas mensagens" — floating pill above the reply input.
   Vivid amber para destacar dos balões do chat (que são roxo/cinza).
   Anchor relativo ao .wa-thread (desktop) ou .wa-mobile-thread-screen
   (mobile). Distância do bottom diferente porque desktop tem reply-
   hint extra (~24px) e mobile esconde-o. */
.wa-thread { position: relative; }
.wa-new-msgs-toast {
  position: absolute;
  bottom: 110px;       /* desktop: clears reply input + reply-hint */
  left: 50%;
  transform: translateX(-50%);
  background: #F59E0B; /* amber-500 — vivid yellow against chat bg */
  color: #1F2937;       /* dark slate text for contrast on yellow */
  padding: 10px 18px 10px 14px;
  border: 1.5px solid #B45309;  /* darker amber outline for definition */
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(180, 83, 9, 0.45), 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 50;          /* well above bubbles (no z) and reply (no z) */
  white-space: nowrap;
  animation: wa-toast-pop 0.2s ease-out;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}
.wa-new-msgs-toast:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 12px 28px rgba(180, 83, 9, 0.55), 0 4px 6px rgba(0, 0, 0, 0.12);
}
.wa-new-msgs-toast:active { transform: translateX(-50%) translateY(0); }
.wa-new-msgs-toast i { width: 16px; height: 16px; stroke-width: 3; }
@keyframes wa-toast-pop {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%); }
}

/* ----- WhatsApp contact panel (right side, ≥1180px) ----- */
.wa-contact-panel {
  border-left: 1px solid var(--border);
  background: var(--subtle);
  overflow-y: auto;
  display: flex; flex-direction: column;
  min-height: 0;
}
.wa-contact-empty {
  flex: 1;
  display: grid; place-items: center; align-content: center;
  padding: 24px;
  color: var(--text-tertiary);
  text-align: center;
  gap: 8px;
  font-size: 13px;
}
.wa-contact-empty i { width: 26px; height: 26px; opacity: 0.5; }
.wa-contact-loading, .wa-contact-error {
  padding: 18px;
  display: flex; flex-direction: column;
  gap: 10px;
}
.wa-contact-skeleton-line {
  height: 12px;
  background: linear-gradient(90deg, #f0f0f5, #e6e6ed, #f0f0f5);
  background-size: 200% 100%;
  animation: wa-shimmer 1.4s linear infinite;
  border-radius: 4px;
}
.wa-contact-skeleton-block {
  height: 80px;
  background: linear-gradient(90deg, #f0f0f5, #e6e6ed, #f0f0f5);
  background-size: 200% 100%;
  animation: wa-shimmer 1.4s linear infinite;
  border-radius: 6px;
  margin-top: 8px;
}
@keyframes wa-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.wa-contact-error { color: var(--text-secondary); font-size: 13px; }
.wa-contact-error i { color: var(--alert); width: 20px; height: 20px; }
.wa-contact-hint { font-size: 11.5px; color: var(--text-tertiary); }

.wa-contact-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
  background: white;
}
.wa-contact-name { font-weight: 700; font-size: 15px; color: var(--text); }
.wa-contact-phone { font-size: 12px; color: var(--text-tertiary); font-family: 'JetBrains Mono', ui-monospace, monospace; }

.wa-contact-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.wa-contact-section:last-child { border-bottom: none; }
.wa-contact-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.wa-contact-section-empty {
  font-size: 12.5px;
  color: var(--text-tertiary);
  font-style: italic;
}

.wa-contact-kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}
.wa-contact-kv { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wa-contact-kv-wide { grid-column: span 2; }
.wa-contact-kv-label { font-size: 10.5px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.4px; }
.wa-contact-kv-value { font-size: 12.5px; color: var(--text); overflow-wrap: anywhere; }

.wa-orders-list { display: flex; flex-direction: column; gap: 6px; }
.wa-order {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}
.wa-order summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
  user-select: none;
}
.wa-order summary::-webkit-details-marker { display: none; }
.wa-order summary:hover { background: var(--subtle); }
.wa-order-summary-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.wa-order-name { font-weight: 600; font-size: 13px; }
.wa-order-date { font-size: 11.5px; color: var(--text-tertiary); }
.wa-order-total { font-size: 12.5px; color: var(--text); font-weight: 500; }
.wa-order-badge {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.wa-order-badge-good { background: #dcfce7; color: #166534; }
.wa-order-badge-warn { background: #fef3c7; color: #92400e; }
.wa-order-badge-neutral { background: var(--subtle); color: var(--text-secondary); }
.wa-order-detail {
  padding: 6px 10px 10px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.wa-order-tracking { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.wa-order-tracking i { width: 14px; height: 14px; }
.wa-order-tracking code { background: var(--subtle); padding: 1px 6px; border-radius: 4px; font-size: 11.5px; }
.wa-order-items { margin: 0; padding-left: 18px; font-size: 12px; color: var(--text-secondary); }
.wa-order-items li { padding: 1px 0; }
.wa-order-link {
  font-size: 11.5px;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  align-self: flex-start;
}
.wa-order-link:hover { text-decoration: underline; }
.wa-order-link i { width: 12px; height: 12px; }

.wa-contact-notes {
  width: 100%;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  resize: vertical;
  min-height: 56px;
}
.wa-contact-notes:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.wa-contact-notes-meta {
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin-top: 4px;
}
.wa-contact-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.wa-contact-tag {
  font-size: 11px;
  background: var(--primary);
  color: white;
  padding: 3px 4px 3px 9px;
  border-radius: 999px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.wa-contact-tag-x {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 16px; height: 16px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.wa-contact-tag-x:hover { background: rgba(255, 255, 255, 0.4); }
.wa-contact-tag-input {
  font: inherit;
  font-size: 12px;
  border: 1px dashed var(--border);
  background: white;
  border-radius: 999px;
  padding: 3px 10px;
  min-width: 110px;
  flex: 1 0 110px;
  outline: none;
}
.wa-contact-tag-input:focus { border-color: var(--primary); border-style: solid; }
.wa-contact-tag-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.wa-contact-tag-suggest-btn {
  font-size: 10.5px;
  color: var(--text-tertiary);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  cursor: pointer;
}
.wa-contact-tag-suggest-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.cost-sku-add {
  margin-top: 4px;
}
.cost-sku-add input {
  width: 100%;
  padding: 8px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  font: inherit; font-size: 13px;
  background: transparent;
}
@media (max-width: 768px) {
  .cost-grid { grid-template-columns: 1fr; }
  .cost-sku-row { grid-template-columns: minmax(0, 1fr) 90px auto; }
}

/* Settings modal full-screen on mobile, with horizontal nav at top */
@media (max-width: 768px) {
  #settings-modal { padding: 0; align-items: stretch; }
  #settings-modal .modal.modal-large {
    width: 100%; height: 100dvh;
    max-width: none; max-height: none;
    border-radius: 0;
  }
  #settings-modal .modal-head {
    padding-top: calc(16px + env(safe-area-inset-top));
  }
  .settings-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .settings-nav {
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    padding: 10px 12px;
    gap: 4px;
    background: var(--subtle);
  }
  .settings-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 12.5px;
    white-space: nowrap;
  }
  .settings-tab.active { box-shadow: none; background: var(--accent-soft); color: var(--accent-deep); }
  .settings-content {
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }
}
.settings-content h4 { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; margin-bottom: 4px; }
.settings-hint { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }

.settings-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.settings-row {
  display: grid; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--subtle); border: 1px solid var(--border);
  border-radius: 12px;
  transition: background 0.12s ease;
}
.settings-row:hover { background: white; border-color: var(--border-strong); }
.settings-row.bloco-row { grid-template-columns: 28px 36px 1fr 80px auto; }
.settings-row.member-row {
  display: flex; flex-direction: column; align-items: stretch; gap: 10px;
}
.member-row-line1 {
  display: grid; align-items: center; gap: 10px;
  grid-template-columns: 36px 1fr 1fr auto auto auto;
}
.member-admin-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
  font-size: 12px; color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.member-admin-toggle input { accent-color: var(--accent); margin: 0; }
.member-empresas {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding-left: 46px;
  font-size: 12px;
}
.member-empresas-label { color: var(--text-tertiary); font-weight: 600; margin-right: 4px; }
.member-empresas-empty { color: var(--text-tertiary); font-style: italic; }
.empresa-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
  font-size: 12px; color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
}
.empresa-chip:hover { border-color: var(--border-strong); color: var(--text); }
.empresa-chip.active {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent-deep); font-weight: 600;
}
.member-admin-note {
  display: inline-flex; align-items: center; gap: 6px;
  padding-left: 46px;
  font-size: 12px; color: var(--accent-deep); font-style: italic;
}
.member-admin-note i { width: 14px; height: 14px; }

/* Thinner Lucide icons globally — modern, less heavy */
svg.lucide { stroke-width: 1.5; }

/* Hide detail panel + collapse to single column when on Marketing */
body.marketing-mode .detail-panel,
body.marketing-mode .detail-backdrop { display: none; }

/* WhatsApp page: hide task chips (mine/this week/overdue/bloco) — keep
   only the empresa filter so the user can switch stores. */
body.whatsapp-mode .chip[data-filter],
body.whatsapp-mode #bloco-filter-btn,
body.whatsapp-mode .chip-dropdown:has(#bloco-filter-btn) { display: none; }
body.whatsapp-mode .detail-panel,
body.whatsapp-mode .detail-backdrop { display: none; }

/* ============== MARKETING TAB ========================== */
.marketing-view {
  padding: 4px 0 24px;
  display: flex; flex-direction: column; gap: 16px;
  overflow-x: hidden;
  min-width: 0;
}

/* Wide attribute rows (LTV by source, top CTAs) — long labels on desktop,
   stacked on mobile to avoid horizontal overflow */
.attr-row.attr-row-wide-ltv {
  grid-template-columns: 240px minmax(0, 1fr) 80px 110px;
}
.attr-row.attr-row-wide-cta {
  grid-template-columns: 280px minmax(0, 1fr) 60px 60px;
}
@media (max-width: 768px) {
  .attr-row.attr-row-wide-ltv,
  .attr-row.attr-row-wide-cta {
    grid-template-columns: 1fr auto;
    grid-template-areas: "label value" "bar bar" "count count";
    row-gap: 4px;
  }
  .attr-row.attr-row-wide-ltv .attr-label,
  .attr-row.attr-row-wide-cta .attr-label { grid-area: label; }
  .attr-row.attr-row-wide-ltv .attr-bar,
  .attr-row.attr-row-wide-cta .attr-bar { grid-area: bar; }
  .attr-row.attr-row-wide-ltv .attr-value,
  .attr-row.attr-row-wide-cta .attr-value { grid-area: value; text-align: right; }
  .attr-row.attr-row-wide-ltv .attr-count,
  .attr-row.attr-row-wide-cta .attr-count { grid-area: count; font-size: 10.5px; }
}

/* Tabs at top of Marketing page */
.marketing-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.m-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
}
.m-tab:hover { background: var(--subtle); color: var(--text); }
.m-tab.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 600;
}
.m-tab i { width: 14px; height: 14px; }

/* Cohort source filter (chips above retention rows) */
.cohort-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 6px 0 12px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 6px;
}
.cohort-filters-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); font-weight: 600;
  margin-right: 4px;
}
.cohort-chip {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
}
.cohort-chip:hover { border-color: var(--border-strong); color: var(--text); }
.cohort-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
  font-weight: 600;
}

/* Cohort retention rows */
.cohort-grid { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; }
.cohort-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 60px 70px;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
}
.cohort-month { font-weight: 600; color: var(--text); }
.cohort-bar-wrap { height: 16px; background: var(--subtle); border-radius: 5px; overflow: hidden; }
.cohort-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  border-radius: 5px;
}
.cohort-retention { color: var(--text-secondary); font-variant-numeric: tabular-nums; text-align: right; }
.cohort-ltv { color: var(--accent-deep); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.marketing-mock-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(201,154,58,0.10), rgba(201,154,58,0.04));
  border: 1px dashed rgba(201,154,58,0.5);
  border-radius: 10px;
  font-size: 12px; color: #8B6914;
}
.marketing-mock-banner i { width: 14px; height: 14px; flex-shrink: 0; }
.marketing-mock-banner.banner-live {
  background: linear-gradient(90deg, rgba(34,197,94,0.12), rgba(34,197,94,0.04));
  border: 1px solid rgba(34,197,94,0.45);
  color: var(--low-fg);
}
.marketing-mock-banner.banner-loading {
  background: linear-gradient(90deg, rgba(110,91,201,0.10), rgba(110,91,201,0.04));
  border: 1px dashed rgba(110,91,201,0.45);
  color: var(--accent-deep);
}
.marketing-mock-banner.banner-error {
  background: linear-gradient(90deg, rgba(184,57,94,0.12), rgba(184,57,94,0.04));
  border: 1px solid rgba(184,57,94,0.45);
  color: var(--high-fg);
}

.marketing-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.marketing-kpi {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.marketing-kpi .kpi-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); font-weight: 600;
}
.marketing-kpi .kpi-value {
  font-size: 22px; font-weight: 700; letter-spacing: -0.025em;
  color: var(--text);
}
.marketing-kpi .kpi-sub { font-size: 11.5px; color: var(--text-secondary); }
.marketing-kpi-good .kpi-value { color: var(--low-fg); }

.marketing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}
.marketing-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 220px;
  min-width: 0;
}
.marketing-card.marketing-card-wide { grid-column: 1 / -1; }
.marketing-card > header {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.marketing-card > header i { width: 16px; height: 16px; color: var(--accent-deep); flex-shrink: 0; }
.marketing-card > header h3 {
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text); margin: 0; flex: 1; min-width: 0;
}
.marketing-card .card-hint {
  font-size: 11px; color: var(--text-tertiary); font-weight: 500;
}
.marketing-card-empty {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; color: var(--text-tertiary);
  font-style: italic;
  text-align: center;
}

/* Creative tables — wraps in their own horizontal-scroll container so wide
   tables can scroll *inside* the card instead of pushing the whole page. */
.marketing-table-wrap {
  overflow-x: auto;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}
.marketing-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.marketing-table thead th {
  text-align: left; padding: 8px 10px;
  font-size: 10.5px; font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.marketing-table tbody td {
  padding: 10px;
  border-bottom: 1px solid rgba(20,16,31,0.04);
  vertical-align: middle;
}
.marketing-table tbody tr:last-child td { border-bottom: none; }
.marketing-table tbody tr:hover { background: var(--subtle); }
.marketing-table .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

.creative-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.creative-thumb {
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700; color: white; font-size: 14px;
  flex-shrink: 0;
}
.creative-info { display: flex; flex-direction: column; min-width: 0; }
.creative-name {
  font-size: 12.5px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 240px;
}
.creative-adset {
  font-size: 10.5px; color: var(--text-tertiary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 240px;
}
.roas-pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.roas-pill.roas-good { background: var(--low-bg); color: var(--low-fg); }
.roas-pill.roas-mid  { background: var(--med-bg); color: var(--med-fg); }
.roas-pill.roas-bad  { background: var(--high-bg); color: var(--high-fg); }

/* Funnel */
.marketing-funnel { display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.funnel-row {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 90px;
  align-items: center;
  gap: 14px;
}
.funnel-meta { display: flex; flex-direction: column; gap: 2px; }
.funnel-label { font-size: 12.5px; font-weight: 500; color: var(--text); }
.funnel-value { font-size: 11.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.funnel-bar-wrap {
  height: 22px; background: var(--subtle);
  border-radius: 6px; overflow: hidden;
}
.funnel-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  border-radius: 6px;
  transition: width 0.4s ease;
}
.funnel-drop {
  font-size: 11px; color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Attribute performance */
.marketing-attrs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
  padding-top: 4px;
}
.attr-group h4 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); font-weight: 600;
  margin: 0 0 8px;
}
.attr-rows { display: flex; flex-direction: column; gap: 6px; }
.attr-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 50px 70px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.attr-label { color: var(--text); font-weight: 500; }
.attr-bar { height: 8px; background: var(--subtle); border-radius: 4px; overflow: hidden; }
.attr-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  border-radius: 4px;
}
.attr-value { font-weight: 700; color: var(--accent-deep); font-variant-numeric: tabular-nums; }
.attr-count { font-size: 11px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

/* Hide task-only filter chips when on Marketing page */
body.marketing-mode .chip[data-filter],
body.marketing-mode #bloco-filter-btn {
  display: none;
}
body.marketing-mode .chip-dropdown:has(#bloco-filter-btn) { display: none; }

@media (max-width: 1100px) {
  .marketing-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  .marketing-grid { grid-template-columns: minmax(0, 1fr); }
  .marketing-card.marketing-card-wide { grid-column: auto; }
  .marketing-attrs { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: 140px minmax(0, 1fr) 70px; gap: 10px; }
}
@media (max-width: 560px) {
  .marketing-kpis { grid-template-columns: 1fr; }
  .creative-name, .creative-adset { max-width: 140px; }
}

/* Hide management UI when current user is a viewer (set by renderSidebar) */
body.is-viewer .project-menu-foot,
body.is-viewer .nav-item[data-settings-open],
body.is-viewer .settings-tab[data-settings-tab="projects"],
body.is-viewer .settings-tab[data-settings-tab="team"],
body.is-viewer .settings-tab[data-settings-tab="data"] {
  display: none !important;
}

/* Hide Equipa Perf. sidebar entry when user is a viewer that's not on the team */
body.is-viewer:not(.is-team) .nav-item[data-page-nav="analytics"] {
  display: none !important;
}

/* Manuais visible to admin / team / partner — hidden for plain viewer */
body.is-viewer:not(.is-team):not(.is-partner) .nav-item[data-page-nav="manuals"] {
  display: none !important;
}

/* "Gerar tarefas" button is admin-only — hide for everyone else */
body.is-viewer [data-action="brainstorm-open"] {
  display: none !important;
}

/* Brainstorm modal — channels chips */
.bs-channels {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.bs-channel {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px; color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all 0.12s ease;
}
.bs-channel input { accent-color: var(--accent); margin: 0; }
.bs-channel.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
  font-weight: 600;
}
.brainstorm-loading {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 40px 20px;
  font-size: 13px; color: var(--text-secondary);
}

/* Brainstorm chat */
.bs-chat-header {
  padding: 8px 0 12px;
  font-size: 12px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.bs-chat-msgs {
  display: flex; flex-direction: column; gap: 8px;
  min-height: 240px; max-height: 380px;
  overflow-y: auto;
  padding: 8px 4px;
}
.bs-msg { display: flex; }
.bs-msg-user { justify-content: flex-end; }
.bs-msg-assistant { justify-content: flex-start; }
.bs-msg-bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px; line-height: 1.5;
}
.bs-msg-user .bs-msg-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}
.bs-msg-assistant .bs-msg-bubble {
  background: var(--subtle);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bs-msg-typing { letter-spacing: 0.2em; opacity: 0.6; animation: bs-typing 1s ease-in-out infinite; }
@keyframes bs-typing {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}

.bs-chat-hint {
  padding: 8px 12px;
  background: rgba(110, 91, 201, 0.06);
  border: 1px dashed rgba(110, 91, 201, 0.4);
  border-radius: 8px;
  font-size: 11.5px; color: var(--accent-deep);
  margin: 8px 0;
}
.bs-chat-input {
  display: flex; gap: 8px; align-items: flex-end;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
.bs-chat-input textarea {
  flex: 1;
  font: inherit; font-size: 13.5px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  resize: none;
  outline: none;
}
.bs-chat-input textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10);
}
.bs-chat-input .btn { padding: 10px 14px; flex-shrink: 0; }

/* Brainstorm proposals list */
.bs-proposals { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.bs-proposal {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 14px;
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.12s ease;
}
.bs-proposal.rejected { opacity: 0.45; }
.bs-proposal-check { display: flex; align-items: flex-start; padding-top: 4px; }
.bs-proposal-check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.bs-proposal-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bs-proposal-title {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text);
  border: 1px solid transparent; background: transparent;
  padding: 4px 6px; margin: -4px -6px;
  border-radius: 6px;
  outline: none;
}
.bs-proposal-title:hover { background: white; }
.bs-proposal-title:focus { background: white; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(110,91,201,0.10); }
.bs-proposal-desc { font-size: 12.5px; color: var(--text-secondary); margin: 0; line-height: 1.45; }
.bs-proposal-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.bs-pill {
  display: inline-block;
  padding: 3px 9px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  color: var(--text-secondary);
}
.bs-pill-mode { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent); }
.bs-proposal-draft { margin-top: 6px; }
.bs-proposal-draft summary {
  font-size: 11.5px; color: var(--text-tertiary); cursor: pointer;
  font-weight: 600;
}
.bs-proposal-draft summary:hover { color: var(--accent-deep); }
.bs-proposal-draft pre {
  margin: 6px 0 0; padding: 10px 12px;
  background: white; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; line-height: 1.5; color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  white-space: pre-wrap;
  max-height: 280px; overflow-y: auto;
}
.bs-proposal-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.bs-ctrl {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 10.5px; color: var(--text-tertiary);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.bs-ctrl select, .bs-ctrl input {
  padding: 6px 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text);
  text-transform: none; letter-spacing: 0;
}
.bs-ctrl select:focus, .bs-ctrl input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(110,91,201,0.10);
}

/* ============== MANUAIS (empresa context for AI agents) =============== */
.manuals-view {
  padding: 4px 0 24px;
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
.manual-savebar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 880px;
}
.manual-savebar.is-dirty {
  background: #fff8ec;
  border-color: #f4cf85;
}
.manual-savebar-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
}
.manual-savebar.is-dirty .manual-savebar-status { color: #8a5a13; }
.manual-savebar-status i { width: 16px; height: 16px; }
.manual-savebar-actions { display: flex; gap: 8px; }
.manuals-form {
  display: flex; flex-direction: column; gap: 14px;
  max-width: 880px;
}
.manual-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.manual-section-head h3 {
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em;
  color: var(--text); margin: 0;
}
.manual-hint {
  font-size: 11.5px; color: var(--text-tertiary); margin: 2px 0 0;
  line-height: 1.45;
}
.manual-section textarea {
  font-family: inherit; font-size: 13.5px;
  color: var(--text); line-height: 1.55;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  resize: vertical;
  min-height: 90px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.manual-section textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10);
}
.manuals-form.manuals-readonly textarea {
  background: var(--subtle);
  color: var(--text-secondary);
  cursor: default;
}

/* ============== TASK DRAFTS (per-task variants) ====================== */
/* Hidden for sócios — drafts are internal team content production */
body.is-partner .drafts-section { display: none; }

.drafts-section .section-row { display: flex; align-items: center; gap: 8px; }
.drafts-empty {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  background: var(--subtle);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  font-size: 12px; color: var(--text-tertiary);
  font-style: italic;
}
.drafts-empty i { width: 14px; height: 14px; flex-shrink: 0; }

.drafts-list {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 4px;
}
.draft-card {
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.draft-card:hover { background: var(--card-hover); border-color: var(--border-strong); }
.draft-card.selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft) 0%, white 60%);
  box-shadow: 0 0 0 2px rgba(110, 91, 201, 0.10);
}
.draft-head {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.draft-head .meta-select {
  padding: 4px 22px 4px 10px;
  font-size: 11.5px;
}
.draft-meta {
  font-size: 11px; color: var(--text-tertiary);
  font-weight: 500;
}
.draft-card.selected .draft-head .icon-btn[data-draft-select] i { color: #C99A3A; }
.draft-card.selected .draft-head .icon-btn[data-draft-select] {
  background: rgba(201, 154, 58, 0.10);
}
.draft-body {
  font-family: inherit; font-size: 13.5px;
  color: var(--text); line-height: 1.55;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  resize: vertical;
  min-height: 90px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.draft-body:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10);
}

.draft-card.generating .draft-body { opacity: 0.6; pointer-events: none; }
.draft-card.generating .draft-head .btn { opacity: 0.7; }

/* Generate button: pulsing icon while generating */
.draft-head .btn[data-draft-generate] i { width: 13px; height: 13px; }
.draft-card.generating .draft-head [data-draft-generate] i {
  animation: draft-spin 1s linear infinite;
}
@keyframes draft-spin { to { transform: rotate(360deg); } }

/* Rating row */
.draft-rating {
  display: flex; align-items: center; gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.draft-rating-label {
  font-size: 11.5px; color: var(--text-tertiary); font-weight: 500;
  margin-right: 2px;
}
.draft-rate-btn {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.12s ease;
}
.draft-rate-btn:hover { background: var(--subtle); color: var(--text); }
.draft-rate-btn i { width: 14px; height: 14px; }
.draft-rate-btn.active.good { background: var(--low-bg); border-color: rgba(34,197,94,0.45); color: var(--low-fg); }
.draft-rate-btn.active.bad  { background: var(--high-bg); border-color: rgba(184,57,94,0.45); color: var(--high-fg); }
.draft-rating-version {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-deep); color: var(--text-tertiary);
  padding: 2px 7px; border-radius: 5px;
  margin-left: auto;
}
.draft-rating-comment {
  font: inherit; font-size: 12.5px;
  padding: 8px 10px;
  border: 1px solid rgba(184,57,94,0.30);
  background: rgba(184,57,94,0.04);
  border-radius: 8px;
  color: var(--text);
  resize: vertical;
  outline: none;
}
.draft-rating-comment:focus {
  border-color: var(--high-fg);
  box-shadow: 0 0 0 2px rgba(184,57,94,0.10);
}
.manuals-form.manuals-readonly input,
.manuals-form.manuals-readonly .icon-btn[data-resource-remove],
.manuals-form.manuals-readonly [data-action="resource-add"] {
  pointer-events: none;
}

.manual-resources {
  display: flex; flex-direction: column; gap: 8px;
}
.manual-resource-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1.5fr) auto auto;
  align-items: center;
  gap: 8px;
}
.manual-resource-icon {
  width: 18px; height: 18px;
  color: var(--text-secondary);
  justify-self: center;
}
.manual-resource-row input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit; font-size: 13px;
  background: white;
  color: var(--text);
  outline: none;
}
.manual-resource-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(110, 91, 201, 0.10);
}
.manual-resource-row a.icon-btn,
.manual-resource-row .icon-btn {
  width: 32px; height: 32px;
}
@media (max-width: 768px) {
  .manual-resource-row {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    grid-template-areas: "icon label remove" "icon url url" "icon open open";
    row-gap: 4px;
  }
  .manual-resource-icon { grid-area: icon; }
  .manual-resource-row > input[data-resource-label] { grid-area: label; }
  .manual-resource-row > input[data-resource-url] { grid-area: url; }
  .manual-resource-row > a { grid-area: open; }
  .manual-resource-row > button { grid-area: remove; }
}

/* === Sidebar visibility per user role ============================== */
/* Pending inbox: only admin or team member sees it */
body.is-viewer:not(.is-team) .nav-item[data-page-nav="pending-inbox"] {
  display: none !important;
}
/* Briefing + Os meus pedidos: sócios e CS */
body:not(.is-partner):not(.is-cs) .nav-item[data-page-nav="briefing"],
body:not(.is-partner):not(.is-cs) .nav-item[data-page-nav="my-requests"] {
  display: none !important;
}

/* CS = Customer Service: vê Tarefas (das suas empresas), Pedir tarefa,
   Os meus pedidos, WhatsApp, Manuais. Esconde Arquivadas, Pedidos
   pendentes, Analíticos, Equipa Perf., Settings. */
body.is-cs .nav-item[data-page-nav="archived"],
body.is-cs .nav-item[data-page-nav="pending-inbox"],
body.is-cs .nav-item[data-page-nav="marketing"],
body.is-cs .nav-item[data-page-nav="analytics"],
body.is-cs .nav-item[data-settings-open] {
  display: none !important;
}
/* Sócios don't see board/archived/equipa-perf/settings/project-switcher/search */
body.is-partner .nav-item[data-page-nav="board"],
body.is-partner .nav-item[data-page-nav="archived"],
body.is-partner .nav-item[data-page-nav="analytics"],
body.is-partner .nav-item[data-settings-open],
body.is-partner #project-switcher,
body.is-partner .bcrumb-project,
body.is-partner .search-mini {
  display: none !important;
}
/* Sócios can edit fields on tasks they created — no read-only lock. The
   detail-actions render shows a 'Cancelar pedido' button instead of the
   team's Marcar-como-concluída / Apagar (handled in renderDetail). */

/* Pending badge in sidebar entry — circular, compact */
.nav-item .nav-badge {
  margin-left: auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  background: #E75B5B;
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  line-height: 1;
}

/* === Briefing form (sócio "Pedir tarefa") ========================== */
.briefing-form { padding: 4px 0 24px; }
.briefing-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 14px;
  max-width: 760px;
}
.briefing-card > header {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.briefing-card > header i { width: 16px; height: 16px; color: var(--accent-deep); flex-shrink: 0; }
.briefing-card > header h3 {
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text); margin: 0;
}
.briefing-hint { font-size: 12.5px; color: var(--text-secondary); margin: 0; line-height: 1.5; }
.briefing-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.briefing-row { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.briefing-row.briefing-row-full { grid-column: 1 / -1; }
.briefing-row > span {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-tertiary); font-weight: 600;
}
.briefing-row input[type="text"],
.briefing-row input[type="date"],
.briefing-row select,
.briefing-row textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  font-family: inherit;
  background: white;
  color: var(--text);
  outline: none;
  resize: vertical;
}
.briefing-row input:focus,
.briefing-row select:focus,
.briefing-row textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10);
}
.briefing-row > .subtasks { padding: 0; margin: 0; }
.briefing-row > .subtasks .subtask {
  background: var(--subtle);
  border: 1px solid var(--border);
}
.briefing-row > .subtasks .subtask:hover { background: white; border-color: var(--border-strong); }
.briefing-row > .subtasks .subtask-add { background: transparent; border: 1px dashed var(--border-strong); }
.briefing-row > .subtasks .subtask-add input { background: transparent; border: none; outline: none; flex: 1; font: inherit; font-size: 13px; }
.briefing-row > .subtasks .subtask-remove { opacity: 1; }

/* Attachments inside briefing form */
.briefing-attachments {
  display: flex; flex-direction: column; gap: 6px;
}
.briefing-attach-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
}
.briefing-attach-row > i { width: 14px; height: 14px; color: var(--text-secondary); flex-shrink: 0; }
.briefing-attach-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.briefing-attach-size { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }
.briefing-attach-remove {
  background: transparent; border: none; cursor: pointer;
  padding: 3px; border-radius: 5px;
  color: var(--text-tertiary); flex-shrink: 0;
}
.briefing-attach-remove:hover { background: var(--high-bg); color: var(--high-fg); }
.briefing-attach-remove i { width: 12px; height: 12px; }
.briefing-attach-pick {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: 10px;
  font-size: 12.5px; font-weight: 500;
  color: var(--accent-deep);
  cursor: pointer;
  width: fit-content;
  margin-top: 4px;
  transition: all 0.12s ease;
}
.briefing-attach-pick:hover { background: #DDD3F5; }
.briefing-attach-pick i { width: 14px; height: 14px; }
.briefing-attach-pick input[type="file"] { display: none; }

.briefing-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding-top: 8px; border-top: 1px solid var(--border);
}
@media (max-width: 768px) {
  .briefing-grid { grid-template-columns: 1fr; }
  .briefing-actions { flex-direction: column-reverse; }
  .briefing-actions .btn { width: 100%; justify-content: center; }
}

/* === Os meus pedidos / Pending inbox ============================== */
.my-requests-view, .pending-inbox-view { padding: 4px 0 24px; }
.my-req-list, .pending-list {
  display: flex; flex-direction: column; gap: 8px;
}
.my-req-row, .pending-row {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.my-req-row:hover, .pending-row:hover {
  border-color: var(--border-strong);
  background: var(--card-hover);
}
.my-req-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.my-req-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-size: 11.5px; color: var(--text-tertiary);
}
.my-req-meta i { width: 12px; height: 12px; vertical-align: -1px; margin-right: 3px; }
.my-req-date { display: inline-flex; align-items: center; gap: 4px; }

.status-pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.01em;
}
.status-pill.status-good     { background: var(--low-bg);  color: var(--low-fg); }
.status-pill.status-progress { background: var(--accent-soft); color: var(--accent-deep); }
.status-pill.status-warn     { background: var(--high-bg); color: var(--high-fg); }
.status-pill.status-neutral  { background: var(--bg-deep); color: var(--text-secondary); }

.pending-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}
.pending-info { min-width: 0; }
.pending-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.pending-meta {
  display: flex; flex-wrap: wrap; gap: 12px;
  font-size: 11.5px; color: var(--text-tertiary);
}
.pending-meta span { display: inline-flex; align-items: center; gap: 4px; }
.pending-meta i { width: 12px; height: 12px; }
.pending-actions { display: flex; gap: 8px; flex-shrink: 0; }
@media (max-width: 768px) {
  .pending-row { grid-template-columns: 1fr; }
  .pending-actions { flex-wrap: wrap; }
  .pending-actions .btn { flex: 1; justify-content: center; min-width: 120px; }
}

/* ============== EQUIPA PERF. (POINTS) ================== */
.points-view {
  padding: 4px 0 24px;
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
.points-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.points-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0;
}
.points-card > header {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.points-card > header i { width: 16px; height: 16px; color: var(--accent-deep); flex-shrink: 0; }
.points-card > header h3 {
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text); margin: 0; flex: 1; min-width: 0;
}
.points-card > header .card-hint {
  font-size: 11px; color: var(--text-tertiary); font-weight: 500;
}
.points-card-good .points-card-value { color: var(--low-fg); }
.points-card-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); font-weight: 600;
}
.points-card-value {
  font-size: 28px; font-weight: 700; letter-spacing: -0.025em;
  color: var(--text);
}
.points-card-sub { font-size: 11.5px; color: var(--text-secondary); }

/* Leaderboard (admin view) */
.leaderboard { display: flex; flex-direction: column; gap: 6px; }
.leaderboard-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) auto minmax(0, 2fr);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.leaderboard-row:hover { background: white; border-color: var(--border-strong); }
.lb-member { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lb-name { font-size: 14px; font-weight: 600; color: var(--text); }
.lb-role { font-size: 11.5px; color: var(--text-tertiary); }
.lb-total {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}
.lb-total-unit { font-size: 11px; color: var(--text-tertiary); font-weight: 500; margin-left: 4px; }
.lb-breakdown { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.lb-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  color: var(--text-secondary);
}
.lb-pill i { width: 12px; height: 12px; }

/* Rules section */
.points-card.points-card-rules .rules-body {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
}
.rules-section h4 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); font-weight: 600;
  margin: 0 0 8px;
}
.rules-section ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12.5px; color: var(--text-secondary); line-height: 1.5;
}
.rules-section ul li::before { content: '· '; color: var(--text-tertiary); }
.rules-hint { font-size: 12px; color: var(--text-secondary); margin: 0 0 10px; line-height: 1.5; }

.kpi-list { display: flex; flex-direction: column; gap: 6px; }
.kpi-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 50px minmax(0, 1fr) 60px 80px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.kpi-name { color: var(--text); font-weight: 500; }
.kpi-weight {
  font-weight: 700; color: var(--accent-deep);
  font-variant-numeric: tabular-nums; text-align: right;
}
.kpi-bar { height: 8px; background: var(--subtle); border-radius: 4px; overflow: hidden; }
.kpi-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  border-radius: 4px;
}
.kpi-current { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.kpi-target { font-size: 11px; color: var(--text-tertiary); }

@media (max-width: 1100px) {
  .points-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  .points-summary { grid-template-columns: 1fr; }
  .leaderboard-row { grid-template-columns: 1fr; gap: 8px; text-align: left; }
  .lb-breakdown { justify-content: flex-start; }
  .points-card.points-card-rules .rules-body { grid-template-columns: 1fr; }
  .kpi-row {
    grid-template-columns: 1fr 50px;
    grid-template-areas: "name weight" "bar bar" "current target";
    row-gap: 4px;
  }
  .kpi-name { grid-area: name; }
  .kpi-weight { grid-area: weight; }
  .kpi-bar { grid-area: bar; }
  .kpi-current { grid-area: current; text-align: left; }
  .kpi-target { grid-area: target; text-align: right; }
}

.settings-row .settings-key {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px; font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}
.settings-row input[type="text"] {
  border: 1px solid transparent; background: transparent;
  font: inherit; font-size: 13px; color: inherit;
  padding: 5px 8px; border-radius: 6px; outline: none;
  width: 100%;
  transition: all 0.12s ease;
}
.settings-row input[type="text"]:focus {
  background: white; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10);
}
.settings-row input[type="color"] {
  appearance: none; -webkit-appearance: none;
  width: 36px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}
.settings-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.settings-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
.settings-row .task-count {
  font-size: 11px; font-weight: 500; color: var(--text-tertiary);
  text-align: center;
}
.settings-row .icon-btn:hover { background: var(--high-bg); color: var(--high-fg); }
.settings-row .icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.settings-section + .settings-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.settings-data-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--subtle); border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
}
.settings-data-card .info { flex: 1; min-width: 0; }
.settings-data-card .title { font-size: 13.5px; font-weight: 600; }
.settings-data-card .desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; line-height: 1.45; }

.storage-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 12px;
}
.storage-stat {
  background: var(--subtle); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
}
.storage-stat .stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-secondary); font-weight: 600; }
.storage-stat .stat-value {
  font-size: 18px; font-weight: 700; letter-spacing: -0.015em;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ============== FILE ATTACHMENTS ===================== */
.attachments-area { display: flex; flex-direction: column; gap: 10px; }
.attachments-empty {
  text-align: center; padding: 24px;
  color: var(--text-tertiary); font-size: 12.5px;
  border: 1px dashed var(--border-strong); border-radius: 12px;
}
.attachments-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 0;
}
.attachments-hint { font-size: 11.5px; color: var(--text-tertiary); }
.attachment .download-btn,
.attachment .remove-btn {
  width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent;
  color: var(--text-secondary);
  transition: all 0.12s ease;
  cursor: pointer;
}
.attachment .download-btn:hover { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent); }
.attachment .remove-btn:hover { background: var(--high-bg); color: var(--high-fg); border-color: var(--high-fg); }
.attachment .remove-btn i,
.attachment .download-btn i { width: 13px; height: 13px; }

.attachment-thumb {
  width: 32px; height: 32px; border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ============== ANALYTICS PAGE ======================== */
.analytics-view { display: flex; flex-direction: column; gap: 20px; }

.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.analytics-kpi {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}
.analytics-kpi .kpi-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-secondary); font-weight: 600;
}
.analytics-kpi .kpi-value {
  font-size: 24px; font-weight: 700; letter-spacing: -0.025em;
  margin-top: 6px; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.analytics-kpi .kpi-sub {
  font-size: 11.5px; color: var(--text-secondary); margin-top: 4px;
}
.analytics-kpi .kpi-icon {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  margin-bottom: 8px;
}

.analytics-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
@media (max-width: 1100px) { .analytics-row { grid-template-columns: 1fr; } }

.analytics-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
}
.analytics-card h3 {
  font-size: 14px; font-weight: 600; letter-spacing: -0.005em;
  margin-bottom: 4px;
}
.analytics-card .card-sub {
  font-size: 12px; color: var(--text-secondary); margin-bottom: 14px;
}

/* CSS bar list */
.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-row {
  display: grid; grid-template-columns: 130px 1fr 90px;
  align-items: center; gap: 12px;
  font-size: 12.5px;
}
.bar-label {
  display: flex; align-items: center; gap: 8px;
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-label .lbl-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bar-track {
  background: var(--subtle);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s cubic-bezier(.25,.8,.25,1);
}
.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600; color: var(--text);
}
.bar-value .bar-pct { color: var(--text-tertiary); font-weight: 500; margin-left: 4px; font-size: 11px; }

/* Top tasks list */
.top-tasks { display: flex; flex-direction: column; gap: 10px; }
.top-task {
  display: grid; grid-template-columns: 30px 1fr auto auto; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--subtle); border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.top-task:hover { background: white; border-color: var(--border-strong); }
.top-task .rank {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px; color: var(--text-tertiary); font-weight: 700;
  text-align: center;
}
.top-task .title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-task .time { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============== MEETING MODAL ======================== */
.meeting-tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--subtle); border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 18px;
  width: fit-content;
}
.meeting-tab {
  padding: 7px 14px; border-radius: 7px;
  border: none; background: transparent;
  font: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s ease;
}
.meeting-tab:hover { color: var(--text); }
.meeting-tab.active { background: white; color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.meeting-tab i { width: 13px; height: 13px; }

.recorder {
  display: flex; flex-direction: column; gap: 14px;
}
.recorder-controls {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--subtle);
  border: 1px solid var(--border);
}
.recorder-controls.recording {
  background: linear-gradient(135deg, rgba(184, 57, 94, 0.06) 0%, rgba(255, 224, 236, 0.4) 100%);
  border-color: rgba(184, 57, 94, 0.2);
}
.rec-btn {
  width: 48px; height: 48px; border-radius: 50%;
  border: none;
  background: var(--high-fg); color: white;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px -4px rgba(184, 57, 94, 0.5);
  transition: all 0.15s ease;
}
.rec-btn:hover { transform: scale(1.05); }
.rec-btn:active { transform: scale(0.95); }
.rec-btn i { width: 20px; height: 20px; }
.rec-btn.idle { background: var(--accent); box-shadow: 0 4px 14px -4px rgba(110, 91, 201, 0.5); }
.rec-btn.idle:hover { background: var(--accent-deep); }

.rec-info { flex: 1; min-width: 0; }
.rec-status {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-secondary); font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.recorder-controls.recording .rec-status { color: var(--high-fg); }
.recorder-controls.recording .rec-status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--high-fg);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
.rec-time {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.rec-hint { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }

.transcript-area {
  border: 1px solid var(--border); background: white;
  border-radius: 12px;
  padding: 14px 16px;
  min-height: 200px; max-height: 320px;
  overflow-y: auto;
  font-size: 13px; line-height: 1.55;
}
.transcript-area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10); }
.transcript-area .interim { color: var(--text-tertiary); font-style: italic; }
.transcript-area:empty::before {
  content: "A transcrição vai aparecer aqui em tempo real…";
  color: var(--text-tertiary);
  font-style: italic;
}

.transcript-paste {
  display: flex; flex-direction: column; gap: 10px;
}
.transcript-paste textarea {
  width: 100%; min-height: 220px;
  padding: 12px 14px;
  border: 1px solid var(--border); background: var(--subtle);
  border-radius: 12px;
  font: inherit; font-size: 13px; line-height: 1.55;
  outline: none; resize: vertical;
  color: var(--text);
}
.transcript-paste textarea:focus { border-color: var(--accent); background: white; box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.10); }
.transcript-paste-actions { display: flex; gap: 10px; align-items: center; }
.transcript-paste .hint { font-size: 11.5px; color: var(--text-tertiary); }

.meeting-status-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid rgba(110, 91, 201, 0.2);
  margin-bottom: 14px;
}
.meeting-status-card .icon-bg {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: white;
  flex-shrink: 0;
}
.meeting-status-card .title { font-size: 13.5px; font-weight: 600; color: var(--accent-deep); }
.meeting-status-card .text { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; line-height: 1.5; }

.meeting-loading {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 60px 20px;
  text-align: center;
}
.meeting-loading .spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin-animation 0.8s linear infinite;
}
@keyframes spin-animation { to { transform: rotate(360deg); } }
.meeting-loading .label { font-size: 14px; font-weight: 500; }
.meeting-loading .sub { font-size: 12px; color: var(--text-secondary); }

.meeting-error {
  padding: 14px 16px; border-radius: 12px;
  background: var(--high-bg); color: var(--high-fg);
  border: 1px solid rgba(184, 57, 94, 0.2);
  font-size: 12.5px; line-height: 1.5;
}

/* Review UI */
.review-summary {
  padding: 14px 16px; border-radius: 12px;
  background: var(--subtle); border: 1px solid var(--border);
  font-size: 13px; line-height: 1.55;
  margin-bottom: 18px;
  display: flex; gap: 12px; align-items: flex-start;
}
.review-summary i { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; margin-top: 2px; }

.review-section { margin-bottom: 22px; }
.review-section h4 {
  font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.review-section h4 .pill {
  font-size: 11px; padding: 2px 8px; border-radius: 6px;
  font-weight: 600;
  background: var(--accent-soft); color: var(--accent-deep);
}

.review-list { display: flex; flex-direction: column; gap: 10px; }

.review-item {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 12px;
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.15s ease;
}
.review-item:hover { border-color: var(--border-strong); }
.review-item.unchecked { opacity: 0.55; background: var(--subtle); }

.review-checkbox {
  appearance: none;
  width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  cursor: pointer; margin-top: 2px;
  position: relative;
  transition: all 0.15s ease;
}
.review-checkbox:checked { background: var(--accent); border-color: var(--accent); }
.review-checkbox:checked::after {
  content: ""; position: absolute; left: 5px; top: 2px;
  width: 5px; height: 9px; border: 2px solid white; border-top: 0; border-left: 0;
  transform: rotate(45deg);
}

.review-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }

.review-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.review-title-input {
  flex: 1; min-width: 200px;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--text);
  background: transparent; border: 1px solid transparent;
  padding: 4px 8px; margin: -4px -8px;
  border-radius: 6px; outline: none;
  transition: all 0.12s ease;
}
.review-title-input:hover { background: var(--subtle); }
.review-title-input:focus { background: white; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(110, 91, 201, 0.12); }

.review-meta-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.review-reasoning {
  font-size: 11.5px; color: var(--text-tertiary);
  line-height: 1.45;
  display: flex; gap: 6px; align-items: flex-start;
  font-style: italic;
}
.review-reasoning i { width: 11px; height: 11px; flex-shrink: 0; margin-top: 2px; }

.review-edit-line {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 12px;
  background: var(--subtle); padding: 6px 10px; border-radius: 8px;
}
.review-edit-line .from { color: var(--text-tertiary); text-decoration: line-through; }
.review-edit-line .to { color: var(--accent-deep); font-weight: 600; }
.review-edit-line .arrow { color: var(--text-tertiary); }
.review-edit-line .field { color: var(--text-secondary); font-weight: 500; }

.review-actions { display: flex; gap: 6px; align-items: flex-start; }

/* Settings AI tab */
.api-key-card { display: flex; flex-direction: column; gap: 8px; }
.api-key-row {
  display: flex; gap: 8px; align-items: center;
}
.api-key-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border); background: var(--subtle);
  border-radius: 10px;
  font: inherit; font-size: 13px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  outline: none;
  transition: all 0.15s ease;
}
.api-key-input:focus { border-color: var(--accent); background: white; box-shadow: 0 0 0 3px rgba(110, 91, 201, 0.12); }
.api-key-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500;
  padding: 4px 10px; border-radius: 999px;
}
.api-key-status.set { background: var(--low-bg); color: var(--low-fg); }
.api-key-status.unset { background: var(--high-bg); color: var(--high-fg); }
.api-key-status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============== TOAST ================================ */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: white;
  padding: 12px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast i { width: 16px; height: 16px; color: var(--state-done); }

/* ============== RESPONSIVE =========================== */
/* Drawer width — narrower on tablets, full-width on phones. The panel
   is fixed/slide-in at every breakpoint (see base .detail-panel rule). */
@media (max-width: 1100px) {
  .detail-panel { max-width: 480px; }
  /* Switch to back-arrow affordance instead of X close on drawer/full-screen modes */
  .back-btn { display: inline-grid; place-items: center; }
  .close-x-btn { display: none; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%); transition: transform 0.2s ease;
    z-index: 80;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex !important; }
  .sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 75;
    animation: fadeIn 0.18s ease;
  }
  .main { margin-left: 0; }
  .topbar { padding-left: 12px; padding-right: 12px; gap: 6px; }
  .tasks-area { padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); }
  .view-toggle .view-btn span { display: none; }
  .bcrumb-item:not(.active) { display: none; }
  /* Full-screen task panel on mobile (covers topbar) */
  .detail-panel {
    top: 0;
    max-width: none;
    z-index: 90;
  }
  .detail-backdrop {
    inset: 0;
    z-index: 85;
  }
  /* Bigger touch targets */
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn i { width: 18px; height: 18px; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============== DROPDOWN BOTTOM-SHEET (mobile) ============= */
/* Applied by JS positionDropdown() when window.innerWidth <= 640.
   Overrides each dropdown's default desktop positioning so it
   slides up from the bottom of the viewport like a native sheet. */
.dropdown-bottomsheet {
  position: fixed !important;
  inset: auto 0 0 0 !important;
  width: 100% !important;
  max-width: none !important;
  max-height: 70dvh !important;
  border-radius: 16px 16px 0 0 !important;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15) !important;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)) !important;
  z-index: 200 !important;
  animation: dropdown-slide-up 0.22s ease;
  overflow-y: auto;
}
@keyframes dropdown-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
/* Touch-friendly rows when a menu is presented as a bottom-sheet */
.dropdown-bottomsheet .dropdown-item,
.dropdown-bottomsheet .project-menu-item,
.dropdown-bottomsheet .project-menu-foot button {
  padding: 14px 16px !important;
  font-size: 14px !important;
  min-height: 48px;
  border-radius: 10px !important;
}
.dropdown-bottomsheet .project-menu-head,
.dropdown-bottomsheet .dropdown-section-head {
  padding: 12px 16px 6px !important;
  font-size: 11.5px !important;
}
.dropdown-bottomsheet .project-menu-list {
  max-height: none !important;
}

/* Hamburger button — only visible on mobile (made visible inside the media query) */
.menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  flex-shrink: 0;
}
.menu-btn:hover { background: var(--subtle); }
.menu-btn i { width: 18px; height: 18px; }
.sidebar-backdrop { display: block; }
.sidebar-backdrop[hidden] { display: none; }

/* Import target project selector at the top of the import modal */
.import-target-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.import-target-row label { font-weight: 600; color: var(--text); }
.import-target-row select {
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: white;
  font-size: 13px; color: var(--text);
}
.import-target-hint { font-size: 11.5px; color: var(--text-tertiary); flex: 1; min-width: 200px; }

/* Notification bell + dropdown */
.notif-wrap { position: relative; display: inline-flex; }
.notif-btn { position: relative; }
.notif-badge {
  position: absolute;
  top: -3px; right: -3px;
  background: #E75B5B;
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
  line-height: 1.4;
  pointer-events: none;
}
.notif-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(360px, calc(100vw - 16px));
  max-height: 480px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.10);
  overflow: hidden;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.notif-dropdown[hidden] { display: none; }
.notif-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  flex-shrink: 0;
}
.notif-mark-all {
  background: none;
  border: none;
  color: var(--accent-deep, #5B5FEF);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  cursor: pointer;
  position: relative;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--subtle); }
.notif-item.unread { background: rgba(91, 95, 239, 0.04); }
.notif-icon { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; margin-top: 2px; }
.notif-body { flex: 1; min-width: 0; }
.notif-message { font-size: 13px; color: var(--text); line-height: 1.4; }
.notif-time { font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #E75B5B;
  flex-shrink: 0;
  margin-top: 6px;
}
.notif-empty { padding: 32px 16px; text-align: center; color: var(--text-tertiary); font-size: 13px; }

/* @-mention autocomplete dropdown */
.comment-input { position: relative; }
.mention-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 56px; /* leave room for the Send button */
  max-width: 320px;
  max-height: 240px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.10);
  padding: 4px;
  z-index: 60;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.mention-item:hover, .mention-item.active { background: var(--subtle); }
.mention-meta { display: flex; flex-direction: column; min-width: 0; }
.mention-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.mention-email { font-size: 11px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* @-mention chip in comment text */
.mention {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(91, 95, 239, 0.10);
  color: var(--accent-deep, #5B5FEF);
  font-weight: 600;
  font-size: 0.95em;
}

/* New-task modal form */
.new-task-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.new-task-form .form-row { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.new-task-form .form-row-full { grid-column: 1 / -1; }
.new-task-form .form-row span { font-size: 12px; color: var(--text-tertiary); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
.new-task-form input[type="text"],
.new-task-form input[type="date"],
.new-task-form select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: white;
  color: var(--text);
}
.new-task-form input[type="text"]:focus,
.new-task-form input[type="date"]:focus,
.new-task-form select:focus {
  outline: none;
  border-color: var(--accent-deep, #5B5FEF);
  box-shadow: 0 0 0 3px rgba(91, 95, 239, 0.12);
}
@media (max-width: 560px) {
  .new-task-form { grid-template-columns: 1fr; }
}

/* ============== APP LOADING STATE ====================== */
/* Shown briefly while we fetch the workspace state from Supabase. */
body.loading .app { visibility: hidden; }
body.loading::before {
  content: '';
  position: fixed; inset: 0;
  background: var(--bg, #fafaf9);
  z-index: 800;
  pointer-events: none;
}
body.loading::after {
  content: '';
  position: fixed; top: 50%; left: 50%;
  width: 32px; height: 32px;
  margin: -16px 0 0 -16px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-deep, #5B5FEF);
  border-radius: 50%;
  z-index: 801;
  animation: auth-spin 0.7s linear infinite;
}

/* ============== AUTH OVERLAY ============================ */
.auth-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #F4F0FF 0%, #FFFFFF 60%, #E8F4FF 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.auth-overlay[hidden] { display: none; }
.auth-card {
  width: 100%; max-width: 380px;
  background: white;
  border-radius: 18px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.04);
  padding: 32px 28px;
  text-align: center;
}
.auth-brand {
  font-weight: 700; font-size: 14px; letter-spacing: 0.5px;
  color: var(--accent-deep, #5B5FEF);
  margin-bottom: 28px;
  text-transform: uppercase;
}
.auth-state { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.auth-state[hidden] { display: none; }
.auth-state h2 {
  font-size: 21px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text);
  margin: 0;
}
.auth-muted { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; margin: 0; }
.auth-muted strong { color: var(--text); font-weight: 600; }
.auth-icon { width: 36px; height: 36px; }
.auth-icon.ok { color: #2D7A4D; }
.auth-icon.err { color: #B8395E; }

.auth-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-deep, #5B5FEF);
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

#auth-form {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%;
  margin-top: 4px;
}
#auth-form input[type="email"] {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: white;
  color: var(--text);
}
#auth-form input[type="email"]:focus {
  outline: none;
  border-color: var(--accent-deep, #5B5FEF);
  box-shadow: 0 0 0 3px rgba(91, 95, 239, 0.12);
}
#auth-form .btn { padding: 12px; font-size: 14px; }

#auth-try-again { margin-top: 6px; }

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; max-width: 100%; }
  .auth-state h2 { font-size: 19px; }
}

/* ===== Realtime status badge (visible only when disconnected) ===== */
.realtime-status-badge {
  position: fixed; bottom: 16px; right: 16px;
  z-index: 9999;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  animation: realtime-pulse 2s ease-in-out infinite;
}
.realtime-status-badge i { width: 14px; height: 14px; }
@keyframes realtime-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ===== Instagram Organic tab ====================================== */
.ig-range-tabs {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 14px;
}
.ig-range-tab {
  background: transparent; border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 12.5px; color: var(--text-secondary);
  transition: all 0.15s;
}
.ig-range-tab:hover { background: var(--surface-2); }
.ig-range-tab.active {
  background: var(--accent-deep); color: #fff; border-color: var(--accent-deep);
}
.ig-range-meta {
  margin-left: auto; font-size: 12px; color: var(--text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ig-chart-wrap {
  position: relative; width: 100%; height: 260px;
  padding: 6px 4px 4px;
}

.marketing-card.marketing-card-warn {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245,158,11,0.03), transparent 40%);
}
.marketing-card-warn > header i { color: #D97706; }

.ig-format-mix { display: flex; flex-direction: column; gap: 14px; padding: 6px 0; }
.ig-format-row { display: flex; flex-direction: column; gap: 4px; }
.ig-format-name { font-weight: 600; font-size: 13px; color: var(--text); }
.ig-format-meta { font-size: 11.5px; color: var(--text-tertiary); }
.ig-format-bars { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.ig-format-bar {
  position: relative; height: 22px; background: var(--surface-2);
  border-radius: 6px; overflow: hidden;
}
.ig-format-bar-fill {
  position: absolute; inset: 0; right: auto;
  background: linear-gradient(90deg, #5B5FEF, #6D5DFB);
  border-radius: 6px;
}
.ig-format-bar-fill-hook  { background: linear-gradient(90deg, #F59E0B, #FB923C); }
.ig-format-bar-fill-share { background: linear-gradient(90deg, #EC4899, #F472B6); }
.ig-format-bar-fill-eng   { background: linear-gradient(90deg, #22D3EE, #0EA5E9); }
.ig-format-bar > span {
  position: relative; z-index: 1;
  display: block; padding: 3px 8px; font-size: 11px;
  color: var(--text); font-weight: 500;
}

.ig-stagnating-ok {
  display: flex; align-items: center; gap: 8px;
  padding: 12px; font-size: 12.5px; color: var(--text-secondary);
}
.ig-stagnating-ok i { color: #16A34A; width: 16px; height: 16px; }
.ig-stagnating-list { display: flex; flex-direction: column; gap: 8px; }
.ig-stagnating-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface);
}
.ig-stag-thumb {
  width: 38px; height: 38px; border-radius: 6px; flex-shrink: 0;
  background: var(--surface-2);
}
.ig-stag-info { flex: 1; min-width: 0; }
.ig-stag-caption {
  font-size: 12.5px; color: var(--text); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ig-stag-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

.ig-demo-list { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.ig-demo-row {
  display: grid; grid-template-columns: 96px 1fr 50px;
  gap: 10px; align-items: center; font-size: 12.5px;
}
.ig-demo-label { color: var(--text-secondary); }
.ig-demo-bar {
  height: 8px; background: var(--surface-2);
  border-radius: 4px; overflow: hidden;
}
.ig-demo-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #5B5FEF, #6D5DFB);
  border-radius: 4px;
}
.ig-demo-pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

.ig-footer-meta {
  margin-top: 14px; font-size: 11.5px; color: var(--text-tertiary);
  text-align: center;
}

/* ===== Performance por atributo (cards in Orgânico) ============== */
.ig-attr-list { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.ig-attr-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 60px;
  gap: 10px; align-items: center;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  transition: background 0.15s;
}
.ig-attr-row:hover { background: var(--surface-2); }
.ig-attr-top {
  background: rgba(34, 197, 94, 0.06);
}
.ig-attr-worst {
  background: rgba(239, 68, 68, 0.05);
}
.ig-attr-label {
  display: flex; align-items: center; gap: 8px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ig-attr-row.ig-attr-top .ig-attr-label::before {
  content: '🏆';
  font-size: 12px;
}
.ig-attr-count {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-tertiary);
}
.ig-attr-bar {
  height: 8px; background: var(--surface-2);
  border-radius: 4px; overflow: hidden;
}
.ig-attr-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #5B5FEF, #6D5DFB);
  border-radius: 4px;
}
.ig-attr-row.ig-attr-top .ig-attr-bar-fill {
  background: linear-gradient(90deg, #16A34A, #22C55E);
}
.ig-attr-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}
.ig-attr-insight {
  margin-top: 10px; padding: 8px 10px;
  background: rgba(91, 95, 239, 0.04);
  border-left: 3px solid var(--accent-deep);
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ===== Customer 360 / Jornada ===================================== */
.cust-state-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 14px 0 10px;
}
.cust-chip {
  --state-color: #6B7280;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font: inherit; font-size: 12.5px; cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}
.cust-chip:hover {
  background: var(--surface-2);
  color: var(--text);
}
.cust-chip.active {
  background: color-mix(in srgb, var(--state-color) 14%, transparent);
  border-color: var(--state-color);
  color: var(--state-color);
  font-weight: 600;
}
.cust-chip i { width: 14px; height: 14px; color: var(--state-color); }
.cust-chip.active i { color: var(--state-color); }
.cust-chip-count {
  display: inline-block; min-width: 20px; padding: 1px 7px;
  border-radius: 999px; background: var(--surface-2);
  font-size: 10.5px; font-weight: 600; color: var(--text-secondary);
  text-align: center;
}
.cust-chip.active .cust-chip-count {
  background: color-mix(in srgb, var(--state-color) 22%, white);
  color: var(--state-color);
}

.cust-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1.4fr) auto;
  gap: 10px; align-items: end;
  margin: 8px 0 16px;
}
.cust-filter {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.cust-filter > span {
  font-size: 11px; color: var(--text-tertiary); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.cust-filter select, .cust-filter input {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; font-size: 12.5px;
  background: var(--surface); color: var(--text);
  min-width: 0; width: 100%;
}
.cust-filter select:focus, .cust-filter input:focus {
  outline: none; border-color: var(--accent-deep);
}
.cust-filter-actions { display: flex; gap: 6px; align-items: end; }
.cust-filter-actions .btn { white-space: nowrap; }

@media (max-width: 980px) {
  .cust-filter-row {
    grid-template-columns: 1fr 1fr;
  }
  .cust-filter-search { grid-column: 1 / -1; }
  .cust-filter-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

.cust-table-wrap {
  border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; background: var(--surface);
}
.cust-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
.cust-table thead {
  background: var(--surface-2);
}
.cust-table th {
  text-align: left; padding: 10px 12px;
  font-size: 11px; font-weight: 600; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.cust-table th.num-col { text-align: right; }
.cust-table tbody tr { transition: background 0.1s; }
.cust-table tbody tr:hover { background: var(--surface-2); }
.cust-table tbody tr + tr td { border-top: 1px solid var(--border); }
.cust-table td {
  padding: 9px 12px; vertical-align: middle;
}
.cust-table td.num-col {
  text-align: right; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cust-cell-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cust-cell-name {
  font-weight: 600; font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 320px;
}
.cust-cell-meta {
  font-size: 11.5px; color: var(--text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 320px;
}
.cust-state-pill {
  --state-color: #6B7280;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--state-color) 12%, transparent);
  color: var(--state-color);
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.cust-state-pill i { width: 12px; height: 12px; }
.cust-channel {
  font-size: 11.5px; color: var(--text-secondary);
}
.cust-actions { display: flex; gap: 4px; }
.cust-actions .icon-btn { width: 28px; height: 28px; }

.cust-pager {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 10px 12px; border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.cust-pager-label {
  font-size: 12px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.cust-legacy-details {
  margin-top: 22px;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface);
}
.cust-legacy-details > summary {
  cursor: pointer; font-weight: 600; font-size: 13px;
  color: var(--text-secondary);
  padding: 4px 0;
}
.cust-legacy-details > summary:hover { color: var(--text); }
.cust-legacy-details[open] > summary { color: var(--text); }

/* ===== Integrations status chips (Definições → Custos) =========== */
.integ-status-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 8px 0 14px;
}
.integ-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}
.integ-dot {
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: #94A3B8;
}
.integ-chip-on {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.25);
  color: #16A34A;
}
.integ-chip-on .integ-dot { background: #22C55E; }
.integ-chip-off {
  background: var(--surface);
  color: var(--text-tertiary);
  opacity: 0.7;
}
.integ-chip-off .integ-dot { background: #CBD5E1; }

/* ===== Audit log (Definições → Sistema) ========================== */
.audit-filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  margin-bottom: 14px;
}
.audit-filter {
  display: flex; flex-direction: column; gap: 4px;
}
.audit-filter > span {
  font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.4px; font-weight: 500;
}
.audit-filter select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 12.5px; background: var(--surface);
}
.audit-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 60vh; overflow-y: auto;
  padding: 4px;
}
.audit-row {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; background: var(--surface);
  font-size: 12.5px;
}
.audit-row.audit-fail {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.04);
}
.audit-row.audit-partial {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.04);
}
.audit-head {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.audit-when {
  font-family: ui-monospace, monospace; font-size: 11.5px;
  color: var(--text-tertiary); white-space: nowrap;
}
.audit-event {
  font-weight: 600; color: var(--text);
}
.audit-result {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.4px;
}
.audit-result-success { background: rgba(34,197,94,0.12); color: #16A34A; }
.audit-result-failure { background: rgba(239,68,68,0.12); color: #DC2626; }
.audit-result-partial { background: rgba(245,158,11,0.12); color: #D97706; }
.audit-tag {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  font-size: 10.5px; font-weight: 500;
  background: var(--surface-2); color: var(--text-secondary);
}
.audit-tag-server   { background: rgba(91,95,239,0.10); color: var(--accent-deep); }
.audit-tag-webhook  { background: rgba(34,211,238,0.12); color: #0891B2; }
.audit-tag-cron     { background: rgba(168,85,247,0.10); color: #7E22CE; }
.audit-tag-browser  { background: rgba(107,114,128,0.10); color: var(--text-secondary); }
.audit-actor {
  font-size: 11.5px; color: var(--text-tertiary);
  margin-left: auto;
}
.audit-entity {
  font-size: 11px; color: var(--text-tertiary);
  font-family: ui-monospace, monospace;
}
.audit-error {
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(239,68,68,0.06);
  border-left: 3px solid #DC2626;
  border-radius: 4px;
  font-size: 12px; color: #991B1B;
  font-family: ui-monospace, monospace;
}
.audit-code {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  background: rgba(239,68,68,0.15); color: #991B1B;
  font-size: 10.5px; font-weight: 600;
}
.audit-payload {
  margin-top: 6px;
}
.audit-payload > summary {
  cursor: pointer; font-size: 11.5px; color: var(--text-tertiary);
  user-select: none;
}
.audit-payload > summary:hover { color: var(--text-secondary); }
.audit-payload pre {
  margin-top: 4px; padding: 8px;
  background: var(--surface-2); border-radius: 6px;
  font-size: 11px; line-height: 1.4;
  max-height: 200px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}

/* ===== Diagnóstico modal ============================================ */
#diagnostico-modal .modal-body { padding: 20px 24px 24px; }
.diag-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 60px 0; color: var(--text-secondary); font-size: 14px;
}
.diag-loading .spin { animation: diag-spin 1s linear infinite; width: 18px; height: 18px; }
@keyframes diag-spin { to { transform: rotate(360deg); } }
.diag-error {
  display: flex; gap: 12px; padding: 16px;
  background: #FFF4F4; border: 1px solid #F5C6CB; border-radius: 8px;
  color: #842029;
}
.diag-error i { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.diag-error-msg { font-size: 13px; margin: 4px 0; opacity: 0.85; }
.diag-error-hint { font-size: 12px; opacity: 0.7; }
.diag-headline {
  font-size: 15px; font-weight: 500; color: var(--text);
  padding: 12px 16px; background: var(--accent-soft); border-radius: 8px;
  margin-bottom: 16px;
}
.diag-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 20px;
}
.diag-card {
  background: #FAFAFB; border: 1px solid var(--border);
  border-radius: 8px; padding: 14px;
}
.diag-card-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-tertiary); margin-bottom: 6px; font-weight: 600;
}
.diag-card-value {
  font-size: 22px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.diag-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-tertiary); margin: 16px 0 8px; font-weight: 600;
}
.diag-signals { display: flex; flex-direction: column; gap: 8px; }
.diag-signals-empty {
  padding: 12px; background: #FAFAFB; border-radius: 8px;
  color: var(--text-tertiary); font-size: 13px; text-align: center;
}
.diag-signal {
  display: flex; gap: 10px; padding: 12px; border-radius: 8px;
  border: 1px solid var(--border);
}
.diag-signal i { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.diag-signal-msg { font-size: 13px; color: var(--text); font-weight: 500; }
.diag-signal-action { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.diag-signal-ok    { background: #F0F9F1; border-color: #C8E6C9; }
.diag-signal-ok i  { color: #2E7D32; }
.diag-signal-warn  { background: #FFF8E1; border-color: #FFE082; }
.diag-signal-warn i{ color: #B45309; }
.diag-signal-err   { background: #FFF4F4; border-color: #F5C6CB; }
.diag-signal-err i { color: #C62828; }
.diag-staleness {
  margin-top: 16px; font-size: 11px; color: var(--text-tertiary);
  text-align: right; font-variant-numeric: tabular-nums;
}

