/* ============================================================================
   ATL ACTIVITY TRACKER — STYLESHEET
   Organized into: Variables, Reset, Typography, Layout, Components,
   Utilities, Responsive Breakpoints. BEM naming throughout.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. VARIABLES (design tokens — IBM Carbon-inspired palette)
   ---------------------------------------------------------------------------- */
:root {
  /* Brand */
  --color-primary: #0530ad;
  --color-secondary: #4589ff;
  --color-accent: #ff7eb6;

  /* IBM Carbon token palette */
  --blue-60: #0f62fe;
  --blue-50: #4589ff;
  --cyan-30: #a6c8ff;
  --purple-40: #be95ff;
  --magenta-40: #ff7eb6;
  --teal-30: #3ddbd9;
  --green-50: #24a148;
  --yellow-30: #f1c21b;
  --red-60: #da1e28;

  /* Semantic */
  --color-success: var(--green-50);
  --color-warning: var(--yellow-30);
  --color-danger: var(--red-60);
  --color-info: var(--blue-60);

  /* Surface / text — light theme defaults */
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-border: #dde3f0;
  --color-text: #1b2333;
  --color-text-muted: #5b6478;
  --color-text-on-primary: #ffffff;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15, 25, 60, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 25, 60, 0.1);
  --shadow-lg: 0 12px 32px rgba(15, 25, 60, 0.16);

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Typography */
  --font-base: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2.25rem;

  /* Motion */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 360ms cubic-bezier(0.22, 1, 0.36, 1);

  /* Layout */
  --header-height: 64px;
  --content-max-width: 1180px;
}

/* Dark theme overrides */
[data-theme="dark"] {
  --color-bg: #0e1320;
  --color-surface: #161d2e;
  --color-surface-raised: #1c2438;
  --color-border: #2b3552;
  --color-text: #eef1fa;
  --color-text-muted: #a3adc6;
  --color-text-on-primary: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* ----------------------------------------------------------------------------
   2. RESET
   ---------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body,
h1, h2, h3, h4, p, figure, blockquote, dl, dd {
  margin: 0;
}

ul[class], ol[class] {
  list-style: none;
  margin: 0;
  padding: 0;
}

img, picture, svg {
  max-width: 100%;
  display: block;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: var(--color-secondary);
  text-decoration-thickness: 1px;
}

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

/* ----------------------------------------------------------------------------
   3. TYPOGRAPHY
   ---------------------------------------------------------------------------- */
body {
  font-family: var(--font-base);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background var(--transition-base), color var(--transition-base);
}

h1 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: var(--fs-xl); font-weight: 700; }
h3 { font-size: var(--fs-md); font-weight: 600; }

.section-heading h1 { margin-bottom: var(--space-2); }
.section-heading p { color: var(--color-text-muted); font-size: var(--fs-sm); margin-bottom: var(--space-5); }

.dashboard-welcome {
  color: var(--color-text) !important;
  font-size: var(--fs-md, 1rem) !important;
  font-weight: 600;
  margin-bottom: var(--space-2) !important;
}
.dashboard-welcome:empty { display: none; }

#dashboard-customer-chips.chip-row { margin-bottom: var(--space-5); }
#dashboard-customer-chips:empty { margin-bottom: 0; }

/* ----------------------------------------------------------------------------
   4. LAYOUT
   ---------------------------------------------------------------------------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--content-max-width);
  margin-inline: auto;
  padding: var(--space-5) var(--space-4) var(--space-8);
}

.app-footer {
  text-align: center;
  padding: var(--space-5) var(--space-4);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

.tab-panel {
  animation: fade-in var(--transition-slow);
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ----------------------------------------------------------------------------
   5. COMPONENTS
   ---------------------------------------------------------------------------- */

