/* Digital Footprints — Admin command center (playground revamp).
   Builds on brand.css tokens. Sidebar shell + dashboard system. */

:root {
  --sidebar-w: 244px;
  /* Digital Footprints brand palette */
  --df-navy: #16294A;
  --df-navy-2: #1E3560;
  --df-yellow: #FFE500;
  --df-pink: #EC0F8D;
  --df-cyan: #25CFE0;
  --df-orange: #FF8A1E;

  --amber: #F59E0B;
  --amber-strong: #B45309;
  --green: #22C55E;
  --red: #EF4444;
  --ink: #16294A;            /* navy — headings + sidebar */
  --panel: #FFFFFF;
  --canvas: #F5F7FA;
  --line: rgba(22, 41, 74, 0.10);
  --line-strong: rgba(22, 41, 74, 0.18);
  --shadow-sm: 0 1px 2px rgba(22,41,74,0.05), 0 1px 3px rgba(22,41,74,0.07);
  --shadow-md: 0 4px 12px rgba(22,41,74,0.08), 0 2px 4px rgba(22,41,74,0.05);
  --shadow-lg: 0 14px 34px rgba(22,41,74,0.14);
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--canvas);
}

/* -------- Sidebar -------- */
.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background: var(--df-navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  gap: 6px;
}
.side__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 15px;
  line-height: 1.15;
}
.side__logo { width: 178px; height: auto; display: block; }
.side__brand .accent { color: var(--df-yellow); }
.side__section {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  padding: 16px 10px 6px;
}
/* The nav is the only part that scrolls: brand and footer stay put however
   many clients the agency has. */
