/* Sell CRM shell and theme.
   Loaded after studio.css: re-themes every page to the look of the client's
   existing CRM (indigo primary, slate neutrals, dark slate sidebar, white top
   bar) and adds the CRM components (view tabs, filter bar, data table, board,
   record header, stage pipeline, slide-over, search palette). */

:root {
  --accent: #4f46e5;          /* indigo-600: primary actions, links, focus */
  --accent-hover: #6366f1;    /* indigo-500 */
  --accent-strong: #4338ca;   /* indigo-700 */
  --accent-soft: #eef2ff;     /* indigo-50 */
  --accent-soft-2: #e0e7ff;   /* indigo-100 */
  --accent-ink: #3730a3;      /* indigo-800, text on soft */

  --bg: #f1f5f9;              /* slate-100 page */
  --surface: #ffffff;
  --surface-2: #f8fafc;       /* slate-50: table heads, sticky cells */
  --tint: #f1f5f9;
  --tint-2: #e2e8f0;
  --line: #e2e8f0;            /* slate-200 */
  --line-strong: #cbd5e1;     /* slate-300 */
  --text: #0f172a;            /* slate-900 */
  --text-2: #334155;          /* slate-700 */
  --muted: #64748b;           /* slate-500, 4.76:1 on white */

  --green: #16a34a; --green-ink: #ffffff; --green-soft: #f0fdf4; --green-text: #15803d;
  --red: #dc2626; --red-soft: #fef2f2;
  --orange: #d97706; --orange-soft: #fffbeb; --amber-text: #b45309;
  --purple: #7c3aed; --purple-soft: #f5f3ff;

  --side-bg: #1e293b;         /* slate-800 */
  --side-ink: #f8fafc;
  --side-icon: #cbd5e1;
  --side-hover: rgba(255, 255, 255, .1);
  --side-rule: #334155;

  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04), 0 0 0 1px var(--line);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, .1), 0 4px 6px -4px rgba(15, 23, 42, .08), 0 0 0 1px var(--line);
  --r: 8px;
  --r-sm: 6px;
  --side: 224px;
  --top: 64px;
  --font: 'Inter var', Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* z-index scale */
  --z-sticky: 10; --z-dropdown: 20; --z-drawer: 40; --z-toast: 60;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #818cf8; --accent-hover: #a5b4fc; --accent-strong: #6366f1; --accent-soft: #1e1b4b; --accent-soft-2: #312e81; --accent-ink: #c7d2fe;
    --bg: #0f172a; --surface: #1e293b; --surface-2: #172033; --tint: #172033; --tint-2: #334155; --line: #334155; --line-strong: #475569;
    --text: #f1f5f9; --text-2: #cbd5e1; --muted: #94a3b8;
    --green: #22c55e; --green-ink: #052e16; --green-soft: #052e16; --green-text: #4ade80;
    --red: #f87171; --red-soft: #3b0d0d; --orange: #fbbf24; --orange-soft: #2a1d05; --amber-text: #fbbf24;
    --purple: #a78bfa; --purple-soft: #2e1065;
    --side-bg: #0b1220; --side-rule: #1e293b;
    --shadow: 0 0 0 1px var(--line); --shadow-lg: 0 10px 25px rgba(0, 0, 0, .45), 0 0 0 1px var(--line);
  }
}
:root[data-theme="dark"] {
  --accent: #818cf8; --accent-hover: #a5b4fc; --accent-strong: #6366f1; --accent-soft: #1e1b4b; --accent-soft-2: #312e81; --accent-ink: #c7d2fe;
  --bg: #0f172a; --surface: #1e293b; --surface-2: #172033; --tint: #172033; --tint-2: #334155; --line: #334155; --line-strong: #475569;
  --text: #f1f5f9; --text-2: #cbd5e1; --muted: #94a3b8;
  --green: #22c55e; --green-ink: #052e16; --green-soft: #052e16; --green-text: #4ade80;
  --red: #f87171; --red-soft: #3b0d0d; --orange: #fbbf24; --orange-soft: #2a1d05; --amber-text: #fbbf24;
  --purple: #a78bfa; --purple-soft: #2e1065;
  --side-bg: #0b1220; --side-rule: #1e293b;
  --shadow: 0 0 0 1px var(--line); --shadow-lg: 0 10px 25px rgba(0, 0, 0, .45), 0 0 0 1px var(--line);
}

body { font-family: var(--font); font-size: 14px; line-height: 1.6; color: var(--text-2); background: var(--bg); font-feature-settings: 'cv11', 'ss01'; }
h1, h2, h3, b, strong { color: var(--text); }
h1 { font-size: 22px; letter-spacing: -.01em; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: var(--z-toast); background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Primary colour everywhere the old theme used green as "primary" ── */
.btn { height: 34px; padding: 0 12px; font-weight: 600; font-size: 14px; border-radius: var(--r); background: var(--surface); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-strong), 0 1px 2px rgba(15, 23, 42, .05); transition: background-color .15s, box-shadow .15s, color .15s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: none; background: var(--tint); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .1); }
.btn-primary:hover { background: var(--accent-hover); filter: none; }
.btn-primary:active { background: var(--accent-strong); }
.btn-outline { background: var(--surface); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); box-shadow: none; }
.btn-soft:hover { background: var(--accent-soft-2); }
.btn-success { background: var(--green); color: #fff; box-shadow: none; }
.btn-success:hover { filter: brightness(1.06); background: var(--green); }
.btn-danger { background: var(--red); color: #fff; box-shadow: none; }
.btn-danger:hover { filter: brightness(1.06); background: var(--red); }
.btn-basic { background: transparent; box-shadow: none; color: var(--text-2); font-weight: 500; }
.btn-basic:hover { background: var(--tint); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: var(--r-sm); }
.btn-link { box-shadow: none; color: var(--accent); font-weight: 600; }
.btn-link:hover { color: var(--accent-hover); }
.btn.loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { color: var(--muted); border-radius: var(--r-sm); }
.icon-btn:hover { background: var(--tint); color: var(--text); }
.icon-btn.round { border-radius: 999px; width: 38px; height: 38px; justify-content: center; align-items: center; box-shadow: inset 0 0 0 1px var(--line); position: relative; }
input:focus, textarea:focus, select:focus { box-shadow: inset 0 0 0 2px var(--accent) !important; }
input[type=text], input[type=url], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], textarea, select {
  border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line-strong), 0 1px 2px rgba(15, 23, 42, .04); background-color: var(--surface); height: 36px; padding: 0 12px; border: 0; color: var(--text); }