/* --- Header / Nav ---------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--color-primary);
  color: var(--color-text-on-primary);
  box-shadow: var(--shadow-md);
}

.app-header__bar {
  max-width: var(--content-max-width);
  margin-inline: auto;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-4);
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  white-space: nowrap;
}

.app-header__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: #241022;
  font-size: var(--fs-sm);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-header__title {
  font-size: var(--fs-md);
}

.app-header__menu-toggle {
  display: none;
  margin-left: auto;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
}

.app-header__menu-icon,
.app-header__menu-icon::before,
.app-header__menu-icon::after {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--transition-fast);
}

.app-header__menu-icon::before,
.app-header__menu-icon::after {
  content: "";
  position: relative;
}
.app-header__menu-icon::before { top: 6px; }
.app-header__menu-icon::after { top: 2px; }

.app-nav {
  flex: 1;
}

.app-nav__list {
  display: flex;
  gap: var(--space-2);
}

.app-nav__tab {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.app-nav__tab:hover,
.app-nav__tab:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.app-nav__tab.is-active {
  background: #fff;
  color: var(--color-primary);
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.app-header__signed-in-as {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--fs-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
  border: 1px solid transparent;
}

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

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

.btn--primary {
  background: var(--blue-60);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--color-primary); box-shadow: var(--shadow-md); }

.btn--secondary {
  background: var(--color-surface-raised);
  color: var(--color-primary);
  border-color: var(--color-border);
}
.btn--secondary:hover { border-color: var(--blue-60); }

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.btn--ghost:hover { color: var(--color-text); background: rgba(120, 130, 160, 0.1); }

.btn--danger {
  color: var(--red-60);
}

.btn--small {
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-xs);
}

.btn--google {
  width: 100%;
  background: var(--color-surface-raised);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}
.btn--google:hover { border-color: var(--blue-60); box-shadow: var(--shadow-md); }
.btn--google__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: conic-gradient(from 90deg, #4285f4 0deg 90deg, #34a853 90deg 180deg, #fbbc05 180deg 270deg, #ea4335 270deg 360deg);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  color: inherit;
  transition: background var(--transition-fast);
}
.icon-btn:hover { background: rgba(120, 130, 160, 0.16); }
.icon-btn--small { width: 28px; height: 28px; color: var(--color-text-muted); }

/* --- Forms -------------------------------------------------------------------- */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.form-field label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-field__optional {
  font-weight: 400;
  color: var(--color-text-muted);
}

/* Used under the auth screen's Admin code field — an explicit, un-autofillable
   "yes really apply this" gate so a stray autofilled value in the field above
   can never trigger claim_admin_with_code() on its own. See index.html. */
.form-field__checkbox {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  font-weight: 400 !important;
  color: var(--color-text-muted);
  cursor: pointer;
}

.form-field__checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--blue-60);
  box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.2);
}

.form-field input:invalid[data-touched="true"] {
  border-color: var(--red-60);
}

.form-field__error {
  min-height: 1.1em;
  font-size: var(--fs-xs);
  color: var(--red-60);
}

.form-field--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}
.form-field--inline label { white-space: nowrap; }

.inline-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  align-items: end;
  padding-top: var(--space-3);
  border-top: 1px dashed var(--color-border);
}

/* --- Setup banner / auth ------------------------------------------------------ */
.setup-banner {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.setup-banner__inner { max-width: 640px; }
.setup-banner__title { margin-bottom: var(--space-2); }
.setup-banner__text { color: var(--color-text-muted); margin-bottom: var(--space-4); font-size: var(--fs-sm); }

.auth-view {
  display: flex;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
}

.auth-card__title { margin-bottom: var(--space-2); }
.auth-card__subtitle { color: var(--color-text-muted); font-size: var(--fs-sm); margin-bottom: var(--space-5); }
.auth-card__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.auth-card__message { margin-top: var(--space-3); font-size: var(--fs-sm); min-height: 1.2em; color: var(--red-60); }

.auth-card__divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-5) 0;
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.auth-card__divider::before,
.auth-card__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.auth-card__mode {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}
.auth-card__mode legend {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 var(--space-1);
}
.auth-card__mode-option {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--fs-sm);
  cursor: pointer;
}

