/*
 * TorqOS component + utility classes — "Torque Glass" (Apple-design v2).
 *
 * Synced from the "Torque Group Design System" Claude Design project
 * (ebee99c6): tokens/base.css (element base) + tokens/components.css
 * (the .tq-* redesign). Same class names as before — capsule buttons,
 * glass fills with backdrop blur, continuous-corner cards, soft focus
 * ring, press scale. Design tokens live in
 * app/assets/tailwind/application.css (@theme + :root + [data-theme=light]).
 *
 * The "app-compat + polish" section at the very bottom is NOT part of the
 * DS bundle — it re-adds a few classes the Rails ERB uses that the redesign
 * renamed/omitted (.tq-flash*, .tq-badge--success alias, .tq-section-title).
 * Keep it when re-syncing components.css from the design project.
 *
 * Served by Propshaft. Included in app/views/layouts/application.html.erb
 * via stylesheet_link_tag "torqos".
 */

/* ═════════ Base element styles (tokens/base.css) ═════════ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: var(--text-body-size);
  line-height: var(--leading-body);
}

::selection { background: rgba(70,245,31,0.25); color: var(--text-strong); }

h1, h2, h3, h4, h5 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: var(--tracking-normal);
  margin: 0;
}

a { color: var(--torque-violet); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ═════════ Torque Glass components (tokens/components.css) ═════════ */

/* Button — capsule, filled or glass */
.tq-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px;
  font-family: var(--font-body); font-weight: 500; font-size: 14px;
  border-radius: var(--r-pill); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: transform 0.18s var(--ease-spring),
              background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              filter var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.tq-btn:active { transform: scale(0.96); }
.tq-btn:focus-visible { outline: none; box-shadow: var(--focus); }

.tq-btn--primary {
  background: linear-gradient(180deg, color-mix(in oklab, var(--torque-green) 88%, white), var(--torque-green));
  color: #071d02; font-weight: 600;
  box-shadow: var(--shadow-btn);
}
.tq-btn--primary:hover { filter: brightness(1.06); box-shadow: var(--shadow-btn), var(--glow-green); }

.tq-btn--secondary {
  background: linear-gradient(180deg, color-mix(in oklab, var(--torque-purple) 82%, white), var(--torque-purple));
  color: var(--text-strong);
  box-shadow: var(--shadow-btn);
}
.tq-btn--secondary:hover { filter: brightness(1.1); }

.tq-btn--ghost {
  background: var(--glass-fill); color: var(--text);
  border-color: var(--hairline);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07);
}
.tq-btn--ghost:hover { background: var(--glass-fill-hover); }

.tq-btn--danger { background: var(--danger-soft); color: var(--danger-fg); border-color: color-mix(in oklab, var(--danger) 30%, transparent); }
.tq-btn--danger:hover { background: color-mix(in oklab, var(--danger) 22%, transparent); }

.tq-btn--sm { height: 30px; padding: 0 14px; font-size: 13px; }
.tq-btn--xs { height: 24px; padding: 0 11px; font-size: 12px; }
.tq-btn--icon { width: 34px; padding: 0; }

/* Input / select / textarea — glass fill, soft purple focus ring */
.tq-input, .tq-select, .tq-textarea {
  width: 100%; display: block;
  height: 38px; padding: 0 14px;
  background: var(--glass-fill); color: var(--text);
  border: 1px solid var(--hairline-soft); border-radius: var(--r);
  font-family: var(--font-body); font-size: 14px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.18);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background-color var(--dur-fast);
}
.tq-textarea { height: auto; padding: 10px 14px; resize: vertical; min-height: 80px; line-height: 1.5; }
.tq-input:focus, .tq-select:focus, .tq-textarea:focus {
  outline: none; border-color: color-mix(in oklab, var(--torque-purple) 70%, transparent);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.18), var(--focus);
  background: var(--glass-fill-hover);
}
.tq-input::placeholder, .tq-textarea::placeholder { color: var(--text-dim); }
.tq-select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='none' stroke='%239C93B8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5l3 3 3-3'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* The <option> popup is an OS widget: it does NOT inherit the translucent
   glass fill of .tq-select, so it must be painted with an OPAQUE token or
   the text lands on the browser's default white. `color-scheme` (set on
   :root in tokens) covers most browsers; this is the belt-and-braces pass
   for the ones that ignore it. */
.tq-select option, .tq-select optgroup {
  background-color: var(--surface-raised);
  color: var(--text);
}