.side__nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -6px;
  padding: 0 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.22) transparent;
}
.side__nav::-webkit-scrollbar { width: 8px; }
.side__nav::-webkit-scrollbar-track { background: transparent; }
.side__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 8px; }
.side__nav:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.28); }
button.side__section {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  text-align: left;
}
button.side__section:hover { color: rgba(255,255,255,0.75); }
.side__count {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.35);
}
.side__chev { width: 13px; height: 13px; flex-shrink: 0; transition: transform 0.15s; }
.side__count + .side__chev { margin-left: 6px; }
.side__chev:only-of-type { margin-left: auto; }
button.side__section[aria-expanded="false"] .side__chev { transform: rotate(-90deg); }
.side__group { display: flex; flex-direction: column; gap: 2px; }
.side__group[hidden], .side__link[hidden] { display: none; }
.side__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__link--add { color: rgba(255,255,255,0.55); }
.side__filter {
  margin: 2px 0 6px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
}
.side__filter::placeholder { color: rgba(255,255,255,0.4); }
.side__filter:focus { outline: none; border-color: rgba(255,255,255,0.35); background: rgba(255,255,255,0.10); }
.side__nohits { padding: 4px 12px 8px; font-size: 12px; color: rgba(255,255,255,0.45); }
.side__link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: rgba(255,255,255,0.72);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.side__link:hover { background: rgba(255,255,255,0.07); color: #fff; }
.side__link--active { background: rgba(255,255,255,0.10); color: #fff; box-shadow: inset 3px 0 0 var(--df-yellow); }
.side__link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
.side__spacer { flex: 1; }
.side__foot {
  border-top: 1px solid rgba(255,255,255,0.10);
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.side__user { font-size: 12px; color: rgba(255,255,255,0.6); padding-left: 8px; }
.side__signout {
  font-size: 12px; color: rgba(255,255,255,0.6);
  padding: 6px 10px; border-radius: 7px; border: 1px solid rgba(255,255,255,0.14);
}
.side__signout:hover { color: #fff; border-color: rgba(255,255,255,0.3); }

/* -------- Main -------- */
.main { padding: 30px 40px 60px; min-width: 0; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.page-head__title {
  font-family: var(--font-heading);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: 30px;
  margin: 0;
  color: var(--ink);
}
.page-head__sub { font-size: 13px; color: var(--grey-600); margin-top: 4px; }
.page-head__actions { display: flex; gap: 12px; align-items: flex-end; }
.head-field { display: flex; flex-direction: column; gap: 4px; }
.head-field__label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--grey-600);
}
.head-field--accent .head-field__label { color: var(--df-pink); }
.head-field--accent input[type=month] {
  border-color: var(--df-pink);
  box-shadow: 0 0 0 3px rgba(240,20,147,0.10);
  font-weight: 700;
}

/* -------- Buttons -------- */
.button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s;
}
.button svg { width: 15px; height: 15px; }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: 0.45; cursor: default; pointer-events: none; box-shadow: none; }
.button--primary { background: var(--df-pink); color: #fff; box-shadow: var(--shadow-sm); }
.button--primary:hover { background: #d10a7d; box-shadow: var(--shadow-md); }
.button--ghost { background: var(--panel); color: var(--ink); border-color: var(--line-strong); }
.button--ghost:hover { border-color: var(--ink); }
.button--dark { background: var(--ink); color: #fff; }
.button--dark:hover { background: #26282b; }
.button--sm { padding: 7px 12px; font-size: 12px; border-radius: 8px; }
.button--danger { color: var(--negative); border-color: rgba(255,79,64,0.3); }
.button--danger:hover { background: rgba(255,79,64,0.07); border-color: var(--negative); color: var(--negative); }

/* -------- KPI overview cards -------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 30px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--grey-600); font-weight: 700;
}
.stat__value {
  font-family: var(--font-heading);
  font-weight: 900; font-style: italic;
  font-size: 34px; line-height: 1.05; margin: 10px 0 2px;
  color: var(--ink);
}
.stat__foot { font-size: 12px; color: var(--grey-600); display: flex; align-items: center; gap: 6px; }
.stat__accent { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.stat--coral .stat__accent { background: var(--df-pink); }
.stat--teal .stat__accent  { background: var(--df-cyan); }
.stat--amber .stat__accent { background: var(--df-yellow); }
.stat--blue .stat__accent  { background: var(--df-navy); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.delta--up   { color: var(--accent-strong); }
.delta--down { color: var(--negative); }
.delta--flat { color: var(--grey-400); }

/* -------- Section heading -------- */
.section-title {
  display: flex; align-items: center; gap: 12px;
  margin: 4px 0 16px;
}
.section-title h2 {
  font-family: var(--font-heading);
  font-weight: 900; font-style: italic; text-transform: uppercase;
  font-size: 16px; letter-spacing: 0.03em; margin: 0; color: var(--ink);
}
.section-title .count {
  font-size: 12px; color: var(--grey-600);
  background: var(--grey-100); padding: 2px 9px; border-radius: 20px; font-weight: 600;
}

/* -------- Client cards -------- */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
  margin-bottom: 34px;
}
.client-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.client-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--line-strong); }
.client-card__top {
  display: flex; align-items: center; gap: 13px;
  padding: 18px 20px 14px;
}
.client-card__logo {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--ink), #33363a);
  color: #fff; display: grid; place-items: center;
  font-family: var(--font-heading); font-weight: 900; font-style: italic; font-size: 19px;
  flex-shrink: 0;
}
.client-card__name { font-weight: 700; font-size: 16px; color: var(--ink); }
.client-card__meta { font-size: 12px; color: var(--grey-600); margin-top: 1px; }
.client-card__status {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 5px 10px; border-radius: 20px;
}
.client-card__status .dot { width: 7px; height: 7px; border-radius: 50%; }
.status--live   { background: rgba(34,197,94,0.12);  color: #15803D; }
.status--live .dot   { background: var(--green); }
.status--draft  { background: rgba(245,158,11,0.14); color: var(--amber-strong); }
.status--draft .dot  { background: var(--amber); }
.status--empty  { background: var(--grey-100); color: var(--grey-600); }
.status--empty .dot  { background: var(--grey-400); }

.client-card__kpis {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--grey-50);
}
.mini {
  padding: 13px 16px;
  border-right: 1px solid var(--line);
}
.mini:last-child { border-right: 0; }
.mini__label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--grey-600); font-weight: 700; }
.mini__value { font-size: 20px; font-weight: 800; color: var(--ink); margin-top: 4px; font-family: var(--font-heading); font-style: italic; }
.mini__value.sm { font-size: 15px; }

.spark { padding: 14px 20px 4px; }
.spark__row { display: flex; align-items: flex-end; gap: 4px; height: 40px; }
.spark__bar { flex: 1; background: var(--df-cyan); border-radius: 3px 3px 0 0; min-height: 3px; opacity: 0.85; }
.spark__bar:last-child { background: var(--df-pink); opacity: 1; }
.spark__label { font-size: 10px; color: var(--grey-400); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 8px; }

