:root {
  --bg: #0b1020;
  --panel: #121a2f;
  --panel-2: #18223b;
  --text: #eef3ff;
  --muted: #aeb9d6;
  --line: #2a3658;
  --accent: #74d4ff;
  --accent-2: #2dd4bf;
  --danger: #fb7185;
  --ok: #86efac;
  --warn: #fde68a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(45,212,191,.20) 0, transparent 28rem),
    radial-gradient(circle at top right, rgba(116,212,255,.18) 0, transparent 26rem),
    var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar, .footer {
  max-width: 1220px;
  margin: 0 auto;
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.topbar h1 { margin: 4px 0 0; font-size: 26px; }
.subhead { color: var(--muted); margin-top: 6px; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .13em; font-size: 12px; font-weight: 900; }
nav { display: flex; gap: 12px; flex-wrap: wrap; }
nav a { padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.03); }
.page { max-width: 1220px; margin: 0 auto; padding: 0 22px 40px; }
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.025));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  margin: 18px 0;
  box-shadow: 0 18px 60px rgba(0,0,0,.24);
}
.hero { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 22px; align-items: center; }
.hero h2 { font-size: 34px; line-height: 1.08; margin: 6px 0 10px; }
.status-panel { background: rgba(0,0,0,.18); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; gap: 12px; }
.metric span { display: block; font-size: 30px; font-weight: 900; color: var(--accent); }
.narrow { max-width: 460px; margin: 54px auto; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.compact { gap: 12px; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: var(--muted); font-weight: 800; }
input, select, textarea {
  width: 100%;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0d1428;
  color: var(--text);
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(116,212,255,.12); }
.checkbox { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.checkbox input { width: auto; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #07111e;
  font-weight: 950;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { filter: brightness(1.05); text-decoration: none; }
.button.small { padding: 8px 12px; font-size: 14px; }
button.secondary, .button.secondary { background: #20304f; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--danger); color: #fff; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.split { display: flex; justify-content: space-between; gap: 18px; align-items: start; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 12px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
small, p, li { color: var(--muted); line-height: 1.55; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.messages { margin: 10px 0; }
.message { padding: 12px 14px; border-radius: 12px; margin: 8px 0; background: var(--panel-2); }
.message.success { border: 1px solid rgba(134,239,172,.5); }
.message.error { border: 1px solid rgba(251,113,133,.6); }
.status, .pill { display: inline-block; padding: 6px 10px; border-radius: 999px; font-weight: 900; font-size: 12px; }
.status.ok { color: #052e16; background: var(--ok); }
.status.warn { color: #422006; background: var(--warn); }
.pill { background: rgba(116,212,255,.13); border: 1px solid rgba(116,212,255,.35); color: var(--accent); }
.clean-list { padding-left: 18px; }
.run-list { display: grid; gap: 12px; padding-left: 18px; }
.report pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #080d1a;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  line-height: 1.58;
  color: #eef3ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.footer { color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
@media (max-width: 860px) {
  .grid.two, .hero { grid-template-columns: 1fr; }
  .topbar, .split { flex-direction: column; align-items: stretch; }
  .button-row { justify-content: stretch; }
}

/* Detailed sync output */
.sync-output-card { border-color: rgba(110, 232, 255, 0.35); }
.sync-summary { display: flex; gap: 0.55rem; flex-wrap: wrap; justify-content: flex-end; }
.mini-stat { display: inline-flex; align-items: center; border: 1px solid rgba(160,180,220,0.28); border-radius: 999px; padding: 0.42rem 0.75rem; background: rgba(255,255,255,0.04); color: #d8e7ff; font-weight: 800; }
.mini-stat.ok { border-color: rgba(117, 255, 179, 0.45); color: #9fffc5; }
.mini-stat.warn { border-color: rgba(255, 220, 120, 0.45); color: #ffe09a; }
.mini-stat.error { border-color: rgba(255, 120, 145, 0.45); color: #ff9bae; }
.sync-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.sync-meta span { border: 1px solid rgba(160,180,220,0.18); border-radius: 14px; padding: 0.7rem; background: rgba(255,255,255,0.035); color: #c9d7ff; }
.diagnostic-box { border: 1px solid rgba(255, 120, 145, 0.5); background: rgba(255, 70, 95, 0.08); color: #ffd7df; border-radius: 16px; padding: 1rem; margin: 1rem 0; }
.diagnostic-box ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.sync-steps { display: grid; gap: 0.7rem; margin-top: 1rem; max-height: 520px; overflow: auto; padding-right: 0.35rem; }
.sync-step { border: 1px solid rgba(160,180,220,0.18); border-radius: 16px; padding: 0.85rem 1rem; background: rgba(255,255,255,0.035); }
.sync-step.ok { border-color: rgba(117, 255, 179, 0.35); background: rgba(80, 255, 155, 0.055); }
.sync-step.error { border-color: rgba(255, 120, 145, 0.45); background: rgba(255, 70, 95, 0.065); }
.sync-step.skip { border-color: rgba(255, 220, 120, 0.35); background: rgba(255, 220, 120, 0.045); }
.sync-step-head { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; }
.sync-step-head small { margin-left: auto; color: #91a4c8; }
.sync-badge { font-size: 0.72rem; line-height: 1; padding: 0.35rem 0.5rem; border-radius: 999px; border: 1px solid rgba(110, 232, 255, 0.25); color: #6ee8ff; background: rgba(110, 232, 255, 0.08); font-weight: 900; letter-spacing: 0.04em; }
.sync-step p { margin: 0.45rem 0 0; color: #c9d7ff; }
.muted { color: #94a8cb; }
@media (max-width: 900px) { .sync-meta { grid-template-columns: 1fr; } .sync-step-head small { margin-left: 0; width: 100%; } }

/* Action visibility panels: used by every button that performs a write/fetch/report job. */
.action-panel {
  border: 1px solid rgba(112, 210, 255, 0.35);
  background: linear-gradient(135deg, rgba(17, 35, 67, 0.98), rgba(10, 21, 43, 0.98));
  box-shadow: 0 18px 50px rgba(0,0,0,0.26);
}
.hidden { display: none !important; }
.action-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.progress-shell {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  margin: 0.75rem 0 1rem;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6fd1ff, #34dbc6, #86f0a8);
  transition: width 0.25s ease;
}
.inline-summary {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .75rem 0;
}
.mini-stat {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .35rem .65rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #d8e8ff;
  font-size: .86rem;
  font-weight: 700;
}
.mini-stat.ok { background: rgba(78, 229, 143, .18); border-color: rgba(78,229,143,.35); color: #b7ffd3; }
.mini-stat.warn { background: rgba(255, 207, 92, .16); border-color: rgba(255,207,92,.36); color: #ffe8a3; }
.mini-stat.error { background: rgba(255, 111, 134, .16); border-color: rgba(255,111,134,.36); color: #ffc5ce; }
.sync-steps.live-steps {
  max-height: 540px;
  overflow: auto;
  padding-right: .35rem;
}
.sync-step {
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.045);
  border-radius: 18px;
  padding: .9rem 1rem;
  margin: .7rem 0;
}
.sync-step.ok { border-color: rgba(78,229,143,.34); background: rgba(78,229,143,.07); }
.sync-step.warn, .sync-step.skip { border-color: rgba(255,207,92,.34); background: rgba(255,207,92,.07); }
.sync-step.error { border-color: rgba(255,111,134,.38); background: rgba(255,111,134,.08); }
.sync-step.working { border-color: rgba(112,210,255,.38); background: rgba(112,210,255,.07); }
.sync-step-head {
  display: flex;
  align-items: center;
  gap: .65rem;
  justify-content: space-between;
  flex-wrap: wrap;
}
.sync-badge {
  border-radius: 999px;
  padding: .2rem .55rem;
  background: rgba(112,210,255,.18);
  color: #7fe2ff;
  font-size: .72rem;
  letter-spacing: .08em;
  font-weight: 900;
}
.sync-step p { margin: .45rem 0 0; }
.muted { color: #9fb3d8; }
.message.error {
  border-color: rgba(255,111,134,.45);
  background: rgba(255,111,134,.1);
}


/* Client-facing report preview layer */
.client-report-shell {
  background: #f7f9fc;
  color: #172033;
  border-radius: 24px;
  padding: 22px;
  margin: 18px 0;
  box-shadow: 0 18px 60px rgba(0,0,0,.24);
}
.client-report-shell .eyebrow { color: #0f766e; }
.client-report-hero {
  background: white;
  border: 1px solid #d7e1ef;
  border-radius: 22px;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 20px;
  align-items: center;
}
.client-report-hero h2 { color: #0f172a; margin: 6px 0; }
.report-score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.report-score-grid div {
  background: #eef6ff;
  border: 1px solid #c8dff8;
  border-radius: 16px;
  padding: 16px;
}
.report-score-grid strong { display: block; color: #0f766e; font-size: 30px; }
.report-score-grid span { color: #475569; font-weight: 800; }
.report-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}
.tab-button {
  background: white;
  color: #0f172a;
  border: 1px solid #d7e1ef;
  border-radius: 999px;
}
.tab-button.active {
  background: linear-gradient(90deg, #ef4444, #22c55e);
  color: white;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.white-card {
  background: white;
  color: #172033;
  border: 1px solid #d7e1ef;
  border-radius: 20px;
  padding: 22px;
}
.white-card h3, .white-card h4 { color: #0f172a; margin-top: 0; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(120px, 1fr) 46px;
  gap: 12px;
  align-items: center;
  margin: 10px 0;
}
.bar-label { font-weight: 800; color: #334155; }
.bar-track {
  height: 16px;
  background: #e5edf7;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  border-radius: 999px;
}
.bar-count { font-weight: 900; color: #0f766e; text-align: right; }
.pill-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.pill.ok { background: #dcfce7; color: #14532d; border-color: #86efac; }
.pill.warn { background: #fef3c7; color: #78350f; border-color: #fde68a; }
.hint { color: var(--muted); font-size: 13px; margin-top: 8px; }
code {
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 6px;
}
@media (max-width: 900px) {
  .client-report-hero { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; }
  .bar-count { text-align: left; }
}

/* Client report listening + white output polish */
.client-report-page {
  color: #172033;
}
.client-report-topline {
  background: #ffffff;
  color: #172033;
  border: 1px solid #d7e1ef;
  border-radius: 24px;
  padding: 22px;
  margin: 18px 0;
  box-shadow: 0 18px 60px rgba(0,0,0,.18);
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}
.client-report-topline h2 {
  color: #0f172a;
  margin: 6px 0;
}
.client-report-topline p,
.client-report-shell p,
.white-card p,
.white-card li {
  color: #334155;
}
.report-actions .button.listen {
  background: linear-gradient(90deg, #ef4444, #22c55e);
  color: #fff;
  border: 0;
}
.report-actions .button.listen:disabled {
  opacity: .7;
  cursor: wait;
}
.report-actions .listen-stop {
  background: #fff;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.speech-status {
  background: #ecfeff;
  color: #155e75;
  border: 1px solid #a5f3fc;
  border-radius: 16px;
  padding: 12px 14px;
  margin: 12px 0 18px;
  font-weight: 800;
}
.speech-status.speech-error {
  background: #fff1f2;
  color: #9f1239;
  border-color: #fecdd3;
}
.client-full-report pre,
.client-report-shell .report pre,
.white-card.report pre {
  background: #ffffff;
  color: #111827;
  border: 1px solid #d7e1ef;
  border-radius: 16px;
  padding: 20px;
  line-height: 1.72;
  font-size: 15px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  white-space: pre-wrap;
  word-break: break-word;
}
.client-note {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #14532d !important;
  border-radius: 14px;
  padding: 12px 14px;
}
@media (max-width: 900px) {
  .client-report-topline {
    flex-direction: column;
  }
  .report-actions {
    justify-content: stretch;
    width: 100%;
  }
  .report-actions .button,
  .report-actions button {
    width: 100%;
  }
}
