/* ============================================================================
 * mureo configure — visual system
 * "Calm precision instrument": a quiet, trustworthy local tool. Refined
 * minimalism — the polish is in spacing rhythm, hairline borders, a single
 * confident accent, crafted shadows and restrained motion. Bundled CSS only
 * (strict CSP: no web fonts, no CDN). Light + dark via tokens.
 * Every class / [data-*] hook used by app.html + the JS is preserved.
 * ========================================================================== */

:root {
  /* ---- palette (light) ------------------------------------------------ */
  --paper: #f4f4f1;          /* warm canvas, not cold blue-grey            */
  --surface: #ffffff;
  --surface-2: #fafaf8;      /* sunken / inset                            */
  --ink: #14161a;
  --ink-soft: #3b3f47;
  --muted: #6c7079;
  --hairline: #e4e3df;       /* low-contrast 1px borders                  */
  --hairline-strong: #d2d1cb;

  /* Accent: a deep, slightly desaturated indigo — confident, not the
     default #2563eb SaaS blue. One accent, used sparingly. */
  --accent: #4b4fd6;
  --accent-press: #3a3eb0;
  --accent-tint: #ecedfb;    /* soft fill for selected / info             */
  --accent-ring: rgba(75, 79, 214, 0.38);

  --success: #1f7a4d;
  --success-tint: #e6f4ec;
  --danger: #b3261e;
  --danger-press: #8f1e18;
  --danger-tint: #fbe9e7;
  --warn-tint: #fdf3da;
  --warn-line: #e6c463;

  /* legacy token aliases — kept so existing rules and any consumer that
     references --color-* / --radius keep resolving. */
  --color-bg: var(--paper);
  --color-surface: var(--surface);
  --color-text: var(--ink);
  --color-muted: var(--muted);
  --color-border: var(--hairline);
  --color-primary: var(--accent);
  --color-primary-hover: var(--accent-press);
  --color-success: var(--success);
  --color-danger: var(--danger);

  /* ---- scale ---------------------------------------------------------- */
  --r-sm: 7px;
  --r-md: 11px;
  --r-lg: 16px;
  --r-pill: 999px;
  --radius: var(--r-md);

  --shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.05),
    0 1px 1px rgba(20, 22, 26, 0.04);
  --shadow-md: 0 6px 22px -8px rgba(20, 22, 26, 0.18),
    0 2px 6px -2px rgba(20, 22, 26, 0.08);
  --shadow-pop: 0 24px 60px -20px rgba(20, 22, 26, 0.35);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    monospace;

  color-scheme: light dark;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e0f12;
    --surface: #16181d;
    --surface-2: #1c1f25;
    --ink: #ecedf0;
    --ink-soft: #c4c7cf;
    --muted: #8a8f99;
    --hairline: #2a2d34;
    --hairline-strong: #3a3e47;
    --accent: #8a8df5;
    --accent-press: #a3a5f8;
    --accent-tint: #20223a;
    --accent-ring: rgba(138, 141, 245, 0.45);
    --success: #4cc38a;
    --success-tint: #16271f;
    --danger: #f4857c;        /* ~5:1 on dark surfaces (AA for small text) */
    --danger-press: #f7a39c;
    --danger-tint: #2a1816;
    --warn-tint: #2a2410;
    --warn-line: #6b5a25;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 26px -10px rgba(0, 0, 0, 0.65);
    --shadow-pop: 0 26px 70px -22px rgba(0, 0, 0, 0.8);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  /* faint atmospheric depth instead of a dead flat fill */
  background-image: radial-gradient(
    1100px 600px at 50% -10%,
    color-mix(in srgb, var(--accent) 7%, transparent),
    transparent 70%
  );
  background-attachment: fixed;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0.005em;
}

h1,
h2,
h3,
h4 {
  letter-spacing: -0.015em;
  color: var(--ink);
}

a {
  color: var(--accent);
}

::selection {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- header --------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--hairline);
}

.app-header-title {
  display: flex;
  align-items: center;
  line-height: 0;
}