.client-card__reports { padding: 6px 8px 8px; }
.report-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  transition: background 0.12s;
}
.report-row:hover { background: var(--grey-50); }
.report-row__period { font-weight: 700; font-size: 13px; color: var(--ink); min-width: 62px; }
.report-row__date { font-size: 11px; color: var(--grey-400); }
.report-row__actions { margin-left: auto; display: flex; gap: 4px; }
.chip-link {
  font-size: 11px; font-weight: 600; color: var(--grey-600);
  padding: 5px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; font-family: inherit;
}
.chip-link:hover { border-color: var(--ink); color: var(--ink); }
.chip-link--go { color: var(--accent-strong); border-color: rgba(0,160,127,0.3); }
.chip-link--go:hover { background: rgba(0,216,174,0.08); border-color: var(--accent-strong); }

.client-card__foot {
  display: flex; gap: 8px; padding: 12px 16px 16px; margin-top: auto;
}
.client-card__foot .button { flex: 1; justify-content: center; }

.client-card__empty {
  padding: 26px 20px; text-align: center; color: var(--grey-600); font-size: 13px;
}

/* -------- Flash messages -------- */
.flash {
  padding: 13px 18px; border-radius: 12px; margin-bottom: 20px;
  font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 10px;
}
.flash--ok  { background: rgba(0,216,174,0.10); color: var(--accent-strong); }
.flash--err { background: rgba(255,79,64,0.10); color: var(--negative); }

/* -------- Share reveal -------- */
.share-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 24px; box-shadow: var(--shadow-sm);
}
.share-box input {
  width: 100%; margin-top: 8px; padding: 11px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  font-size: 13px; font-family: 'SF Mono', ui-monospace, monospace; color: var(--ink);
}

/* -------- Upload controls + source cards on shell -------- */
.upload-controls {
  display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px; margin-bottom: 22px; box-shadow: var(--shadow-sm);
}
.upload-controls select, .upload-controls input {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line-strong);
  border-radius: 10px; font-size: 14px; font-family: inherit; color: var(--ink); background: var(--panel);
}
.main .source-grid { margin-bottom: 20px; }
.main .source-card { border-radius: 14px; box-shadow: var(--shadow-sm); }
.main .upload-actions { justify-content: flex-end; gap: 12px; }

/* -------- Login (split screen) -------- */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--canvas);
}
.login__brand {
  background: var(--ink);
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.login__chevrons { position: absolute; top: -40px; right: -30px; opacity: 0.12; }
.login__mark {
  display: flex; align-items: center; gap: 12px;
  font-weight: 800; letter-spacing: 0.02em; font-size: 16px;
}
.login__logo { width: 230px; height: auto; display: block; }
.login__mark .accent { color: var(--df-yellow); }
.login__lead {
  margin-top: auto;
  font-family: var(--font-heading);
  font-weight: 900; font-style: italic; text-transform: uppercase;
  font-size: 46px; line-height: 1.02; letter-spacing: 0.01em;
}
.login__lead .teal { color: var(--df-cyan); }
.login__sub { margin-top: 16px; font-size: 15px; color: rgba(255,255,255,0.65); max-width: 400px; line-height: 1.6; }
.login__foot { margin-top: 40px; font-size: 12px; color: rgba(255,255,255,0.4); letter-spacing: 0.06em; }

.login__panel { display: grid; place-items: center; padding: 40px; }
.login__form { width: 100%; max-width: 360px; }
.login__form h1 {
  font-family: var(--font-heading);
  font-weight: 900; font-style: italic; text-transform: uppercase;
  font-size: 26px; margin: 0 0 6px; color: var(--ink);
}
.login__form .muted { font-size: 13px; color: var(--grey-600); margin-bottom: 26px; }

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login__brand { display: none; }
}

/* -------- Setup / new client form -------- */
.setup__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.panel__head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.panel__num {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: var(--ink); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 13px;
}
.panel__title { font-weight: 700; font-size: 15px; color: var(--ink); }
.panel__title .opt { font-size: 11px; font-weight: 600; color: var(--grey-400); text-transform: uppercase; letter-spacing: 0.06em; margin-left: 6px; }
.panel__hint { font-size: 12px; color: var(--grey-600); margin-top: 2px; }

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  font-weight: 700; color: var(--grey-600); margin-bottom: 6px;
}
.field input[type=text], .field input:not([type]), .field textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line-strong);
  border-radius: 10px; font-size: 14px; font-family: inherit; color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(0,216,174,0.12);
}
.field textarea { resize: vertical; line-height: 1.5; }
.field__hint { font-size: 11px; color: var(--grey-400); margin-top: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.swatch { display: flex; align-items: center; gap: 8px; }
.swatch input[type=color] {
  width: 44px; height: 40px; padding: 0; border: 1px solid var(--line-strong);
  border-radius: 10px; background: none; cursor: pointer;
}
.swatch .hex {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong);
  border-radius: 10px; font-family: 'SF Mono', ui-monospace, monospace; font-size: 13px;
}