/* --- Auth screen: Super Admin Code disclosure ----------------------------------- */
.auth-card__details {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}
.auth-card__details summary {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
}
.auth-card__details[open] summary {
  margin-bottom: var(--space-3);
}
.auth-card__details .form-field {
  margin-bottom: 0;
}
.auth-card__verify-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.auth-card__verify-status {
  font-size: var(--fs-sm);
}
.auth-card__verify-status[data-state="success"] { color: var(--green-50); }
.auth-card__verify-status[data-state="error"] { color: var(--red-60); }

/* --- Admin view: "Viewing user" picker on the Dashboard tab -------------------- */
.admin-user-picker {
  align-items: flex-end;
}
.admin-user-picker #admin-user-select {
  min-width: 260px;
}

/* --- Summary strip -------------------------------------------------------------- */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.summary-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.summary-stat__value {
  display: block;
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--color-primary);
}
[data-theme="dark"] .summary-stat__value { color: var(--cyan-30); }

.summary-stat__label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

/* Summary tiles are rendered as <button> elements so they're clickable and
   keyboard-focusable — reset default button chrome back to the plain-div
   look above, then layer on a hover/focus/active affordance so it reads as
   interactive without changing the tile's basic appearance. */
.summary-stat--filterable {
  font: inherit;
  color: inherit;
  cursor: pointer;
  width: 100%;
}
.summary-stat--filterable:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}
.summary-stat--filterable:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.summary-stat--filterable.summary-stat--active {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle, var(--color-surface));
  box-shadow: 0 0 0 1px var(--color-primary) inset;
}

/* --- Dashboard filter status bar (shown only while a summary tile filter is active) --- */
.dashboard-filter-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin: calc(var(--space-3) * -1) 0 var(--space-4);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
  text-decoration: underline;
}
.link-btn:hover,
.link-btn:focus-visible {
  color: var(--color-primary-hover, var(--color-primary));
}

/* --- Toolbar ------------------------------------------------------------------- */
.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.week-picker {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

/* --- KPI grid / cards ------------------------------------------------------------ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.kpi-card--clickable {
  cursor: pointer;
}
.kpi-card--clickable:hover {
  border-color: var(--blue-50, #4589ff);
}
.kpi-card--clickable:focus-visible {
  outline: 2px solid var(--blue-50, #4589ff);
  outline-offset: 2px;
}

.kpi-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.kpi-card__title {
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.3;
}

.kpi-card__progress-label {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

.kpi-card__bar {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
  overflow: hidden;
}

.kpi-card__bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue-60), var(--color-secondary));
  border-radius: var(--radius-pill);
  transition: width var(--transition-slow);
}

.kpi-card--on-track .kpi-card__bar-fill { background: linear-gradient(90deg, var(--green-50), var(--teal-30)); }
.kpi-card--behind .kpi-card__bar-fill { background: linear-gradient(90deg, var(--yellow-30), var(--color-accent)); }
.kpi-card--at-risk .kpi-card__bar-fill { background: linear-gradient(90deg, var(--red-60), var(--color-accent)); }

/* target_period:'none' KPIs (e.g. Technical Risks Resolved) get the
   .kpi-card--neutral class instead of --on-track/--behind/--at-risk — no
   target means none of those three states apply. Deliberately no CSS rule
   here: the default .kpi-card styling (no status color) already reads as
   neutral; the class exists as a hook for any future styling and so it's
   never confused with the "behind" default in the markup. The progress bar
   itself is hidden entirely by renderDashboard() via the global .is-hidden
   utility. */

.kpi-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-card__trend {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--color-text-muted);
}

.kpi-card__trend--up { color: var(--green-50); }
.kpi-card__trend--down { color: var(--red-60); }

