/* CartAEO Admin additions on top of the base admin stylesheet. */

.flash { margin-bottom: 16px; }
.login-error.flash { text-align: left; }
.sidebar-foot a.whoami { text-decoration: none; }
.sidebar-foot a.whoami:hover { color: var(--accent); }

/* Forms on full pages */
.form-card { padding: 20px 24px; max-width: 880px; }
.form-card.wide { max-width: none; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .field { margin-bottom: 0; min-width: 0; }
.form-grid .field.full { grid-column: 1 / -1; }
.settings-form .field { margin-bottom: 14px; }
.settings-form .form-grid .field { margin-bottom: 0; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.45; font-weight: 400; }
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
}
.form-section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.input-affix { display: flex; align-items: stretch; }
.input-affix > span {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-2);
  font-size: 13px;
}
.input-affix > span:first-child { border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-affix > span:last-child { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-affix > input { min-width: 0; flex: 1; }
.input-affix > span:first-child + input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-affix > input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.check-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text); font-weight: 500; }
.check-row input[type="checkbox"] { width: 16px; height: 16px; margin-top: 3px; flex: none; accent-color: var(--accent); }
.check-row small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.settings-form .check-row, .modal-body .check-row { text-transform: none; letter-spacing: 0; }

/* Panels and detail pages */
.cx-panel-body { padding: 4px 22px 20px; }
.cx-kv {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px 22px;
  padding: 4px 22px 20px;
}
.cx-kv > div { min-width: 0; }
.cx-kv dt { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.cx-kv dd { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.cx-kv dd small { display: block; color: var(--muted); font-size: 12px; }
.cx-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 22px 20px; }
.cx-note {
  margin: 0 22px 18px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}
.cx-note.warn { background: #fff8e6; color: #7a4d00; }
.cx-note strong { color: var(--text); }
.cx-inline-form { display: inline; }
.cx-stack > * + * { margin-top: 16px; }
.cx-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.cx-kv dd.cx-mono { font-size: 12.5px; line-height: 1.6; }
.cx-wrap { overflow-wrap: anywhere; }
.cx-right { text-align: right; }
.cx-neg { color: var(--danger); }
.cx-pos { color: var(--ok); }
.cx-thumb {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--panel-2);
  border: 1px solid var(--border-light);
  flex: none;
}
.cx-thumb.lg { width: 64px; height: 64px; border-radius: 8px; }
.cx-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cx-cell-copy { min-width: 0; display: flex; flex-direction: column; }
.cx-cell-copy > :first-child { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-cell-copy small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.cx-cell { text-decoration: none; color: inherit; }
a.cx-cell:hover .cx-cell-copy > :first-child { color: var(--accent); }
.cx-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cx-score.low { background: #f0f0f0; color: var(--muted); }
.cx-phrases { list-style: none; margin: 0; padding: 0 22px 16px; }
.cx-phrases li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--border-light);
  font-size: 13.5px;
}
.cx-phrases li:first-child { border-top: 0; }
.cx-phrases li > span:first-child { flex: 1; min-width: 0; }
.cx-product {
  border-top: 1px solid var(--border-light);
  padding-top: 14px;
}
.cx-product:first-of-type { border-top: 0; padding-top: 0; }
.cx-product-head { display: flex; align-items: center; gap: 12px; padding: 0 22px 10px; flex-wrap: wrap; }
.cx-product-head .cx-cell { flex: 1; min-width: 220px; }
.cx-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 22px 16px; font-size: 13px; color: var(--muted); }
.cx-pager div { display: flex; gap: 8px; }

/* Server-rendered charts */
.cx-chart-wrap { padding: 6px 22px 18px; }
.cx-chart { display: block; width: 100%; height: 150px; }
.cx-chart-axis { stroke: var(--border); stroke-width: 1; }
.cx-chart-bar { fill: var(--accent); opacity: 0.88; }
.cx-chart-bar:hover { opacity: 1; }
.cx-chart-bar.is-zero { fill: var(--border); }
.cx-chart-foot { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Plan and platform cards */
.cx-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cx-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.cx-card h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cx-card-price { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); line-height: 1.1; }
.cx-card-price small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.cx-card-meta { font-size: 13px; color: var(--text-2); }
.cx-card ul { list-style: none; padding: 0; margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.cx-card ul li { padding: 3px 0 3px 20px; position: relative; }
.cx-card ul li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 9px;
  height: 5px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}