.tq-label { display: block; font-size: var(--text-footnote); font-weight: 500; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.02em; }
.tq-hint { font-size: var(--text-footnote); color: var(--text-dim); margin-top: 6px; }

/* Card — continuous-corner glass panel */
.tq-card {
  background: var(--material-card);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
}
.tq-card--raised { background: var(--material-popover); backdrop-filter: blur(var(--blur-popover)) saturate(180%); -webkit-backdrop-filter: blur(var(--blur-popover)) saturate(180%); box-shadow: var(--shadow-raised); }

/* Badges / pills — tinted capsules */
.tq-badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--text-caption); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.tq-badge--green { background: var(--success-soft); color: var(--success-fg); }
.tq-badge--purple { background: rgba(90,64,203,0.22); color: var(--badge-purple-fg); }
.tq-badge--violet { background: var(--info-soft); color: var(--badge-violet-fg); }
.tq-badge--warn { background: var(--warning-soft); color: var(--warn-fg); }
.tq-badge--danger { background: var(--danger-soft); color: var(--danger-fg); }
.tq-badge--neutral { background: var(--glass-fill-hover); color: var(--text-muted); }

.tq-dot { width: 8px; height: 8px; border-radius: var(--r-pill); display: inline-block; }

/* Stage pill — stage-tinted capsule */
.tq-stage { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--r-pill); font-size: var(--text-caption); font-weight: 600; text-transform: uppercase; letter-spacing: var(--tracking-wide); background: var(--glass-fill); border: 1px solid var(--hairline-soft); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06); }

/* Avatar */
.tq-avatar { width: 28px; height: 28px; border-radius: var(--r-pill); display: inline-flex; align-items: center; justify-content: center; background: var(--torque-purple); color: #fff; font-weight: 600; font-size: 12px; font-family: var(--font-heading); flex-shrink: 0; box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 1px 3px rgba(0,0,0,0.4); }
.tq-avatar--sm { width: 22px; height: 22px; font-size: 10px; }
.tq-avatar--lg { width: 40px; height: 40px; font-size: 14px; }

/* Checkbox — fills green, pops on check */
.tq-check { width: 18px; height: 18px; border-radius: var(--r-sm); border: 1.5px solid var(--hairline); background: var(--glass-fill); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: all var(--dur-fast) var(--ease-spring); }
.tq-check:hover { border-color: var(--torque-purple); }
.tq-check.checked { background: var(--torque-green); border-color: var(--torque-green); box-shadow: 0 0 12px rgba(70,245,31,0.35); }
.tq-check.checked svg { color: #071d02; }

/* Divider */
.tq-divider { height: 1px; background: var(--hairline-soft); }

/* Table */
.tq-table { width: 100%; border-collapse: collapse; font-size: var(--text-callout); }
.tq-table th { text-align: left; font-family: var(--font-heading); font-weight: 600; color: var(--text-dim); font-size: var(--text-caption); letter-spacing: 0.08em; text-transform: uppercase; padding: 10px 16px; border-bottom: 1px solid var(--hairline); }
.tq-table td { padding: 12px 16px; border-bottom: 1px solid var(--hairline-soft); vertical-align: middle; }
.tq-table tr:last-child td { border-bottom: none; }
.tq-table tr:hover td { background: var(--row-hover); }

/* Clickable row: the real <a> stays in one cell (keyboard focus, middle-click,
   open in new tab) and its ::after stretches over the whole row, so clicking
   any cell follows the link — no inline onclick, no JS. */
.tq-table tr.tq-row-link { position: relative; cursor: pointer; }
.tq-row-link__target::after { content: ""; position: absolute; inset: 0; }
.tq-row-link:focus-within td { background: var(--row-hover); }

/* Kanban card — glass tile */
.tq-kanban-card {
  background: var(--material-card); border: 1px solid var(--hairline-soft);
  border-radius: var(--r-lg); padding: 14px;
  cursor: pointer; box-shadow: var(--shadow-card);
  transition: border-color var(--dur-fast), background-color var(--dur-fast), transform 0.18s var(--ease-spring);
  position: relative;
}
/* Hover feedback is colour only — NO transform. A positional shift on hover
   reads as the card "picking up / moving" before you've even pressed, which is
   exactly the reported bug. Colour + shadow signal "hoverable"; movement is
   reserved for an actual drag. */
.tq-kanban-card:hover { background: var(--material-card-hover); border-color: color-mix(in oklab, var(--torque-purple) 55%, var(--hairline)); }
/* Armed state (SortableJS chosenClass, only after the press-and-hold delay):
   just the grabbing cursor — no scale, so pressing doesn't visibly grab the
   card until a real drag is under way (the .dragging ghost is the drag cue). */
.tq-kanban-card.tq-drag-armed { cursor: grabbing; }
.tq-kanban-card.dragging { opacity: .4; transform: rotate(-1deg); }
.tq-kanban-card.is-stale::before { content:''; position: absolute; inset: -1px; border-radius: var(--r-lg); border: 1px solid var(--warning); pointer-events: none; opacity: .55; }

/* KPI tile */
.tq-kpi { background: var(--material-card); border: 1px solid var(--hairline-soft); border-radius: var(--r-xl); padding: 18px 20px; position: relative; overflow: hidden; box-shadow: var(--shadow-card); }
.tq-kpi__label { font-size: var(--text-caption); font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.tq-kpi__value { font-family: var(--font-heading); font-size: 32px; font-weight: 700; color: var(--text-strong); letter-spacing: var(--tracking-tight); margin-top: 8px; white-space: nowrap; }
.tq-kpi__delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-footnote); font-weight: 500; margin-top: 4px; white-space: nowrap; }
.tq-kpi__delta.up { color: var(--success-fg); }
.tq-kpi__delta.down { color: var(--danger-fg); }

/* Sidebar nav — tinted selection pill */
.tq-nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r); color: var(--text-muted); font-size: 14px; font-weight: 500; cursor: pointer; transition: background-color var(--dur-fast), color var(--dur-fast); }
.tq-nav-item:hover { background: var(--glass-fill); color: var(--text); }
.tq-nav-item.active { background: var(--nav-active-bg); color: var(--text-strong); box-shadow: inset 0 1px 0 rgba(255,255,255,0.10); }
.tq-nav-item.active .tq-nav-icon { color: var(--nav-active-fg); }
.tq-nav-icon { width: 18px; height: 18px; color: currentColor; flex-shrink: 0; }

