/* Trillium Ads — modern admin shell */
:root {
  --ink: #0b1220;
  --ink-soft: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --canvas: #f1f5f9;
  --panel: #ffffff;
  --sidebar: #0b1220;
  --sidebar-text: #94a3b8;
  --sidebar-active: #f8fafc;
  --accent: #0284c7;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--panel));
  --focus: color-mix(in srgb, var(--accent) 40%, transparent);
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --err: #dc2626;
  --err-soft: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
  --font: "Manrope", "Source Sans 3", system-ui, sans-serif;
  --font-display: "Manrope", system-ui, sans-serif;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
  color: var(--sidebar-text);
  padding: 20px 14px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid rgba(148, 163, 184, 0.12);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
  padding: 6px 10px 18px;
}
.sidebar-brand img { height: 28px; width: auto; }
.sidebar-brand span { line-height: 1.2; }

.nav-group { margin-bottom: 18px; }
.nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  padding: 0 10px 8px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 8px;
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover {
  background: rgba(148, 163, 184, 0.1);
  color: #fff;
  text-decoration: none;
}
.nav-link.is-active {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  color: #fff;
}
.nav-link.is-active::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--warn);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}
html[data-sidebar="collapsed"] .nav-badge { position: absolute; top: 2px; right: 4px; min-width: 16px; padding: 0 4px; font-size: 10px; }
.nav-more { margin: 4px 0 18px; }
.nav-more summary {
  list-style: none;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 10px;
}
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary:hover { color: #fff; }
html[data-sidebar="collapsed"] .nav-more summary { font-size: 0; }
html[data-sidebar="collapsed"] .nav-more summary::before {
  content: "";
  display: block;
  width: 16px;
  height: 2px;
  margin: 8px auto;
  background: var(--sidebar-text);
  box-shadow: 0 -5px 0 var(--sidebar-text), 0 5px 0 var(--sidebar-text);
}

.main {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  margin-right: auto;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.menu-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 700;
  cursor: pointer;
}

html[data-sidebar="collapsed"] { --sidebar-w: 76px; }
html[data-sidebar="collapsed"] .sidebar { padding-left: 8px; padding-right: 8px; }
html[data-sidebar="collapsed"] .sidebar-brand span,
html[data-sidebar="collapsed"] .nav-label,
html[data-sidebar="collapsed"] .sidebar-foot { display: none; }
html[data-sidebar="collapsed"] .nav-link {
  justify-content: center;
  font-size: 0;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
}
html[data-sidebar="collapsed"] .nav-link .icon { width: 20px; height: 20px; }
html[data-sidebar="collapsed"] .nav-link.is-active::before { display: none; }

.content {
  padding: 28px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  animation: rise 0.4s ease-out both;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.2vw, 1.9rem);
  letter-spacing: -0.04em;
  margin: 0 0 6px;
  font-weight: 800;
  color: var(--ink);
}
.page-head .muted { margin: 0; max-width: 56ch; color: var(--muted); }
.page-head .btn-row { margin-top: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.card h2 {
  font-family: var(--font-display);
  font-size: 1.02rem;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.muted { color: var(--muted); }
.flash {
  background: var(--ok-soft);
  color: #14532d;
  border: 1px solid #bbf7d0;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
}
.error {
  background: var(--err-soft);
  color: #7f1d1d;
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
}

label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 0.86rem; font-weight: 600; }
input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 90px; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--focus);
  border-color: var(--accent);
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, filter 0.15s ease;
}
button:hover, .btn:hover {
  filter: brightness(1.05);
  text-decoration: none;
  transform: translateY(-1px);
  color: #fff;
}
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn-secondary:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong));
  background: var(--accent-soft);
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.btn-row form { margin: 0; }
.btn-row button, .btn-row .btn { margin-top: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
th { color: var(--muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

pre {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
  font-size: 0.84rem;
  color: var(--ink-soft);
}
code { font-size: 0.8rem; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-active { color: #166534; background: var(--ok-soft); border-color: #bbf7d0; }
.status-paused { color: #92400e; background: var(--warn-soft); border-color: #fde68a; }
.status-other { color: #334155; background: #f1f5f9; border-color: var(--line); }

.meta-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.meta-list li { display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.92rem; color: var(--muted); }
.meta-list strong { color: var(--ink); font-weight: 700; min-width: 7.5rem; }

.campaign-media {
  width: 100%;
  max-height: 340px;
  border-radius: 12px;
  background: #0b1220;
  border: 1px solid var(--line);
  object-fit: contain;
}
.divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }
.footer { margin-top: 28px; color: var(--muted); font-size: 0.78rem; }

.sidebar-foot {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  font-size: 0.78rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--sidebar-w));
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 40;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 30;
  }
  .menu-toggle { display: inline-flex; }
  html[data-sidebar="collapsed"] { --sidebar-w: 248px; }
  .content { padding: 18px 16px 32px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Icons — color follows currentColor / accent */
.icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: -3px;
  color: currentColor;
}
.nav-link .icon { color: inherit; opacity: 0.9; }
.nav-link.is-active .icon,
.nav-link:hover .icon { color: var(--accent); opacity: 1; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  margin: 0;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); transform: none; filter: none; }
.icon-btn .icon { width: 18px; height: 18px; }

.theme-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.accent-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
  padding: 0;
  margin: 0;
}
.accent-dot.is-selected { box-shadow: 0 0 0 2px var(--accent); }

/* Dark theme */
html[data-theme="dark"] {
  --ink: #e2e8f0;
  --ink-soft: #cbd5e1;
  --muted: #94a3b8;
  --line: #1f2a3a;
  --line-strong: #334155;
  --canvas: #020617;
  --panel: #0f172a;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 28px rgba(0,0,0,.25);
}
html[data-theme="dark"] .topbar {
  background: rgba(15, 23, 42, 0.9);
  border-bottom-color: var(--line);
}
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: #020617;
  color: var(--ink);
  border-color: var(--line-strong);
}
html[data-theme="dark"] .btn-secondary {
  background: #1e293b;
  color: var(--ink);
  border-color: var(--line-strong);
}
html[data-theme="dark"] pre,
html[data-theme="dark"] code { background: #020617; color: var(--ink-soft); }
html[data-theme="dark"] .flash { background: #052e16; color: #86efac; border-color: #166534; }
html[data-theme="dark"] .error { background: #450a0a; color: #fecaca; border-color: #7f1d1d; }
html[data-theme="dark"] .status-active { color: #86efac; background: #052e16; border-color: #166534; }
html[data-theme="dark"] .status-paused { color: #fcd34d; background: #422006; border-color: #92400e; }
html[data-theme="dark"] .status-other { color: #cbd5e1; background: #1e293b; border-color: #334155; }
html[data-theme="dark"] .menu-toggle,
html[data-theme="dark"] .bulk-bar,
html[data-theme="dark"] .tl-body,
html[data-theme="dark"] pre { background: #020617; }
html[data-theme="dark"] .board-col { background: #0b1220; }
html[data-theme="dark"] .board-card { background: var(--panel); }
html[data-theme="dark"] .sheet-table tbody tr:hover td,
html[data-theme="dark"] .due-row:hover,
html[data-theme="dark"] .msg-row:hover { background: #111827; }
html[data-theme="dark"] .filters,
html[data-theme="dark"] .approval { background: var(--panel); }

@media (prefers-reduced-motion: reduce) {
  .content { animation: none; }
  button, .btn, .nav-link, .sidebar { transition: none; }
}

/* Widgets */
.widget-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.widget { grid-column: span 3; min-width: 0; }
.widget-wide { grid-column: span 8; }
.widget-side { grid-column: span 4; }
.widget-full { grid-column: span 12; }
@media (max-width: 1100px) {
  .widget, .widget-wide, .widget-side { grid-column: span 6; }
}
@media (max-width: 700px) {
  .widget, .widget-wide, .widget-side, .widget-full { grid-column: span 12; }
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
}
.stat-card .stat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-card .stat-label .icon { color: var(--accent); }
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--ink);
  line-height: 1.1;
}
.stat-card .stat-hint { color: var(--muted); font-size: 0.85rem; }

.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { max-width: 100%; }

.widget-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.widget-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  margin: 0;
}
.widget-toggle input { width: auto; margin: 0; accent-color: var(--accent); }
.widget-toggle.is-on { color: var(--ink); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.widget[hidden] { display: none !important; }

/* Notification center */
.notif-wrap {
  position: relative;
}
.notif-bell {
  position: relative;
}
.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  border: 2px solid var(--panel, #fff);
}
.notif-badge.is-hidden,
.notif-badge[hidden] {
  display: none;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 480px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14);
  z-index: 40;
  overflow: hidden;
  animation: notif-in 0.16s ease-out;
}
.notif-panel[hidden] { display: none !important; }
@keyframes notif-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .notif-panel { animation: none; }
}
.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.notif-panel-head strong {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}
.notif-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.notif-panel-actions form { margin: 0; }
.notif-link-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}
.notif-link-btn:hover { text-decoration: underline; }
.notif-panel-list {
  overflow-y: auto;
  flex: 1;
}
.notif-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--line);
  transition: background 0.12s ease;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.notif-item.is-unread { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.notif-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.notif-item-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}
.notif-item-body {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}
.notif-item-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
}
.notif-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 0.9rem;
}
.notif-sev {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--muted);
}
.notif-sev-success { background: var(--ok, #16a34a); }
.notif-sev-warning { background: var(--warn, #ca8a04); }
.notif-sev-error { background: #e11d48; }
.notif-sev-info { background: var(--accent); }

.notif-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--line);
}
.notif-row:last-child { border-bottom: 0; }
.notif-row:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.notif-row.is-unread .notif-title { font-weight: 800; }
.notif-body { min-width: 0; }
.notif-title { color: var(--ink); font-size: 0.95rem; font-weight: 700; }

html[data-theme="dark"] .notif-panel {
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}
html[data-theme="dark"] .notif-badge {
  border-color: var(--sidebar, #0f172a);
}

.ask-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr) 260px; gap: 22px; align-items: start; }
.ask-rail ul, .ask-task { list-style: none; padding: 0; margin: 12px 0 0; }
.ask-rail li { margin: 8px 0; }
.ask-rail a { display: flex; flex-direction: column; gap: 4px; color: var(--ink); text-decoration: none; }
.ask-rail a.is-current strong { color: var(--accent); }
.ask-hello h1 { font-size: 1.7rem; letter-spacing: -0.03em; margin: 8px 0; }
.ask-msg { padding: 12px 0; border-bottom: 1px solid var(--line); }
.ask-msg span { display: block; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ask-msg em { font-style: normal; margin-left: 6px; }
.ask-msg p { margin: 4px 0 0; white-space: pre-wrap; }
.ask-box { display: flex; gap: 8px; align-items: flex-end; margin-top: 16px; }
.ask-box textarea { flex: 1; min-height: 64px; margin: 0; }
.ask-box button { margin: 0; }
.ask-plus { position: relative; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 9px; font-weight: 800; cursor: pointer; margin: 0; }
.ask-plus input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ask-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ask-chips form { margin: 0; }
.ask-chips button { margin: 0; text-align: left; }
.ask-hint { margin-top: 8px; }
.ask-task { padding-top: 4px; }
@media (max-width: 980px) {
  .ask-shell { grid-template-columns: 1fr; }
}

.channel-picks { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 14px 0; display: flex; flex-wrap: wrap; gap: 10px 18px; }
.channel-picks legend { padding: 0 6px; color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.channel-picks label, .check-line { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 0; }
.channel-picks input, .check-line input { width: auto; margin: 0; }
.toolbar,
.toolbar form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin: 0 0 12px;
}
.toolbar:last-child { margin-bottom: 0; }
.toolbar > div,
.toolbar form > div { min-width: 160px; }
.toolbar input,
.toolbar select { margin: 0; }
.toolbar .btn,
.toolbar .btn-secondary { margin: 0; }

.fact-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.fact {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 6px;
}
.fact strong { font-size: 1.05rem; }
@media (max-width: 700px) {
  .fact-row { grid-template-columns: 1fr; }
}

.data-sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.sheet-head { padding: 16px 18px 4px; }
.sheet-head h2 { margin-bottom: 4px; }
.sheet-head p { margin: 0; }
.sheet-empty { margin: 0; padding: 8px 18px 18px; }
.sheet-scroll {
  overflow: auto;
  background: var(--panel);
  max-height: min(70vh, 760px);
}
.sheet-scroll table {
  width: max-content;
  min-width: 100%;
  background: var(--panel);
}
.sheet-scroll th,
.sheet-scroll td {
  background: var(--panel);
  white-space: nowrap;
}
.sheet-scroll th {
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: inset 0 -1px 0 var(--line);
}
a.sort {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}
a.sort:hover { color: var(--ink); text-decoration: none; }
a.sort.is-sorted { color: var(--ink); }
a.sort.is-sorted.asc::after { content: "  ↑"; }
a.sort.is-sorted.desc::after { content: "  ↓"; }
.sheet-scroll .btn-secondary,
.sheet-scroll .btn {
  margin: 0;
  padding: 6px 10px;
  font-size: 12px;
}

/* Lead pipeline: stage chips, resizable sheet, board */
.stage {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #334155;
  white-space: nowrap;
}
.stage-contacted { color: #075985; background: var(--accent-soft); border-color: #bae6fd; }
.stage-qualified { color: #115e59; background: #ccfbf1; border-color: #99f6e4; }
.stage-proposal { color: #92400e; background: var(--warn-soft); border-color: #fde68a; }
.stage-negotiation { color: #9a3412; background: #ffedd5; border-color: #fed7aa; }
.stage-won { color: #166534; background: var(--ok-soft); border-color: #bbf7d0; }
.stage-lost { color: #991b1b; background: var(--err-soft); border-color: #fecaca; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--panel); }
.seg a { padding: 8px 14px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg a + a { border-left: 1px solid var(--line-strong); }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a.is-on { background: var(--accent); color: #fff; }

.toolbar .grow { flex: 1 1 220px; }
.toolbar .narrow { min-width: 130px; }
.filters { padding-bottom: 6px; }

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}
.bulk-bar select { width: auto; margin: 0; padding: 6px 10px; font-size: 13px; }
.bulk-bar .btn-secondary { margin: 0; padding: 6px 10px; font-size: 12px; }
.bulk-bar button { opacity: .5; pointer-events: none; }
.bulk-bar.has-selection button { opacity: 1; pointer-events: auto; }
.bulk-count { font-size: 13px; min-width: 84px; }

.sheet-table.is-fixed { table-layout: fixed; }
.sheet-table.is-fixed th,
.sheet-table.is-fixed td { overflow: hidden; text-overflow: ellipsis; }
.sheet-table th { position: sticky; }
.sheet-table th[data-col] { padding-right: 14px; }
.sheet-table .col-check { width: 40px; min-width: 40px; max-width: 40px; text-align: center; }
.sheet-table .col-check input { width: auto; margin: 0; }
.sheet-table .num { font-variant-numeric: tabular-nums; }
.sheet-table .is-due { color: var(--err); font-weight: 700; }
.sheet-table tbody tr:hover td { background: #f8fafc; }
.lead-link { font-weight: 700; color: var(--ink); }
.col-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}
.col-resize::after {
  content: "";
  position: absolute;
  top: 25%;
  bottom: 25%;
  right: 3px;
  width: 2px;
  border-radius: 2px;
  background: var(--line-strong);
  opacity: 0;
  transition: opacity .15s;
}
th:hover .col-resize::after,
.is-resizing .col-resize::after { opacity: 1; }
.is-resizing, .is-resizing * { cursor: col-resize !important; user-select: none; }

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: start;
}
.board-col {
  background: #e9eef5;
  border-radius: var(--radius);
  padding: 10px;
  min-height: 240px;
  transition: background .15s, box-shadow .15s;
}
.board-col.is-over { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.board-col header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.board-count { font-size: 12px; font-weight: 700; color: var(--muted); }
.board-cards { display: grid; gap: 8px; min-height: 40px; }
.board-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}
.board-card.is-dragging { opacity: .5; }
.board-card a { font-weight: 700; color: var(--ink); }
.board-card p { margin: 2px 0 8px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-card footer { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.board-card footer span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-card strong { display: block; margin-top: 6px; font-size: 13px; }

/* Lead page */
.crumbs { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.lead-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(260px, 320px);
  gap: 16px;
  align-items: start;
}
.lead-pane { display: grid; gap: 12px; }
.pane-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0;
}
.pane-block h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }
.pane-block label { margin-top: 8px; }
.pane-block .btn, .pane-block .btn-secondary { margin-top: 12px; width: 100%; justify-content: center; }
.pane-block textarea { width: 100%; }
.pane-block .split { display: grid; grid-template-columns: 1fr 84px; gap: 8px; }
.kv { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 6px 10px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv-stack { grid-template-columns: 1fr; gap: 2px; }
.kv-stack dd { margin-bottom: 8px; font-weight: 600; }
.lead-main { min-width: 0; display: grid; gap: 12px; }
.lead-main .card { margin: 0; }
.note-form textarea { width: 100%; margin: 0; }
.note-form select { width: auto; margin: 0; }
.timeline { list-style: none; margin: 16px 0 0; padding: 0; border-left: 2px solid var(--line); }
.tl { position: relative; padding: 0 0 16px 16px; }
.tl::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--line-strong);
}
.tl-message_out::before { border-color: var(--accent); }
.tl-message_in::before { border-color: var(--ok); background: var(--ok); }
.tl-ai_draft::before { border-color: var(--warn); }
.tl-stage_change::before { border-color: var(--ink); background: var(--ink); }
.tl-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13.5px; }
.tl-head time { margin-left: auto; color: var(--muted); font-size: 12px; }
.tl-chip { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.tl-status { font-size: 11px; font-weight: 700; text-transform: capitalize; color: var(--muted); }
.tl-status-sent, .tl-status-approved, .tl-status-auto_sent { color: var(--ok); }
.tl-status-failed, .tl-status-rejected { color: var(--err); }
.tl-status-pending_approval { color: var(--warn); }
.tl p { margin: 4px 0 0; font-size: 13.5px; }
.tl-subject { font-weight: 700; }
.tl-body { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.tl-message_in .tl-body { background: var(--ok-soft); border-color: #bbf7d0; }
.tl-error { color: var(--err); font-size: 13px; }
.tl-by { color: var(--muted); font-size: 12px; }
.seg-sm { margin-bottom: 8px; }
.seg-sm label { margin: 0; padding: 6px 12px; font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg-sm label + label { border-left: 1px solid var(--line-strong); }
.seg-sm label.is-on { background: var(--accent); color: #fff; }
.seg-sm input { position: absolute; opacity: 0; pointer-events: none; }
.seg button { margin: 0; border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 8px 14px; font-weight: 700; font-size: 13px; box-shadow: none; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.is-on { background: var(--accent); color: #fff; }
@media (max-width: 1100px) {
  .lead-layout { grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); }
  .lead-layout > .lead-pane:first-child { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}
@media (max-width: 760px) {
  .lead-layout { grid-template-columns: 1fr; }
}

/* Dashboard date range and zoomable chart */
.range-bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 0 0 14px; }
.range-custom { display: flex; align-items: center; gap: 8px; }
.range-custom input { width: auto; margin: 0; padding: 7px 10px; font-size: 13px; }
.range-custom .btn-secondary { margin: 0; padding: 7px 12px; font-size: 13px; }
.range-group { display: flex; align-items: center; gap: 8px; margin: 0; }
.range-group select { width: auto; margin: 0; padding: 7px 10px; font-size: 13px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.chart-head h2 { margin: 0; }
.chart-head .btn-secondary { margin: 0; padding: 6px 12px; font-size: 12px; }
.chart-hint { margin: 4px 0 8px; }
.chart-head [hidden] { display: none; }
#trendChart { cursor: crosshair; touch-action: pan-y; }

/* Campaign cost against results */
.fact-row-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1000px) { .fact-row-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .fact-row-5 { grid-template-columns: 1fr; } }
.roi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.roi-grid .card { margin: 0; }
.roi-grid textarea { width: 100%; }
.limit-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.limit-row input { width: 100%; }
@media (max-width: 860px) {
    .roi-grid, .limit-row { grid-template-columns: 1fr; }
}
.stack-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #eef2f7; margin: 10px 0 12px; }
.stack-bar span { display: block; height: 100%; }
.seg-new { background: #94a3b8; }
.seg-contacted { background: #38bdf8; }
.seg-qualified { background: #14b8a6; }
.seg-proposal { background: #f59e0b; }
.seg-negotiation { background: #f97316; }
.seg-won { background: #16a34a; }
.seg-lost { background: #ef4444; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px 12px; font-size: 13px; }
.legend a { color: var(--ink); display: flex; align-items: center; gap: 6px; }
.legend strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; }
.bar-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: 13.5px; margin: 8px 0; }
.bar-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.conn-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.conn { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px dashed var(--line-strong); color: var(--muted); }
.conn.is-live { border-style: solid; border-color: #bbf7d0; background: var(--ok-soft); color: #166534; }
.conn.is-source { box-shadow: inset 0 0 0 1px var(--accent); }

/* Approvals and inbox */
.approval {
  background: var(--panel);
  border: 1px solid #fde68a;
  border-left: 4px solid var(--warn);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.approval header { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; margin-bottom: 6px; }
.approval-why { margin: 0 0 8px; font-size: 12.5px; color: #92400e; }
.approval textarea, .approval input { width: 100%; margin: 0 0 8px; }
.approval .btn-row { margin-top: 0; }
.mode-switch { display: flex; align-items: center; gap: 10px; margin: 0; }
.mode-note { margin: -6px 0 16px; max-width: 90ch; }
.inbox-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 16px; align-items: start; }
.inbox-layout aside { display: grid; gap: 12px; }
.inbox-layout aside .card { margin: 0; }
.section-title { font-size: 15px; margin: 0 0 10px; display: flex; gap: 8px; align-items: center; }
.section-title .count { font-size: 12px; background: var(--warn-soft); color: #92400e; border-radius: 999px; padding: 1px 8px; }
.empty-state { text-align: left; }
.due-row, .msg-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 13.5px;
}
.due-row:hover, .msg-row:hover { text-decoration: none; background: #f8fafc; }
.due-row > span:first-child, .msg-text { display: grid; min-width: 0; }
.msg-text .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-dir { font-size: 10.5px; font-weight: 800; text-transform: uppercase; border-radius: 6px; padding: 2px 6px; align-self: start; }
.msg-dir.in { background: var(--ok-soft); color: #166534; }
.msg-dir.out { background: var(--accent-soft); color: #075985; }
.is-due { color: var(--err); font-weight: 700; }
@media (max-width: 900px) { .inbox-layout { grid-template-columns: 1fr; } }

.card table form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.card table button { margin-top: 0; }
.card table select, .card table input { margin: 0; width: auto; min-width: 120px; }

.studio { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(240px, .8fr); gap: 28px; align-items: start; }
.studio-thread { display: flex; flex-direction: column; gap: 14px; }
.studio-msg { padding: 12px 0; border-bottom: 1px solid var(--line); }
.studio-msg span { display: block; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.studio-msg p { margin: 0; white-space: pre-wrap; }
.studio-compose textarea { width: 100%; min-height: 96px; }
.ask-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.ask-tools button, .ask-tools .btn { margin-top: 0; }
.ask-file { margin: 0; cursor: pointer; }
.ask-file input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ask-file-name { margin: 8px 0 0; }
.ask-more { margin-top: 18px; }
.ask-more summary { cursor: pointer; color: var(--muted); }
.studio-side h2 { font-size: 15px; margin: 18px 0 8px; }
.studio-side ul { list-style: none; padding: 0; margin: 0; }
.studio-side li { margin: 6px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
@media (max-width: 860px) { .studio { grid-template-columns: 1fr; } }