/* --- Charts / tables --------------------------------------------------------------- */
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.chart-card__svg {
  width: 100%;
  height: auto;
}

.chart-axis-label {
  font-size: 10px;
  fill: var(--color-text-muted);
}

.chart-empty-label {
  font-size: 13px;
  fill: var(--color-text-muted);
}

.table-wrap {
  overflow-x: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.data-table th,
.data-table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: rgba(69, 137, 255, 0.08);
}

/* --- Chips ---------------------------------------------------------------------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  font-size: var(--fs-xs);
  font-weight: 600;
}

/* --- News / suggestions ------------------------------------------------------------ */
.empty-state {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  padding: var(--space-5);
  text-align: center;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}

/* Left-aligned fallback box (e.g. "paste a URL" on the leadership card) —
   same dashed-border language as .empty-state but built for a form, not a
   centered message. */
.manual-source-fallback {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-top: var(--space-4);
}
.manual-source-fallback p {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.manual-source-fallback .form-field--inline input[type="url"] {
  min-width: 320px;
}

.suggestion-list {
  display: grid;
  gap: var(--space-3);
}

.suggestion-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
}

.suggestion-card__customer {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-secondary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Category badge — distinguishes a per-customer scan result from the
   general "Scan for IBM News" / "Scan for general Technology news" results
   (see news_suggestions.category in schema.sql). Hidden entirely for
   category:"customer" rows (the common case) via renderSuggestions(). */
.suggestion-card__category-badge {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full, 999px);
  color: #fff;
}
.suggestion-card__category-badge[data-category="ibm"] { background: var(--color-primary); }
.suggestion-card__category-badge[data-category="technology"] { background: var(--color-teal-30, #3ddbd9); color: var(--color-text, #161616); }
.suggestion-card__category-badge:empty { display: none; }

.suggestion-card__summary { color: var(--color-text-muted); font-size: var(--fs-sm); margin-top: var(--space-1); }
.suggestion-card__action { margin-top: var(--space-2); font-size: var(--fs-sm); font-weight: 600; }

.suggestion-card__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-end;
  min-width: 140px;
}

.suggestion-card__link { font-size: var(--fs-xs); }

/* --- Config cards ------------------------------------------------------------------- */
.config-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.config-card__hint {
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--color-text-muted);
}

.config-card__header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.config-card__header-row h2 { margin: 0; }

.customer-list,
.kpi-config-list {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-4) 0;
}

.customer-row {
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  cursor: grab;
}

.kpi-config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  cursor: grab;
}

/* The customer row's top line (name/meta + remove button) keeps the same
   flex layout the combined .customer-row/.kpi-config-row rule used to share
   — split out so the row can also host the collapsible documents panel
   below it without that panel getting squeezed into the flex row too. */
.customer-row__main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.customer-row[draggable="true"]:active,
.kpi-config-row[draggable="true"]:active {
  cursor: grabbing;
}

.customer-row.is-drag-over,
.kpi-config-row.is-drag-over {
  border-color: var(--blue-60);
  box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.15);
}

.customer-row__name {
  font-weight: 700;
  font-size: var(--fs-sm);
}

.customer-row__meta {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

/* KPI Library row's name/description are editable in place (unlike the
   customer row's plain <p> text above) — styled to read as plain text at
   rest (no border, transparent background) so the row doesn't look like a
   form, with a visible border only on hover/focus as the "you can edit
   this" affordance. */
.kpi-config-row__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.kpi-config-row__name-input,
.kpi-config-row__meta-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin: -2px -4px;
  font-family: inherit;
}

.kpi-config-row__name-input:hover,
.kpi-config-row__meta-input:hover {
  border-color: var(--color-border);
}