.brand-preview {
  margin-top: 14px; display: flex; align-items: center; gap: 12px;
}
.brand-preview__hero {
  flex: 1; border-radius: 12px; padding: 16px 18px; color: #fff;
  display: flex; flex-direction: column; gap: 4px; min-height: 74px; justify-content: center;
  background: var(--coral); transition: background 0.15s;
}
.brand-preview__label { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.8; }
.brand-preview__title { font-family: var(--font-heading); font-weight: 900; font-style: italic; font-size: 20px; }
.brand-preview__chip {
  padding: 8px 16px; border-radius: 20px; color: #04241d; font-weight: 700; font-size: 12px;
  background: var(--teal); transition: background 0.15s;
}

.setup__foot {
  display: flex; justify-content: flex-end; gap: 12px;
  margin-top: 20px; padding-top: 4px;
}

@media (max-width: 1100px) {
  .setup__grid { grid-template-columns: 1fr; }
}

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side__spacer { display: none; }
  /* Sidebar becomes a wrapping row. Nothing scrolls here, so the group
     headers stay - they are the way back into a collapsed group. */
  .side__nav { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; align-items: center; overflow: visible; min-height: 0; }
  button.side__section { flex: 1 1 100%; padding: 10px 10px 2px; }
  .side__group { flex-direction: row; flex-wrap: wrap; }
  .side__filter, .side__nohits { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* -------- Month workspace -------- */
.ws-grid {
  display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; align-items: start;
}
.ws-rail { display: flex; flex-direction: column; gap: 18px; order: 2; }

/* Client setup: the configure-once panels, a full-width row below the
   monthly data | deliver row. CSS order keeps the data column and rail on
   row 1, so this spans row 2 despite sitting mid-DOM. */
/* Client settings page: the configure-once panels, stacked two-up. */
.cs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.cs-grid .ws-connections { margin-top: 0; }
/* The API-connections panel holds a card grid, so let it span both columns. */
.cs-grid #connections { grid-column: 1 / -1; }
@media (max-width: 1024px) { .cs-grid { grid-template-columns: 1fr; } }

.panel__head h2 { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0; }
.panel__head { align-items: center; justify-content: space-between; }
.panel__head .count {
  background: var(--grey-100); color: var(--grey-600); font-size: 12px; font-weight: 700;
  padding: 2px 9px; border-radius: 12px;
}
.ws-filled { font-size: 12px; font-weight: 700; color: var(--grey-600); }
.ws-views { font-size: 12px; color: var(--grey-600); }

.page-head__actions select, .page-head__actions input[type=month] {
  padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  font-size: 13px; font-family: inherit; color: var(--ink); background: var(--panel);
}

.ws-sources { display: flex; flex-direction: column; }
.ws-source {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 4px;
  border-top: 1px solid var(--line);
}
.ws-source .source-card__dot { margin-top: 5px; flex-shrink: 0; }
.ws-source__body { flex: 1; min-width: 0; }
.ws-source__title { font-weight: 700; font-size: 13px; color: var(--ink); }
.ws-source__purpose { font-weight: 500; font-size: 11px; color: var(--grey-400); margin-left: 6px; }
.ws-source__status { margin-top: 2px; }
.ws-source__status .status-summary { font-weight: 500; }
.ws-source__status .status-summary--ok, .ws-source__status .status-summary--warning,
.ws-source__status .status-summary--error { font-weight: 600; }
.ws-source__actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.ws-source__help { padding: 2px 8px; }
.ws-source__hint {
  margin-top: 4px; font-size: 11px; color: var(--grey-600);
  font-family: 'SF Mono', ui-monospace, monospace;
}
.ws-source__status .status-summary--quiet { color: var(--grey-400); font-weight: 500; }
.ws-sources__foot {
  border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px;
  display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
}

/* Setup status strip: what's configured for this client, links into settings */
.ws-setupbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -8px 0 18px; }
.ws-setupbar__title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--grey-400); margin-right: 2px;
}
.ws-setupbar__chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--grey-600);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 6px 13px; text-decoration: none;
  transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.ws-setupbar__chip:hover { border-color: var(--ink); color: var(--ink); box-shadow: var(--shadow-sm); }
