/* ============================================================================
   Client Dashboard global stylesheet
   Apple-professional aesthetic with a glassy lift:
     - native font stack (San Francisco / Segoe / Roboto)
     - light, slightly warm neutrals (not corporate gray)
     - subtle backdrop-blur on cards and the sticky header for the
       glass-pane look
     - capsule chips with very soft pastel fills
     - centered status cells inside the dashboard table for symmetry

   Sections:
     A. Reset + tokens
     B. Shell + header
     C. Search bar + filter chips
     D. Dashboard table (centered, symmetric, draggable)
     E. Chips + badges
     F. Client detail page (hero, KPI tiles, sections)
     G. Quote callouts + timeline
     H. Responsive
   ============================================================================ */

/* ---------- A. Reset + tokens ---------- */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display",
               "SF Pro Text", "Helvetica Neue", system-ui, "Segoe UI",
               Roboto, "Inter", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Background palette: light, gently warm, with a soft gradient on the
     page so it doesn't feel flat / corporate. */
  --bg:           #f4f4f7;
  --bg-2:         #ecedf2;
  --surface:      rgba(255, 255, 255, 0.78);  /* glass white */
  --surface-solid:#ffffff;
  --surface-2:    #f8f8fb;
  --surface-3:    #f0f1f6;
  --border:       rgba(60, 60, 67, 0.10);
  --border-strong:rgba(60, 60, 67, 0.20);
  --text:         #1d1d1f;
  --text-muted:   #56565a;
  --text-faint:   #8e8e93;
  --link:         #0a84ff;
  --link-hover:   #0066cc;
  --accent:       #5e5ce6;             /* soft indigo for highlights */

  /* Traffic-light tokens. Pastels, with darker text for AA contrast. */
  --happy-bg:       #def5e3;
  --happy-fg:       #1c7a36;
  --neutral-bg:     #ecedf2;
  --neutral-fg:     #3a3a3c;
  --risk-bg:        #ffe5cf;
  --risk-fg:        #a0521e;
  --frustrated-bg:  #ffd9d9;
  --frustrated-fg:  #a82424;
  --nosig-bg:       #ececef;
  --nosig-fg:       #6e6e73;

  --active-bg:  #d2f1dc;
  --active-fg:  #1c7a36;
  --quiet-bg:   #fff1c8;
  --quiet-fg:   #876200;
  --stalled-bg: #ffd9d9;
  --stalled-fg: #a82424;
  --noscope-bg: #ececef;
  --noscope-fg: #6e6e73;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 22px;

  /* Soft Apple shadows. */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow:    0 4px 14px rgba(0, 0, 0, 0.06),
               0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.10),
               0 4px 10px rgba(0, 0, 0, 0.06);

  /* Tabular numbers everywhere by default (better alignment for scores,
     days, dates). */
  font-variant-numeric: tabular-nums;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background-color: var(--bg);
}
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(ellipse 60% 70% at 20% 0%, rgba(94, 92, 230, 0.10), transparent 60%),
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(10, 132, 255, 0.07), transparent 70%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 280px);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover { color: var(--link-hover); text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }


/* ---------- B. Shell + header ---------- */

.shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.65);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.app-header .brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  letter-spacing: -0.005em;
}
.app-header .brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--link));
  box-shadow: 0 0 8px rgba(94, 92, 230, 0.5);
}
.app-header nav {
  display: flex;
  gap: 4px;
  font-size: 13px;
}
.app-header nav a {
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.app-header nav a:hover {
  color: var(--text);
  background: rgba(60, 60, 67, 0.06);
  text-decoration: none;
}
.app-header .meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-faint);
}

main.dashboard {
  padding: 28px 28px 96px;
  max-width: 1700px;
  margin: 0 auto;
  width: 100%;
}

h1.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
}
.page-subtitle {
  color: var(--text-muted);
  margin: 0 0 22px;
  font-size: 13.5px;
  max-width: 760px;
}


/* ---------- C. Search bar + filter chips ---------- */