/* Segmented control — capsule track + sliding glass thumb */
.tq-seg { position: relative; display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: var(--r-pill); background: var(--glass-fill); border: 1px solid var(--hairline-soft); box-shadow: inset 0 1px 2px rgba(0,0,0,0.2); }
.tq-seg__item { position: relative; z-index: 1; border: none; background: transparent; cursor: pointer; height: 28px; padding: 0 14px; border-radius: var(--r-pill); font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; transition: color var(--dur-fast); white-space: nowrap; }
.tq-seg__item:hover { color: var(--text); }
.tq-seg__item.is-active { color: var(--text-strong); }
.tq-seg__thumb { position: absolute; top: 3px; bottom: 3px; z-index: 0; border-radius: var(--r-pill); background: var(--glass-fill-hover); border: 1px solid var(--hairline); box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 2px 8px rgba(0,0,0,0.35); transition: left 0.28s var(--ease-spring), width 0.28s var(--ease-spring); }

/* Shell chrome — glass over wallpaper */
.tq-shell { display: flex; height: 100vh; background: radial-gradient(120% 80% at 50% 100%, color-mix(in oklab, var(--torque-purple) 20%, transparent), transparent 68%), var(--surface-page); position: relative; }
.tq-shell--wallpaper { background: url("/assets/backgrounds/purple-studio-bfa62fa2.jpg") center / cover fixed, var(--surface-page); }
.tq-shell--wallpaper::before { content: ''; position: absolute; inset: 0; background: rgba(3,2,8,0.45); pointer-events: none; }
[data-theme="light"] .tq-shell--wallpaper { background: linear-gradient(180deg, #ECE8F8 0%, #F7F5FC 60%, #F2EEFA 100%); }
[data-theme="light"] .tq-shell--wallpaper::before { background: transparent; }
.tq-sidebar { width: 232px; background: var(--material-sidebar); backdrop-filter: blur(var(--blur-sidebar)) saturate(180%); -webkit-backdrop-filter: blur(var(--blur-sidebar)) saturate(180%); border-right: 1px solid var(--hairline-soft); display: flex; flex-direction: column; flex-shrink: 0; position: relative; }
/* Header: seamless (transparent) at the top so it reads as part of the page;
   gains the glass material only once the page scrolls, so it floats over the
   content underneath. Toggled by the `headerbar` Stimulus controller. */
.tq-header-blur { background: transparent; transition: background-color var(--dur-med) var(--ease-out); }
.tq-header-blur.is-scrolled { background: var(--material-toolbar); backdrop-filter: blur(var(--blur-toolbar)) saturate(180%); -webkit-backdrop-filter: blur(var(--blur-toolbar)) saturate(180%); }
.tq-popover { background: var(--material-popover); backdrop-filter: blur(var(--blur-popover)) saturate(180%); -webkit-backdrop-filter: blur(var(--blur-popover)) saturate(180%); border: 1px solid var(--hairline); border-radius: var(--r-2xl); box-shadow: var(--shadow-popover); }

/* Utils */
.tq-mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; }
.tq-muted { color: var(--text-muted); }
.tq-dim { color: var(--text-dim); }
.tq-link { color: var(--torque-violet); text-decoration: none; }
.tq-link:hover { text-decoration: underline; }
.tq-back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; text-decoration: none; }
.tq-back-link::before { content: "←"; font-size: 14px; line-height: 1; }