.cx-card-foot { margin-top: auto; padding-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cx-card.is-off { opacity: 0.72; }
.cx-platform-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  flex: none;
}
.cx-platform-icon svg { width: 22px; height: 22px; }
.cx-key {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  border: 1px dashed var(--accent-light);
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cx-key code { flex: 1; min-width: 200px; font-size: 13px; overflow-wrap: anywhere; }

/* Article preview in the admin */
.cx-article { padding: 8px 26px 26px; max-width: 820px; }
.cx-article h2 { font-size: 20px; margin: 22px 0 8px; letter-spacing: -0.01em; }
.cx-article h3 { font-size: 16px; margin: 18px 0 6px; }
.cx-article p, .cx-article li { font-size: 15px; line-height: 1.65; color: var(--text); }
.cx-article p { margin: 0 0 12px; }
.cx-article ul, .cx-article ol { margin: 0 0 12px 22px; }
.cx-article img { max-width: 100%; height: auto; border-radius: 8px; }
.cx-article table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; }
.cx-article th, .cx-article td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.cx-article .cartaeo-answer { padding: 12px 16px; background: var(--accent-bg); border-radius: 8px; margin-bottom: 14px; }
.cx-article .cartaeo-takeaways { padding: 12px 16px 4px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; }
.cx-article .cartaeo-product-card { display: flex; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: 10px; margin: 18px 0; }
.cx-article .cartaeo-product-card img { width: 96px; height: 96px; object-fit: cover; }
.cx-article .cartaeo-author { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border-light); color: var(--text-2); font-size: 13.5px; }
.cx-cover { display: block; width: 100%; max-height: 340px; object-fit: cover; border-radius: 10px; margin: 0 0 16px; }
pre.cx-pre {
  margin: 0 22px 20px;
  padding: 14px;
  background: #0b1220;
  color: #d9e2ef;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  overflow: auto;
  max-height: 420px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Tables inside panels */
.ov-table td .pill { white-space: nowrap; }
.ov-table td.actions { white-space: nowrap; text-align: right; }
.ov-table td.actions form { display: inline; }
.ov-table .cx-cell { max-width: 420px; }
.cx-setup { margin-bottom: 16px; }

@media (max-width: 760px) {
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .form-card { padding: 16px; }
  .cx-kv { padding: 4px 16px 16px; }
  .cx-chart-wrap, .cx-panel-body { padding-left: 16px; padding-right: 16px; }
}

/* Numbered how-to lists inside panels */
.cx-steps { margin: 0; padding: 4px 22px 20px 42px; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.cx-steps li { padding: 4px 0; }
.cx-steps strong { color: var(--text); }
.cx-summary { cursor: pointer; padding: 6px 22px 14px; font-size: 13px; font-weight: 600; color: var(--accent); }
.cx-summary:hover { text-decoration: underline; }

/* AI call routing rows */
.cx-routes { padding: 0 22px 8px; }
.cx-route {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 1.6fr);
  gap: 14px 24px;
  padding: 16px 0;
  border-top: 1px solid var(--border-light);
  align-items: start;
}
.cx-route:first-child { border-top: 0; padding-top: 4px; }
.cx-route-copy strong { font-size: 14px; color: var(--text); margin-right: 6px; }
.cx-route-copy p { margin: 6px 0 0; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.cx-route-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.cx-route-form .field { margin: 0; flex: 1 1 150px; min-width: 0; }
.cx-route-form .field.cx-route-tokens { flex: 0 1 140px; }
.cx-route-actions { display: flex; gap: 6px; padding-bottom: 1px; }
.input-affix > span + input + span { border-left: 0; border-right: 0; border-radius: 0; }
.input-affix > input + span + input { border-radius: 0; }
@media (max-width: 900px) {
  .cx-route { grid-template-columns: 1fr; }
}

/* Seven-up stat strip on the overview */
@media (min-width: 961px) {
  .ov-stats.cx-stats-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
