:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --text: #202733;
  --muted: #687386;
  --accent: #2559d6;
  --accent-2: #1d4ab0;
  --border: #e2e8f0;
  --danger: #c1292e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.flash-wrap { position: fixed; top: 1rem; right: 1rem; z-index: 50; }
.flash { background: var(--panel); border: 1px solid var(--border); border-left-width: 4px; padding: .75rem 1rem; margin-bottom: .5rem; border-radius: .5rem; }
.flash-success { border-left-color: #2f9e44; }
.flash-danger { border-left-color: var(--danger); }
.flash-warning { border-left-color: #f08c00; }
.flash-info { border-left-color: var(--accent); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(100%, 430px); background: var(--panel); border-radius: .9rem; padding: 2rem; border: 1px solid var(--border); box-shadow: 0 8px 30px rgba(0,0,0,.06); }

label { display: flex; flex-direction: column; gap: .4rem; font-weight: 600; font-size: .9rem; }
input, textarea, select, button { font: inherit; }
input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: .55rem;
  padding: .62rem .7rem;
  background: #fff;
}
input:focus, textarea:focus { outline: 2px solid #aac4ff; border-color: #8faef8; }

.btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: .55rem;
  padding: .6rem .9rem;
  cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary { background: #eef3ff; border-color: #d2e0ff; }
.btn-danger { border: 1px solid #f5c2c7; color: var(--danger); background: #fff5f5; border-radius: .5rem; padding: .45rem .7rem; cursor: pointer; }
.stack-gap { display: flex; flex-direction: column; gap: .9rem; }
.form-row { display: grid; gap: .8rem; grid-template-columns: repeat(2, 1fr); }
.inline-actions { display: grid; gap: .6rem; grid-template-columns: 1fr auto auto; align-items: end; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #101826;
  color: #edf2ff;
  padding: 1rem .75rem;
  transition: width .2s ease;
  overflow-x: hidden;
}
.app-shell.collapsed .sidebar { width: 76px; }
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 1rem;
  min-height: 40px;
  box-sizing: border-box;
}
.app-shell.collapsed .sidebar-head {
  justify-content: center;
}
.icon-btn {
  border: 0;
  background: #1e293b;
  color: #fff;
  border-radius: .5rem;
  padding: .45rem .65rem;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.15rem;
  line-height: 1;
}
.brand-lockup {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}
.brand-lockup.topbar-brand {
  flex: 0 0 auto;
  flex-shrink: 0;
  max-width: min(100%, 320px);
  overflow: visible;
}
.app-shell.collapsed .brand-lockup {
  flex: 0 0 auto;
  justify-content: flex-start;
  overflow: visible;
}
/* Do not set display on .brand-lockup img — it overrides .brand-logo-icon { display: none } */
.brand-logo-full {
  display: block;
  height: auto;
  max-width: 100%;
  max-height: 40px;
  width: auto;
  object-fit: contain;
  object-position: left center;
}
.brand-logo-icon {
  display: none;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: contain;
  object-position: center center;
}
.app-shell.collapsed .brand-logo-full { display: none; }
.app-shell.collapsed .brand-logo-icon { display: block; }
.app-shell.collapsed .nav-label { display: none; }
.auth-brand {
  display: flex;
  justify-content: center;
  margin: 0 0 1.1rem;
}
.auth-brand img {
  max-width: 100%;
  height: auto;
  max-height: 52px;
  width: auto;
}
.sidebar-nav { display: flex; flex-direction: column; gap: .5rem; }
/* Last menu item: subtle separator only (no viewport-height gap). */
.nav-item-after-settings {
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .62rem .75rem; border-radius: .55rem; color: #ced8ee; }
.nav-item:hover, .nav-item.active { background: #1c2b45; color: #fff; }
.nav-icon { width: 1.2rem; text-align: center; }

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
}
/* Left = logo (intrinsic width); center = fills; right = profile — avoids equal thirds squeezing the wordmark to 0 width */
.topbar-left {
  flex: 0 0 auto;
  justify-content: flex-start;
  min-width: 0;
}
.topbar-center {
  flex: 1 1 auto;
  justify-content: center;
  min-width: 0;
}
.topbar-right {
  flex: 0 0 auto;
  justify-content: flex-end;
  min-width: 0;
}
.run-auto-form {
  display: flex;
  align-items: center;
  gap: .55rem;
}
.run-bg-switch {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  color: var(--muted);
  user-select: none;
}
.run-bg-switch input {
  width: 14px;
  height: 14px;
}
.profile-menu { position: relative; }
.profile-trigger { border: 1px solid var(--border); background: #fff; border-radius: .55rem; padding: .5rem .75rem; cursor: pointer; }
.profile-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + .4rem);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: .6rem;
  min-width: 170px;
  box-shadow: 0 12px 20px rgba(0,0,0,.08);
}
.profile-dropdown.open { display: block; }
.dropdown-item { border: 0; width: 100%; text-align: left; background: #fff; padding: .7rem .9rem; cursor: pointer; }
.dropdown-item:hover { background: #f6f8fc; }

.content-wrap { padding: 1.2rem; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: .8rem; padding: .9rem 1rem; }
.manifestation-top { margin-bottom: 1rem; text-align: center; }
.om-symbol { font-size: 2rem; font-weight: 700; line-height: 1; }
.manifest-line { margin: .12rem 0 0; color: var(--muted); font-size: .95rem; }
.manifestation-bottom { margin-top: 1rem; }
.manifest-hindi { margin: .3rem 0; color: var(--muted); font-size: .95rem; line-height: 1.45; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.gs-section { margin-top: 1rem; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)); gap: .9rem; }
.settings-card { background: #f9fbff; border: 1px solid var(--border); border-radius: .8rem; padding: 1rem; display: grid; gap: .5rem; }
.settings-icon { font-size: 1.2rem; }
.settings-title { font-weight: 650; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .55rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .92rem; }
th { color: var(--muted); font-weight: 650; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f8fbff; }
.clickable-row:focus { outline: 2px solid #aac4ff; outline-offset: -2px; }
.inline-buttons { display: flex; gap: .6rem; flex-wrap: wrap; }
.tiny { font-size: .82rem; margin-top: .7rem; }
.compact-table th, .compact-table td { padding: .4rem .45rem; font-size: .85rem; line-height: 1.25; white-space: nowrap; }
.compact-table td:nth-child(8) { white-space: normal; min-width: 280px; }
.activity-quick-list, .activity-full-list { display: grid; gap: .45rem; margin-top: .7rem; }
.activity-live-section .activity-full-list {
  max-height: min(55vh, 520px);
  overflow-y: auto;
  margin-top: .5rem;
}
.activity-live-meta { font-size: .8rem; color: var(--muted); margin: .25rem 0 .5rem; }
.lead-rows-placeholder {
  padding: 1.25rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: .6rem;
  margin: 0;
}
.activity-item {
  border: 1px solid var(--border);
  background: #fbfcff;
  border-radius: .5rem;
  padding: .45rem .55rem;
  font-size: .84rem;
}
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 38, .45);
  z-index: 200;
  padding: 2rem;
}
.modal-backdrop.open { display: block; }
.modal-panel {
  background: #fff;
  border-radius: .8rem;
  border: 1px solid var(--border);
  max-width: 980px;
  max-height: calc(100vh - 4rem);
  overflow: auto;
  margin: 0 auto;
  padding: 1rem;
}
.modal-panel h2, .modal-panel h3 { margin: .35rem 0 .45rem; }
#actionlog-modal-title { flex: 1; }
#actionlog-meta-body th { width: 170px; color: var(--muted); }
.run-headline { display:flex; align-items:center; justify-content:space-between; gap:.7rem; margin-bottom:.2rem; }
.run-title-wrap { display:flex; align-items:center; gap:.5rem; }
.run-pill {
  border: 1px solid #c7d7ff;
  color: #1c4cb2;
  background: #edf3ff;
  border-radius: 999px;
  font-size: .75rem;
  padding: .12rem .55rem;
  font-weight: 600;
}
.run-kpi-grid { display:grid; grid-template-columns: repeat(8, minmax(96px, 1fr)); gap:.35rem; }
.run-kpi {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #fcfdff 0%, #f7f9ff 100%);
  border-radius: .55rem;
  padding: .3rem .4rem;
  display: grid;
  gap: .04rem;
  box-shadow: inset 0 1px 0 #ffffff;
}
.run-kpi strong {
  font-size: .76rem;
  line-height: 1.2;
  word-break: break-word;
}
.run-kpi-wide { grid-column: span 3; }
.activity-link {
  color: var(--accent);
  font-size: .9rem;
  text-decoration: underline;
}
.copy-chip {
  border: 1px dashed #b8c8ef;
  background: #f5f8ff;
  color: #1f4fae;
  border-radius: .45rem;
  padding: .2rem .35rem;
  font-size: .78rem;
  cursor: pointer;
  max-width: 350px;
  text-align: left;
}
.copy-chip:hover { background: #edf3ff; }

.config-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .4rem;
  font-size: .86rem;
}
.config-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: .6rem;
  align-items: start;
  padding: .55rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.config-row:last-of-type {
  border-bottom: none;
}
.config-label {
  font-weight: 600;
  font-size: .82rem;
  color: var(--muted);
  padding-top: .42rem;
}
.config-field input,
.config-field textarea,
.config-field select,
select.config-select-wide {
  font-size: .86rem;
  padding: .45rem .55rem;
  max-width: 100%;
}
.config-field select,
select.config-select-wide {
  min-width: min(100%, 22rem);
  appearance: auto;
  cursor: pointer;
}
.config-field .muted.tiny {
  max-width: 52rem;
  line-height: 1.45;
  word-wrap: break-word;
}
.config-display-pref-select {
  font-weight: 500;
  background-color: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.55rem;
}
.config-display-pref-select option {
  color: var(--text);
  background: #fff;
}
.field-error {
  color: #b91c1c;
  font-size: 0.82rem;
  margin-top: 0.25rem;
}
.config-test-email-row {
  margin-top: .4rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.test-email-feedback {
  display: block;
  margin-top: .45rem;
  padding: .5rem .65rem;
  border-radius: .45rem;
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.4;
  max-width: min(100%, 540px);
}
.test-email-feedback.is-sending {
  background: #e8f1ff;
  border: 1px solid #9db7f0;
  color: #1a3a73;
}
.test-email-feedback.is-ok {
  background: #e8f7ed;
  border: 1px solid #7dd3a0;
  color: #14532d;
}
.test-email-feedback.is-err {
  background: #fff1f1;
  border: 1px solid #f0a8a8;
  color: #7f1d1d;
}
.config-actions {
  margin-top: .4rem;
}
.btn-xs {
  padding: .25rem .55rem;
  font-size: .8rem;
}
.config-modal-panel {
  max-width: 820px;
}
.config-modal-body {
  margin-top: .6rem;
  font-size: .78rem;
  line-height: 1.35;
  background: #0b1020;
  color: #e5e9ff;
  padding: .6rem .75rem;
  border-radius: .5rem;
  border: 1px solid #232a46;
  max-height: calc(100vh - 8rem);
  overflow: auto;
  white-space: pre-wrap;
}
.modal-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.mapping-panel {
  background: linear-gradient(180deg, #fcfdff 0%, #ffffff 100%);
  border-color: #d8e4f8;
}
.mapping-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.mapping-panel-head h2 { margin: 0 0 0.25rem; }
.mapping-table-wrap { border-radius: 0.55rem; border: 1px solid var(--border); background: #fff; }
.mapping-split-table .col-detail { min-width: 200px; white-space: normal; }
.mapping-split-table .col-sample {
  max-width: 260px;
  white-space: normal;
  word-break: break-word;
}
.mapping-split-table .col-gs { min-width: 160px; }
.mapping-select {
  width: 100%;
  max-width: 280px;
  font-size: 0.85rem;
  padding: 0.45rem 0.5rem;
}
.mapping-form { margin-top: 0.25rem; }

.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.data-table th, .data-table td { border-bottom: 1px solid var(--border); padding: .55rem .45rem; text-align: left; vertical-align: top; }
.data-table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.auto-name { font-weight: 600; }
.auto-desc { max-width: 420px; line-height: 1.35; }
.automations-save { margin-top: .75rem; }
.automation-stub-row .btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.automation-config-th { width: 2.75rem; text-align: center; }
.automation-config-cell {
  width: 2.75rem;
  text-align: center;
  vertical-align: middle;
}
.automation-config-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: .45rem;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  text-decoration: none;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.automation-config-link:hover {
  background: #eef3ff;
  color: var(--accent);
  border-color: #c7d7f5;
}
.automation-config-ico { display: block; transform: translateY(1px); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.inline-check { display: flex; align-items: center; gap: .35rem; font-weight: 400; }
.inline-form { display: inline; }
.interval-input { max-width: 100px; }

.backlog-page .backlog-section-title { font-size: 1.05rem; margin: 1.25rem 0 0.65rem; }
.backlog-list-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.65rem;
  margin: 1.25rem 0 0.65rem;
}
.backlog-list-heading-start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1.25rem;
  justify-self: start;
  min-width: 0;
}
.backlog-list-heading-doit {
  justify-self: center;
  text-align: center;
  white-space: nowrap;
}
.backlog-list-heading .backlog-section-title { margin: 0; }
.backlog-exclude-done-label {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.backlog-exclude-done-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent, #2563eb);
}
.backlog-list-heading-filter {
  justify-self: end;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
}
.backlog-category-filter-label {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.backlog-filter-label-text {
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.2;
  color: var(--text);
  white-space: nowrap;
}
.backlog-category-filter-select {
  min-width: 11rem;
  max-width: 20rem;
  min-height: 2.25rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: #fff;
  font-size: 0.92rem;
  line-height: 1.25;
}
.backlog-inline-form { display: inline; margin: 0; }
.backlog-doit-meter {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--accent);
}
.backlog-composer-wrap {
  background: linear-gradient(180deg, #f8fbff 0%, #fff 100%);
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: 1.5rem;
}
.backlog-composer { display: flex; flex-direction: column; gap: 0.75rem; }
.backlog-field { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.88rem; }
.backlog-field-label { font-weight: 600; font-size: 0.88rem; }
.backlog-category-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-weight: 400;
  min-height: 3.1rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: #fff;
}
/* #15: global `label { flex-direction: column }` must not stack radio above text — radio left, name right */
label.backlog-cat-pill {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  margin: 0;
  min-height: 2.35rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  user-select: none;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
label.backlog-cat-pill > span {
  line-height: 1.25;
  font-weight: 500;
}
label.backlog-cat-pill:hover {
  border-color: #c7d7f5;
  background: #f8fbff;
}
label.backlog-cat-pill:has(input:checked) {
  border-color: var(--accent, #2563eb);
  background: #eef3ff;
  box-shadow: 0 0 0 1px var(--accent, #2563eb);
}
label.backlog-cat-pill input[type="radio"] {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent, #2563eb);
}
.backlog-field-grow textarea,
.backlog-composer-textarea { min-height: 220px; resize: vertical; }
.backlog-composer-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.backlog-image-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; min-height: 0; }
.backlog-chip {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 0.45rem;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
}
.backlog-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.backlog-chip-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.backlog-table textarea.backlog-body-inline {
  min-width: 240px;
  max-width: min(520px, 55vw);
  min-height: 4.5rem;
  font-size: 0.82rem;
  font-weight: 400;
  font-family: inherit;
  line-height: 1.45;
}
.backlog-mini-input { max-width: 140px; font-size: 0.82rem; }
.backlog-pri-select {
  max-width: 72px;
  min-height: 2.125rem;
  padding: 0.35rem 0.4rem;
  font-size: 0.82rem;
  line-height: 1.2;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: #fff;
}
.backlog-table select {
  min-height: 2.125rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: #fff;
  font-size: 0.82rem;
  line-height: 1.25;
  max-width: 100%;
}
.backlog-row-thumbs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.backlog-row-thumbs img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 0.35rem;
  border: 1px solid var(--border);
}
.table-scroll { overflow-x: auto; }
kbd {
  font-size: 0.75em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
  background: #fff;
}

@media (max-width: 980px) {
  .split, .settings-grid { grid-template-columns: 1fr; }
  .form-row, .inline-actions { grid-template-columns: 1fr; }
  .run-kpi-grid { grid-template-columns: 1fr 1fr; }
  .run-kpi-wide { grid-column: span 2; }
  .config-row { grid-template-columns: 1fr; align-items: flex-start; }
}

@media (max-width: 720px) {
  .backlog-list-heading {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }
  .backlog-list-heading-start { justify-self: start; }
  .backlog-list-heading-doit { justify-self: center; }
  .backlog-list-heading-filter { justify-self: end; }
}