/* Cadence index: one line per (channel) cadence inside the stage row. */
.tq-cadence-cell { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tq-back-link:hover { color: var(--text); }
.tq-page-title { font-size: var(--text-title-1); line-height: var(--leading-title); letter-spacing: var(--tracking-tight); }

/* Opportunity drawer — slide-out panel (right side) */
/* Responsive width overrides live in the media-query block below. */
.tq-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 480px; max-width: 100vw;
  z-index: 80;
  /* Solid, opaque panel — no backdrop-filter: it creates a compositing layer
     that softens the panel's OWN text on many browsers ("blurred" content). */
  background: var(--surface-raised);
  border-left: 1px solid var(--hairline);
  border-radius: var(--r-2xl) 0 0 var(--r-2xl);
  box-shadow: var(--shadow-drawer);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur-med) var(--ease-out);
  overflow: hidden;
}
.tq-drawer.is-open { transform: translateX(0); }

/* Scrim — full-viewport dark overlay behind the drawer */
.tq-drawer-scrim {
  position: fixed; inset: 0;
  background: rgba(3, 2, 8, 0.55);
  z-index: 79;
  animation: tq-scrim-in var(--dur-med) var(--ease-out) both;
}
@keyframes tq-scrim-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
[data-theme="light"] .tq-drawer-scrim { background: rgba(30, 20, 70, 0.3); }

/* Drawer layout zones */
.tq-drawer__header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--hairline-soft);
  flex-shrink: 0;
}
.tq-drawer__lead-name {
  font-family: var(--font-heading); font-size: var(--text-title-2); font-weight: 700;
  color: var(--text-strong); letter-spacing: var(--tracking-tight); margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tq-drawer__subtitle {
  font-size: var(--text-callout); margin: 4px 0 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tq-drawer__meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--hairline-soft);
  flex-shrink: 0;
}
.tq-drawer__value {
  font-size: 18px; font-weight: 700; color: var(--success-fg);
  margin-left: auto;
}
.tq-drawer__body {
  flex: 1; overflow-y: auto; padding: 0;
}
.tq-drawer__section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline-soft);
}
.tq-drawer__section:last-child { border-bottom: none; }
.tq-drawer__field-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px;
}
.tq-drawer__field { display: flex; flex-direction: column; gap: 4px; }
.tq-drawer__note-form { display: flex; flex-direction: column; gap: 8px; }
.tq-drawer__timeline {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.tq-drawer__timeline-item {
  display: flex; align-items: baseline; gap: 10px; font-size: 13px;
}
.tq-drawer__footer {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--hairline-soft);
  background: var(--glass-fill);
  flex-shrink: 0;
}
.tq-drawer__meeting { position: relative; }
.tq-drawer__meeting-form {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  background: var(--material-popover);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: 12px;
  min-width: 280px;
  box-shadow: var(--shadow-popover);
  display: flex; gap: 8px; align-items: center;
  z-index: 1;
}

/* Ganhar / Perder — terminal outcomes below the footer actions. */
.tq-drawer__outcome {
  display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--hairline-soft);
  flex-shrink: 0;
}
.tq-drawer__lost > summary {
  list-style: none; cursor: pointer;
}
.tq-drawer__lost > summary::-webkit-details-marker { display: none; }
.tq-drawer__lost-form {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 8px; min-width: 260px;
}