.search-wrap {
  position: relative;
  margin-bottom: 14px;
}
.search-input {
  width: 100%;
  height: 46px;
  padding: 0 60px 0 46px;
  border-radius: 23px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 14px;
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s, background .15s;
}
.search-input::placeholder { color: var(--text-faint); }
.search-input:focus {
  border-color: var(--link);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.15);
}
.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.search-meta {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 12px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.happiness-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 20px;
}
.happiness-bar .count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  transition: background .15s, border-color .15s, transform .1s;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.happiness-bar .count:hover {
  background: #fff;
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.happiness-bar .count.active {
  background: var(--text);
  color: var(--surface-solid);
  border-color: var(--text);
}
.happiness-bar .count b {
  font-weight: 600;
  color: var(--text);
}
.happiness-bar .count.active b { color: var(--surface-solid); }


/* ---------- D. Dashboard table ---------- */

.table-wrap {
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* The actual scroll container. Drag-to-scroll wiring lives here. */
.table-scroll {
  overflow-x: auto;
  cursor: grab;
}
.table-scroll.is-dragging { cursor: grabbing; }
.client-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  table-layout: fixed;
}
/* Symmetric column widths. The Business · Client column gets the lion's
   share; the channel columns are equal width; happiness, score, status
   columns are sized to their content. */
.client-table colgroup col.col-name        { width: 240px; }
.client-table colgroup col.col-happiness   { width: 130px; }
.client-table colgroup col.col-score       { width: 60px; }
.client-table colgroup col.col-channel     { width: 120px; }
.client-table colgroup col.col-website     { width: 140px; }
.client-table colgroup col.col-last        { width: 110px; }
.client-table colgroup col.col-quicklinks  { width: 200px; }

.client-table thead { background: rgba(255, 255, 255, 0.55); }
.client-table th {
  text-align: center;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 13px 8px;
  border-bottom: 1px solid var(--border);
  /* Allow wrapping so "Marketing channel" / "Web channel" don't collide
     in narrow columns. Trade-off: tiny 2-line headers, but symmetry
     stays intact. */
  white-space: normal;
  line-height: 1.25;
  vertical-align: bottom;
}
.client-table th.col-name-h { text-align: left; padding-left: 16px; }

.client-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: center;
}
.client-table tbody tr {
  transition: background .12s;
}
.client-table tbody tr:hover {
  background: rgba(94, 92, 230, 0.045);
}
.client-table tbody tr:last-child td { border-bottom: 0; }

.client-table td.col-name {
  font-weight: 500;
  text-align: left;
  padding-left: 16px;
  line-height: 1.35;
  white-space: normal;
  word-wrap: break-word;
}
.client-table td.col-name a {
  color: var(--text);
  font-size: 13.5px;
}
.client-table td.col-name a:hover {
  color: var(--link);
  text-decoration: none;
}
.client-table td.col-name .subline {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

.client-table td.col-score {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 13px;
}

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}


/* ---------- E. Chips + badges ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  white-space: nowrap;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1.5;
}
.chip:hover { text-decoration: none; }

/* Happiness chips. */
.chip-happy       { background: var(--happy-bg);       color: var(--happy-fg); }
.chip-neutral     { background: var(--neutral-bg);     color: var(--neutral-fg); }
.chip-risk        { background: var(--risk-bg);        color: var(--risk-fg); }
.chip-frustrated  { background: var(--frustrated-bg);  color: var(--frustrated-fg); }
.chip-nosig       { background: var(--nosig-bg);       color: var(--nosig-fg); }

/* Per-channel status chips. */
.chip-active   { background: var(--active-bg);   color: var(--active-fg); }
.chip-quiet    { background: var(--quiet-bg);    color: var(--quiet-fg); }
.chip-stalled  { background: var(--stalled-bg);  color: var(--stalled-fg); }
.chip-noscope  { background: var(--noscope-bg);  color: var(--noscope-fg); }

/* Website status: map to traffic light by tone. */
.chip-status-blue   { background: #d8e8ff; color: #1f4ea8; }
.chip-status-purple { background: #e8dcff; color: #5b1fb8; }
.chip-status-green  { background: var(--happy-bg);    color: var(--happy-fg); }
.chip-status-red    { background: var(--stalled-bg);  color: var(--stalled-fg); }
.chip-status-orange { background: var(--risk-bg);     color: var(--risk-fg); }
.chip-status-yellow { background: var(--quiet-bg);    color: var(--quiet-fg); }
.chip-status-gray   { background: var(--noscope-bg);  color: var(--noscope-fg); }

/* "Open" channel links: render like the chip but with a subtle arrow. */
.chip.is-link::after {
  content: "↗";
  font-size: 10px;
  color: currentColor;
  opacity: 0.65;
  margin-left: 3px;
  transition: opacity .15s, transform .15s;
}
.chip.is-link:hover::after { opacity: 1; transform: translate(1px, -1px); }
.chip.is-link:hover { filter: brightness(0.96); }

.chip-link-row {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}


/* ---------- F. Client detail page ---------- */

main.client-page {
  padding: 32px 28px 96px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 18px;
  padding: 4px 10px;
  border-radius: 8px;
  transition: background .12s, color .12s;
}
.back-link:hover {
  color: var(--text);
  background: rgba(60, 60, 67, 0.06);
  text-decoration: none;
}

.client-hero {
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 26px 30px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.client-hero h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
}
.client-hero .who {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 18px;
}
.client-hero .row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.client-hero .row + .row { margin-top: 12px; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 20px 0 0;
}
.kpi {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.kpi .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 4px;
  font-weight: 600;
}
.kpi .value {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
  word-break: break-word;
  line-height: 1.35;
}
.kpi .value.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
}

.section-card {
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.section-card h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--text);
  letter-spacing: -0.005em;
}
.section-card h2 .lead {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
  font-size: 13px;
}