/* Official mureo wordmark (413×63). Two variants, swapped by scheme so
   the mark stays legible on both light and dark headers. */
.app-logo {
  height: 24px;
  width: auto;
  display: block;
}

.app-logo-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .app-logo-light {
    display: none;
  }
  .app-logo-dark {
    display: block;
  }
}

.app-header-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

.lang-toggle {
  background: transparent;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease),
    background 0.15s var(--ease);
}

.lang-toggle:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}

.lang-toggle[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  .lang-toggle[aria-pressed="true"] {
    color: #0e0f12;
  }
}

/* ---- main shell ----------------------------------------------------- */
.app-main {
  max-width: 760px;
  margin: clamp(28px, 6vh, 56px) auto;
  padding: 0 clamp(16px, 4vw, 32px);
  animation: rise 0.5s var(--ease) both;
}

/* The dashboard uses a sidebar + content layout that needs far more
 * horizontal room than the single-column wizard/landing. The dashboard
 * <section data-dashboard> only loses its native `hidden` attribute
 * while the dashboard view is active (toggled in dashboard.js), so
 * scoping a wider max-width via :has() widens ONLY the dashboard.
 * Browsers without :has() simply fall back to the narrow width. */
.app-main:has([data-dashboard]:not([hidden])) {
  max-width: 1180px;
}

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

/* shared surface treatment */
.landing-card,
.wizard,
.dashboard {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}

/* ---- landing -------------------------------------------------------- */
.landing {
  text-align: center;
}

.landing-card {
  padding: clamp(40px, 8vw, 72px) clamp(24px, 6vw, 56px);
}

.landing-title {
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 660;
  margin: 0 0 10px;
}

.landing-desc {
  color: var(--muted);
  margin: 0 auto 36px;
  max-width: 46ch;
  font-size: 16px;
}

.landing-cta {
  font: inherit;
  font-size: 16px;
  font-weight: 560;
  padding: 14px 40px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--r-pill);
  cursor: pointer;
  box-shadow: 0 8px 20px -8px var(--accent-ring);
  transition: transform 0.16s var(--ease), background 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}

.landing-cta:hover {
  background: var(--accent-press);
  transform: translateY(-1px);
  box-shadow: 0 12px 26px -8px var(--accent-ring);
}

.landing-cta:active {
  transform: translateY(0);
}

@media (prefers-color-scheme: dark) {
  .landing-cta,
  .btn-primary,
  .dashboard-controls button {
    color: #0e0f12;
  }
}

.landing-legacy-notice {
  margin-top: 24px;
  background: var(--warn-tint);
  border: 1px solid var(--warn-line);
  border-radius: var(--r-md);
  padding: 18px 20px;
  text-align: left;
}

.landing-legacy-notice h2 {
  font-size: 15px;
  margin: 0 0 6px;
}

.landing-legacy-notice p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.landing-legacy-notice button {
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--danger);
  color: #fff;
  border: 0;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ---- wizard --------------------------------------------------------- */
.wizard {
  padding: clamp(28px, 5vw, 44px);
}

.wizard-step {
  animation: stepIn 0.32s var(--ease) both;
}

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

.wizard-step h2 {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 620;
}

.wizard-step > p {
  color: var(--muted);
  margin-top: 0;
}

.wizard-step label {
  display: block;
  margin: 14px 0;
  font-size: 14px;
}

.wizard-step label > span {
  display: inline-block;
  margin-bottom: 5px;
  color: var(--ink-soft);
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px solid var(--hairline);
  gap: 12px;
}

.wizard-actions [data-wizard-action="prev"] {
  margin-right: auto;
}

/* Pin Next to the right edge even when prev/skip are hidden (Step 1).
 * `justify-content: space-between` flex-starts a lone child, so we
 * force the Next button to the right with margin-left:auto. */
.wizard-actions [data-wizard-action="next"] {
  margin-left: auto;
}

.wizard-actions button {
  padding: 10px 22px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
    transform 0.12s var(--ease);
}

.wizard-actions button:hover {
  background: var(--surface-2);
  border-color: var(--ink-soft);
}