/* Stretch link inside kanban card — covers card for click-to-open-drawer */
.tq-kanban-card-link {
  position: absolute; inset: 0;
  border-radius: var(--r-lg);
  /* Above the card content so a click ANYWHERE on the card opens the drawer
     (not only the empty/padding areas). SortableJS still starts the drag from
     mousedown on the card, so hold-to-drag is unaffected. */
  z-index: 2;
  /* Accessibility: show focus ring on keyboard navigation */
}
.tq-kanban-card-link:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* ───────── Responsive layout — mobile → 32″ ───────── */
.tq-main-pad { padding: 24px; }
.tq-hamburger { display: none; }
.tq-sidebar-scrim { display: none; }
.tq-mobile-only { display: none; }
.tq-desktop-only { display: flex; }

@media (max-width: 1000px) {
  .tq-sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; transform: translateX(-105%); transition: transform .24s var(--ease-out); box-shadow: var(--shadow-drawer); }
  .tq-sidebar.is-open { transform: translateX(0); }
  .tq-sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(3,2,8,0.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 55; }
  [data-theme="light"] .tq-sidebar-scrim { background: rgba(30, 20, 70, 0.25); }
  .tq-hamburger { display: inline-flex; }
  .tq-header { padding: 22px 16px 12px !important; }
  .tq-main-pad { padding: 16px; }
  .tq-drawer { width: 100vw !important; max-width: 100vw !important; border-radius: 0 !important; top: 0 !important; right: 0 !important; bottom: 0 !important; }
}
@media (max-width: 1400px) and (min-width: 1001px) {
  .tq-drawer { width: 560px !important; }
}

@media (max-width: 720px) {
  .tq-mobile-only { display: flex; }
  .tq-desktop-only { display: none !important; }
  body { font-size: 15px; }
  .tq-main-pad { padding: 16px 16px 92px; }
  .tq-kpi__value { font-size: 26px; }
  .tq-page-title { font-size: 24px; }
}
@media (max-width: 640px) {
  .tq-header-search { display: none !important; }
}

.tq-mobile-tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--material-toolbar);
  backdrop-filter: blur(var(--blur-toolbar)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-toolbar)) saturate(180%);
  border-top: 1px solid var(--hairline-soft);
  display: none;
}
@media (max-width: 720px) {
  .tq-mobile-tabs { display: flex; }
}
.tq-mobile-tab {
  flex: 1; background: transparent; border: none; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; font-weight: 500; font-family: var(--font-body);
  cursor: pointer; padding: 8px 4px; position: relative;
  transition: color var(--dur-fast);
}
.tq-mobile-tab:active { transform: scale(0.94); }
.tq-mobile-tab.is-active { color: var(--nav-active-fg); }
.tq-mobile-tab.is-active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; background: var(--nav-active-fg); border-radius: 0 0 4px 4px;
}

@media (min-width: 1920px) {
  body { font-size: 15px; }
  .tq-sidebar { width: 264px; }
  .tq-main-pad { padding: 32px 40px; }
  .tq-header { padding: 30px 40px 20px !important; }
  .tq-kpi__value { font-size: 38px; }
  .tq-btn { height: 40px; }
  .tq-input, .tq-select { height: 40px; }
}
@media (min-width: 2400px) {
  body { font-size: 16px; }
  .tq-sidebar { width: 296px; }
  .tq-main-pad { padding: 40px 56px; }
  .tq-kpi__value { font-size: 44px; }
  .tq-nav-item { padding: 10px 14px; font-size: 15px; }
  .tq-table { font-size: 14px; }
}

/* ═════════ TorqOS app-compat + polish (NOT in the DS bundle) ═════════
   Classes the Rails ERB uses that the redesign renamed or omitted.
   Restyled in the Torque Glass language. Keep across DS re-syncs. */

/* Form-level error banner (pipelines/cadences forms). */
.tq-flash { padding: 12px 16px; border-radius: var(--r); border: 1px solid var(--hairline); background: var(--glass-fill); color: var(--text); font-size: var(--text-callout); }
.tq-flash--danger { background: var(--danger-soft); border-color: color-mix(in oklab, var(--danger) 30%, transparent); color: var(--danger-fg); }
.tq-flash--notice, .tq-flash--success { background: var(--success-soft); border-color: color-mix(in oklab, var(--success) 30%, transparent); color: var(--success-fg); }
.tq-flash--warn, .tq-flash--alert { background: var(--warning-soft); border-color: color-mix(in oklab, var(--warning) 30%, transparent); color: var(--warn-fg); }