.ws-setupbar__chip--ok { border-color: rgba(0,160,127,0.35); }
.ws-setupbar__tick { font-weight: 800; color: var(--grey-400); }
.ws-setupbar__chip--ok .ws-setupbar__tick { color: var(--accent-strong); }
.ws-setupbar__sub { color: var(--grey-400); font-weight: 500; }

/* Grouped source accordions, stacked full-width so cards never squeeze */
.ws-groups { display: flex; flex-direction: column; gap: 10px; }
.ws-group { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.ws-group summary {
  display: flex; align-items: center; gap: 9px; padding: 12px 14px;
  cursor: pointer; list-style: none; font-size: 13px; font-weight: 700; color: var(--ink);
}
.ws-group summary::-webkit-details-marker { display: none; }
.ws-group summary::after {
  content: '▸'; margin-left: auto; color: var(--grey-400);
  transition: transform 0.15s; font-size: 12px;
}
.ws-group[open] summary::after { transform: rotate(90deg); }
.ws-group__count {
  font-size: 11px; font-weight: 700; color: var(--grey-600);
  background: var(--grey-100); border-radius: 10px; padding: 1px 8px;
}
.ws-group__dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: var(--grey-100); border: 1px solid var(--line-strong);
}
.ws-group__dot--part { background: var(--amber); border-color: var(--amber); }
.ws-group__dot--full { background: var(--green); border-color: var(--green); }
.ws-group__body { padding: 0 14px 6px; }
.ws-group__body .ws-source:first-child { border-top: none; }

.ws-hint { font-size: 12px; color: var(--grey-600); margin: 0 0 12px; line-height: 1.5; }

/* Build panel: what exists for the month on screen, before you overwrite it */
.ws-state {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; background: var(--grey-50, #FAFAFB);
}
.ws-state__row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.ws-state__row + .ws-state__row { margin-top: 6px; }
.ws-state__k { color: var(--grey-600); }
.ws-state__v { color: var(--ink); font-weight: 700; white-space: nowrap; }
.ws-warn {
  font-size: 12px; line-height: 1.5; margin: 0 0 12px;
  background: rgba(245,158,11,0.12); color: var(--amber-strong);
  border: 1px solid rgba(245,158,11,0.3); border-radius: 10px; padding: 9px 12px;
}

/* Published-report actions, inside the month panel so they read as one thing */
.ws-built { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.ws-built__label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--grey-400); margin-bottom: 9px;
}
.ws-built__views { font-size: 11px; color: var(--grey-400); margin-top: 9px; }

/* Rail index of every month that has a report or data */
.ws-months { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; }
.ws-month {
  display: block; text-decoration: none; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ws-month:hover { border-color: var(--ink); box-shadow: var(--shadow-sm); }
.ws-month--now { border-color: var(--df-pink); background: rgba(236,15,141,0.04); }
.ws-month__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ws-month__name { font-size: 13px; font-weight: 700; color: var(--ink); }
.ws-month__tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--grey-600); background: var(--grey-100);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.ws-month__tag--now { background: var(--df-pink); color: #fff; }
.ws-month__tag--stale { background: rgba(245,158,11,0.16); color: var(--amber-strong); }
.ws-month__meta { font-size: 11px; color: var(--grey-400); margin-top: 3px; }

.ws-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ws-actions .button { flex: 1; text-align: center; justify-content: center; }

.ws-progress {
  height: 8px; background: var(--grey-100); border-radius: 6px; overflow: hidden; margin: 10px 0 8px;
}
.ws-progress__bar {
  height: 100%; width: 4%; border-radius: 6px; background: var(--df-pink);
  transition: width 0.5s ease;
}
.ws-progress__label { font-weight: 700; font-size: 13px; color: var(--ink); }
.ws-progress__detail { font-size: 12px; color: var(--grey-600); min-height: 16px; }

.ws-share {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.ws-share input {
  flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line-strong);
  border-radius: 8px; font-size: 11px; font-family: 'SF Mono', ui-monospace, monospace;
  color: var(--ink);
}
.ws-share__meta { font-size: 11px; color: var(--grey-400); white-space: nowrap; }
.ws-share--dead input { opacity: 0.5; text-decoration: line-through; }

.chip-link--danger { color: var(--negative); border-color: rgba(255,79,64,0.3); }
.chip-link--danger:hover { background: rgba(255,79,64,0.07); border-color: var(--negative); }

/* -------- Portal member management -------- */
.member-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px;
  border-top: 1px solid var(--line); font-size: 13px;
}
.member-row--revoked { opacity: 0.5; }
.member-row__id { flex: 1; min-width: 0; }
.member-row__email { font-weight: 700; color: var(--ink); display: block; }
.member-row__name { font-size: 12px; color: var(--grey-600); }
.member-row__meta { font-size: 12px; color: var(--grey-400); white-space: nowrap; }
.member-add {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px;
}
.member-add input[type=email], .member-add input[type=text] {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line-strong);
  border-radius: 10px; font-size: 14px; font-family: inherit; color: var(--ink);
}