textarea { height: auto; padding: 8px 12px; }
select { appearance: none; padding-right: 30px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center; cursor: pointer; }
input::placeholder, textarea::placeholder { color: #94a3b8; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
.toggle input:checked + span { background: var(--accent); }
.field > label, .flabel { font-size: 14px; font-weight: 500; color: var(--text-2); }
.card { border-radius: var(--r); box-shadow: var(--shadow); }
.chip { background: var(--tint); color: var(--text-2); border-radius: var(--r-sm); }
.info-box.purple { background: var(--accent-soft); color: var(--accent-ink); }
.status-chip.won, .status-chip.ok { background: var(--green-soft); color: var(--green-text); }
.pill-soft.on { background: var(--green); color: #fff; }
.logo { background: var(--accent); color: #fff; }
a { color: var(--accent); }
.nav a, .menu a, td a.plain, .pal-item { color: inherit; }
a.btn:not(.btn-primary):not(.btn-success):not(.btn-danger):not(.btn-link) { color: var(--text-2); }
th { color: var(--muted); }

/* ── Shell ── */
.shell { grid-template-columns: var(--side) 1fr; }
.sidebar { background: var(--side-bg); color: var(--side-ink); padding: 20px 0 16px; gap: 0; }
.side-brand { display: flex; align-items: center; padding: 0 16px; min-height: 44px; }
.brand-logo { display: flex; align-items: center; min-width: 0; text-decoration: none; color: #fff; }
.brand-logo img { max-height: 44px; max-width: 192px; object-fit: contain; border-radius: 4px; background: #fff; padding: 3px 6px; }
.brand-fallback { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: #fff; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.brand-fallback .logo { width: 28px; height: 28px; border-radius: 6px; font-size: 14px; flex: none; }
.side-close { margin-left: auto; color: var(--side-icon); }

.sidebar .account { margin: 16px 12px 0; padding: 0; }
.sidebar .account-btn { background: #e2e8f0; color: #1e293b; padding: 8px 12px; border-radius: var(--r-sm); gap: 10px; }
.sidebar .account-btn:hover { background: #f1f5f9; }
.sidebar .account-btn .ph { color: #64748b; }
.account-av { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; }
.account-who { flex: 1; min-width: 0; display: grid; text-align: left; line-height: 1.3; }
.account-who b { color: #1e293b; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-who span { color: #475569; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .menu { top: calc(100% + 6px); bottom: auto; color: var(--text-2); z-index: var(--z-dropdown); border-radius: var(--r); box-shadow: var(--shadow-lg); }

.sidebar .nav { margin-top: 24px; padding: 0 8px; gap: 4px; overflow-y: auto; }
.sidebar .nav a, .nav-group > summary { height: 40px; padding: 0 8px; gap: 12px; border-radius: var(--r-sm); color: var(--side-ink); font-weight: 500; font-size: 14px; position: relative; transition: background-color .15s; }
.sidebar .nav a .ph { color: var(--side-icon); font-size: 21px; }
.sidebar .nav a:hover, .nav-group > summary:hover { background: var(--side-hover); }
.sidebar .nav a.active { background: var(--side-hover); color: #fff; font-weight: 600; }
.sidebar .nav a.active .ph { color: #fff; }
.sidebar .nav .count { position: absolute; top: 2px; left: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; margin: 0; line-height: 1; }
.sidebar .nav .count:empty { display: none; }
.nav-group { margin-top: 8px; }
.nav-group > summary { display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer; color: #94a3b8; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; height: 34px; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary .ph { transition: transform .2s cubic-bezier(.22, 1, .36, 1); font-size: 14px; }
.nav-group:not([open]) > summary .ph { transform: rotate(-90deg); }
.nav-group > a, .nav-group > #navCampaigns { margin-left: 18px; padding-left: 12px; border-left: 1px solid var(--side-rule); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.nav-group > a { height: 36px !important; }
.nav-group > a .ph { font-size: 18px !important; }
#navCampaigns a { height: 34px !important; font-weight: 400 !important; color: #cbd5e1 !important; }
#navCampaigns .nav-more { color: #94a3b8; padding: 0 8px; height: 30px; }
.sidebar .nav-quiet { color: #94a3b8 !important; }
.dot { background: #64748b; }
.dot.active { background: #4ade80; }

.side-foot { margin: 24px 12px 0; display: grid; gap: 4px; }
.foot-link { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 6px; border: 0; background: none; color: #e2e8f0; font-size: 14px; text-decoration: none; border-radius: var(--r-sm); cursor: pointer; font-family: inherit; }
.foot-link:hover { background: var(--side-hover); }
.foot-dot { width: 10px; height: 10px; border-radius: 50%; background: #64748b; flex: none; }
.foot-dot.blue { background: #60a5fa; }
.foot-dot.on { background: #4ade80; }
.product-mark { margin-top: 10px; padding: 0 6px; font-size: 12px; color: #94a3b8; letter-spacing: .02em; }

.main { padding: 0; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; height: var(--top); background: var(--surface); box-shadow: 0 1px 3px rgba(15, 23, 42, .08); position: sticky; top: 0; z-index: var(--z-sticky); padding: 0 24px 0 0; gap: 0; }
.page-title { margin: 0 32px; font-size: 15px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text); white-space: nowrap; }
.search-trigger { flex: 1; align-self: stretch; display: flex; align-items: center; gap: 12px; padding: 0 24px; border: 0; border-left: 1px solid var(--line); background: none; color: var(--muted); font-size: 15px; cursor: pointer; text-align: left; min-width: 0; }
.search-trigger .ph { font-size: 20px; }
.search-trigger span { flex: 1; }
kbd { font: 500 12px var(--font); color: var(--muted); border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px 7px; background: var(--surface); }
.top-actions { display: flex; align-items: center; gap: 10px; padding-left: 16px; }
.dot-badge { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--surface); }
.top-create { height: 38px; padding: 0 16px; }
.view { max-width: none; width: 100%; margin: 0; padding: 24px 32px 48px; }
.view > .narrow, .view > .narrower { margin-left: auto; margin-right: auto; }

/* ── Toast & dialogs ── */
.toast { background: #1e293b; color: #fff; border-radius: var(--r); z-index: var(--z-toast); }
.modal { border-radius: 12px; box-shadow: var(--shadow-lg); }
dialog:focus, dialog:focus-visible { outline: none; }   /* the dialog itself; its buttons keep their focus ring */

.slideover { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(640px, 100vw); max-width: 100vw; padding: 0; border: 0; background: var(--surface); color: var(--text-2); box-shadow: -20px 0 40px rgba(15, 23, 42, .18); }
.slideover.wide { width: min(768px, 100vw); }
.slideover[open] { animation: so-in .28s cubic-bezier(.22, 1, .36, 1); }
.slideover::backdrop { background: rgba(15, 23, 42, .45); }
.slideover[open]::backdrop { animation: fade-in .2s ease-out; }
@keyframes so-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } }
.so-inner { display: flex; flex-direction: column; height: 100%; }
.so-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.so-head h2 { font-size: 18px; font-weight: 600; }
.so-body { flex: 1; overflow-y: auto; padding: 20px 24px; display: grid; gap: 18px; align-content: start; }
.so-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); }
.so-error { background: var(--red-soft); color: var(--red); border-radius: var(--r); padding: 10px 12px; font-size: 13.5px; }
.req::after { content: " *"; color: var(--red); }
.divider-label { display: flex; align-items: center; gap: 12px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.divider-label::before, .divider-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.palette { margin: 12vh auto auto; width: min(640px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg), 0 24px 60px rgba(15, 23, 42, .25); color: var(--text-2); }
.palette::backdrop { background: rgba(15, 23, 42, .4); }
.pal-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.pal-input .ph { font-size: 20px; color: var(--muted); }
.pal-input input { flex: 1; height: 56px; box-shadow: none !important; padding: 0; font-size: 16px; background: none; }
.pal-results { max-height: 420px; overflow-y: auto; padding: 8px; }
.pal-group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: var(--r); text-align: left; cursor: pointer; }
.pal-item .ph { font-size: 18px; color: var(--muted); }
.pal-item b { display: block; font-weight: 500; }
.pal-item span span { color: var(--muted); font-size: 12.5px; }
.pal-item.on { background: var(--accent-soft); }
.pal-item.on .ph, .pal-item.on b { color: var(--accent-ink); }
.pal-hint { padding: 18px 12px; color: var(--muted); text-align: center; font-size: 13.5px; }

/* ── CRM: charts ── */
.chart-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 20px 12px; height: 208px; display: flex; flex-direction: column; }
.chart-card h3 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.chart-card h3 .ph { color: #94a3b8; font-size: 15px; }
.chart-card .chart-sub { font-size: 12.5px; color: var(--muted); }
.chart-card svg { flex: 1; width: 100%; min-height: 0; margin-top: 8px; overflow: visible; }
.chart-card svg text { font: 11.5px var(--font); fill: var(--muted); }
.chart-card svg .grid { stroke: var(--line); stroke-dasharray: 3 3; }
.chart-card svg .bar { fill: var(--accent-hover); transition: fill .15s; }
.chart-card svg .bar:hover { fill: var(--accent-strong); }
.chart-card svg .line { fill: none; stroke: var(--green); stroke-width: 2; }
.chart-card svg .area { fill: var(--green); opacity: .08; }
.chart-card svg .val { fill: var(--text-2); font-weight: 600; }

/* ── CRM: view tabs, filter bar ── */
.view-tabs { display: flex; align-items: flex-end; border-bottom: 1px solid var(--line-strong); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.view-tabs button { flex: 0 1 260px; min-width: 110px; height: 40px; padding: 0 18px; border: 1px solid var(--line-strong); border-bottom: 0; margin-right: -1px; background: var(--tint); color: var(--text-2); font: 500 14px var(--font); text-align: left; cursor: pointer; white-space: nowrap; transition: background-color .15s; }
.view-tabs button:first-child { border-top-left-radius: var(--r); }
.view-tabs button:last-of-type { border-top-right-radius: var(--r); }
.view-tabs button:hover { background: var(--surface-2); }
.view-tabs button.on { background: var(--surface); color: var(--text); font-weight: 600; position: relative; }
.view-tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--surface); }
.view-tabs .tab-count { color: var(--muted); font-weight: 500; margin-left: 6px; }

.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.search-box { position: relative; width: 240px; max-width: 100%; }
.search-box .ph { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 17px; pointer-events: none; }
.search-box input { padding-left: 34px; }
.filter-select { height: 34px; box-shadow: none !important; background-color: transparent; font-weight: 600; color: var(--text-2); padding-left: 8px; }
.filter-select:hover { background-color: var(--tint); }
.filter-select.set { background-color: var(--accent-soft); color: var(--accent-ink); }
.filter-select:focus { box-shadow: inset 0 0 0 2px var(--accent) !important; }
.filter-summary { margin-left: auto; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.filter-summary b { font-weight: 600; }

/* ── CRM: data table ── */
.data-table { background: var(--surface); border-radius: var(--r); box-shadow: 0 0 0 1px rgba(15, 23, 42, .1); overflow: hidden; }
.data-table .scroll { overflow-x: auto; }
.data-table table { min-width: 860px; }
.data-table th { text-transform: none; letter-spacing: 0; font-size: 13.5px; font-weight: 500; color: var(--text-2); background: var(--surface-2); padding: 10px 16px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 12px 16px; border-top: 0; border-bottom: 1px solid rgba(15, 23, 42, .05); color: var(--text-2); font-size: 14px; }
.data-table tbody tr { transition: background-color .12s; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tbody tr.overdue td { background: color-mix(in srgb, var(--orange-soft) 70%, transparent); }
.data-table td.cb, .data-table th.cb { width: 44px; padding-right: 0; }
.data-table .rec-link { font-weight: 500; color: var(--accent); text-decoration: none; }
.data-table .rec-link:hover { color: var(--accent-hover); text-decoration: underline; }
.data-table .sub-line { font-size: 12px; color: var(--muted); }
.data-table td.actions, .data-table th.actions { position: sticky; right: 0; background: var(--surface-2); width: 56px; text-align: center; box-shadow: -1px 0 0 var(--line); }
.data-table tbody tr:hover td.actions { background: var(--tint); }
.owner-cell { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.av { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10.5px; font-weight: 600; color: #fff; flex: none; }
.av.lg { width: 32px; height: 32px; font-size: 13px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; font-size: 13.5px; color: var(--muted); flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; }
.pager .pages button { min-width: 34px; height: 34px; border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; color: var(--text-2); font: 500 13.5px var(--font); }
.pager .pages button:hover:not(:disabled) { background: var(--tint); }
.pager .pages button.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.pager .pages button:disabled { opacity: .4; cursor: default; }

.badge-s { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500; line-height: 1.5; white-space: nowrap; background: var(--tint); color: var(--text-2); box-shadow: inset 0 0 0 1px rgba(100, 116, 139, .2); }
.badge-s.success { background: var(--green-soft); color: var(--green-text); box-shadow: inset 0 0 0 1px rgba(22, 163, 74, .25); }
.badge-s.danger { background: var(--red-soft); color: var(--red); box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .2); }
.badge-s.warning { background: var(--orange-soft); color: var(--amber-text); box-shadow: inset 0 0 0 1px rgba(217, 119, 6, .25); }
.badge-s.primary { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .2); }
.svc-list { display: flex; flex-wrap: wrap; gap: 4px; }

.row-menu { position: fixed; z-index: var(--z-dropdown); background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 4px; min-width: 190px; }
.row-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: var(--r-sm); font: 14px var(--font); color: var(--text-2); cursor: pointer; text-align: left; }
.row-menu button:hover { background: var(--tint); }
.row-menu button.danger { color: var(--red); }
.row-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.empty-state { text-align: center; padding: 56px 24px; }
.empty-state .ph { font-size: 44px; color: #94a3b8; }
.empty-state h3 { font-size: 16px; margin: 12px 0 4px; }
.empty-state p { color: var(--muted); margin: 0 auto 16px; max-width: 46ch; }
.skeleton-row td div { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--tint) 25%, var(--tint-2) 50%, var(--tint) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── CRM: board ── */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 300px; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.board-col { background: color-mix(in srgb, var(--tint-2) 45%, transparent); border: 1px solid color-mix(in srgb, var(--line-strong) 45%, transparent); border-radius: var(--r); min-height: 200px; transition: background-color .15s; }
.board-col.drop { background: var(--accent-soft); border-color: var(--accent); }
.board-col header { padding: 10px 12px 8px; }
.board-col header b { font-size: 14px; font-weight: 600; }
.board-col header span { display: block; font-size: 12.5px; color: var(--muted); }
.board-card { background: var(--surface); border-radius: var(--r-sm); box-shadow: 0 1px 3px rgba(15, 23, 42, .1); margin: 0 8px 8px; padding: 10px 14px; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.board-card:hover { box-shadow: 0 4px 10px rgba(15, 23, 42, .12); }
.board-card[draggable=true] { cursor: grab; }
.board-card.dragging { opacity: .5; }
.board-card .bc-name { font-weight: 500; color: var(--accent); }
.board-card .bc-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-top: 4px; }
.board-card .bc-date { font-size: 12px; color: var(--muted); margin-top: 2px; }
.board-card .bc-date.late { color: var(--amber-text); font-weight: 500; }
.board-card.overdue { background: color-mix(in srgb, var(--orange-soft) 60%, var(--surface)); }

/* ── CRM: record pages ── */
.record { max-width: 1280px; margin: 0 auto; }
.rec-head { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 24px; }
.rec-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.rec-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.rec-title h2 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.rec-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--tint-2); color: var(--muted); display: grid; place-items: center; font-size: 22px; flex: none; }
.rec-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 6px; color: var(--muted); font-size: 13.5px; }
.rec-meta b { color: var(--text-2); font-weight: 600; }
.rec-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-actions .btn-success, .rec-actions .btn-danger { padding: 0 20px; }
.rec-lock { margin-top: 14px; display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--muted); }

.stage-bar { display: flex; margin-top: 20px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); overflow-x: auto; }
.stage-bar .st { flex: 1 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 16px; border: 0; background: none; font: 500 13.5px var(--font); color: var(--muted); cursor: pointer; position: relative; white-space: nowrap; min-height: 48px; }
.stage-bar .st:disabled { cursor: default; }
.stage-bar .st + .st::before { content: ""; position: absolute; left: -1px; top: 0; bottom: 0; width: 20px; background: no-repeat center/20px 100% url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 80' preserveAspectRatio='none'%3E%3Cpath d='M0 -2L20 40L0 82' fill='none' stroke='%23cbd5e1' stroke-width='1.5'/%3E%3C/svg%3E"); transform: translateX(-10px); }
.stage-bar .st:not(:disabled):hover { background: var(--tint); }
.stage-bar .circ { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 2px solid var(--line-strong); color: #94a3b8; font-size: 14px; background: var(--surface); }
.stage-bar .st.done { color: var(--text); }
.stage-bar .st.done .circ { background: var(--green); border-color: var(--green); color: #fff; }
.stage-bar .st.cur { color: var(--green-text); font-weight: 600; }
.stage-bar .st.cur .circ { border-color: var(--green); color: var(--green); }
.stage-bar.lost .st.done .circ, .stage-bar.lost .st.cur .circ { background: var(--red); border-color: var(--red); color: #fff; }
.stage-bar.lost .st.cur { color: var(--red); }

.rec-body { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: 32px; margin-top: 24px; align-items: start; }
.panel { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-head h3 span { color: var(--muted); font-weight: 500; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.mini-row + .mini-row { border-top: 1px solid var(--line); }
.mini-row .txt { flex: 1; min-width: 0; }
.mini-row .txt a, .mini-row .txt b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .txt span { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .hover-act { opacity: 0; transition: opacity .15s; }
.mini-row:hover .hover-act, .mini-row:focus-within .hover-act { opacity: 1; }
.tabs-card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
.u-tabs { display: flex; justify-content: center; gap: 28px; border-bottom: 1px solid var(--line); padding: 0 16px; overflow-x: auto; }
.u-tabs button { border: 0; background: none; padding: 16px 2px 14px; font: 500 14px var(--font); color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.u-tabs button:hover { color: var(--text-2); }
.u-tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body { padding: 20px 24px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding-bottom: 18px; position: relative; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 32px; bottom: 0; width: 1px; background: var(--line); }
.timeline .t-ic { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.timeline .t-ic.green { background: var(--green-soft); color: var(--green-text); }
.timeline .t-ic.red { background: var(--red-soft); color: var(--red); }
.timeline b { font-weight: 500; }
.timeline .t-when { font-size: 12.5px; color: var(--muted); }

.svc-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.svc-picker label { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line-strong); cursor: pointer; font-size: 13.5px; font-weight: 500; transition: background-color .15s, box-shadow .15s; user-select: none; }
.svc-picker input { position: absolute; opacity: 0; width: 0; height: 0; }
.svc-picker label:has(input:checked) { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent); }
.svc-picker label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.contact-pick { display: grid; gap: 6px; }
.contact-pick label { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; font-weight: 400; }
.contact-pick label:has(input:checked) { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-soft); }
.new-contact { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.notice-dup { display: flex; gap: 8px; align-items: flex-start; background: var(--orange-soft); color: var(--amber-text); border-radius: var(--r); padding: 10px 12px; font-size: 13.5px; }

/* ── Sign-in page brand ── */
.auth-brand img { max-height: 48px; max-width: 220px; object-fit: contain; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .chart-cards { grid-template-columns: 1fr; }
  .chart-cards .chart-card:nth-child(2) { display: none; }
  .rec-body { grid-template-columns: minmax(0, 1fr); }
  .rec-body > .tabs-card { order: -1; }   /* emails and timeline right under the header */
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: var(--z-drawer); transform: translateX(-100%); transition: transform .25s cubic-bezier(.22, 1, .36, 1); box-shadow: 20px 0 40px rgba(0, 0, 0, .3); }
  .sidebar.open { transform: none; }
  .only-mobile { display: inline-flex !important; }
  .topbar { padding: 0 12px; gap: 8px; }
  .page-title { margin: 0 8px; font-size: 14px; }
  .search-trigger { padding: 0 12px; font-size: 14px; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .hide-sm { display: none !important; }
  .view { padding: 16px 16px 40px; }
  .top-create span { display: none; }
  .top-create { width: 38px; padding: 0; }
  .filter-summary { margin-left: 0; width: 100%; }
  .search-box { width: 100%; }
  .new-contact { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Sign-in page (no app chrome) ── */
body.auth-page .sidebar, body.auth-page .topbar { display: none; }
body.auth-page .shell { grid-template-columns: 1fr; }
body.auth-page { background: var(--side-bg); }
.auth-wrap { max-width: 420px; margin: 10vh auto 0; display: grid; gap: 20px; }
.auth-brand { display: flex; justify-content: center; min-height: 48px; }
.auth-brand img { max-height: 52px; max-width: 240px; background: #fff; padding: 6px 10px; border-radius: 6px; }
.auth-brand .brand-fallback { color: #fff; font-size: 20px; }
.auth-card { background: var(--surface); border-radius: 12px; padding: 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.auth-card h1 { font-size: 20px !important; }
.auth-foot { text-align: center; color: #94a3b8; font-size: 12.5px; margin: 0; }

#view:focus, #view:focus-visible { outline: none; }
.filter-bar select.filter-select { width: auto; max-width: 190px; text-overflow: ellipsis; }
@media (min-width: 641px) and (max-width: 900px) {
  .data-table tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
@media (max-width: 900px) {
  .filter-bar select.filter-select { max-width: calc(50% - 6px); }
}

/* Sidebar scrolls as one column; menu items never shrink. */
.sidebar { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #475569 transparent; }
.sidebar > * { flex-shrink: 0; }
.sidebar .nav { flex: 1 0 auto; overflow: visible; min-height: auto; }
.sidebar .nav > a, .sidebar .nav-group, .sidebar .nav-group > a, #navCampaigns a { flex-shrink: 0; }
.side-foot { margin-top: auto; padding-top: 24px; }
.sidebar .nav { margin-bottom: 0; }

/* Long names end in an ellipsis instead of being cut at the edge. */
.brand-logo { flex: 1; }
.brand-fallback > span:last-child, .nav .ell-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .nav a { min-width: 0; }

/* ── Compact forms (slide-overs and panels) ── */
.slideover { width: min(560px, 100vw); }
.slideover.wide { width: min(720px, 100vw); }
.so-head { padding: 14px 20px; }
.so-head h2 { font-size: 16px; }
.so-body { padding: 16px 20px 20px; gap: 14px; }
.so-foot { padding: 10px 20px; align-items: center; justify-content: space-between; }
.so-btns { display: flex; gap: 8px; margin-left: auto; }
.so-discard { display: flex; align-items: center; gap: 8px; color: var(--amber-text); font-size: 13.5px; font-weight: 500; flex-wrap: wrap; }
.so-body .field, .panel .field { gap: 4px; }
.so-body .field > label, .so-body .flabel { font-size: 13px; font-weight: 500; color: var(--text-2); }
.so-body input[type=text], .so-body input[type=email], .so-body input[type=number], .so-body input[type=date], .so-body input[type=search], .so-body select { height: 34px; font-size: 14px; }
.so-body textarea { min-height: 64px; font-size: 14px; }
.so-body .help { font-size: 12px; }
.so-body .form-grid { gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.svc-picker { gap: 6px; }
.svc-picker label { padding: 5px 10px; font-size: 13px; border-radius: 999px; }
.contact-pick label { padding: 6px 10px; }
.section-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin: 2px 0 -4px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: 600 13px var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.link-btn:hover { color: var(--accent-hover); }

/* Company picker (search, pick yours, or create new) */
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; z-index: 5; padding: 4px; }
.combo-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: var(--r-sm); text-align: left; font: 14px var(--font); color: var(--text-2); cursor: pointer; }
.combo-opt:hover:not(:disabled), .combo-opt.on { background: var(--accent-soft); color: var(--accent-ink); }
.combo-opt:disabled { cursor: not-allowed; opacity: .75; }
.combo-opt small { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.combo-opt.create { color: var(--accent); font-weight: 600; }
.new-co { background: var(--surface-2); border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line); padding: 12px; display: grid; gap: 10px; }
.new-co .between b { font-size: 13.5px; }
@media (max-width: 640px) {
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .so-body { padding: 14px 16px; }
  .so-head, .so-foot { padding-left: 16px; padding-right: 16px; }
}

/* ── Mail ── */
.view.mail-view { padding: 16px 20px; }
.mail { display: grid; grid-template-columns: 210px minmax(300px, 380px) minmax(0, 1fr); height: calc(100dvh - var(--top) - 32px); background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.mail-folders { border-right: 1px solid var(--line); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; background: var(--surface-2); }
.mail-addr { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); padding: 2px 6px 8px; min-width: 0; }
.mail-addr span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-folders select { margin-bottom: 8px; height: 32px; font-size: 13px; }
.mail-compose { margin-bottom: 10px; width: 100%; }
.mail-folder { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 0; background: none; border-radius: var(--r-sm); font: 500 14px var(--font); color: var(--text-2); cursor: pointer; text-align: left; flex-shrink: 0; }
.mail-folder .ph { font-size: 18px; color: var(--muted); }
.mail-folder:hover { background: var(--tint-2); }
.mail-folder.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.mail-folder.on .ph { color: var(--accent); }
.mail-folder span { flex: 1; }
.mail-unread { font-size: 12px; font-weight: 600; color: var(--accent-ink); }
.mail-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.mail-list-head { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); align-items: center; }
.mail-items { overflow-y: auto; flex: 1; min-height: 0; }
.mail-item { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; font: inherit; color: var(--text-2); }
.mail-item:hover { background: var(--surface-2); }
.mail-item.on { background: var(--accent-soft); }
.mail-item .av { margin-top: 2px; width: 30px; height: 30px; font-size: 11.5px; }
.mi-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.mi-top { display: flex; gap: 8px; align-items: baseline; }
.mi-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--text); }
.mi-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.mi-subj { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.mi-snip { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-tags { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.mail-item.unread .mi-who, .mail-item.unread .mi-subj { font-weight: 600; color: var(--text); }
.mail-item.unread .mi-date { color: var(--accent); font-weight: 600; }
.skel-item { cursor: default; flex-direction: column; }
.skel-item div { height: 12px; border-radius: 4px; background: var(--tint); width: 80%; }
.skel-item div + div { width: 55%; margin-top: 6px; }
.skel { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--tint) 25%, var(--tint-2) 50%, var(--tint) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.mail-read { overflow-y: auto; min-width: 0; min-height: 0; }
.mail-empty { height: 100%; min-height: 200px; display: grid; place-content: center; justify-items: center; gap: 4px; color: var(--muted); text-align: center; padding: 24px; }
.mail-empty .ph { font-size: 36px; color: #94a3b8; }
.reader { padding: 20px 24px 32px; }
.reader-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.reader-head h2 { flex: 1; min-width: 200px; font-size: 19px; font-weight: 600; overflow-wrap: anywhere; }
.reader-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mail-back { display: none; }
.reader-meta { display: flex; align-items: flex-start; gap: 12px; margin-top: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.rm-who { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.rm-side { display: grid; justify-items: end; gap: 6px; text-align: right; }
.mail-link { text-decoration: none; }
.reader-atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.att { display: inline-flex; align-items: center; gap: 8px; max-width: 280px; padding: 7px 12px; border: 0; border-radius: var(--r); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font: 500 13px var(--font); color: var(--text-2); cursor: pointer; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--muted); font-weight: 400; white-space: nowrap; }
.att:hover { background: var(--accent-soft); }
.reader-body { margin-top: 18px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.65; color: var(--text); max-width: 80ch; }
.slideover .reader { padding: 0; }
.deal-mails { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.deal-mails .mail-item { align-items: center; }
.mail-item { min-width: 0; max-width: 100%; overflow: hidden; }
.mi-top { min-width: 0; }
.deal-mails .mail-item:last-child { border-bottom: 0; }

@media (max-width: 1100px) {
  .mail { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .mail-folders { grid-column: 1 / -1; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; padding: 8px 10px; gap: 4px; scrollbar-width: none; }
  .mail-addr { display: none; }
  .mail-folders select { margin: 0 6px 0 0; width: auto; }
  .mail-compose { width: auto; margin: 0 8px 0 0; order: 9; margin-left: auto; }
  .mail-folder { height: 34px; white-space: nowrap; }
}
@media (max-width: 760px) {
  .view.mail-view { padding: 0; }
  .mail { grid-template-columns: 1fr; height: calc(100dvh - var(--top)); border-radius: 0; box-shadow: none; }
  .mail-compose { display: none; }
  .mail-read { display: none; }
  .mail.reading .mail-list { display: none; }
  .mail.reading .mail-read { display: block; }
  .mail-back { display: inline-flex; margin: -4px 0 0 -6px; }
  .reader { padding: 14px 16px 28px; }
  .reader-head h2 { min-width: 0; flex-basis: calc(100% - 48px); font-size: 17px; }
  .reader-actions { width: 100%; }
  .reader-meta { flex-wrap: wrap; }
  .rm-side { justify-items: start; text-align: left; width: 100%; padding-left: 44px; }
}

/* ── Phones and small tablets: tables become stacked cards, record pages tighten ── */
@media (max-width: 900px) {
  .data-table table { min-width: 0 !important; }
  .data-table thead { display: none; }
  .data-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); position: relative; }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td { display: block; padding: 0; border: 0 !important; background: none !important; font-size: 13.5px; min-width: 0; text-align: left !important; }
  .data-table td::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 1px; }
  .data-table td.primary-cell { grid-column: 1 / -1; padding-right: 40px; }
  .data-table td.primary-cell::before, .data-table td.full-cell::before, .data-table td[data-label=""]::before { display: none; }
  .data-table td.full-cell { grid-column: 1 / -1; }
  .data-table td.cb { display: none; }
  .data-table td.actions::before, .data-table td .sub-line:only-of-type:empty { display: none; }
  #getStarted { display: none !important; }
  .data-table td.actions { position: absolute; top: 8px; right: 6px; width: auto; box-shadow: none; }
  .data-table tbody tr.overdue { background: color-mix(in srgb, var(--orange-soft) 70%, transparent); }
  .pager { justify-content: center; }
  .pager > span:first-child { width: 100%; text-align: center; }
  .rec-head { padding: 16px; }
  .rec-title h2 { font-size: 19px; }
  .rec-top { gap: 12px; }
  .rec-actions { width: 100%; }
  .rec-actions .btn-success, .rec-actions .btn-danger { flex: 1; }
  .rec-body { gap: 16px; margin-top: 16px; }
  .panel { padding: 14px 16px; }
  .u-tabs { justify-content: flex-start; gap: 20px; }
  .tab-body { padding: 16px; }
  .chart-card { height: 180px; padding: 14px 16px 10px; }
  .view-tabs button { min-width: 0; flex: 0 0 auto; padding: 0 14px; }
  .filter-bar { gap: 6px; }
  .filter-bar .seg { margin-left: auto; }
  .board { grid-auto-columns: 82vw; }
  .stage-bar .st { padding: 8px 12px; }
}

/* ── Forms open as a centred pop-up box (not a side panel) ── */
.slideover { margin: auto; height: fit-content; max-height: min(92dvh, 860px); width: min(640px, calc(100vw - 32px)); border-radius: 14px; box-shadow: 0 24px 64px rgba(15, 23, 42, .28), 0 0 0 1px var(--line); overflow: hidden; }
.slideover.wide { width: min(760px, calc(100vw - 32px)); }
.slideover[open] { animation: pop-in .22s cubic-bezier(.22, 1, .36, 1); }
@keyframes pop-in { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.slideover .so-inner { max-height: inherit; height: auto; }
.slideover .so-body { max-height: calc(min(92dvh, 860px) - 118px); }
.so-head { background: var(--surface); }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ai-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--purple); background: var(--purple-soft); border-radius: 999px; padding: 0 7px; margin-left: 6px; }
.ai-btn { margin-left: auto; border: 0; background: none; color: var(--purple); font: 600 12px var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 3px; padding: 0; }
.ai-btn:disabled { opacity: .5; cursor: progress; }
.field > label.with-act { display: flex; align-items: center; }
@media (max-width: 640px) {
  .slideover, .slideover.wide { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .slideover .so-inner { height: 100dvh; max-height: none; }
  .slideover .so-body { max-height: none; }
  .form-grid.two { grid-template-columns: 1fr; }
}

/* ── Compose button (Inbox) ── */
.mail-folders .mail-compose { display: inline-flex; align-items: center; gap: 10px; height: 48px; padding: 0 22px 0 18px; margin: 0 0 12px; width: auto; align-self: flex-start; border: 0; border-radius: 16px; background: var(--accent); color: #fff; font: 600 14.5px var(--font); cursor: pointer; box-shadow: 0 1px 3px rgba(15, 23, 42, .18), 0 4px 10px rgba(79, 70, 229, .25); transition: box-shadow .15s, background-color .15s; }
.mail-folders .mail-compose:hover { background: var(--accent-hover); box-shadow: 0 2px 6px rgba(15, 23, 42, .2), 0 8px 18px rgba(79, 70, 229, .3); }
.mail-folders .mail-compose .ph { font-size: 20px; color: #fff; }
@media (max-width: 1100px) {
  .mail-folders .mail-compose { height: 36px; margin: 0 8px 0 0; padding: 0 14px; border-radius: 10px; order: 0; box-shadow: none; }
}
@media (max-width: 760px) {
  .mail-folders .mail-compose { display: inline-flex !important; position: fixed; right: 16px; bottom: 20px; z-index: var(--z-sticky); height: 54px; padding: 0 20px; border-radius: 18px; margin: 0; box-shadow: 0 6px 20px rgba(15, 23, 42, .3); }
  .mail.reading .mail-folders .mail-compose { display: none !important; }
}

/* ── Composer window (Gmail-style) ── */
.composer-win { position: fixed; right: 24px; bottom: 0; z-index: var(--z-drawer); width: min(560px, calc(100vw - 32px)); height: min(600px, calc(100dvh - 80px)); display: flex; flex-direction: column; background: var(--surface); color: var(--text-2); border-radius: 12px 12px 0 0; box-shadow: 0 8px 40px rgba(15, 23, 42, .28), 0 0 0 1px var(--line); animation: cw-in .22s cubic-bezier(.22, 1, .36, 1); }
@keyframes cw-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.composer-win.min { height: auto; width: 300px; }
.composer-win.min > :not(.cw-head) { display: none; }
.composer-win.max { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(1000px, calc(100vw - 64px)); height: min(820px, calc(100dvh - 64px)); border-radius: 12px; animation: none; box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .4), 0 24px 64px rgba(15, 23, 42, .35); }
.cw-head { display: flex; align-items: center; gap: 2px; height: 42px; padding: 0 8px 0 16px; background: #1e293b; color: #fff; border-radius: 12px 12px 0 0; cursor: pointer; flex: none; }
.composer-win.max .cw-head { border-radius: 12px 12px 0 0; }
.cw-title { flex: 1; color: #fff; font-size: 14px; font-weight: 600; }
.cw-hbtn { width: 30px; height: 30px; border: 0; background: none; color: #cbd5e1; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.cw-hbtn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.cw-hbtn .ph { font-size: 17px; }
.cw-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding: 0 16px; position: relative; }
.cw-row { display: flex; align-items: center; gap: 8px; min-height: 42px; border-bottom: 1px solid var(--line); flex: none; }
.cw-lbl { font-size: 13.5px; color: var(--muted); width: 34px; flex: none; }
.cw-from { height: 32px !important; box-shadow: none !important; padding-left: 0; background-color: transparent; font-size: 14px; max-width: 100%; }
.cw-subj { height: 40px !important; box-shadow: none !important; padding: 0 !important; font-size: 14.5px !important; font-weight: 500; background: transparent !important; }
.cw-ccbcc { display: flex; gap: 8px; margin-left: auto; }
.cw-ccbcc button { border: 0; background: none; color: var(--muted); font: 500 13px var(--font); cursor: pointer; padding: 4px; }
.cw-ccbcc button:hover { color: var(--text); text-decoration: underline; }
.rcpt { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 5px 0; position: relative; cursor: text; }
.rcpt-in { flex: 1; min-width: 120px; height: 28px !important; border: 0; box-shadow: none !important; padding: 0 2px !important; background: transparent !important; font-size: 14px; }
.rcpt-chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--tint); box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; color: var(--text); max-width: 100%; }
.rcpt-chip.bad { background: var(--red-soft); color: var(--red); box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .35); }
.rcpt-chip button { border: 0; background: none; padding: 2px; border-radius: 50%; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.rcpt-chip button:hover { background: var(--tint-2); color: var(--text); }
.rcpt-list { position: absolute; left: 0; top: calc(100% + 2px); z-index: 3; width: min(420px, 100%); background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 4px; }
.rcpt-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; background: none; border-radius: var(--r-sm); text-align: left; font: 13.5px var(--font); color: var(--text-2); cursor: pointer; }
.rcpt-list button.on, .rcpt-list button:hover { background: var(--accent-soft); }
.rcpt-list b { font-weight: 500; color: var(--text); }
.cw-editor { flex: 1; min-height: 160px; padding: 12px 0; outline: none; font-size: 14.5px; line-height: 1.6; color: var(--text); overflow-wrap: anywhere; }
.cw-editor:empty::before { content: attr(data-placeholder); color: #94a3b8; }
.cw-editor blockquote { margin: 8px 0 0; padding-left: 12px; border-left: 1px solid var(--line-strong); color: var(--muted); }
.cw-editor ul, .cw-editor ol { padding-left: 22px; margin: 4px 0; }
.cw-editor a { color: var(--accent); }
.cw-sig { font-size: 13px; color: var(--muted); padding: 6px 0 10px; border-top: 1px dashed var(--line); white-space: normal; }
.cw-files { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 10px; }
.cw-files:empty { display: none; }
.cw-files .att { cursor: default; }
.cw-files .att button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 0 0 2px; display: grid; place-items: center; }
.cw-files .att button:hover { color: var(--red); }
.cw-drop { display: none; position: absolute; inset: 8px; border: 2px dashed var(--accent); border-radius: var(--r); background: color-mix(in srgb, var(--accent-soft) 85%, transparent); color: var(--accent-ink); font-weight: 600; place-items: center; z-index: 4; }
.composer-win.dragging .cw-drop { display: grid; }
.cw-err { margin: 0 16px 8px; flex: none; }
.cw-foot { display: flex; align-items: center; gap: 6px; padding: 10px 12px 12px 16px; border-top: 1px solid var(--line); flex: none; }
.cw-send { height: 38px; padding: 0 20px; border-radius: 999px; }
.cw-tools { display: flex; align-items: center; gap: 1px; flex-wrap: wrap; margin-left: 6px; }
.cw-tools button { width: 32px; height: 32px; border: 0; background: none; border-radius: 6px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.cw-tools button:hover { background: var(--tint); color: var(--text); }
.cw-tools button.on { background: var(--accent-soft); color: var(--accent-ink); }
.cw-tools .ph { font-size: 18px; }
.cw-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.cw-trash { margin-left: auto; width: 34px; height: 34px; border: 0; background: none; border-radius: 6px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.cw-trash:hover { background: var(--red-soft); color: var(--red); }
.cw-trash .ph { font-size: 18px; }
@media (max-width: 640px) {
  .composer-win, .composer-win.max { right: 0; bottom: 0; left: 0; top: 0; transform: none; width: 100vw; height: 100dvh; border-radius: 0; box-shadow: none; }
  .composer-win.min { top: auto; height: auto; width: 100vw; }
  .cw-head, .composer-win.max .cw-head { border-radius: 0; }
  .cw-tools button[data-cmd="removeFormat"], .cw-tools button[data-cmd="insertOrderedList"], .cw-sep { display: none; }
  .cw-tools { flex-wrap: nowrap; margin-left: 2px; }
  .cw-tools button { width: 30px; }
  .cw-send { padding: 0 16px; }
}

/* ── Recipients: suggestions and contact picker ── */
.cw-pick { border: 0; background: none; padding: 2px 0; text-align: left; font: inherit; color: var(--muted); cursor: pointer; border-radius: 4px; }
.cw-pick:hover { color: var(--accent); text-decoration: underline; }
.cw-book { color: var(--muted); display: grid !important; place-items: center; }
.cw-book .ph { font-size: 18px; }
.rcpt-list { width: min(460px, 100%); max-height: 320px; overflow-y: auto; }
.rcpt-head { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 6px 8px 4px; }
.rcpt-list button { align-items: center; }
.rl-txt { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.rl-txt b { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-txt span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rcpt-list small { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cw-picker { position: absolute; inset: 42px 0 0; z-index: 6; background: var(--surface); display: flex; flex-direction: column; animation: fade-in .15s ease-out; }
.cwp-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.cwp-head b { flex: 1; font-size: 14px; }
.cwp-mine { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.cwp-search { position: relative; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.cwp-search .ph { position: absolute; left: 24px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.cwp-search input { padding-left: 34px; }
.cwp-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.cwp-co { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 6px 4px; }
.cwp-row { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--r-sm); cursor: pointer; font-weight: 400; }
.cwp-row:hover { background: var(--surface-2); }
.cwp-row:has(input:checked) { background: var(--accent-soft); }
.cwp-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }

/* ── Deals table: tighter rows ── */
.data-table td { padding-top: 10px; padding-bottom: 10px; }
.stage-cell { display: inline-flex; align-items: center; gap: 8px; max-width: 230px; white-space: nowrap; }
.stage-cell .st-name { overflow: hidden; text-overflow: ellipsis; font-weight: 500; color: var(--text); }
.st-dots { display: inline-flex; gap: 3px; flex: none; }
.st-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--tint-2); }
.st-dots i.on { background: var(--accent-hover); }
.st-dots.won i.on { background: var(--green); }
.st-dots.lost i.on { background: var(--red); }
.data-table td .svc-list { flex-wrap: nowrap; }
.data-table td:has(.svc-list) { max-width: 230px; overflow: hidden; }
.data-table .deal-close { white-space: nowrap; }
@media (max-width: 640px) {
  .stage-cell { max-width: 100%; white-space: normal; }
  .data-table td .svc-list { flex-wrap: wrap; }
  .data-table td:has(.svc-list) { max-width: none; }
}

/* ── Leads that got an email reply ── */
.reply-line { display: inline-flex; align-items: center; gap: 5px; margin-top: 2px; font-size: 12.5px; color: var(--green-text); max-width: 100%; }
.reply-line .ph { font-size: 14px; flex: none; }
.reply-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-line b { flex: none; font-size: 11px; font-weight: 700; color: #fff; background: var(--green); border-radius: 999px; padding: 0 7px; line-height: 18px; }
.reply-line.new span { font-weight: 600; }
.data-table tbody tr.replied td { background: color-mix(in srgb, var(--green-soft) 70%, transparent); }
.data-table tbody tr.replied:hover td { background: var(--green-soft); }
.data-table tbody tr.replied td.actions { background: color-mix(in srgb, var(--green-soft) 85%, var(--surface-2)); }
.view-tabs button.has-new { color: var(--green-text); }
.view-tabs button .ph { font-size: 15px; vertical-align: -2px; }
.tab-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-left: 6px; vertical-align: 1px; }
.u-tabs button .ph { font-size: 16px; vertical-align: -3px; }
.rec-head .reply-line { margin-top: 6px; font-size: 13.5px; }

/* ── Phones: compact everything ── */
@media (max-width: 640px) {
  .view { padding: 12px 12px 32px; }
  .chart-cards { display: none; }
  .view-tabs { margin-bottom: 10px; }
  .view-tabs button { height: 36px; padding: 0 12px; font-size: 13.5px; }
  .filter-bar { gap: 6px; margin-bottom: 10px; }
  .filter-bar .search-box input { height: 36px; }
  .filter-bar select.filter-select { height: 30px; font-size: 13px; padding: 0 24px 0 8px; max-width: calc(50% - 4px); background-position: right 8px center; }
  .filter-summary { font-size: 13px; width: auto; margin-left: 0; }
  .filter-bar .seg { margin-left: auto; }
  .filter-bar .seg button { padding: 3px 8px; font-size: 13px; }

  /* Generic tables: one short line per field */
  .data-table tbody tr { gap: 3px 12px; padding: 10px 12px; }
  .data-table td { font-size: 13px; line-height: 1.4; }
  .data-table td::before { display: inline; margin: 0 4px 0 0; font-size: 12px; }
  .data-table td .sub-line { font-size: 12px; }

  /* Record pages */
  .rec-head { padding: 14px; }
  .rec-title h2 { font-size: 18px; }
  .stage-bar { margin-top: 12px; }
  .stage-bar .st { min-height: 40px; padding: 6px 10px; gap: 6px; font-size: 12.5px; }
  .stage-bar .circ { width: 22px; height: 22px; font-size: 12px; }
  .panel { margin-bottom: 10px; }
  .kv { gap: 6px 10px; font-size: 13px; }
}

/* ── Deals under 900px: a three-line card, no field labels ── */
.reply-line { display: flex; width: fit-content; }
@media (max-width: 900px) {
  .chart-cards { display: none; }
  .data-table tbody tr { gap: 3px 12px; padding: 10px 12px; }
  .data-table td { font-size: 13px; line-height: 1.4; }
  .data-table td::before { display: inline; margin: 0 4px 0 0; font-size: 12px; }
  .data-table td .sub-line { font-size: 12px; }
  .deals-table tbody tr { display: flex !important; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 10px 12px; }
  .deals-table td { padding: 0 !important; }
  .deals-table td::before { display: none !important; }
  .deals-table td.c-name { flex: 1 1 60%; min-width: 0; order: 1; padding-right: 32px !important; }
  .deals-table td.c-amt { order: 2; font-weight: 600; color: var(--text); margin-right: 26px; }
  .deals-table td.c-stage { flex: 1 1 100%; order: 3; }
  .deals-table td.c-svc { order: 4; }
  .deals-table td.c-close { order: 5; font-size: 12.5px; color: var(--muted); }
  .deals-table td.c-status { order: 6; }
  .deals-table td.c-owner { order: 7; margin-left: auto; font-size: 12.5px; }
  .deals-table td.c-close:empty, .deals-table td.c-close:not(:has(*)):is(:empty) { display: none; }
  .deals-table td.actions { top: 6px; right: 4px; }
  .deals-table tbody tr.replied { background: var(--green-soft); }
  .deals-table tbody tr.overdue:not(.replied) { background: color-mix(in srgb, var(--orange-soft) 70%, transparent); }
  .deals-table .rec-link { font-size: 14.5px; }
  .deals-table .stage-cell { font-size: 13px; }
}

/* ── Conversation (thread) view ── */
.thread { padding: 18px 22px 24px; }
.thread-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.thread-top h2 { font-size: 19px; font-weight: 600; flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.thread-count { font-size: 12.5px; color: var(--muted); background: var(--tint); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.thread-msgs { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.tm + .tm { border-top: 1px solid var(--line); }
.tm-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; min-width: 0; }
.tm-head:hover { background: var(--surface-2); }
.tm-head:focus-visible { outline-offset: -2px; }
.tm-head .av { width: 30px; height: 30px; font-size: 11.5px; flex: none; }
.tm-who { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.tm-who b { font-weight: 600; color: var(--text); white-space: nowrap; }
.tm-who .badge-s { font-size: 11px; padding: 0 6px; }
.tm-snip { flex: 1 1 200px; min-width: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-to { display: none; flex-basis: 100%; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-date { font-size: 12.5px; color: var(--muted); white-space: nowrap; flex: none; }
.tm-clip { flex: none; }
.tm-body { display: none; padding: 2px 14px 14px 54px; }
.tm.open .tm-body { display: block; }
.tm.open .tm-snip { display: none; }
.tm.open .tm-to { display: block; }
.tm.ours:not(.open) .tm-head { background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.tm .reader-body { margin-top: 6px; }
.tm-more { margin-top: 8px; border: 0; background: var(--tint-2); color: var(--text-2); border-radius: 6px; padding: 0 8px; height: 16px; line-height: 16px; font-size: 10px; letter-spacing: 1px; cursor: pointer; }
.tm-more:hover { background: var(--line-strong); }
.tm-quoted { color: var(--muted); border-left: 1px solid var(--line-strong); padding-left: 12px; margin-top: 8px; font-size: 13.5px; }
.tm-acts { display: flex; gap: 4px; margin-top: 12px; }
.tm-acts .btn { color: var(--muted); }
.thread-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.thread-actions .btn { border-radius: 999px; padding: 0 18px; }
.conv-n { display: inline-block; font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--tint-2); border-radius: 999px; padding: 0 6px; margin-left: 2px; }
.conv-row .badge-s { flex: none; }
.so-body { grid-template-columns: minmax(0, 1fr); }
.slideover.thread-dialog .so-body { padding: 12px 16px 16px; }
.slideover.thread-dialog .thread { padding: 0; }
@media (max-width: 760px) {
  .thread { padding: 12px 12px 20px; }
  .thread-top { gap: 8px; }
  .thread-top h2 { font-size: 17px; flex-basis: calc(100% - 48px); }
  .tm-head { padding: 10px 12px; gap: 8px; }
  .tm-body { padding: 2px 12px 12px; }
  .tm-snip { flex-basis: 100%; }
  .thread-actions .btn { flex: 1; padding: 0 10px; }
}

/* ── Reply inside the thread (not a floating window) ── */
.thread-reply { margin-top: 16px; }
.thread-reply .thread-actions { margin-top: 0; }
.composer-win.composer-inline, .composer-win.composer-inline.max {
  position: static !important; inset: auto !important; transform: none !important; z-index: auto;
  width: 100% !important; height: auto !important; min-height: 0; max-height: none;
  border-radius: var(--r) !important; animation: cw-inline-in .2s cubic-bezier(.22, 1, .36, 1);
  box-shadow: 0 0 0 1px var(--line-strong), 0 4px 14px rgba(15, 23, 42, .08) !important;
}
@keyframes cw-inline-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.composer-inline .cw-head { background: var(--surface-2); border-bottom: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0 !important; cursor: default; height: 40px; }
.composer-inline .cw-title { color: var(--text); font-size: 13.5px; }
.composer-inline .cw-hbtn { color: var(--muted); }
.composer-inline .cw-hbtn:hover { background: var(--tint-2); color: var(--text); }
.composer-inline .cw-hbtn[data-cw="min"], .composer-inline .cw-hbtn[data-cw="max"] { display: none; }
.composer-inline .cw-body { overflow: visible; }
.composer-inline .cw-editor { min-height: 140px; }
.composer-inline .cw-picker { inset: 40px 0 0; border-radius: 0 0 var(--r) var(--r); }

/* ── Write with AI ── */
.cw-ai-row { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--purple-soft); flex: none; }
.cw-ai-row > .ph { color: var(--purple); font-size: 16px; flex: none; }
.cw-ai-row input { flex: 1; min-width: 0; height: 30px !important; border: 0; box-shadow: none !important; background: transparent !important; padding: 0 !important; font-size: 13.5px; }
.cw-ai-go { flex: none; height: 30px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--purple); color: #fff; font: 600 13px var(--font); cursor: pointer; transition: filter .15s; }
.cw-ai-go:hover { filter: brightness(1.08); }
.cw-ai-go:disabled { cursor: progress; }
.cw-ai-go.busy { background: linear-gradient(90deg, var(--purple), #a78bfa, var(--purple)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.cw-editor blockquote { font-size: 13.5px; }
.cw-editor blockquote b { color: var(--text-2); font-weight: 600; }
@media (max-width: 640px) {
  .cw-ai-row { border-radius: var(--r); flex-wrap: wrap; padding: 8px 10px; }
  .cw-ai-row input { flex-basis: calc(100% - 30px); }
  .cw-ai-go { width: 100%; }
}

/* ── Send and the editing tools stay in reach (pinned while you scroll) ── */
.composer-inline .cw-foot {
  position: sticky; bottom: 0; z-index: 3; background: var(--surface);
  border-radius: 0 0 var(--r) var(--r); box-shadow: 0 -6px 12px -8px rgba(15, 23, 42, .18);
}
.composer-inline .cw-err { position: sticky; bottom: 58px; z-index: 3; }

/* The email trail under a reply: folded, read-only, sent under the signature */
.cw-trail-wrap { padding: 4px 0 12px; }
.cw-trail-toggle { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--tint-2); color: var(--text-2); font: 500 12.5px var(--font); cursor: pointer; }
.cw-trail-toggle:hover { background: var(--line-strong); }
.cw-trail-toggle .ph { font-size: 15px; }
.cw-trail { margin: 10px 0 0; padding-left: 12px; border-left: 1px solid var(--line-strong); color: var(--muted); font-size: 13.5px; line-height: 1.55; overflow-wrap: anywhere; }
.cw-trail b { color: var(--text-2); font-weight: 600; }
.composer-inline .cw-sig { margin-top: 4px; }