.kpi-config-row__name-input:focus,
.kpi-config-row__meta-input:focus {
  border-color: var(--blue-50, #4589ff);
  background: var(--color-surface);
  outline: none;
}

.kpi-config-row__name-input {
  font-weight: 700;
  font-size: var(--fs-sm);
}

.kpi-config-row__meta-input {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

.kpi-config-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Per-customer collapsible "Reference links" panel — website/news URL plus
   the 3 reference-link fields, editable any time (not just at customer
   creation). Sits between the name/meta/remove row and "Reference
   documents" below; same dashed-divider/summary-arrow language as that
   panel so the two read as a matched pair. */
.customer-row__links {
  margin-top: var(--space-3);
  border-top: 1px dashed var(--color-border);
  padding-top: var(--space-2);
}
.customer-row__links summary {
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--color-primary);
  list-style: none;
}
[data-theme="dark"] .customer-row__links summary { color: var(--blue-50); }
.customer-row__links summary::-webkit-details-marker { display: none; }
.customer-row__links summary::before { content: "▸ "; }
.customer-row__links[open] summary::before { content: "▾ "; }
.customer-row__link-count {
  font-weight: 400;
  color: var(--color-text-muted);
}
.customer-row__links-hint {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin: var(--space-2) 0;
}
.customer-row__link-fields {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.customer-row__link-fields .form-field {
  margin-bottom: 0;
}
.customer-row__website-input,
.customer-row__link-input {
  width: 100%;
  font-size: var(--fs-xs);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: inherit;
}
.customer-row__website-input:focus,
.customer-row__link-input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.customer-row__links-status {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  min-height: 1.2em;
}
.customer-row__links-status[data-state="error"] { color: var(--color-danger, #da1e28); }
.customer-row__links-status[data-state="success"] { color: var(--color-success, #24a148); }

/* Per-customer collapsible "Reference documents" panel — sits below the
   name/meta/remove row, drag handle (cursor:grab) stays on the whole card so
   dragging to reorder still works even with this panel expanded. */
.customer-row__docs {
  margin-top: var(--space-3);
  border-top: 1px dashed var(--color-border);
  padding-top: var(--space-2);
}
.customer-row__docs summary {
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--color-primary);
  list-style: none;
}
[data-theme="dark"] .customer-row__docs summary { color: var(--blue-50); }
.customer-row__docs summary::-webkit-details-marker { display: none; }
.customer-row__docs summary::before { content: "▸ "; }
.customer-row__docs[open] summary::before { content: "▾ "; }
.customer-row__doc-count {
  font-weight: 400;
  color: var(--color-text-muted);
}
.customer-row__doc-list {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}
.customer-doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: var(--fs-xs);
}
.customer-doc-row__name {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.customer-doc-row__size {
  color: var(--color-text-muted);
  white-space: nowrap;
}
.customer-row__doc-upload-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.customer-row__doc-input {
  font-size: var(--fs-xs);
}
.customer-row__doc-status {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  min-height: 1.2em;
}
.customer-row__doc-status[data-state="error"] { color: var(--color-danger, #da1e28); }
.customer-row__doc-status[data-state="success"] { color: var(--color-success, #24a148); }

.weekly-update-slot {
  padding-top: var(--space-3);
  margin-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.weekly-update-slot:first-of-type { border-top: none; margin-top: 0; }
.weekly-update-slot h3 {
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.weekly-update-history {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-2);
  list-style: none;
  padding: 0;
}
.weekly-update-history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: var(--fs-xs);
}
.weekly-update-history li .weekly-update-history__name {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.weekly-update-history li .weekly-update-history__date {
  color: var(--color-text-muted);
  white-space: nowrap;
}
.weekly-update-history__empty {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  margin-top: var(--space-2);
}

.assistant-date-range {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-style: italic;
  margin-bottom: var(--space-3);
}

.kpi-extract-rows {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.kpi-extract-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.kpi-extract-row__checkbox {
  margin-top: var(--space-1);
}
.kpi-extract-row__name {
  font-weight: 600;
  font-size: var(--fs-sm);
}
.kpi-extract-row__current {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.kpi-extract-row__rationale {
  font-size: var(--fs-xs);
  font-style: italic;
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}
.kpi-extract-row__value-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}
.kpi-extract-row__value {
  width: 84px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}
.kpi-extract-row__unit {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.kpi-extract-empty {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-3);
}

.kpi-config-row__target {
  width: 72px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.kpi-config-row__period {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--fs-xs);
}

.add-kpi-details {
  border-top: 1px dashed var(--color-border);
  padding-top: var(--space-3);
}
.add-kpi-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-secondary);
}

/* --- Modal / dialog ------------------------------------------------------------------- */
.modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(480px, 92vw);
  box-shadow: var(--shadow-lg);
  background: var(--color-surface);
  color: var(--color-text);
}

.modal::backdrop {
  background: rgba(10, 15, 30, 0.55);
  backdrop-filter: blur(2px);
}

.modal__form {
  padding: var(--space-6);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* --- Tooltip popover -------------------------------------------------------------------- */
.tooltip-popover {
  position: fixed;
  z-index: 60;
  max-width: 260px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: #1b2333;
  color: #fff;
  font-size: var(--fs-xs);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

/* --- Account Strategy tab ------------------------------------------------------------- */
.strategy-status {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  min-height: 1.25em;
  margin-top: var(--space-2);
}

.strategy-status[data-state="error"] { color: var(--color-danger); font-weight: 600; }
.strategy-status[data-state="success"] { color: var(--color-success); font-weight: 600; }

.strategy-doc-list {
  display: grid;
  gap: var(--space-3);
}

.strategy-doc-card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--blue-60);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
}

.strategy-doc-card__title { font-weight: 700; font-size: var(--fs-sm); }
.strategy-doc-card__meta { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: var(--space-1); }
.strategy-doc-card__citations { font-size: var(--fs-xs); color: var(--color-secondary); margin-top: var(--space-1); }

.strategy-doc-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: flex-start;
  min-width: 200px;
}

/* --- Wide modal (document preview) --------------------------------------------------- */
.modal--wide {
  width: min(880px, 94vw);
  max-height: 88vh;
}

/* --- Edit user modal (Super Admin, Create Users tab) ---------------------------------- */
#edit-user-modal {
  width: min(520px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
}

.modal__divider {
  border: none;
  border-top: 1px dashed var(--color-border);
  margin: var(--space-5) 0;
}

#reset-password-form h3 {
  font-size: var(--fs-sm);
  margin-bottom: var(--space-2);
}

.data-table__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* --- "How Am I Doing?" traffic-light modal (Dashboard tab) ---------------------------- */
#how-am-i-doing-modal {
  max-height: 88vh;
  overflow-y: auto;
}

.traffic-light-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.traffic-light-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
}

.traffic-light-row--overall {
  margin-top: var(--space-4);
  border-left: 4px solid var(--color-border);
}

.traffic-light-row__title {
  font-weight: 700;
  font-size: var(--fs-sm);
}

.traffic-light-row__rationale {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.traffic-light-dot {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin-top: 2px;
  background: var(--color-border);
}

.traffic-light-dot[data-status="green"] { background: var(--color-success); }
.traffic-light-dot[data-status="yellow"] { background: var(--color-warning); }
.traffic-light-dot[data-status="red"] { background: var(--color-danger); }

.strategy-preview-body {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: var(--space-2);
}

/* Used on the Org Chart tab, where the same section renderers run inline in
   the page instead of inside a height-constrained modal. */
.strategy-preview-body--static {
  max-height: none;
  overflow-y: visible;
  padding-right: 0;
  margin-top: var(--space-5);
}

.strategy-preview-section {
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.strategy-preview-section:last-child { border-bottom: none; }

.strategy-preview-section h3 {
  font-size: var(--fs-md);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}
[data-theme="dark"] .strategy-preview-section h3 { color: var(--blue-50); }

.strategy-preview-section p { margin-bottom: var(--space-2); font-size: var(--fs-sm); }

.strategy-preview-section ul {
  list-style: disc;
  padding-left: var(--space-5);
  display: grid;
  gap: var(--space-1);
  font-size: var(--fs-sm);
}

.strategy-preview-section table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-xs);
  margin-top: var(--space-2);
}
.strategy-preview-section th,
.strategy-preview-section td {
  border: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.strategy-preview-section th { background: var(--color-bg); }

.strategy-preview-citations {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  border-top: 1px dashed var(--color-border);
  padding-top: var(--space-3);
  margin-top: var(--space-5);
}
.strategy-preview-citations li { margin-bottom: var(--space-1); }
.strategy-preview-citations a,
.strategy-preview-citations li {
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* Per-row "Sources" column used on the Account Overview tab's tables: a
   <details>/<summary> disclosure per row instead of one long citations
   block at the bottom of the page, so long source URLs never blow out the
   table's layout — they wrap inside a width-capped popover instead. */
.sources-cell {
  max-width: 800px; /* doubled again from 400px per explicit request (was 200px originally) */
  white-space: normal;
}
.sources-details summary {
  cursor: pointer;
  color: var(--color-primary);
  font-weight: 600;
  font-size: var(--fs-xs);
  list-style: none;
}
[data-theme="dark"] .sources-details summary { color: var(--blue-50); }
.sources-details summary::-webkit-details-marker { display: none; }
.sources-details summary::before { content: "▸ "; }
.sources-details[open] summary::before { content: "▾ "; }
.sources-list {
  list-style: none;
  padding-left: 0;
  margin-top: var(--space-2);
  display: grid;
  gap: var(--space-2);
  max-width: 520px; /* scaled up alongside .sources-cell so the popover isn't narrower than its own cell */
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.sources-list li,
.sources-list a {
  overflow-wrap: anywhere;
  word-break: break-all;
}
.sources-list a { color: var(--color-primary); }
[data-theme="dark"] .sources-list a { color: var(--blue-50); }
.sources-cell--empty {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
}

/* Org chart tree, rendered as nested lists in the preview */
.org-chart-tree, .org-chart-tree ul {
  list-style: none;
  padding-left: var(--space-5);
  margin: 0;
}
.org-chart-tree { padding-left: 0; }
.org-chart-tree li { position: relative; padding: var(--space-1) 0; }
.org-chart-node {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  font-size: var(--fs-sm);
}
.org-chart-node strong { display: block; }
.org-chart-node span { font-size: var(--fs-xs); color: var(--color-text-muted); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

/* ----------------------------------------------------------------------------
   6. UTILITIES
   ---------------------------------------------------------------------------- */
.is-hidden { display: none !important; }

.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app__skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: #fff;
  color: var(--color-primary);
  padding: var(--space-3);
  z-index: 100;
  border-radius: 0 0 var(--radius-sm) 0;
}
.app__skip-link:focus {
  left: 0;
}

/* ----------------------------------------------------------------------------
   7. RESPONSIVE BREAKPOINTS (mobile-first: base styles above are mobile)
   ---------------------------------------------------------------------------- */

/* Tablet */
@media (min-width: 640px) {
  .summary-strip {
    grid-template-columns: repeat(4, 1fr);
  }

  .inline-form {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Small mobile nav collapse threshold */
@media (max-width: 767px) {
  .app-header__menu-toggle {
    display: inline-flex;
  }

  .app-nav {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--color-primary);
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-base);
  }

  .app-nav.is-open {
    max-height: 320px;
    box-shadow: var(--shadow-md);
  }

  .app-nav__list {
    flex-direction: column;
    padding: var(--space-3) var(--space-4) var(--space-4);
  }

  .app-nav__tab {
    width: 100%;
    text-align: left;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .inline-form {
    grid-template-columns: repeat(4, 1fr);
  }

  .app-header__bar {
    padding: 0 var(--space-6);
  }
}