/* Legacy modifier: the ERB writes .tq-badge--success; the redesign calls it --green. */
.tq-badge--success { background: var(--success-soft); color: var(--success-fg); }

/* Small section subheading used across CRM views. */
.tq-section-title { font-family: var(--font-heading); font-size: var(--text-title-3); font-weight: 700; color: var(--text-strong); letter-spacing: var(--tracking-normal); }

/* Server-rendered segmented control: the segments are links (navigate on
   click), so instead of the JS sliding thumb the active segment carries the
   thumb look. inset box-shadow as a faux-border avoids a 1px layout shift. */
.tq-seg__item { text-decoration: none; }
.tq-seg__item:hover { text-decoration: none; }
.tq-seg__item.is-active {
  background: var(--glass-fill-hover);
  box-shadow: inset 0 0 0 1px var(--hairline), inset 0 1px 0 rgba(255,255,255,0.14), 0 2px 8px rgba(0,0,0,0.28);
}

/* Brand logo swaps with the theme: white on dark (default), purple on light. */
.tq-logo-light { display: none; }
[data-theme="light"] .tq-logo-dark { display: none; }
[data-theme="light"] .tq-logo-light { display: inline-block; }

/* ── Spotlight search modal (⌘K) ────────────────────────────────────────── */

/* Scrim — same recipe as .tq-drawer-scrim but higher z-index */
.tq-spotlight-scrim {
  position: fixed; inset: 0;
  background: rgba(3, 2, 8, 0.62);
  z-index: 98;
  animation: tq-scrim-in var(--dur-med) var(--ease-out) both;
}
[data-theme="light"] .tq-spotlight-scrim { background: rgba(30, 20, 70, 0.35); }

/* Centered panel — glass popover at top ~15vh */
.tq-spotlight {
  position: fixed;
  top: 15vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 32px));
  z-index: 99;
  background: var(--material-popover);
  backdrop-filter: blur(var(--blur-popover)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-popover)) saturate(180%);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}

/* Search bar row: icon + input + Esc kbd */
.tq-spotlight__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline-soft);
}
.tq-spotlight__bar-icon { color: var(--text-dim); flex-shrink: 0; }

/* The search input — resets .tq-input defaults that conflict */
.tq-spotlight__input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text-strong);
  height: auto;
  padding: 0;
  width: 100%;
}
.tq-spotlight__input::placeholder { color: var(--text-dim); }
/* Hide the browser-native × clear button on search type */
.tq-spotlight__input::-webkit-search-cancel-button { display: none; }

.tq-spotlight__esc {
  font-size: 10px;
  color: var(--text-dim);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
  cursor: default;
}

/* Results scroll container */
.tq-spotlight__results {
  max-height: 400px;
  overflow-y: auto;
  padding-bottom: 8px;
}

/* Hint (blank query) and empty (no match) states */
.tq-spotlight__hint,
.tq-spotlight__empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: var(--text-callout);
}

/* Section labels (Leads / Oportunidades) */
.tq-spotlight__section-label {
  padding: 10px 16px 4px;
  font-size: var(--text-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-dim);
}

/* Individual result row — a link */
.tq-spotlight__result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--dur-fast);
}
.tq-spotlight__result:hover,
.tq-spotlight__result.is-active {
  background: var(--glass-fill-hover);
  text-decoration: none;
}
.tq-spotlight__result.is-active { outline: none; }

/* Icon badge on the left of each row */
.tq-spotlight__result-icon {
  width: 32px; height: 32px;
  border-radius: var(--r);
  background: var(--glass-fill);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Result text */
.tq-spotlight__result-primary {
  font-weight: 500;
  color: var(--text-strong);
  font-size: var(--text-callout);
  line-height: 1.3;
}
.tq-spotlight__result-secondary {
  font-size: var(--text-footnote);
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.3;
}

/* Header search trigger — button styled to look like the old disabled input */
.tq-header-search-trigger {
  appearance: none;
  -webkit-appearance: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tq-header-search-trigger:focus-visible {
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.18), var(--focus);
  border-color: color-mix(in oklab, var(--torque-purple) 70%, transparent);
}

/* ── Notifications bell + dropdown (header, Fase E3) ────────────────────── */

/* Unread counter pinned to the bell's top-right corner */
.tq-bell-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--torque-violet);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  pointer-events: none;
}