.wizard-actions button:active {
  transform: translateY(1px);
}

.wizard-actions [data-wizard-action="next"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.wizard-actions [data-wizard-action="next"]:hover {
  background: var(--accent-press);
  border-color: var(--accent-press);
}

@media (prefers-color-scheme: dark) {
  .wizard-actions [data-wizard-action="next"] {
    color: #0e0f12;
  }
}

.wizard-actions [data-wizard-action="next"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.wizard-progress {
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  margin-top: 14px;
}

.wizard-advanced-skip {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.wizard-advanced-skip a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.wizard-basic-parts {
  list-style: none;
  padding: 0;
  margin: 18px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* pills — refined tinted chips with a hairline, not candy fills */
.wizard-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 540;
  border: 1px solid transparent;
}

.wizard-step-pill.done {
  background: var(--success-tint);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

.wizard-step-pill.not-done {
  background: var(--danger-tint);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
}

.wizard-completed-summary {
  list-style: none;
  background: var(--accent-tint);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--r-md);
  padding: 16px 22px;
  margin: 16px 0;
}

.wizard-completed-summary li {
  padding: 4px 0;
}

.wizard-choice-already-done {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 560;
  color: var(--success);
}

.wizard-choice-desc {
  margin: 4px 0 10px 26px;
  font-size: 13px;
  color: var(--muted);
}

.wizard-shared-with-sc-note {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--accent-tint);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---- dashboard ------------------------------------------------------ */
.dashboard {
  padding: clamp(26px, 4vw, 40px);
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.dashboard-header h1 {
  font-size: 22px;
  font-weight: 640;
  margin: 0;
}

.dashboard-controls button {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  padding: 9px 17px;
  font: inherit;
  font-size: 14px;
  font-weight: 520;
  cursor: pointer;
  box-shadow: 0 6px 16px -10px var(--accent-ring);
  transition: background 0.15s var(--ease), transform 0.12s var(--ease);
}

.dashboard-controls button:hover {
  background: var(--accent-press);
  border-color: var(--accent-press);
}

.dashboard-controls button:active {
  transform: translateY(1px);
}

/* ------------------------------------------------------------------
 * Dashboard left-sidebar layout: vertical nav + content pane.
 * ------------------------------------------------------------------ */
.dashboard-layout {
  display: flex;
  gap: 28px;
  margin-top: 26px;
  align-items: flex-start;
}

.dashboard-nav {
  flex: 0 0 208px;
  position: sticky;
  top: 84px;
}

.dashboard-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dashboard-nav li {
  margin: 0 0 2px;
}

.dashboard-nav-item {
  position: relative;
  display: block;
  padding: 9px 14px;
  border-radius: var(--r-sm);
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 520;
  transition: color 0.14s var(--ease), background 0.14s var(--ease);
}

.dashboard-nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.dashboard-nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dashboard-nav-item[aria-current="page"] {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 620;
}

.dashboard-nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.dashboard-pane {
  flex: 1 1 auto;
  min-width: 0;
}

.dashboard-group[hidden] {
  display: none;
}

/* Constrain wide controls (e.g. long demo scenario names) to the pane
 * width. Native <option> lists cannot ellipsize while open
 * (browser-controlled); the closed state stays within bounds. */
.dashboard-pane select,
.dashboard-pane input[type="text"],
.dashboard-pane input[type="password"],
.dashboard-section input[type="text"],
.dashboard-section input[type="password"],
.dashboard-section select,
.wizard-step input[type="text"],
.wizard-step input[type="password"],
.wizard-step select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}

.dashboard-pane input:focus,
.dashboard-pane select:focus,
.dashboard-section input:focus,
.dashboard-section select:focus,
.wizard-step input:focus,
.wizard-step select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

.dashboard-section {
  margin-top: 26px;
  padding-top: 26px;
  border-top: 1px solid var(--hairline);
}

.dashboard-group > .dashboard-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.dashboard-section h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 640;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.dashboard-section > p {
  color: var(--ink-soft);
  font-size: 14px;
}

.dashboard-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.dashboard-section li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
}

.dashboard-section li:last-child {
  border-bottom: 0;
}

/* #183 dashboard provider card — give each platform row its own boundary
   so credential boundaries are scannable instead of a flat hairline list.
   Both the Official MCP providers list and the Plugin credentials list
   participate; child notes (e.g. dashboard-provider-hosted-note) fall
   inside the same boundary as the desired grouping.
   The thin hairline alone is too subtle against ``--paper``, so a soft
   1px inset shadow + bottom-edge shadow lift the card off the section
   background enough to scan boundaries at a glance without breaking
   the dark-mode palette (both colors derive from ``--ink`` at low
   alpha). */
[data-dashboard-providers-list] > li,
[data-dashboard-plugin-credentials-list] > * {
  /* Borders use ink-at-low-alpha instead of ``--hairline`` because the
     warmer hairline (#e4e3df) reads as the same value as the cream
     ``--paper`` page on some displays. ``rgba(20,22,26,0.14)`` is a
     true neutral-grey at ~14% opacity — sits between hairline and the
     section text, unmistakable against either cream or pure white. */
  border: 1px solid rgba(20, 22, 26, 0.14);
  border-radius: var(--r-md);
  padding: 12px 14px 12px 18px;
  margin-bottom: 10px;
  /* Lightly tinted cool off-white separates each card from the warm
     paper background without going pure white (which can read as
     indistinguishable on warm-temperature monitors). The dark-mode
     pair uses ``--surface`` directly — the LAB lightness gap there is
     already large. */
  background: #fbfcfd;
  box-shadow: 0 1px 3px rgba(20, 22, 26, 0.10), 0 1px 1px rgba(20, 22, 26, 0.06);
  /* Reserved for the platform-tinted left-accent stripe below. */
  border-left-width: 4px;
  border-left-style: solid;
  border-left-color: rgba(20, 22, 26, 0.14);
}

@media (prefers-color-scheme: dark) {
  [data-dashboard-providers-list] > li,
  [data-dashboard-plugin-credentials-list] > * {
    background: var(--surface);
    border-color: rgba(236, 237, 240, 0.12);
    border-left-color: rgba(236, 237, 240, 0.12);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
  }
}

/* Per-platform accent — left edge color identifies the provider at a
   glance. Brand colors come from each platform's own brand guidelines
   (Google blue, Meta blue, GA4 orange). Plugin-credentials cards
   inherit the neutral default. */
[data-dashboard-providers-list] > li[data-platform="google-ads-official"] {
  border-left-color: #4285f4;
}

[data-dashboard-providers-list] > li[data-platform="meta-ads-official"] {
  border-left-color: #1877f2;
}

[data-dashboard-providers-list] > li[data-platform="ga4-official"] {
  border-left-color: #f9ab00;
}

/* Providers list rows are <li>; preserve the legacy flex layout
   (label-left / Remove-button-right) inherited from
   .dashboard-section li so the Remove button stays right-aligned
   inside the card. The existing
   ``.dashboard-provider-hosted-note { flex-basis: 100% }`` rule keeps
   wrapping the hosted note onto a second line inside the card. */
[data-dashboard-providers-list] > li {
  flex-wrap: wrap;
}

/* Plugin credentials children are <details> blocks (see
   dashboard.js render path); flex would collapse the disclosure
   triangle row. Block is the right default here. */
[data-dashboard-plugin-credentials-list] > * {
  display: block;
}

/* The legacy ``.dashboard-section li:last-child { border-bottom: 0 }``
   would otherwise clear our card's bottom border; restore it
   explicitly so every card carries all four sides. (The plugin
   credentials list contains <details>, not <li>, so the legacy
   override never targeted it — but we keep the margin-reset for both
   for visual consistency at the bottom of each list.) */
[data-dashboard-providers-list] > li:last-child {
  border-bottom: 1px solid var(--hairline);
}

[data-dashboard-providers-list] > li:last-child,
[data-dashboard-plugin-credentials-list] > *:last-child {
  margin-bottom: 0;
}

/* #183/#184 — generic hint typography. Third-party plugin extensions
   render field hints as ``<small class="hint">`` (legacy convention
   shared across the agency-clients / agency-dashboard plugins) and
   mureo's own plugin-credentials form uses ``.field-hint``. Without a
   block declaration the small flows inline with the next sibling
   ``<label>`` heading, producing run-on text like
   ``…short-lived access tokens.Client Secret *``. Forcing block +
   adding margin/typography fixes the layout for every consumer in one
   place. */
.hint,
.field-hint,
label > small {
  display: block;
  margin-top: 4px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* External advisor MCP add form (#288 follow-up): stack each field as a
   labelled block with a full-width control, and render the
   command/args/env/headers values in a monospace font so KEY=VALUE pairs
   and per-line arguments line up and read clearly. */
.advisor-field {
  display: block;
  margin: 12px 0;
}
.advisor-field > span {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 13px;
}
[data-advisor-form] input,
[data-advisor-form] select,
[data-advisor-form] textarea {
  width: 100%;
  box-sizing: border-box;
}
[data-advisor-form] textarea {
  resize: vertical;
}
.advisor-mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.55;
}
.advisor-field .field-hint {
  margin-bottom: 0;
}

.app-toast {
  position: fixed;
  bottom: 26px;
  right: 26px;
  background: var(--ink);
  color: var(--paper);
  padding: 13px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  max-width: 340px;
  box-shadow: var(--shadow-pop);
  animation: toastIn 0.28s var(--ease) both;
  z-index: 50;
}

.app-toast[hidden] {
  display: none;
}

/* #184 toast kinds — color-code success vs error so an operator who
   triggered an action from the bottom of a long Dashboard can tell at
   a glance whether the result was good or bad. Default (.is-info or
   no kind) keeps the existing dark pill. */
.app-toast.is-success {
  background: #1f7a3f;
  color: #ffffff;
}

.app-toast.is-error {
  background: #b3261e;
  color: #ffffff;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

dialog[data-confirm-dialog] {
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 26px;
  max-width: 420px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

dialog[data-confirm-dialog]::backdrop {
  background: rgba(10, 11, 14, 0.45);
  backdrop-filter: blur(2px);
}

dialog[data-confirm-dialog] [data-confirm-text] {
  margin: 0 0 20px;
  font-size: 15px;
}

dialog[data-confirm-dialog] > div {
  display: flex;
  justify-content: flex-end;
}

dialog[data-confirm-dialog] button {
  padding: 9px 18px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  margin-left: 8px;
}

dialog[data-confirm-dialog] [data-confirm-ok] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  dialog[data-confirm-dialog] [data-confirm-ok] {
    color: #0e0f12;
  }
}

/* ------------------------------------------------------------------
 * Generic button classes — per-row delete, bulk clear, install,
 * authenticate, etc.
 * ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 17px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 520;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
    transform 0.12s var(--ease), box-shadow 0.15s var(--ease);
}

/* The `hidden` attribute must win over `.btn`'s `display: inline-flex`:
   author styles override the UA `[hidden] { display: none }`, so without
   this a `.btn` toggled via `hidden` (e.g. the About "Update all" button,
   revealed only when an update exists) would stay visible. Mirrors the
   targeted `.dashboard-group[hidden]` / `.app-toast[hidden]` rules. */
.btn[hidden] {
  display: none;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--ink-soft);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 6px 16px -10px var(--accent-ring);
}

.btn-primary:hover {
  background: var(--accent-press);
  border-color: var(--accent-press);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--hairline-strong);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-press);
  border-color: var(--danger-press);
}

.btn-danger:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

/* Right-align the bulk-clear button inside the danger zone. */
.dashboard-danger {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.dashboard-danger p {
  margin: 0 auto 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Env vars listing — name + masked/plain value side by side. */
.dashboard-env-list {
  margin: 0 0 12px;
}

.dashboard-env-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
  gap: 12px;
}

.dashboard-env-name {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
}

.dashboard-env-value {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
  text-align: right;
  flex: 1;
}

.dashboard-env-value.dashboard-env-unset {
  font-style: italic;
  opacity: 0.8;
}

.dashboard-env [data-env-form] {
  display: grid;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 16px;
  margin-top: 4px;
}

.dashboard-env [data-env-form] button {
  justify-self: start;
}

/* Manual-setup card: hosted MCP that must be added via Claude Desktop
   Connectors (e.g. official Meta Ads). Reads as an actionable info
   callout, not an error. */
.connector-setup-card,
.wizard-pending-reminder {
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin: 14px 0;
}

.connector-setup-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.connector-setup-card p.connector-setup-lead {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.connector-setup-card ol {
  margin: 0;
  padding-left: 20px;
}

.connector-setup-card ol li {
  margin: 5px 0;
  line-height: 1.55;
  font-size: 13.5px;
}

.connector-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.connector-url-row code {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  overflow-x: auto;
  white-space: nowrap;
}

.connector-copy-btn {
  flex: 0 0 auto;
}

.wizard-pending-reminder {
  font-size: 14px;
}

.wizard-pending-reminder strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

/* hosted_http provider sub-note lives inside the provider <li> so it
   reads as part of the same row (no separate divider line). The li
   wraps; the note takes a full-width second line, muted and indented. */
.dashboard-section li:has(.dashboard-provider-hosted-note) {
  flex-wrap: wrap;
}

.dashboard-provider-hosted-note {
  flex-basis: 100%;
  margin: 6px 0 2px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

/* Status marks: green ✓ / red ✗ (own span so locale re-translation of a
   sibling data-i18n text node can't wipe them). */
.mark-ok {
  color: var(--success);
  font-weight: 660;
}

.mark-no {
  color: var(--danger);
  font-weight: 660;
}

/* #239 — red "update available" indicator on the About nav item, plus
   the outdated package rows in the About tab's update area. */
.nav-badge-update {
  color: var(--danger);
  font-weight: 660;
  margin-left: 6px;
  font-size: 0.85em;
  line-height: 1;
}

.about-update-outdated {
  color: var(--danger);
  font-weight: 600;
}

/* #246 — "Check for updates" + "Update all" sit on one row. "Update all"
   is hidden until an update exists, so on a fresh check only the check
   button shows (left-aligned); wrap keeps it tidy on narrow widths. */
.dashboard-about-update-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

/* Native↔official tool toggle: breathing room from the explanatory
   note above, and space between the state text and the switch. */
.dashboard-tooluse {
  margin-top: 12px;
}

.dashboard-tooluse .btn {
  margin-left: 12px;
}

/* ====================================================================== *
 * Reports dashboard — read-only, STATE.json-sourced (platform-agnostic). *
 * A KPI card per platform (built-in AND plugin bridges); freshness from   *
 * last_synced_at; latest-report + recent-actions blocks; empty state.     *
 * Built on the existing tokens (--surface, --hairline, --shadow-sm,       *
 * --r-md/--r-lg, --accent, the *-tint family, --muted, --ink,             *
 * --font-mono) so it reads as one design system with the rest of the UI.  *
 * ====================================================================== */

/* Header row: title left, client selector + freshness right. */
.dashboard-reports-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
}

.dashboard-reports-head h2 {
  margin: 0;
}

.dashboard-reports-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dashboard-reports-client {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

/* The explicit `display` above overrides the UA `[hidden] { display: none }`,
   so the single-client case (renderReports sets the `hidden` attribute) would
   otherwise leave an empty client dropdown on screen. Same gotcha handled for
   .dashboard-group / .app-toast / .btn elsewhere. */
.dashboard-reports-client[hidden] {
  display: none;
}

.dashboard-reports-client span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.dashboard-reports-client select {
  min-width: 0;
  width: auto;
}

.dashboard-reports-freshness {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Period toggle (前日｜30日) — a segmented pill inside the reports head.
   Built only from windows that have data (summary.periods); the active
   segment lifts onto --surface with the accent, idle ones read as muted. */
.dashboard-reports-period {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
}

/* Same `[hidden]`-override gotcha as .dashboard-reports-client: the explicit
   `display` above would otherwise leave an empty toggle on screen when there
   is only one (or zero) window to switch between. */
.dashboard-reports-period[hidden] {
  display: none;
}

.reports-period-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  cursor: pointer;
  white-space: nowrap;
}

.reports-period-btn:hover {
  color: var(--ink);
}

.reports-period-btn.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.reports-period-btn:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 1px;
}

.dashboard-reports-hint {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* Multi-client overview (#307): one selectable card per client, above the
   per-client detail. A single-workspace install shows one card. */
.dashboard-reports-clients {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 12px 0 4px;
}

.dashboard-reports-clients[hidden] {
  display: none;
}

.reports-client-card {
  appearance: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 13px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
}

.reports-client-card:hover {
  border-color: var(--hairline-strong);
}

.reports-client-card.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.reports-client-card:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 1px;
}

.reports-client-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.reports-client-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.reports-client-card-fresh {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.reports-client-card-kpis {
  display: flex;
  gap: 14px;
}

.reports-client-kpi {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.reports-client-kpi-value {
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--ink);
}

.reports-client-kpi-label {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.reports-client-card-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.reports-client-flag-more {
  background: var(--surface-2);
  color: var(--muted);
}

/* Index ↔ detail navigation (#307). The "← Clients" back link sits directly
   under the "Reports" heading (its own stacked column on the head's left). */
.dashboard-reports-detail[hidden],
.reports-back[hidden],
.dashboard-reports-detail-client[hidden] {
  display: none;
}

.dashboard-reports-head-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.reports-back {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 0;
}

.reports-back:hover {
  color: var(--accent-press);
  text-decoration: underline;
}

.reports-back:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Selected client name — the prominent title leading the detail view, set
   apart from the section heading + back link above it. */
.dashboard-reports-detail-client {
  margin: 10px 0 16px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* Responsive KPI card grid — auto-fits cards, never less than ~260px. */
.dashboard-reports-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.report-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 18px 14px;
}

.report-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.report-card-name {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* metrics_period label, e.g. "LAST_30_DAYS" — quiet, mono, tinted pill. */
.report-card-period {
  flex: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 2px 8px;
}

/* Headline number: large, mono so digits align across cards. */
.report-card-headline {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.report-card-headline-value {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.05;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.report-card-headline-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Secondary KPIs in a tidy 2-column grid (label / value pairs). */
.report-card-kpis {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  margin: 0;
}

.report-card-kpis dt {
  font-size: 12px;
  color: var(--muted);
}

.report-card-kpis dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Advisory bridge / not-yet-synced card body. */
.report-card-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.report-card-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}

.report-card-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Latest-report + recent-actions blocks share a quiet sub-section frame. */
.dashboard-reports-block {
  margin-top: 24px;
}

.dashboard-reports-block h3 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 640;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.report-latest-period {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.report-latest-narrative {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.report-latest-generated {
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

/* Free-form report flags as small tinted chips. */
.report-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.report-chip {
  font-size: 11.5px;
  font-weight: 550;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--ink-soft);
}

.report-chip.is-success {
  background: var(--success-tint);
  border-color: transparent;
  color: var(--success);
}

.report-chip.is-warn {
  background: var(--warn-tint);
  border-color: transparent;
  color: var(--ink-soft);
}

.report-chip.is-danger {
  background: var(--danger-tint);
  border-color: transparent;
  color: var(--danger);
}

/* Recent-actions list — one quiet row per logged autonomous action. */
.dashboard-reports-actions-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.report-action {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
}

.report-action:last-child {
  border-bottom: 0;
}

.report-action-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.report-action-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 550;
  color: var(--ink);
}

.report-action-platform {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 1px 8px;
}

.report-action-summary {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.report-action-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Empty state — no platforms / no synced data: point at sync-state. */
.dashboard-reports-empty {
  margin-top: 18px;
  padding: 28px 22px;
  text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--r-lg);
}

.dashboard-reports-empty p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.dashboard-reports-empty p.muted {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---- reduced motion ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