@media (max-width: 1100px) {
  .ws-grid { grid-template-columns: 1fr; }
}

/* -------- API connections -------- */
.conn-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 18px;
  align-items: start;
}
.conn-card__sources { font-size: 11px; color: var(--grey-400); margin-top: 3px; display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.conn-chip {
  font-family: 'SF Mono', ui-monospace, monospace; font-size: 10px;
  background: var(--grey-100); color: var(--grey-600);
  padding: 2px 7px; border-radius: 6px;
}
.conn-status {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 12px; white-space: nowrap;
}
.conn-status--ok { background: rgba(34,197,94,0.12); color: #15803D; }
.conn-status--error { background: rgba(255,79,64,0.12); color: var(--negative); }
.conn-status--untested { background: rgba(245,158,11,0.14); color: var(--amber-strong, #B45309); }
.conn-detail {
  font-size: 12px; color: var(--grey-600); background: var(--grey-50);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 12px;
}
.conn-detail--error { background: rgba(255,79,64,0.07); color: var(--negative); }
.conn-detail--ok { background: rgba(34,197,94,0.07); color: #15803D; }
.conn-saved { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--grey-400); }
.conn-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }

/* -------- Connections panel inside the workspace -------- */
.ws-connections { margin-top: 18px; }
.ws-connections summary {
  cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.ws-connections summary::-webkit-details-marker { display: none; }
.ws-connections summary::before {
  content: "▸"; color: var(--grey-400); font-size: 13px; transition: transform 0.15s;
  display: inline-block;
}
.ws-connections[open] summary::before { transform: rotate(90deg); }
.ws-connections__title { font-weight: 700; font-size: 15px; color: var(--ink); }
.ws-connections__sub { font-size: 12px; color: var(--grey-600); }
.ws-connections[open] summary { margin-bottom: 16px; }
.ws-connections .conn-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.conn-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 16px 16px 14px;
  background: var(--grey-50);
}
.conn-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.conn-card__name { font-weight: 700; font-size: 14px; color: var(--ink); }
.conn-card .field input[type=password],
.conn-card .field input[type=text],
.conn-card .field textarea { background: var(--panel); font-size: 13px; padding: 8px 11px; }
.conn-card .field { margin-bottom: 10px; }

/* Field styling for input types the original rules missed */
.field input[type=password], .field input[type=email],
.field input[type=number], .field input[type=month], .field select {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line-strong);
  border-radius: 10px; font-size: 14px; font-family: inherit; color: var(--ink);
  background: var(--panel);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input[type=password]:focus, .field input[type=email]:focus,
.field input[type=month]:focus, .field select:focus {
  outline: none; border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(0,216,174,0.12);
}

/* -------- "How do I get this key?" popover -------- */
.keyhelp { margin: 0 0 12px; }
.keyhelp summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--df-navy, #1B3B6F);
  background: rgba(0,105,196,0.08); border: 1px solid rgba(0,105,196,0.2);
  padding: 5px 11px; border-radius: 14px;
}
.keyhelp summary::-webkit-details-marker { display: none; }
.keyhelp summary::before { content: "ⓘ"; font-size: 13px; }
.keyhelp summary:hover { background: rgba(0,105,196,0.14); }
.keyhelp[open] summary { border-radius: 10px 10px 0 0; }
.keyhelp ol {
  margin: 0; padding: 12px 14px 12px 30px;
  background: rgba(0,105,196,0.05); border: 1px solid rgba(0,105,196,0.2); border-top: 0;
  border-radius: 0 10px 10px 10px; font-size: 12.5px; color: var(--grey-800);
}
.keyhelp li { margin-bottom: 6px; line-height: 1.5; }
.keyhelp li:last-child { margin-bottom: 0; }