.bullets {
  margin: 0;
  padding-left: 18px;
}
.bullets li {
  margin-bottom: 4px;
  color: var(--text);
  font-size: 13px;
}


/* ---------- G. Quote callouts + timeline ---------- */

/* The "What the client actually said" block. Distinct surface so it
   doesn't blend into the section card. */
.quote-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.quote-list li {
  position: relative;
  padding: 14px 18px 14px 22px;
  border-radius: var(--radius);
  background: #fffaf2;
  border: 1px solid #f0dfc0;
  margin-bottom: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.quote-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: #d99e3f;
  border-radius: 4px 0 0 4px;
}
.quote-list li .meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.quote-list li.role-client { background: #fffaf2; border-color: #f0dfc0; }
.quote-list li.role-client::before { background: #d99e3f; }


/* Per-channel cards: forced 2 columns on desktop (no 3+1 awkwardness). */
.channel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 760px) {
  .channel-grid { grid-template-columns: 1fr; }
}

.channel-card {
  background: rgba(255, 255, 255, 0.62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
}
.channel-card h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: capitalize;
  letter-spacing: -0.002em;
}
.channel-card h3 .source-pill {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.channel-card .meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.channel-card .meta b { color: var(--text); font-weight: 600; }
.channel-card .last-quote {
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  margin-top: 4px;
  line-height: 1.55;
  flex: 1;
  min-height: 72px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.channel-card .last-quote.no-quote {
  color: var(--text-faint);
  font-style: italic;
  background: transparent;
  border-style: dashed;
  border-color: var(--border-strong);
  text-align: center;
  padding: 18px 14px;
}
.channel-card .last-quote .role {
  display: inline-block;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 6px;
}
.channel-card .actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2a2a2c 0%, #1d1d1f 100%);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid #1d1d1f;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  transition: filter .12s, transform .1s, box-shadow .12s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.action-btn:hover {
  filter: brightness(1.18);
  text-decoration: none;
  color: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}
.action-btn:active { transform: translateY(1px); }
.action-btn.secondary {
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  border: 1px solid var(--border-strong);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.action-btn.secondary:hover {
  background: #fff;
  filter: none;
  color: var(--text);
}
.action-btn::after {
  content: "↗";
  font-size: 11px;
  opacity: 0.85;
  margin-left: 2px;
}
.action-btn.no-arrow::after { content: ""; margin: 0; }


/* Timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
}
.timeline li {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.55;
}
.timeline li:last-child { border-bottom: 0; }
.timeline .head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.timeline .ts {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}
.timeline .who {
  color: var(--text-muted);
  font-size: 12px;
}
.timeline .role-client .who { color: var(--link); font-weight: 600; }
.timeline .role-team   .who { color: var(--text); font-weight: 600; }
.timeline .body {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* Subtle hint that the timeline scrolls. */
.timeline-wrap { position: relative; }
.timeline-wrap::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 28px;
  background: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.85));
  pointer-events: none;
  border-radius: 0 0 var(--radius) var(--radius);
}


/* ---------- H. Responsive ---------- */

@media (max-width: 1100px) {
  main.dashboard { padding: 22px 18px 80px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  main.dashboard { padding: 16px 12px 80px; }
  main.client-page { padding: 16px 12px 80px; }

  .client-table { font-size: 12px; }
  .client-table th, .client-table td { padding: 10px 6px; }

  .app-header { padding: 10px 16px; }
  .app-header nav { gap: 4px; }
  .app-header .meta { font-size: 11px; }

  .client-hero { padding: 20px; }
  .client-hero h1 { font-size: 22px; }

  .section-card { padding: 18px 18px; }
}

/* Print: clean white surfaces, no glass. */
@media print {
  body { background: #fff; }
  .table-wrap, .client-hero, .section-card, .channel-card {
    background: #fff;
    backdrop-filter: none;
    box-shadow: none;
  }
}
