:root {
  --bg: #f6f8f9;
  --surface: #ffffff;
  --surface-2: #eef3f4;
  --text: #172023;
  --muted: #6b777c;
  --border: #dbe2e4;
  --teal: #0f8f87;
  --teal-weak: #dff4f1;
  --green: #21865c;
  --green-weak: #e1f4e9;
  --blue: #2767b1;
  --blue-weak: #e4eef9;
  --amber: #a26714;
  --amber-weak: #fff1d8;
  --coral: #bd4c3d;
  --coral-weak: #fde6e1;
  --shadow: 0 18px 50px rgba(23, 32, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: #11181b;
  color: #f7fbfb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #9fb0b5;
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #b8c5c9;
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease;
}

.nav a:hover,
.nav a.active {
  background: #1f2a2e;
  color: #ffffff;
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid #344247;
  border-radius: 6px;
  color: #82d8d1;
  font-size: 12px;
  font-weight: 800;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(246, 248, 249, 0.92);
  backdrop-filter: blur(14px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
  line-height: 1.35;
}

#page-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar > * {
  min-width: 0;
}

.select-label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

select,
.search {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.search {
  width: min(320px, 42vw);
}

.inline-input,
.action-controls input,
.field input,
.field textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  font-size: 12px;
}

.field textarea {
  min-height: 78px;
  padding: 8px;
  resize: vertical;
}

.inline-input:focus,
.action-controls input:focus,
.field input:focus,
.field textarea:focus,
.search:focus,
select:focus {
  border-color: var(--teal);
  outline: 2px solid rgba(15, 143, 135, 0.12);
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--teal);
  border-radius: 7px;
  background: var(--teal);
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.text-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.text-button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.text-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.notice {
  margin: 14px 28px 0;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.notice.success {
  border-color: #b8dfca;
  background: var(--green-weak);
  color: var(--green);
}

.notice.warning {
  border-color: #ecd39c;
  background: var(--amber-weak);
  color: var(--amber);
}

.notice.error {
  border-color: #f1c2ba;
  background: var(--coral-weak);
  color: var(--coral);
}

.content {
  padding: 24px 28px 36px;
}

.meta-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.meta-banner span {
  color: var(--muted);
}

.meta-banner.ready {
  border-color: #b8dfca;
}

.meta-banner.blocked {
  border-color: #f1c2ba;
}

.loading {
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-grid.compact {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.kpi,
.panel,
.queue-card,
.insight {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi {
  display: grid;
  gap: 4px;
  padding: 14px;
  min-height: 102px;
}

.kpi span,
.kpi small,
.muted {
  color: var(--muted);
}

.kpi span {
  font-size: 12px;
  font-weight: 700;
}

.kpi strong {
  font-size: 26px;
  line-height: 1;
}

.kpi.good {
  border-color: #b8dfca;
  background: linear-gradient(180deg, #ffffff 0%, var(--green-weak) 100%);
}

.kpi.info {
  border-color: #bcd4ef;
  background: linear-gradient(180deg, #ffffff 0%, var(--blue-weak) 100%);
}

.kpi.bad {
  border-color: #f1c2ba;
  background: linear-gradient(180deg, #ffffff 0%, var(--coral-weak) 100%);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.settings-grid,
.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.settings-grid > *,
.kanban > * {
  min-width: 0;
}

.kanban {
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel.wide {
  min-height: 250px;
}

.settings-panel {
  grid-column: span 2;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.field.full {
  margin-top: 12px;
}

.export-grid {
  display: grid;
  gap: 8px;
}

.export-link {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.export-link:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  font-size: 13px;
}

.compact-table {
  min-width: 680px;
}

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: #415056;
  font-size: 11px;
  text-transform: uppercase;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
  max-width: 360px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.winner {
  background: var(--green-weak);
  color: var(--green);
}

.scaling {
  background: var(--blue-weak);
  color: var(--blue);
}

.testing {
  background: var(--amber-weak);
  color: var(--amber);
}

.low-score {
  background: var(--coral-weak);
  color: var(--coral);
}

.queue {
  display: grid;
  gap: 10px;
}

.queue-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  box-shadow: none;
}

.queue-card.done {
  opacity: 0.72;
}

.queue-card.done strong {
  text-decoration: line-through;
}

.queue-card span,
.queue-card small,
.insight p,
.insight small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.queue-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.priority {
  color: var(--teal);
  font-weight: 900;
}

.action-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(118px, 1fr);
  gap: 8px;
  align-items: end;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.action-controls label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.action-controls .check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  grid-column: 1 / -1;
  min-height: 32px;
  white-space: nowrap;
}

.action-controls .check-label input {
  width: 16px;
  min-height: 16px;
}

.bar-chart {
  display: grid;
  gap: 16px;
  padding-top: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 64px 1fr 42px;
  align-items: center;
  gap: 12px;
}

.bar-row span,
.bar-row strong {
  font-size: 13px;
}

.bar-track {
  height: 30px;
  overflow: hidden;
  border-radius: 8px;
  background: #edf1f2;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.donut-list,
.settings-list {
  display: grid;
  gap: 12px;
}

.donut-list div,
.settings-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  min-height: 38px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.settings-list strong {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: end;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.insight {
  display: grid;
  gap: 10px;
  padding: 14px;
  box-shadow: none;
}

body {
  background: #f8fafc;
  color: #111827;
}

.app-shell {
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  padding: 22px 14px;
  border-inline-end: 1px solid #e5e7eb;
  background: #ffffff;
  color: #111827;
}

.brand {
  gap: 11px;
  margin-bottom: 30px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: linear-gradient(135deg, #0f8f87, #0d6c88);
  box-shadow: 0 10px 22px rgba(15, 143, 135, 0.24);
}

.brand strong {
  color: #111827;
  font-size: 17px;
}

.brand small {
  color: #526070;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav {
  gap: 5px;
}

.nav-group {
  margin: 20px 7px 8px;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav a {
  min-height: 44px;
  padding: 10px 10px;
  border-radius: 7px;
  color: #1f2937;
  font-size: 14px;
  font-weight: 750;
}

.nav a:hover,
.nav a.active {
  background: #f1f5f9;
  color: #0f766e;
}

.nav a.active {
  box-shadow: inset 3px 0 0 #0f8f87;
}

.nav-icon {
  width: 25px;
  height: 25px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #0f766e;
  background: #ffffff;
}

.topbar {
  min-height: 82px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 0 #e5e7eb;
}

h1 {
  color: #111827;
  font-size: 22px;
  font-weight: 850;
}

#page-subtitle {
  color: #475569;
  font-size: 13px;
}

.toolbar {
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.toolbar .select-label {
  min-width: 128px;
}

.toolbar .select-label:first-child {
  min-width: 178px;
}

.select-label {
  color: #64748b;
}

select,
.select-label input,
.search,
.text-button,
.icon-button {
  border-color: #d8dee8;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.select-label input {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
}

.text-button,
.icon-button {
  color: #0f172a;
}

.text-button.primary {
  border-color: #0f8f87;
  background: #0f8f87;
  box-shadow: 0 10px 20px rgba(15, 143, 135, 0.18);
}

.content {
  padding: 18px 24px 28px;
}

.dashboard-commandbar {
  display: flex;
  justify-content: end;
  align-items: center;
  gap: 10px;
  margin: -8px 0 10px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  margin-bottom: 14px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.metric-tile {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 102px;
  padding: 16px 18px;
  border-inline-end: 1px solid #e5e7eb;
}

.metric-tile:last-child {
  border-inline-end: 0;
}

.metric-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #0e7490, #13a89e);
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  box-shadow: inset 0 -10px 18px rgba(0, 0, 0, 0.08);
}

.metric-tile.good .metric-icon {
  background: linear-gradient(135deg, #16a34a, #0f8f87);
}

.metric-tile.warn .metric-icon {
  background: linear-gradient(135deg, #f59e0b, #facc15);
}

.metric-tile.bad .metric-icon {
  background: linear-gradient(135deg, #ef4444, #fb7185);
}

.metric-tile.money .metric-icon {
  background: linear-gradient(135deg, #0e7490, #0284c7);
}

.metric-tile small,
.metric-tile em {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.metric-tile small {
  text-transform: uppercase;
}

.metric-tile strong {
  display: block;
  margin: 3px 0 5px;
  color: #0f172a;
  font-size: 26px;
  line-height: 1;
}

.dashboard-main-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(520px, 1.35fr) minmax(350px, 0.95fr);
  gap: 14px;
}

.panel {
  border-color: #dfe5ec;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.045);
}

.panel-head h2 {
  font-size: 15px;
  font-weight: 850;
}

.panel-head small {
  display: block;
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
}

.small-select {
  width: auto;
  min-width: 110px;
}

.view-link {
  color: #075dbf;
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.distribution-chart {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 16px;
  min-height: 214px;
  padding: 14px 6px 4px;
  border-bottom: 1px solid #edf2f7;
}

.dist-col {
  display: grid;
  gap: 8px;
  justify-items: center;
  align-items: end;
}

.dist-col strong {
  color: #0f172a;
  font-size: 13px;
}

.dist-col small {
  color: #475569;
  font-size: 12px;
}

.dist-track {
  display: flex;
  align-items: end;
  width: 44px;
  height: 160px;
  border-radius: 7px;
  background: linear-gradient(180deg, transparent, #f1f5f9);
}

.dist-bar {
  display: block;
  width: 100%;
  border-radius: 7px 7px 3px 3px;
}

.dist-bar.low-score {
  background: linear-gradient(180deg, #fb7185, #ef4444);
}

.dist-bar.testing {
  background: linear-gradient(180deg, #facc15, #f59e0b);
}

.dist-bar.scaling {
  background: linear-gradient(180deg, #2dd4bf, #0f8f87);
}

.dist-bar.winner {
  background: linear-gradient(180deg, #0e7490, #075985);
}

.distribution-legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding-top: 12px;
}

.distribution-legend span {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 8px 6px;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  color: #475569;
  font-size: 11px;
}

.distribution-legend b {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.compact-list-table {
  display: grid;
}

.list-head,
.creative-rank-row {
  display: grid;
  grid-template-columns: minmax(168px, 1.25fr) minmax(98px, 0.8fr) 58px 72px 48px;
  gap: 9px;
  align-items: center;
}

.list-head {
  padding: 0 6px 8px;
  color: #334155;
  font-size: 11px;
  font-weight: 850;
}

.creative-rank-row {
  min-height: 62px;
  padding: 9px 6px;
  border-top: 1px solid #e5e7eb;
  font-size: 11px;
}

.creative-cell {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.creative-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 7px;
  background: linear-gradient(135deg, #e0f2fe, #ccfbf1);
  color: #0f766e;
  font-weight: 900;
}

.image-thumb {
  object-fit: cover;
  border: 1px solid #dbeafe;
  background: #f8fafc;
}

.placeholder-thumb {
  font-size: 11px;
}

.table-creative {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.score-chip {
  justify-self: start;
  min-width: 42px;
  padding: 5px 8px;
  border: 1px solid #8bd6d0;
  border-radius: 6px;
  background: #ecfeff;
  color: #0f766e;
  text-align: center;
}

.action-list {
  display: grid;
  margin: 0 -16px -16px;
}

.action-summary {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 70px;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
}

.action-summary strong {
  display: block;
  font-size: 13px;
}

.action-summary small {
  display: block;
  margin-top: 4px;
  color: #475569;
  font-size: 12px;
}

.action-symbol {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  font-weight: 900;
}

.urgency {
  justify-self: end;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 850;
}

.urgency.high {
  background: #fee2e2;
  color: #dc2626;
}

.urgency.medium {
  background: #fef3c7;
  color: #b45309;
}

.urgency.low {
  background: #dcfce7;
  color: #15803d;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-inline-start: 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
}

.runs-panel {
  grid-column: 1 / -1;
}

.runs-table {
  min-width: 1040px;
}

.page-stack {
  display: grid;
  gap: 14px;
}

.compact-strip {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.compact-strip .metric-tile {
  min-height: 92px;
}

.compact-strip .metric-tile:nth-child(4n) {
  border-inline-end: 0;
}

.kanban .panel {
  padding: 14px;
}

.lane {
  min-height: 560px;
}

.lane-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #94a3b8;
}

.lane-dot.p1 {
  background: #ef4444;
}

.lane-dot.p2 {
  background: #f59e0b;
}

.lane-dot.p3 {
  background: #3b82f6;
}

.lane-dot.p4 {
  background: #14b8a6;
}

.queue-card {
  border-color: #e5e7eb;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.queue-card strong {
  color: #0f172a;
}

.insight {
  border-color: #dfe5ec;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.035);
}

.insight h3 {
  color: #0f172a;
}

.settings-grid .panel {
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.045);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 76px 1fr;
  }

  .brand span:last-child,
  .nav a span:last-child {
    display: none;
  }

  .sidebar {
    padding: 18px 12px;
  }

  .kpi-grid,
  .kpi-grid.compact,
  .dashboard-grid,
  .settings-grid,
  .kanban,
  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    display: block;
  }

  .main,
  .topbar,
  .content {
    width: 100%;
    max-width: 100vw;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .topbar {
    position: static;
    align-items: start;
    flex-direction: column;
    padding: 16px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .toolbar .text-button,
  .toolbar .icon-button {
    width: 100%;
  }

  .panel-head {
    display: grid;
    grid-template-columns: 1fr;
    flex-wrap: wrap;
  }

  .settings-panel .mini-button {
    width: 100%;
  }

  .content {
    padding: 16px;
  }

  .kpi-grid,
  .kpi-grid.compact,
  .dashboard-grid,
  .settings-grid,
  .kanban,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .search {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Skeleton loader ─── */
@keyframes shimmer {
  0% { background-position: -800px 0; }
  100% { background-position: 800px 0; }
}

.skeleton-block {
  height: 120px;
  border-radius: 8px;
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  margin-bottom: 14px;
}

.skeleton-block.short {
  height: 64px;
}

/* ─── Empty state ─── */
.empty-state {
  display: grid;
  gap: 10px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state span {
  font-size: 28px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 13px;
}

/* ─── Load more ─── */
.load-more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  transition: border-color 140ms, background 140ms;
}

.load-more:hover {
  border-color: var(--teal);
  background: var(--teal-weak);
  color: var(--teal);
}

/* ─── Budget Recommendation ─── */
.budget-rec {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin: 5px 0 3px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}
.budget-rec.scale { background: #d1fae5; color: #065f46; }
.budget-rec.hold  { background: #fef9c3; color: #92400e; }
.budget-rec.pause { background: #fee2e2; color: #991b1b; }

.muted-metric {
  color: #94a3b8;
  font-style: italic;
  font-size: 12px;
}

.action-cell {
  font-size: 12px;
  max-width: 220px;
  white-space: normal;
  line-height: 1.35;
}

/* ─── Drag-and-drop ─── */
[draggable] {
  cursor: grab;
}

[draggable]:active {
  cursor: grabbing;
}

.drag-over {
  outline: 2px dashed var(--teal);
  outline-offset: -3px;
  background: var(--teal-weak) !important;
}

/* ─── Sparkline ─── */
.sparkline {
  display: inline-block;
  vertical-align: middle;
}

.sparkline.up polyline {
  stroke: var(--green);
}

.sparkline.down polyline {
  stroke: var(--coral);
}

.sparkline.flat polyline {
  stroke: #94a3b8;
}

.no-trend {
  color: var(--muted);
}

/* ─── Settings section fieldsets ─── */
fieldset.settings-section {
  margin: 16px 0 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}

fieldset.settings-section legend {
  padding: 0 6px;
  color: #475569;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field-hint {
  display: block;
  margin: -3px 0 2px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 400;
}

/* ─── Modal ─── */
.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  padding: 24px;
}

.modal-box {
  display: flex;
  flex-direction: column;
  width: min(780px, 100%);
  max-height: 80vh;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.modal-body {
  overflow-y: auto;
  padding: 20px;
}

.modal-loading,
.modal-error {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.modal-error {
  color: var(--coral);
}

/* ─── AI variations content ─── */
.var-body {
  display: grid;
  gap: 20px;
}

.var-insight {
  padding: 12px 14px;
  border: 1px solid #bcd4ef;
  border-radius: 8px;
  background: var(--blue-weak);
  color: var(--blue);
  font-size: 13px;
}

.var-section h3 {
  margin-bottom: 8px;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.var-section ul {
  margin: 0;
  padding: 0 0 0 16px;
  display: grid;
  gap: 6px;
}

.var-section li {
  color: #1e293b;
  font-size: 13px;
  line-height: 1.5;
}

/* ─── AI button ─── */
.ai-btn {
  border-color: #8b5cf6;
  background: #8b5cf6;
}

.ai-btn:hover {
  background: #7c3aed;
}

.mini-button.primary {
  border-color: var(--teal);
  background: var(--teal);
}

.mini-button.primary:hover {
  background: #0d7a73;
}

/* ─── Bell wrap + notification badge ─── */
.bell-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.notif-badge {
  position: absolute;
  top: -4px;
  inset-inline-end: -5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
  pointer-events: none;
}

/* ─── Profile chip ─── */
.profile-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  cursor: default;
  user-select: none;
}

.profile-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f8f87, #0d6c88);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.profile-info strong {
  display: block;
  color: #0f172a;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
}

.profile-info small {
  display: block;
  color: #64748b;
  font-size: 10px;
  line-height: 1.2;
}

/* ─── Three-dot row menu ─── */
.row-menu {
  position: relative;
  display: flex;
  justify-content: center;
}

.row-menu-btn {
  min-height: 26px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 1px;
  transition: background 120ms, color 120ms;
}

.row-menu-btn:hover {
  border-color: #e2e8f0;
  background: #f1f5f9;
  color: #334155;
}

.row-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  inset-inline-end: 0;
  z-index: 50;
  min-width: 148px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.row-menu-dropdown a {
  display: block;
  padding: 9px 14px;
  color: #1e293b;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 100ms;
}

.row-menu-dropdown a:hover {
  background: #f1f5f9;
  color: #0f766e;
}

/* ─── Delta badge ─── */
.delta {
  margin-inline-start: 5px;
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
}

.delta.up {
  background: #dcfce7;
  color: #15803d;
}

.delta.down {
  background: #fee2e2;
  color: #dc2626;
}

/* ─── Distribution on-bar labels ─── */
.dist-label {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 4px;
  color: #334155;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.dist-bar {
  position: relative;
}

/* ─── Very-low score band (0-20) ─── */
.very-low {
  background: linear-gradient(180deg, #7f1d1d, #dc2626) !important;
}

.dist-bar.very-low {
  background: linear-gradient(180deg, #7f1d1d, #dc2626);
}

.distribution-legend b.very-low {
  background: #dc2626;
}

/* ─── Five-band distribution chart ─── */
.distribution-chart.five-band {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.distribution-legend.five-band {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* ─── Table footer ─── */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 6px 4px;
  color: #64748b;
  font-size: 12px;
}

/* ─── Platform badge ─── */
.platform-badge {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 5px;
  background: #1877f2;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

/* ─── Action summary with arrow ─── */
.action-summary {
  grid-template-columns: 42px minmax(0, 1fr) 70px 24px;
}

.action-arrow {
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 18px;
  font-weight: 900;
  text-decoration: none;
  transition: color 120ms;
}

.action-arrow:hover {
  color: #0f766e;
}

/* ─── Action symbol priority colors ─── */
.action-symbol.priority-p1 {
  background: #fee2e2;
  color: #dc2626;
}

.action-symbol.priority-p2 {
  background: #fef3c7;
  color: #b45309;
}

.action-symbol.priority-p3 {
  background: #dbeafe;
  color: #2563eb;
}

.action-symbol.priority-p4 {
  background: #f1f5f9;
  color: #64748b;
}

/* ─── Runs table wider ─── */
.runs-table {
  min-width: 1180px;
}

/* ─── Extended creative rank row (6 columns) ─── */
.rank-head,
.rank-row-ext {
  grid-template-columns: minmax(168px, 1.25fr) minmax(98px, 0.8fr) 58px 72px 48px 32px;
}

/* ─── Nav bottom links ─── */
.sidebar {
  display: flex;
  flex-direction: column;
}

.nav {
  flex: 1;
}

.nav-bottom {
  display: grid;
  gap: 4px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
  margin-top: 12px;
}

.nav-bottom-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-align: start;
  text-decoration: none;
  transition: background 140ms, color 140ms;
}

.nav-bottom-link:hover {
  background: #f1f5f9;
  color: #0f766e;
}

/* ─── Dark mode ─── */
html.dark {
  --bg: #0f1117;
  --surface: #1a1f2e;
  --surface-2: #232838;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #2d3748;
  --teal-weak: #0d2d2b;
  --green-weak: #052e16;
  --blue-weak: #0c1a35;
  --amber-weak: #261a00;
  --coral-weak: #2d0c08;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

html.dark body {
  background: var(--bg);
  color: var(--text);
}

html.dark .sidebar {
  background: #111827;
  color: #e2e8f0;
  border-inline-end-color: #2d3748;
}

html.dark .nav a {
  color: #94a3b8;
}

html.dark .nav a:hover,
html.dark .nav a.active {
  background: #1e293b;
  color: #e2e8f0;
}

html.dark .nav-icon {
  border-color: #374151;
  background: #1e293b;
  color: #5eead4;
}

html.dark .nav-group {
  color: #64748b;
}

html.dark .nav-bottom {
  border-top-color: #2d3748;
}

html.dark .nav-bottom-link {
  color: #64748b;
}

html.dark .nav-bottom-link:hover {
  background: #1e293b;
  color: #5eead4;
}

html.dark .topbar {
  background: rgba(26, 31, 46, 0.96);
  box-shadow: 0 1px 0 #2d3748;
}

html.dark h1,
html.dark h2,
html.dark h3 {
  color: #e2e8f0;
}

html.dark #page-subtitle {
  color: #94a3b8;
}

html.dark select,
html.dark .search,
html.dark .text-button,
html.dark .icon-button,
html.dark .select-label input {
  border-color: #2d3748;
  background: #1a1f2e;
  color: #e2e8f0;
  box-shadow: none;
}

html.dark .text-button.primary {
  background: #0f8f87;
  border-color: #0f8f87;
  color: #ffffff;
}

html.dark .panel,
html.dark .queue-card,
html.dark .insight {
  border-color: #2d3748;
  background: #1a1f2e;
}

html.dark .panel-head small {
  color: #94a3b8;
}

html.dark .metric-strip {
  border-color: #2d3748;
  background: #1a1f2e;
}

html.dark .metric-tile {
  border-inline-end-color: #2d3748;
}

html.dark .metric-tile small,
html.dark .metric-tile em {
  color: #94a3b8;
}

html.dark .metric-tile strong {
  color: #e2e8f0;
}

html.dark th {
  background: #232838;
  color: #94a3b8;
}

html.dark td {
  border-bottom-color: #2d3748;
}

html.dark td small {
  color: #94a3b8;
}

html.dark .queue-card strong {
  color: #e2e8f0;
}

html.dark .queue-card span,
html.dark .queue-card small {
  color: #94a3b8;
}

html.dark .insight h3 {
  color: #e2e8f0;
}

html.dark .insight p,
html.dark .insight small {
  color: #94a3b8;
}

html.dark .action-summary {
  border-top-color: #2d3748;
}

html.dark .action-summary strong {
  color: #e2e8f0;
}

html.dark .action-summary small {
  color: #94a3b8;
}

html.dark .creative-rank-row {
  border-top-color: #2d3748;
}

html.dark .list-head {
  color: #94a3b8;
}

html.dark .score-chip {
  border-color: #2d3748;
  background: #1e293b;
  color: #5eead4;
}

html.dark .export-link {
  border-color: #2d3748;
  background: #232838;
  color: #e2e8f0;
}

html.dark .export-link:hover {
  border-color: var(--teal);
  color: #5eead4;
}

html.dark fieldset.settings-section {
  border-color: #2d3748;
  background: #181d2a;
}

html.dark fieldset.settings-section legend {
  color: #94a3b8;
}

html.dark .field-hint {
  color: #64748b;
}

html.dark .inline-input,
html.dark .action-controls input,
html.dark .field input,
html.dark .field textarea {
  border-color: #2d3748;
  background: #1a1f2e;
  color: #e2e8f0;
}

html.dark .settings-list div {
  border-bottom-color: #2d3748;
}

html.dark .distribution-legend span {
  border-color: #2d3748;
  color: #94a3b8;
}

html.dark .dist-track {
  background: linear-gradient(180deg, transparent, #232838);
}

html.dark .dist-col small {
  color: #94a3b8;
}

html.dark .dist-label {
  color: #e2e8f0;
}

html.dark .modal-box {
  background: #1a1f2e;
  border-color: #2d3748;
}

html.dark .modal-head {
  background: #232838;
  border-bottom-color: #2d3748;
}

html.dark .var-insight {
  background: #0c1a35;
  border-color: #1e3a5f;
  color: #93c5fd;
}

html.dark .var-section h3 {
  color: #94a3b8;
}

html.dark .var-section li {
  color: #cbd5e1;
}

html.dark .modal-loading,
html.dark .modal-error {
  color: #94a3b8;
}

html.dark .row-menu-dropdown {
  background: #1a1f2e;
  border-color: #2d3748;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

html.dark .row-menu-dropdown a {
  color: #e2e8f0;
}

html.dark .row-menu-dropdown a:hover {
  background: #232838;
  color: #5eead4;
}

html.dark .row-menu-btn:hover {
  border-color: #2d3748;
  background: #232838;
  color: #e2e8f0;
}

html.dark .profile-chip {
  border-color: #2d3748;
  background: #232838;
}

html.dark .profile-info strong {
  color: #e2e8f0;
}

html.dark .profile-info small {
  color: #94a3b8;
}

html.dark .load-more {
  border-color: #2d3748;
  color: #94a3b8;
}

html.dark .load-more:hover {
  border-color: var(--teal);
  background: #0d2d2b;
  color: #5eead4;
}

html.dark .empty-state {
  color: #64748b;
}

html.dark .budget-rec.scale { background: #064e3b; color: #6ee7b7; }
html.dark .budget-rec.hold  { background: #422006; color: #fcd34d; }
html.dark .budget-rec.pause { background: #450a0a; color: #fca5a5; }

html.dark .notice {
  border-color: #2d3748;
  background: #232838;
  color: #e2e8f0;
}

html.dark .lane-dot {
  background: #475569;
}

html.dark .meta-banner {
  background: #1a1f2e;
  border-color: #2d3748;
}

html.dark .meta-banner span {
  color: #94a3b8;
}

html.dark .skeleton-block {
  background: linear-gradient(90deg, #1a1f2e 25%, #232838 50%, #1a1f2e 75%);
}

html.dark .table-footer {
  color: #64748b;
}

html.dark .nav-bottom-link {
  color: #64748b;
}

html.dark .delta.up {
  background: #052e16;
  color: #4ade80;
}

html.dark .delta.down {
  background: #2d0c08;
  color: #f87171;
}

html.dark .urgency.high {
  background: #2d0c08;
  color: #f87171;
}

html.dark .urgency.medium {
  background: #261a00;
  color: #fbbf24;
}

html.dark .urgency.low {
  background: #052e16;
  color: #4ade80;
}

html.dark .action-symbol.priority-p1 {
  background: #2d0c08;
  color: #f87171;
}

html.dark .action-symbol.priority-p2 {
  background: #261a00;
  color: #fbbf24;
}

html.dark .action-symbol.priority-p3 {
  background: #0c1a35;
  color: #60a5fa;
}

html.dark .action-symbol.priority-p4 {
  background: #1e293b;
  color: #64748b;
}

html.dark .bar-track {
  background: #232838;
}

html.dark .donut-list div,
html.dark .settings-list div {
  border-bottom-color: #2d3748;
}

html.dark .muted {
  color: #64748b;
}

html.dark .view-link {
  color: #60a5fa;
}

/* ---- Login ---- */
[hidden] {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  padding: 24px 16px;
  place-items: center;
  background: var(--bg);
}

.login-card {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 380px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-size: 20px;
}

.login-card .select-label {
  font-size: 12px;
}

.login-card input {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.login-card .notice {
  margin: 0;
}

.login-card .text-button {
  min-height: 40px;
}

/* ─── Score trend view (Trend Analysis page + detail modal) ─── */
.trend-chart {
  display: block;
  width: 100%;
  height: auto;
  margin: 8px 0;
}

.trend-chart .grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.trend-chart .axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.trend-chart .trend-line {
  fill: none;
  stroke: var(--teal);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.trend-chart .trend-dot {
  fill: var(--surface);
  stroke: var(--teal);
  stroke-width: 2;
}

.trend-chart .ref-line {
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.trend-chart .ref-line.winner { stroke: var(--green); }
.trend-chart .ref-line.scaling { stroke: var(--blue); }
.trend-chart .ref-line.testing { stroke: var(--amber); }

.trend-chart .marker-line {
  stroke: var(--coral);
  stroke-width: 2;
  stroke-dasharray: 2 3;
}

.status-bars .bar.winner, .bar-key.winner { fill: var(--green); background: var(--green); }
.status-bars .bar.scaling, .bar-key.scaling { fill: var(--blue); background: var(--blue); }
.status-bars .bar.testing, .bar-key.testing { fill: var(--amber); background: var(--amber); }
.status-bars .bar.low-score, .bar-key.low-score { fill: var(--coral); background: var(--coral); }

.bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.bar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bar-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.trend-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.segmented {
  display: flex;
  gap: 6px;
}

.segmented .mini-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.segmented .mini-button.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.movers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.movers-list h3,
.trend-subhead {
  margin: 0 0 8px;
  font-size: 14px;
}

.mover-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: start;
  cursor: pointer;
  margin-bottom: 6px;
  font: inherit;
}

.mover-row:hover {
  border-color: var(--teal);
}

.mover-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mover-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mover-name small,
.mover-scores {
  color: var(--muted);
  font-size: 12px;
}

.mover-change {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.mover-change.up { color: var(--green); }
.mover-change.down { color: var(--coral); }

.trend-link {
  padding: 2px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.trend-link:hover {
  border-color: var(--teal);
}

.trend-changes {
  margin: 0;
  padding: 0;
  list-style: none;
}

.trend-changes li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 600px) {
  .mover-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .segmented {
    flex-wrap: wrap;
  }
}

/* ─── Date range control (Meta-style presets) ─── */
.date-preset-label {
  min-width: 220px;
}

.date-tz {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.date-quick {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.date-quick .mini-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.date-quick .mini-button.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.no-data-state p {
  max-width: 560px;
  margin: 6px auto;
}

.no-data-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 900px) {
  .date-quick {
    display: none;
  }
}

/* ─── Metric trends (feature 004) ─── */
.metric-pickers {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.metric-pickers .select-label {
  min-width: 170px;
}

.metric-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 6px 0 4px;
}

.metric-summary > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.metric-summary small {
  color: var(--muted);
  font-size: 11px;
}

.metric-summary strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.metric-summary .good strong { color: var(--green); }
.metric-summary .bad strong { color: var(--coral); }

.trend-chart .trend-line.second {
  stroke: var(--amber);
}

.trend-chart .trend-dot.second {
  stroke: var(--amber);
}

.trend-chart .axis-label.second {
  fill: var(--amber);
}

.bar-key.line-key {
  height: 3px;
  background: var(--teal);
}

.bar-key.line-key.second {
  background: var(--amber);
}

.bar-key.dash-key {
  height: 0;
  border-top: 2px dashed var(--green);
  border-radius: 0;
}

.detail-switch {
  display: flex;
  align-items: end;
  gap: 10px;
  margin: 4px 0 10px;
}

.detail-switch .mini-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.detail-switch .mini-button.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.detail-metric {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.detail-metric select {
  min-width: 190px;
}

/* ─── Alerts (feature 005) ─── */
.alerts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.alert-list {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.alert-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-inline-start-width: 4px;
  border-radius: 8px;
  margin-bottom: 6px;
}

.alert-list li.unread {
  background: var(--teal-weak);
}

.alert-list li.kind-winner { border-inline-start-color: var(--green); }
.alert-list li.kind-lost-winner,
.alert-list li.kind-low { border-inline-start-color: var(--coral); }
.alert-list li.kind-recovered { border-inline-start-color: var(--blue); }
.alert-list li.kind-change { border-inline-start-color: var(--amber); }

.alert-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.alert-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-main small {
  color: var(--muted);
  font-size: 12px;
}

.alert-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#telegram-test {
  margin-top: 10px;
}

@media (max-width: 600px) {
  .alert-list li {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .alert-status {
    grid-column: 1 / -1;
  }
}

/* ─── Mixed currencies note (feature 006) ─── */
.currency-note {
  position: static;
  margin: 0 0 14px;
}

/* ─── Decision engine (feature 008) ─── */
.decisions-panel {
  margin-bottom: 14px;
}

.decision-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.decision-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-inline-start-width: 4px;
  border-radius: 10px;
  background: var(--surface);
}

.decision-card.type-scale { border-inline-start-color: var(--green); }
.decision-card.type-pause { border-inline-start-color: var(--coral); }
.decision-card.type-refresh { border-inline-start-color: var(--amber); }
.decision-card.type-fix { border-inline-start-color: var(--blue); }
.decision-card.type-test { border-inline-start-color: var(--muted); }
.decision-card.logged { opacity: 0.7; }

.decision-top,
.decision-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.decision-type {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.confidence {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

.conf-high { background: var(--green-weak); color: var(--green); }
.conf-medium { background: var(--amber-weak); color: var(--amber); }
.conf-low { background: var(--coral-weak); color: var(--coral); }

.decision-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decision-rec {
  margin: 0;
  font-weight: 700;
}

.decision-reason {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.decision-money {
  display: flex;
  flex-direction: column;
}

.decision-money strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.decision-money small { color: var(--muted); font-size: 11px; }
.decision-money.good strong { color: var(--green); }
.decision-money.bad strong { color: var(--coral); }
.decision-money.warn strong { color: var(--amber); }

.decision-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.decision-actions .mini-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.decision-actions .mini-button.primary-mini {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.decision-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal);
}

.why-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.why-summary > div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.why-summary small { color: var(--muted); font-size: 11px; }
.why-summary strong { font-size: 24px; }
.why-summary p { margin: 0; }

.why-table {
  width: 100%;
  min-width: 0;
  font-size: 13px;
}

.why-table th,
.why-table td {
  padding: 6px 6px;
  text-align: start;
}

.why-table tr.weak td:first-child { color: var(--coral); font-weight: 700; }
.why-table tr.strong td:first-child { color: var(--green); font-weight: 700; }

.why-bar {
  display: inline-block;
  width: 50px;
  height: 6px;
  margin-inline-end: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--border);
  vertical-align: middle;
}

.why-bar i {
  display: block;
  height: 100%;
  background: var(--teal);
}

.why-notes {
  margin: 10px 0 0;
  padding-inline-start: 18px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 759px) {
  .decision-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .why-table th:nth-child(3),
  .why-table td:nth-child(3),
  .why-table th:nth-child(5),
  .why-table td:nth-child(5) {
    display: none;
  }
  .why-bar {
    display: none;
  }
}

/* ─── Budget & ad sets (feature 009) ─── */
.move-list {
  display: grid;
  gap: 10px;
}

.move-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--teal);
  border-radius: 10px;
}

.move-flow {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.move-from,
.move-to {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.move-from strong,
.move-to strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.move-from small,
.move-to small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.move-from em,
.move-to em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.move-from strong { color: var(--coral); }
.move-to strong { color: var(--green); }
.move-to.cut strong { color: var(--muted); }

.move-arrow {
  font-size: 20px;
  color: var(--muted);
}

.move-numbers {
  display: flex;
  align-items: center;
  gap: 16px;
}

.budget-table td.up,
.score-table td.up { color: var(--green); font-weight: 700; }
.budget-table td.down,
.score-table td.down { color: var(--coral); font-weight: 700; }

.decision-chips {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

@media (max-width: 759px) {
  .move-flow {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .move-arrow {
    transform: rotate(90deg);
  }
}

/* ─── Creative strategy (feature 010) ─── */
.idea-list,
.test-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.idea-card,
.test-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-inline-start-width: 4px;
  border-radius: 10px;
}

.idea-card.make { border-inline-start-color: var(--green); }
.idea-card.stop { border-inline-start-color: var(--coral); }
.idea-card p { margin: 0; font-weight: 600; }
.idea-card small { color: var(--muted); }

.idea-type {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.test-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--border);
}

.test-progress i {
  display: block;
  height: 100%;
  background: var(--teal);
}

.muted-row td { color: var(--muted); }

/* ─── Apply to Meta (feature 011) ─── */
.decision-actions .mini-button.apply-mini,
.move-numbers .mini-button.apply-mini,
.mini-button.apply-mini {
  border: 1px solid var(--amber);
  background: var(--amber-weak);
  color: var(--amber);
  font-weight: 700;
}

.mini-button.apply-mini:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.apply-steps {
  margin: 10px 0;
}

.apply-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 6px;
}

.apply-warnings {
  color: var(--amber);
}

.applied-line {
  margin-top: 4px;
  font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════
   Responsive layout v2 (feature 007). Last in the file on purpose: it overrides the older layers above.
   Breakpoints: ≥1024 fixed sidebar · <1024 slide-in menu (☰) · <760 phone layout.
   ═══════════════════════════════════════════════════════════════════════════════════════════ */

/* `clip`, not `hidden`: hidden would make <body> a scroll container and break the sticky topbar. */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

/* Sidebar keeps its labels at every width (the old 76px icon-only mode is gone). */
.brand span:last-child,
.nav a span:last-child {
  display: revert;
}

.app-shell {
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  overflow-y: auto;
}

.nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.nav-toggle,
.nav-backdrop,
.filters-toggle {
  display: none;
}

/* ── Topbar: title + main actions on one row, filters on a second row ── */
.topbar {
  display: block;
  padding: 14px 24px 12px;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-heading {
  flex: 1;
  min-width: 0;
}

.page-heading h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#page-subtitle {
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.filter-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-bar .select-label {
  min-width: 150px;
}

.filter-bar .date-preset-label {
  min-width: 230px;
}

.date-quick {
  align-self: flex-end;
  padding-bottom: 14px; /* line up with the selects, not their captions */
}

/* ── "More" menu (secondary actions) ── */
.more-wrap {
  position: relative;
}

.more-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 40;
  display: grid;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
}

.more-menu[hidden] {
  display: none;
}

.more-menu button {
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: start;
  cursor: pointer;
}

.more-menu button:hover:not(:disabled),
.more-menu button:focus-visible {
  background: var(--teal-weak);
  color: var(--teal);
}

.more-menu button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

/* ── KPI tiles wrap instead of overflowing ── */
/* Separators are drawn by each tile (right + bottom) and clipped at the strip's edge, so a short last row
   leaves white space instead of a grey block. */
.metric-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr)); /* most pages have 4 tiles */
  gap: 0;
  overflow: hidden;
}

.metric-strip:has(> :nth-child(6):last-child) {
  grid-template-columns: repeat(6, minmax(0, 1fr)); /* dashboard */
}

@media (max-width: 1399px) {
  .metric-strip:has(> :nth-child(6):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1023px) and (min-width: 760px) {
  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metric-strip:has(> :nth-child(6):last-child) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.metric-tile {
  min-width: 0;
  border-inline-end: 0;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border), 0 1px 0 var(--border);
}

.metric-tile > div {
  min-width: 0;
}

/* ── Dashboard grid: 3 columns only when there is room ── */
.dashboard-main-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.35fr) minmax(0, 0.95fr);
}

.dashboard-main-grid > * {
  min-width: 0;
}

@media (max-width: 1399px) {
  .dashboard-main-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-main-grid > :nth-child(3) {
    grid-column: 1 / -1;
  }
}

/* ── Tables: keep the creative name readable while the rest scrolls sideways ── */
.table-wrap {
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.table-creative {
  min-width: 200px;
}

.table-wrap th:first-child,
.table-wrap td:first-child {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: var(--surface);
}

.table-wrap th:first-child {
  z-index: 2;
}

/* ── Action plan cards: fields shrink instead of overflowing ── */
.action-controls {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.action-controls label,
.action-controls input {
  min-width: 0;
  max-width: 100%;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.refresh-btn .btn-icon {
  font-size: 15px;
  line-height: 1;
}

/* ═══ < 1024px: slide-in menu ═══ */
@media (max-width: 1023px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    z-index: 70;
    width: min(290px, 86vw);
    height: auto;
    transform: translateX(-105%);
    transition: transform 200ms ease;
    box-shadow: 0 0 40px rgba(15, 23, 42, 0.25);
  }

  body.nav-open .sidebar {
    transform: none;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: block;
    background: rgba(15, 23, 42, 0.45);
  }

  .nav-backdrop[hidden] {
    display: none;
  }

  .nav-toggle {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
  }

  .profile-chip {
    display: none;
  }

  .kanban,
  .insight-grid,
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ═══ < 760px: phone ═══ */
@media (max-width: 759px) {
  .topbar {
    position: sticky;
    top: 0;
    padding: 10px 14px;
  }

  .topbar-row {
    gap: 8px;
  }

  #page-subtitle {
    display: none;
  }

  .page-heading h1 {
    font-size: 18px;
  }

  .topbar-actions .refresh-btn {
    justify-content: center;
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
  }

  .refresh-btn .btn-label {
    display: none;
  }

  .refresh-btn .btn-icon {
    font-size: 18px;
  }

  .topbar-actions .icon-button,
  .nav-toggle {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
  }

  .filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-top: 8px;
  }

  .filter-bar .select-label,
  .filter-bar .date-preset-label {
    min-width: 0;
  }

  .date-tz {
    display: none;
  }

  .filters-toggle {
    display: inline-flex;
    align-items: center;
    align-self: end;
    min-height: 36px;
  }

  .filters-toggle[aria-expanded="true"] {
    border-color: var(--teal);
    color: var(--teal);
  }

  .date-custom {
    grid-column: 1 / -1;
  }

  .filter-extra {
    display: none;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
  }

  .topbar.filters-open .filter-extra {
    display: grid;
  }

  .filter-extra .select-label:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .content {
    padding: 12px 12px 24px;
  }

  .page-stack,
  .dashboard-main-grid {
    gap: 12px;
  }

  .dashboard-main-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric-strip,
  .metric-strip:has(> :nth-child(6):last-child) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-tile {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px;
    min-height: 0;
    padding: 12px;
  }

  .metric-tile .metric-icon {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }

  .metric-tile strong {
    font-size: 20px;
  }

  .panel {
    padding: 14px;
  }

  .panel-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .panel-head .search,
  .panel-head select,
  .metric-pickers,
  .metric-pickers .select-label,
  .segmented {
    width: 100%;
    min-width: 0;
  }

  .segmented .mini-button {
    flex: 1;
  }

  .mini-button,
  .text-button {
    min-height: 36px;
  }

  /* Score table → one card per creative */
  .score-table {
    min-width: 0;
  }

  .score-table thead {
    display: none;
  }

  .score-table,
  .score-table tbody,
  .score-table tr,
  .score-table td {
    display: block;
    width: 100%;
  }

  .score-table tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

  .score-table td {
    padding: 0;
    border: 0;
    font-size: 13px;
  }

  .score-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .score-table td.cell-creative,
  .score-table td.action-cell {
    grid-column: 1 / -1;
    position: static;
  }

  .score-table .table-creative {
    min-width: 0;
  }

  .table-wrap:has(.score-table) {
    overflow: visible;
  }

  /* Pop-ups become bottom sheets */
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-box {
    width: 100%;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
  }

  .modal-body {
    padding: 14px;
  }

  .detail-switch {
    flex-wrap: wrap;
  }

  .detail-metric,
  .detail-metric select {
    width: 100%;
    min-width: 0;
  }
}

html.dark .more-menu {
  background: #1a1f2e;
  border-color: #2d3748;
}

html.dark .metric-tile {
  box-shadow: 1px 0 0 #2d3748, 0 1px 0 #2d3748;
}

html.dark .metric-tile,
html.dark .table-wrap th:first-child,
html.dark .table-wrap td:first-child {
  background: #1a1f2e;
}

/* ═══ Brand, header and Arabic layout (feature 014) ═══ */
.brand-logo {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  box-shadow: 0 10px 22px rgba(15, 143, 135, 0.24);
}

.brand strong {
  letter-spacing: -0.01em;
}

.icon {
  display: block;
  flex: none;
}

.nav-icon {
  border: 0;
  background: transparent;
  color: currentColor;
  opacity: 0.8;
}

.nav a.active .nav-icon,
.nav a:hover .nav-icon {
  opacity: 1;
}

/* not .nav-toggle: it is shown only below 1024px */
.icon-button:not(.nav-toggle) {
  display: inline-grid;
  place-items: center;
}

.refresh-btn .btn-icon {
  display: inline-grid;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.last-refresh {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.lang-toggle {
  font-size: 15px;
  font-weight: 800;
  font-family: "IBM Plex Sans Arabic", Inter, ui-sans-serif, system-ui, sans-serif;
}

.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 38px;
  padding-block: 3px;
  padding-inline: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.account-btn:hover,
.account-btn[aria-expanded="true"] {
  border-color: var(--teal);
  color: var(--teal);
}

.account-btn .profile-avatar {
  width: 30px;
  height: 30px;
}

.more-menu {
  min-width: 270px;
  gap: 1px;
}

.more-menu button {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
}

.mi-icon {
  display: grid;
  flex: none;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--teal);
}

.mi-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.mi-text strong {
  font-size: 13.5px;
  font-weight: 650;
}

.mi-text small {
  color: var(--muted);
  font-size: 12px;
}

.menu-head {
  display: grid;
  gap: 2px;
  margin-bottom: 4px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
}

.menu-head small,
.menu-section {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.menu-head strong {
  overflow: hidden;
  font-size: 13.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-section {
  padding: 8px 10px 3px;
}

.menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}

.more-menu .menu-danger .mi-icon {
  color: var(--coral);
}

.more-menu .menu-danger:hover {
  background: var(--coral-weak);
  color: var(--coral);
}

.settings-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 14px;
}

.settings-tools .mini-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.login-lang {
  justify-self: center;
  margin-top: 4px;
  border: 0;
  background: none;
  color: var(--teal);
  font: inherit;
  font-family: "IBM Plex Sans Arabic", Inter, ui-sans-serif, system-ui, sans-serif;
  font-weight: 650;
  cursor: pointer;
}

html.dark .account-btn,
html.dark .last-refresh {
  border-color: #2d3748;
  background: #232838;
  color: #cbd5e1;
}

html.dark .mi-icon {
  background: #232838;
  color: #5eead4;
}

html.dark .menu-head,
html.dark .menu-sep {
  border-color: #2d3748;
}

html.dark .menu-sep {
  background: #2d3748;
}

@media (max-width: 1023px) {
  .last-refresh {
    display: none;
  }
}

@media (max-width: 759px) {
  .topbar-actions {
    gap: 6px;
  }

  .account-btn {
    height: 40px;
  }

  .account-btn .account-caret {
    display: none;
  }

  .topbar-actions .lang-toggle {
    width: 36px;
    min-width: 36px;
  }
}

/* Arabic: Arabic font first, mirrored details; charts keep a left-to-right time axis */
[dir="rtl"] body,
[dir="rtl"] button,
[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea {
  font-family: "IBM Plex Sans Arabic", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

[dir="rtl"] .nav a.active {
  box-shadow: inset -3px 0 0 #0f8f87;
}

[dir="rtl"] .menu-head small,
[dir="rtl"] .menu-section,
[dir="rtl"] .nav-group {
  letter-spacing: 0;
}

[dir="rtl"] svg {
  direction: ltr;
}

[dir="rtl"] input[type="number"],
[dir="rtl"] input[type="date"],
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"] {
  direction: ltr;
  text-align: end;
}

@media (max-width: 1023px) {
  [dir="rtl"] .sidebar {
    transform: translateX(105%);
  }

  [dir="rtl"] body.nav-open .sidebar {
    transform: none;
  }
}

/* Max CPP per product (feature 016) */
.max-cpp-table .max-cpp-input {
  width: 110px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.max-cpp-table .max-cpp-input:focus {
  border-color: var(--teal);
  outline: 2px solid var(--teal-weak);
}

html.dark .max-cpp-table .max-cpp-input {
  border-color: #2d3748;
  background: #232838;
  color: #e2e8f0;
}

/* ─── Dashboard, Scoring Brain and Trend Analysis (feature 017) ─── */
.range-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-perf-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.dashboard-lists {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.95fr);
}

.trend-chart .spend-bar { fill: var(--teal); opacity: 0.28; }
.trend-chart .trend-line.cpp { stroke: var(--blue); }
.trend-chart .trend-dot.cpp { stroke: var(--blue); }
.trend-chart .trend-dot.cpp.over { stroke: var(--coral); fill: var(--coral); }
.trend-chart .trend-dot.cpp.under { stroke: var(--green); fill: var(--green); }
.trend-chart .ref-line.loss { stroke: var(--coral); }
.trend-chart .axis-label.cpp { fill: var(--blue); }
.bar-key.spend-key { background: var(--teal); opacity: 0.4; }
.bar-key.line-key.cpp { background: var(--blue); }
.bar-key.dash-key.loss { border-top-color: var(--coral); }
.bar-key.dash-key.scaling { border-top-color: var(--blue); }
.bar-key.dash-key.testing { border-top-color: var(--amber); }

.status-mix {
  display: flex;
  overflow: hidden;
  height: 14px;
  margin: 6px 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
}

.mix-seg.winner { background: var(--green); }
.mix-seg.scaling { background: var(--blue); }
.mix-seg.testing { background: var(--amber); }
.mix-seg.low-score { background: var(--coral); }

.mix-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 14px;
  margin-bottom: 14px;
}

.mix-legend div {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  column-gap: 6px;
  font-size: 13px;
}

.mix-legend small {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 11px;
}

/* Scoring Brain */
.brain-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.flow-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.flow-step strong { display: block; font-size: 14px; }
.flow-step small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.4; }

.flow-num {
  display: grid;
  flex: 0 0 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
}

.formula {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  white-space: nowrap;
}

.formula.big { display: block; margin: 6px 0; padding: 8px 10px; font-size: 13px; white-space: normal; }

.brain-table td { vertical-align: top; font-size: 13px; }
.brain-table .muted-row td { color: var(--muted); }

.brain-steps,
.brain-rules {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding-inline-start: 22px;
}

.brain-steps li {
  display: grid;
  grid-template-columns: 150px auto 1fr;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.brain-steps small { color: var(--muted); }

.brain-rules li { font-size: 13px; line-height: 1.5; }

.rule-tag {
  display: inline-block;
  min-width: 150px;
  margin-inline-end: 8px;
  font-weight: 800;
}

.brain-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.brain-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.brain-card > small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.brain-card p { margin: 6px 0 0; }
.brain-card ol { margin: 6px 0 0; padding-inline-start: 18px; }

.threshold-scale {
  display: flex;
  overflow: hidden;
  border-radius: 8px;
}

.threshold-band {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 10px;
  color: #fff;
  font-size: 12px;
}

.threshold-band strong { font-size: 13px; }
.threshold-band em { font-style: normal; font-weight: 800; }
.threshold-band.low-score { background: var(--coral); }
.threshold-band.testing { background: var(--amber); }
.threshold-band.scaling { background: var(--blue); }
.threshold-band.winner { background: var(--green); }

/* Trend Analysis health check */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.health-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-inline-start-width: 4px;
  border-radius: 8px;
  background: var(--surface);
}

.health-card.on-target { border-inline-start-color: var(--green); }
.health-card.off-target { border-inline-start-color: var(--coral); }

.health-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.health-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.health-tag.good { background: var(--green-weak); color: var(--green); }
.health-tag.bad { background: var(--coral-weak); color: var(--coral); }

.health-value {
  font-size: 24px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.health-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.health-change { font-weight: 800; }
.health-change.good { color: var(--green); }
.health-change.bad { color: var(--coral); }

.health-what {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.mini-spark {
  display: block;
  width: 100%;
  height: 36px;
}

.mini-spark .spark-line { fill: none; stroke: var(--teal); stroke-width: 2; vector-effect: non-scaling-stroke; }
.mini-spark .spark-target { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }

@media (max-width: 1023px) {
  .dashboard-lists {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1180px) {
  .dashboard-perf-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .brain-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 759px) {
  .brain-flow,
  .mix-legend {
    grid-template-columns: minmax(0, 1fr);
  }

  .brain-steps li {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .formula { white-space: normal; }

  .rule-tag { display: block; min-width: 0; }

  .threshold-band { padding: 8px 6px; font-size: 11px; }
}

/* ─── Creative preview popup, thumbnails everywhere, clickable status mix (feature 018) ─── */
[data-preview-ad] {
  cursor: zoom-in;
  transition: transform 120ms, box-shadow 120ms;
}

[data-preview-ad]:hover,
[data-preview-ad]:focus-visible {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px var(--teal);
  outline: none;
}

.creative-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  vertical-align: middle;
}

.creative-line .thumb {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  font-size: 10px;
}

.creative-line strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight h3 .creative-line strong { white-space: normal; }

.action-list .action-summary {
  grid-template-columns: 42px 36px minmax(0, 1fr) 70px 24px;
}

.modal-box.preview-box {
  width: min(1040px, 100%);
  max-height: 92vh;
}

.cp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 20px;
  align-items: start;
}

.cp-tabs {
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.cp-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

.cp-image-wrap {
  max-width: 100%;
  max-height: 64vh;
  overflow: auto;
  border-radius: 8px;
}

.cp-image {
  display: block;
  max-width: 100%;
  max-height: 64vh;
  margin: 0 auto;
  border-radius: 8px;
  object-fit: contain;
  cursor: zoom-in;
}

.cp-image-wrap.loading .cp-image {
  min-width: min(420px, 100%);
  filter: blur(6px);
}

.cp-image-wrap.zoomed .cp-image {
  max-width: none;
  max-height: none;
  width: 200%;
  cursor: zoom-out;
}

.cp-hint { margin-top: 8px; }

.cp-frame {
  display: block;
  width: min(100%, 420px);
  height: auto;
  max-height: 70vh;
  border: 0;
  border-radius: 8px;
  background: #fff;
}

.cp-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 800;
}

.cp-links a { color: var(--blue); }

.cp-facts {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cp-score {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cp-score strong { font-size: 32px; font-weight: 900; }

.cp-fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cp-fact-grid > div {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.cp-fact-grid small { display: block; color: var(--muted); font-size: 11px; }
.cp-fact-grid strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.cp-fact-grid .up strong { color: var(--green); }
.cp-fact-grid .down strong { color: var(--coral); }
.cp-action { margin: 0; font-size: 13px; line-height: 1.5; }
.cp-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

/* Status mix: every part opens Scorecards filtered to that status */
.status-mix .mix-seg {
  padding: 0;
  border: 0;
  cursor: pointer;
}

.status-mix .mix-seg:hover { filter: brightness(1.12); }

.mix-legend button {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  column-gap: 6px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font-size: 13px;
  text-align: start;
  cursor: pointer;
}

.mix-legend button:hover,
.mix-legend button:focus-visible {
  border-color: var(--border);
  background: var(--surface-2);
}

.mix-legend button small {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 759px) {
  .cp-layout { grid-template-columns: minmax(0, 1fr); }
  .cp-stage { min-height: 220px; padding: 8px; }
  .modal-box.preview-box { max-height: 96vh; }

  /* Top Creatives: cards instead of a wide row */
  .compact-list-table .rank-head { display: none; }

  .compact-list-table .rank-row-ext {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    row-gap: 6px;
    min-width: 0;
  }

  .rank-row-ext > .creative-cell,
  .rank-row-ext > span:nth-child(2) {
    grid-column: 1 / -1;
  }

  .rank-row-ext > span:nth-child(2) { color: var(--muted); }
  .rank-row-ext > strong:nth-child(5) { justify-self: end; }
}

/* Dark mode: brighter blue for the CPP line, and lighter links in the preview popup (features 017–018) */
html.dark .trend-chart .trend-line.cpp,
html.dark .trend-chart .trend-dot.cpp { stroke: #60a5fa; }
html.dark .trend-chart .axis-label.cpp { fill: #60a5fa; }
html.dark .bar-key.line-key.cpp { background: #60a5fa; }
html.dark .trend-chart .spend-bar { opacity: 0.45; }
html.dark .cp-links a { color: #60a5fa; }
html.dark .cp-frame { background: #fff; }

/* ─── Market Pulse (feature 019) ─── */
.rank-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.rank-badge.good { background: var(--green-weak); color: var(--green); }
.rank-badge.warn { background: var(--amber-weak); color: var(--amber); }
.rank-badge.bad { background: var(--coral-weak); color: var(--coral); }

.driver-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin-bottom: 12px;
}

.driver-head > div { display: flex; align-items: baseline; gap: 10px; }
.driver-head small { color: var(--muted); font-weight: 800; }
.driver-head strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.driver-head span { font-weight: 900; }
.driver-head p { margin: 0; font-weight: 700; }
.driver-head .up, .driver-row .up { color: var(--green); }
.driver-head .down, .driver-row .down { color: var(--coral); }

.driver-list { display: grid; gap: 8px; }

.driver-row {
  display: grid;
  grid-template-columns: 76px minmax(160px, 1.2fr) minmax(0, 2fr) 56px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.driver-side {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.driver-side.market { background: var(--blue-weak); color: var(--blue); }
.driver-side.you { background: var(--teal-weak); color: var(--teal); }
.driver-label small { display: block; color: var(--muted); font-size: 11px; }

.driver-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.driver-bar i { display: block; height: 100%; border-radius: 999px; }
.driver-bar i.raise { background: var(--coral); }
.driver-bar i.lower { background: var(--green); }
.driver-row strong { text-align: end; font-variant-numeric: tabular-nums; }

.driver-advice {
  margin: 10px 0 0;
  padding-inline-start: 20px;
  font-size: 13px;
  line-height: 1.6;
}

.rank-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}

.rank-kind small { color: var(--muted); font-size: 12px; }

.event-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.event-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.event-card.now { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.event-card.past { opacity: 0.6; }
.event-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.event-card small { color: var(--muted); }
.event-card p { margin: 6px 0 0; line-height: 1.5; }

.cp-ranks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
}

.cp-ranks > small { width: 100%; color: var(--muted); font-weight: 800; }
.cp-ranks p { width: 100%; margin: 2px 0 0; line-height: 1.5; }

@media (max-width: 759px) {
  .driver-row {
    grid-template-columns: 70px minmax(0, 1fr) 52px;
  }

  .driver-row .driver-bar { grid-column: 1 / -1; grid-row: 2; }
  .rank-summary { grid-template-columns: minmax(0, 1fr); }
}

/* ─── Competitor watch (feature 020) ─── */
.competitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.competitor-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.competitor-card.add { border-style: dashed; }
.competitor-pages { display: flex; flex-wrap: wrap; gap: 6px 12px; font-weight: 800; }
.competitor-pages a { color: var(--blue); }
.competitor-edit summary { cursor: pointer; color: var(--muted); font-weight: 800; }
.competitor-edit[open] { display: grid; gap: 8px; }

.comp-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.comp-form .field.wide { grid-column: span 2; }
.comp-form .field textarea { min-height: 64px; }

.comp-form select,
.comp-table select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.comp-table select { min-width: 130px; }
.comp-table td small { display: block; color: var(--muted); font-size: 11px; }
.comp-table .comp-ad { max-width: 320px; }
.comp-table .comp-ad a { color: var(--blue); font-weight: 800; }
.comp-table tr.stopped td { opacity: 0.55; }
.comp-actions { white-space: nowrap; }

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
}

.gap-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.gap-col h3 { margin: 0 0 8px; font-size: 14px; }

.gap-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-inline-start: 3px solid var(--amber);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 13px;
}

.gap-item small { color: var(--muted); }
.gap-only { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.gap-only > small { width: 100%; color: var(--muted); font-weight: 800; }

html.dark .comp-form select,
html.dark .comp-table select { background: #232838; }

@media (max-width: 1023px) {
  .comp-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gap-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 759px) {
  .comp-form { grid-template-columns: minmax(0, 1fr); }
  .comp-form .field.wide { grid-column: auto; }
}

/* ---------- Creative X-ray + diagnosis (feature 021) */
.xr-box,
.xr-diag {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.xr-box { margin-top: 10px; }
.xr-head,
.xr-diag-head,
.xr-leak-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.xr-head .mini-button { margin-inline-start: auto; }
.xr-diag-head small { color: var(--muted); }
.xr-stage,
.xr-score {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
}
.xr-stage.bad, .xr-score.bad { background: var(--coral-weak); color: var(--coral); }
.xr-stage.warn, .xr-score.warn { background: var(--amber-weak); color: var(--amber); }
.xr-stage.good, .xr-score.good { background: var(--green-weak); color: var(--green); }
.xr-stage.info { background: var(--blue-weak); color: var(--blue); }
.xr-stage.muted { color: var(--muted); }
.xr-summary { margin: 0; font-weight: 600; line-height: 1.45; }
.xr-chips, .xr-offers, .xr-metrics { display: flex; flex-wrap: wrap; gap: 6px; }
.xr-chip {
  display: inline-flex;
  flex-direction: column;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
}
.xr-chip small, .xr-pain small, .xr-fix small, .xr-money small { color: var(--muted); font-size: 10px; font-weight: 500; }
.xr-pain, .xr-fix, .xr-change { margin: 0; line-height: 1.45; }
.xr-fix { padding: 6px 8px; border-radius: 8px; background: var(--teal-weak); }
.xr-metric { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: var(--surface-2); }
.xr-metric.down strong { color: var(--coral); }
.xr-metric.up strong { color: var(--green); }
.xr-metric small { color: var(--muted); }
.xr-causes, .xr-checks { margin: 0; padding-inline-start: 18px; display: grid; gap: 3px; font-size: 13px; }
.xr-checks { list-style: none; padding-inline-start: 0; }
.xr-checks li.pass > span:first-child { color: var(--green); font-weight: 700; }
.xr-checks li.fail > span:first-child { color: var(--coral); font-weight: 700; }
.xr-filter { flex-wrap: wrap; margin: 6px 0 10px; }
.xr-filter .mini-button small { color: var(--muted); font-weight: 500; }
.xr-product { max-width: 280px; margin-bottom: 10px; }
.xr-leaks { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.xr-leak { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.xr-leak .xr-diag { background: var(--surface); }
.xr-money { margin-inline-start: auto; display: grid; text-align: end; }
@media (max-width: 640px) {
  .xr-leaks { grid-template-columns: 1fr; }
  .xr-filter .mini-button { flex: 1 1 45%; }
}
[dir="rtl"] .xr-change > strong { display: inline-block; transform: scaleX(-1); }

/* ---------- Mobile review fixes (2026-09-28) */
/* A <fieldset> never shrinks below its widest content by default: wide tables inside pushed the page sideways. */
fieldset { min-width: 0; }
/* Active filter button: counts stay readable on the teal background. */
.segmented .mini-button.active small { color: inherit; opacity: 0.85; }
/* Diagnosis text in one size. */
.xr-change, .xr-fix, .xr-causes { font-size: 13px; }
.xr-fix span { font-weight: 600; }
@media (max-width: 640px) {
  /* Preview tabs: one row that scrolls sideways instead of wrapping onto two rows. */
  .cp-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .cp-tabs .mini-button { flex: 0 0 auto; }
  /* Leak filters: tidy two-column grid. */
  .xr-filter { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .xr-filter .mini-button { display: grid; gap: 2px; text-align: center; }
  .xr-filter .mini-button:first-child { grid-column: 1 / -1; }
  /* Bigger touch areas (at least ~36px) for small links, checkboxes and the status bar. */
  .view-link { display: inline-block; padding: 10px 0; }
  main input[type="checkbox"] { width: 22px; height: 22px; }
  .status-mix .mix-seg { min-height: 22px; }
  .row-menu-btn { min-width: 36px; min-height: 36px; }
}

/* ---------- Product Playbook (feature 022) */
.pb-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.pb-picker { min-width: 220px; max-width: 320px; margin: 0; }
.pb-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.pb-dims { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.pb-dim { display: grid; gap: 8px; align-content: start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.pb-dim h3 { margin: 0; font-size: 15px; }
.pb-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: var(--surface); }
.pb-row .pill { flex: 0 0 auto; }
.pb-row-main { display: grid; gap: 2px; min-width: 0; flex: 1 1 auto; }
.pb-row-main small { color: var(--muted); font-size: 11px; }
.pb-row .thumb { width: 36px; height: 36px; flex: 0 0 36px; }
.pb-none { margin: 0; font-size: 13px; }
.pb-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pb-chips > small { color: var(--muted); font-size: 11px; font-weight: 700; margin-inline-end: 2px; }
.pb-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.pb-chip small { color: var(--muted); font-weight: 500; }
.pb-chip.untested { border-style: dashed; color: var(--blue); }
.pb-chip em { color: var(--amber); font-style: normal; }
.pb-brief { display: grid; gap: 6px; }
.pb-base { display: grid; gap: 4px; }
.pb-base > small { color: var(--muted); }
.pb-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pb-mistakes, .pb-pains { margin: 0 0 10px; padding: 0; list-style: none; display: grid; gap: 8px; }
.pb-mistakes li { display: grid; gap: 2px; font-size: 13px; }
.pb-mistakes small { color: var(--muted); }
.pb-mistakes i { display: block; height: 4px; border-radius: 4px; background: var(--coral); }
.pb-pains li { padding: 6px 8px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
@media (max-width: 900px) { .pb-two { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .pb-dims { grid-template-columns: 1fr; }
  .pb-tools, .pb-picker { width: 100%; max-width: none; }
}

/* ---------- Creative Studio (feature 023) */
.studio-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.studio-facts .wide, .studio-field.wide { grid-column: 1 / -1; }
.studio-field textarea, .studio-field input, .studio-layer input, .studio-copy-fields input, .studio-copy-fields textarea, .studio-note {
  width: 100%; min-width: 0; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
.studio-offers { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; min-width: 0; }
.studio-offers legend { font-weight: 600; padding: 0 6px; }
.studio .check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.studio-pct input { width: 80px; }
.studio-photos { display: grid; gap: 8px; }
.studio-photo-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.studio-photo { position: relative; }
.studio-photo img, .studio-ad-photo img { width: 88px; height: 88px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.studio-photo .mini-button { position: absolute; top: -8px; inset-inline-end: -8px; padding: 0 7px; border-radius: 50%; }
.studio-ad-photo { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 10px; min-width: 60px; min-height: 60px; }
.studio-ad-photo img { width: 60px; height: 60px; }
.studio-ad-photo:hover img { outline: 2px solid var(--teal); }
.studio-upload { cursor: pointer; }
.studio-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.studio-actions .studio-note { flex: 1 1 180px; width: auto; }
.studio-cost { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); }
.studio-busy { display: flex; align-items: center; gap: 10px; position: sticky; top: 8px; z-index: 5; }
.studio-spinner { width: 16px; height: 16px; border-radius: 50%; border: 3px solid currentColor; border-inline-end-color: transparent; animation: studio-spin 0.9s linear infinite; flex: none; }
@keyframes studio-spin { to { transform: rotate(360deg); } }
.studio-history { display: grid; gap: 8px; }
.studio-history-row { display: grid; grid-template-columns: 52px 1fr auto auto auto; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 10px; }
.studio-history-row img, .studio-history-row .thumb { width: 52px; height: 65px; object-fit: cover; border-radius: 6px; }
.studio-history-row small { display: block; color: var(--muted); }
.studio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.studio-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.studio-card.has-fail { border-color: var(--coral); }
.studio-card-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.studio-card-head > strong { font-size: 1.2rem; margin-inline-end: 4px; }
.studio-hyp { margin: 0; color: var(--muted); font-size: 0.9rem; }
.studio-canvas-wrap { width: 100%; }
.studio-canvas { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; border-radius: 12px; background: var(--surface-2); }
.studio-canvas.placeholder { display: grid; place-items: center; color: var(--muted); border: 2px dashed var(--border); }
.studio-thumbs { display: flex; gap: 8px; }
.studio-thumbs button { padding: 0; border: 2px solid transparent; border-radius: 8px; background: none; cursor: pointer; }
.studio-thumbs button.active { border-color: var(--teal); }
.studio-thumbs img { width: 56px; height: 70px; object-fit: cover; border-radius: 6px; display: block; }
.studio-layer { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.studio-layer legend { font-weight: 600; padding: 0 6px; }
.studio-layer .field:first-of-type { grid-column: 1 / -1; }
.studio-checks-inline { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.studio-copy summary, .studio-prompt summary, .studio-brief summary { cursor: pointer; font-weight: 600; }
.studio-brief summary h2 { display: inline; font-size: 1.05rem; }
.studio-copy-fields { display: grid; gap: 6px; margin-top: 8px; }
.studio-copy-fields small { color: var(--muted); margin-top: 6px; }
.studio-checks { margin: 0; padding-inline-start: 18px; display: grid; gap: 4px; font-size: 0.9rem; }
.studio-checks li.fail { color: var(--coral); }
.studio-checks li.warn { color: var(--amber); }
.studio-ok { margin: 0; color: var(--green); font-size: 0.9rem; }
.studio-name { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.studio-name code { font-size: 0.8rem; background: var(--surface-2); padding: 4px 8px; border-radius: 6px; word-break: break-all; }
.studio-prompt p { font-size: 0.85rem; color: var(--muted); white-space: pre-wrap; }
.studio-brief-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.studio-brief-grid h3 { margin: 10px 0 4px; font-size: 0.95rem; }
.studio-list { margin: 0; padding-inline-start: 18px; display: grid; gap: 4px; }
.studio-vo { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.studio-vo article { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.studio-vo p { white-space: pre-wrap; line-height: 1.7; }
@media (max-width: 759px) {
  .studio-grid { grid-template-columns: 1fr; }
  .studio-layer { grid-template-columns: 1fr; }
  .studio-history-row { grid-template-columns: 44px 1fr auto; }
  .studio-history-row .mini-button { grid-column: span 1; }
}

.studio .check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; width: auto; }
.studio .check input { width: auto; margin: 0; }
.studio-layer input, .studio-layer select, .studio-copy-fields input, .studio-copy-fields textarea, .studio-field input, .studio-field textarea, .studio-note { font-size: 0.95rem; }
.studio-layer .field, .studio-field { display: grid; gap: 4px; }
.studio-photo-tip { display: block; }
.studio-logo img { object-fit: contain; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 50% / 16px 16px; }
.studio-design select { min-width: 220px; }
.studio-editor { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.studio-editor .wide { grid-column: 1 / -1; }
.studio-colors { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.studio-colors input[type="color"] { width: 32px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; }
.studio-canvas[data-studio-canvas] { touch-action: none; cursor: move; }
.studio-textcheck { border-radius: 10px; padding: 8px 12px; font-size: 0.9rem; }
.studio-textcheck.ok { background: var(--green-weak); color: var(--green); }
.studio-textcheck.fail { background: var(--coral-weak); color: var(--coral); }
.studio-textcheck p { margin: 4px 0 0; color: var(--text); }
@media (max-width: 759px) { .studio-editor { grid-template-columns: 1fr; } }
.studio-launch code { font-size: 0.8rem; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.studio-plan { margin-top: 12px; display: grid; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.studio-plan p { margin: 0; }
.studio-brief-chain dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; margin: 8px 0 0; font-size: 0.9rem; }
.studio-brief-chain dt { color: var(--muted); font-weight: 600; }
.studio-brief-chain dd { margin: 0; }