/* Anchored glass panel under the bell (material comes from .tq-popover) */
.tq-notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, calc(100vw - 32px));
  z-index: 60;
  overflow: hidden;
}
/* button_to wrappers must not break the flex rows */
.tq-notif-panel form.button_to { display: contents; }

.tq-notif-menu__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline-soft);
}
.tq-notif-menu__title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-strong);
}
.tq-notif-menu__mark-all {
  background: none;
  border: none;
  padding: 0;
  color: var(--torque-violet);
  font-size: 12px;
  cursor: pointer;
}
.tq-notif-menu__mark-all:hover { text-decoration: underline; }

.tq-notif-menu__list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 380px;
  overflow-y: auto;
}
.tq-notif-menu__empty {
  padding: 24px 16px;
  text-align: center;
  font-size: var(--text-callout);
}

/* One notification row */
.tq-notif {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
}
.tq-notif + .tq-notif { border-top: 1px solid var(--hairline-soft); }

/* Unread indicator dot — invisible placeholder on read rows keeps alignment */
.tq-notif__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: transparent;
}
.tq-notif--unread .tq-notif__dot { background: var(--torque-violet); }

.tq-notif__body { flex: 1; min-width: 0; }
.tq-notif__message {
  display: block;
  font-size: 13px;
  color: var(--text);
  line-height: 1.35;
  overflow-wrap: break-word;
  text-decoration: none;
}
a.tq-notif__message:hover { color: var(--text-strong); text-decoration: underline; }
.tq-notif--unread .tq-notif__message {
  font-weight: 600;
  color: var(--text-strong);
}
.tq-notif__time {
  display: block;
  margin-top: 2px;
  font-size: var(--text-caption);
}

/* Per-row "mark as read" check */
.tq-notif__read-btn {
  background: none;
  border: none;
  padding: 4px;
  border-radius: var(--r);
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
}
.tq-notif__read-btn:hover {
  color: var(--torque-violet);
  background: var(--glass-fill);
}

/* ═════════ Dropzone — file-upload card (click or drag & drop) ═════════
   Replaces the browser's bare "Choose File" control, which carries no
   affordance at all. The <label> is the whole card; the real file input
   sits inside it, visually hidden but focusable, so click and keyboard
   still work with JavaScript off. */
.tq-dropzone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  border: 1.5px dashed var(--hairline);
  border-radius: var(--r-xl);
  background: var(--glass-fill);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.tq-dropzone:hover {
  background: var(--glass-fill-hover);
  border-color: var(--text-faint);
}
.tq-dropzone:focus-within {
  box-shadow: var(--focus);
  border-color: var(--accent);
}

/* Visually hidden, still focusable and still submitted with the form. */
.tq-dropzone__input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}

.tq-dropzone__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  background: var(--glass-fill-hover);
  color: var(--text-muted);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.tq-dropzone__copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tq-dropzone__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}
.tq-dropzone__hint {
  font-size: 13px;
  color: var(--text-muted);
}

/* Dragging a file over the card. */
.tq-dropzone--active {
  border-style: solid;
  border-color: var(--accent-cta);
  background: var(--success-soft);
}
.tq-dropzone--active .tq-dropzone__icon {
  background: var(--success-soft);
  color: var(--success-fg);
}

/* A file is chosen — the title holds its name. */
.tq-dropzone--filled {
  border-style: solid;
  border-color: color-mix(in oklab, var(--success) 45%, transparent);
}
.tq-dropzone--filled .tq-dropzone__icon {
  background: var(--success-soft);
  color: var(--success-fg);
}

/* Dropped file the `accept` list doesn't cover. */
.tq-dropzone--invalid {
  border-style: solid;
  border-color: var(--danger);
  background: var(--danger-soft);
}
.tq-dropzone--invalid .tq-dropzone__title { color: var(--danger-fg); }
.tq-dropzone--invalid .tq-dropzone__icon {
  background: var(--danger-soft);
  color: var(--danger-fg);
}

/* The unread-count wrapper is always in the markup so turbo_stream.replace
   has a stable target, even at zero. Left as a normal child it is still a
   flex item of .tq-btn, and the button's gap: 8px shoves the bell 4px left
   of centre. display: contents drops it out of the box tree; the badge
   inside stays absolutely positioned against the button. */
.tq-bell-badge-slot { display: contents; }
