/*
 * Partner area and the administrator's partner pages.
 *
 * A calm, light design in the same family as the researcher and organisation dashboards: a left side panel for
 * navigation, a slim top bar, white cards on a pale grey page, one accent colour. No gradients, glows or hover lifts.
 * Colour comes from the tokens below. Status colours (ok, warn, bad, info) are reserved for state and always come with
 * a text label. The old --p-* names are kept because some templates use them inline.
 */

/* ---- 1. Tokens ---------------------------------------------------------------------------------------------- */
:root {
  color-scheme: light;
  --p-bg: #f4f6f8;
  --p-card: #ffffff;
  --p-card-2: #f9fafb;
  --p-border: #e5e7eb;
  --p-border-strong: #d1d5db;
  --p-text: #111827;
  --p-text-2: #374151;
  --p-muted: #6b7280;
  --p-heading: #12304e;
  --p-navy: #12304e;
  --p-teal: #0e7490;
  --p-teal-dark: #0b5e75;
  --p-teal-soft: #ebf5f8;
  --p-teal-line: #b9dbe6;
  --p-danger: #b42318;
  --p-ok: #15803d;

  --ok-bg: #e6f6ec;   --ok-fg: #166534;   --ok-line: #bfe6cd;
  --warn-bg: #fdf3d9; --warn-fg: #8a4b08; --warn-line: #f3dc95;
  --bad-bg: #fde9e7;  --bad-fg: #a1241b;  --bad-line: #f5bdb7;
  --info-bg: #e5f1fb; --info-fg: #0b5a8c; --info-line: #bad9f0;
  --neutral-bg: #eef0f3; --neutral-fg: #374151;

  /* Rows: red = everything hidden or not shared; grey with red marks = only some details hidden. */
  --row-red-bg: #fdf0ee;  --row-red-edge: #d92d20;  --row-red-hover: #fbe3e0;
  --row-grey-bg: #f1f2f4; --row-grey-edge: #d92d20; --row-grey-hover: #e8eaed;

  --shadow-1: 0 1px 2px rgba(17, 24, 39, .05);
  --shadow-3: 0 16px 40px rgba(17, 24, 39, .18);
  --radius: 10px;
  --focus: rgba(14, 116, 144, .4);
  --side-w: 256px;
  --top-h: 60px;
}

/* ---- 2. Base ------------------------------------------------------------------------------------------------ */
* { box-sizing: border-box; }
body.partner-body {
  margin: 0; background: var(--p-bg); color: var(--p-text);
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif; font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
a { color: var(--p-teal); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Every icon has a safe default size, so one placed somewhere new can never blow up. Contexts below override it. */
.p-ico { width: 18px; height: 18px; flex: none; }
.p-btn .p-ico { width: 16px; height: 16px; }

/* ---- 3. Layout: side panel, top bar, content ------------------------------------------------------------------ */
.p-shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.p-side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px 16px; background: var(--p-card); border-right: 1px solid var(--p-border); }
.p-brand { display: flex; flex-direction: column; gap: 12px; padding: 0 6px 18px; border-bottom: 1px solid var(--p-border); }
.p-logo-chip { align-self: flex-start; background: #fff; border: 1px solid var(--p-border); border-radius: 8px; padding: 6px 10px; line-height: 0; }
.p-logo-chip img { height: 32px; width: auto; display: block; }
.p-who strong { display: block; font-size: 15px; font-weight: 700; color: var(--p-heading); line-height: 1.3; }
.p-region { display: inline-block; margin-top: 4px; padding: 1px 9px; border-radius: 999px; background: var(--p-teal-soft); border: 1px solid var(--p-teal-line); color: var(--p-teal-dark); font-size: 12px; font-weight: 600; }

.p-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 0 10px; }
.p-nav-group { margin: 18px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--p-muted); }
.p-nav-group:first-child { margin-top: 4px; }
.p-nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 1px 0; border-radius: 8px; color: var(--p-text-2); text-decoration: none; font-weight: 550; font-size: 14px; transition: background .12s, color .12s; }
.p-nav a svg { width: 18px; height: 18px; flex: none; color: var(--p-muted); }
.p-nav a:hover { background: var(--p-card-2); color: var(--p-text); }
.p-nav a.active { background: var(--p-teal-soft); color: var(--p-heading); font-weight: 650; }
.p-nav a.active::before { content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--p-teal); }
.p-nav a.active svg { color: var(--p-teal); }
.p-nav .p-badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #dc2626; color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 20px; }

.p-side-foot { padding-top: 12px; border-top: 1px solid var(--p-border); }
.p-logout { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--p-text-2); text-decoration: none; font-size: 14px; font-weight: 550; transition: background .12s, color .12s; }
.p-logout svg { width: 18px; height: 18px; flex: none; color: var(--p-muted); }
.p-logout:hover { background: var(--p-card-2); color: var(--p-text); }

.p-content { min-width: 0; display: flex; flex-direction: column; }
.p-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; height: var(--top-h); padding: 0 32px; background: var(--p-card); border-bottom: 1px solid var(--p-border); }
.p-top-crumb { font-size: 14px; color: var(--p-muted); }
.p-top-crumb strong { color: var(--p-heading); font-weight: 650; }
.p-top-user { display: flex; align-items: center; gap: 10px; }
.p-top-region { padding: 2px 10px; border-radius: 999px; background: var(--p-card-2); border: 1px solid var(--p-border); font-size: 12px; font-weight: 600; color: var(--p-text-2); }
.p-top-name { font-size: 14px; font-weight: 600; color: var(--p-heading); }
.p-top-user .p-avatar { width: 30px; height: 30px; font-size: 11.5px; }
.p-main { width: 100%; max-width: 1720px; padding: 30px 32px 72px; }

.p-main h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.015em; color: var(--p-heading); }
.p-lead { margin: 0 0 24px; color: var(--p-muted); max-width: 76ch; }
.p-eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--p-teal); }
.p-head-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.p-head-row .p-lead { margin-bottom: 0; }
.p-small { font-size: 13px; color: var(--p-muted); }
.p-small a { color: var(--p-teal); }

/* The older stand-alone header (administrator pages and sign-in) */
.p-header { background: var(--p-heading); color: #fff; }
.p-header-inner { max-width: 1360px; margin: 0 auto; padding: 14px 32px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.p-header .p-who { flex: 1; min-width: 200px; }
.p-header .p-who strong { color: #fff; }
.p-header .p-region { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); color: #fff; }
.p-header .p-logout { display: inline-flex; background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .4); padding: 8px 15px; font-weight: 600; }
.p-header .p-logout:hover { background: rgba(255, 255, 255, .12); }

/* ---- 4. Back link, cards, overview ------------------------------------------------------------------------------ */
.p-back { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 18px; padding: 7px 14px 7px 11px; border: 1px solid var(--p-border-strong); border-radius: 8px; background: var(--p-card); color: var(--p-text-2); text-decoration: none; font-size: 14px; font-weight: 600; transition: background .12s, border-color .12s; }
.p-back:hover { background: var(--p-card-2); border-color: var(--p-teal-line); color: var(--p-heading); }
.p-back svg { width: 16px; height: 16px; }

.p-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; align-items: stretch; }
.p-card { background: var(--p-card); border: 1px solid var(--p-border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-1); }
.p-card h2 { margin: 0 0 14px; font-size: 16px; font-weight: 700; color: var(--p-heading); }
.p-main .p-card + .p-card { margin-top: 20px; }
.p-grid > .p-card + .p-card { margin-top: 0; }
.p-main section.p-card h2, .p-main .p-card > h2 { padding-bottom: 12px; border-bottom: 1px solid var(--p-border); }

.p-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.p-hero .p-lead { margin-bottom: 0; }
.p-hero-meta { color: var(--p-muted); font-size: 13px; white-space: nowrap; }

.p-attention { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin: 0 0 20px; }
.p-attn { display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--p-border); background: var(--p-card); box-shadow: var(--shadow-1); color: inherit; text-decoration: none; }
a.p-attn:hover { border-color: var(--p-teal-line); background: var(--p-card-2); }
.p-attn-icon { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--info-bg); color: var(--info-fg); }
.p-attn.is-warn .p-attn-icon { background: var(--warn-bg); color: var(--warn-fg); }
.p-attn.is-calm .p-attn-icon { background: var(--ok-bg); color: var(--ok-fg); }
.p-attn-icon svg { width: 19px; height: 19px; }
.p-attn > span:last-child { min-width: 0; font-size: 13px; line-height: 1.35; color: var(--p-muted); }
.p-attn strong { display: block; margin-bottom: 2px; font-size: 24px; line-height: 1; font-weight: 700; letter-spacing: -.02em; color: var(--p-heading); }

/* Five tiles that always line up edge to edge: 3 + 2 on medium screens, 5 across on wide ones, 1 on phones. */
.p-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.p-kpis > .p-kpi { grid-column: span 2; }
.p-kpis > .p-kpi:nth-child(n+4) { grid-column: span 3; }
@media (min-width: 1280px) {
  .p-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .p-kpis > .p-kpi, .p-kpis > .p-kpi:nth-child(n+4) { grid-column: span 1; }
}
.p-kpi { display: flex; flex-direction: column; gap: 16px; padding: 20px; background: var(--p-card); border: 1px solid var(--p-border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.p-kpi-top { display: flex; align-items: center; gap: 10px; }
.p-kpi-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--p-teal-soft); color: var(--p-teal); }
.p-kpi-icon svg { width: 17px; height: 17px; }
.p-kpi-icon.t-teal { background: #e6f4f8; color: #0e7490; }
.p-kpi-icon.t-indigo { background: #eceefe; color: #4338ca; }
.p-kpi-icon.t-amber { background: #fdf1d6; color: #b45309; }
.p-kpi-icon.t-green { background: #e3f5ea; color: #15803d; }
.p-kpi-icon.t-sky { background: #e3f0fb; color: #0369a1; }
.p-kpi-label { font-size: 14px; font-weight: 600; color: var(--p-text-2); }
.p-kpi-value { font-size: 40px; font-weight: 700; letter-spacing: -.025em; line-height: 1; color: var(--p-heading); }
.p-kpi-foot { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.p-kpi-value + .p-kpi-foot { margin-top: 0; }
.p-kpi-note { font-size: 13px; color: var(--p-muted); }
.p-kpi-link { align-self: stretch; display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 1px solid var(--p-border-strong); border-radius: 8px; background: var(--p-card); color: var(--p-text-2); font-size: 13px; font-weight: 600; text-decoration: none; transition: background .12s, border-color .12s, color .12s; }
.p-kpi-link:hover { background: var(--p-teal-soft); border-color: var(--p-teal-line); color: var(--p-heading); }
.p-kpi-link.is-empty { visibility: hidden; }

/* A part-to-whole split read beside its figures: a thin segmented bar with a 2px gap between parts. */
.p-split { display: flex; gap: 2px; height: 8px; border-radius: 999px; overflow: hidden; background: var(--p-border); }
.p-split > span { display: block; height: 100%; }
.p-split .a { background: var(--p-teal); }
.p-split .b { background: var(--p-border-strong); }
.p-split .c { background: #8cc6d8; }
.p-legend-row { display: flex; flex-direction: column; gap: 5px; min-height: 68px; font-size: 13px; color: var(--p-text-2); }
.p-legend-row i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.p-legend-row .a { background: var(--p-teal); }
.p-legend-row .b { background: var(--p-border-strong); }
.p-legend-row .c { background: #8cc6d8; }

.p-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.p-main .p-two > .p-card, .p-main .p-two > .p-card + .p-card { margin: 0; }
.p-card-foot { margin-top: auto; padding-top: 16px; font-size: 13px; color: var(--p-muted); border-top: 1px solid var(--p-border); }
.p-card-foot a { font-weight: 600; text-decoration: none; }
.p-card-foot a:hover { text-decoration: underline; }
.p-two > .p-card { display: flex; flex-direction: column; }
.p-two > .p-card > .p-meter-row:last-of-type { margin-bottom: 18px; }
.p-meter-row { margin-bottom: 18px; }
.p-meter-row:last-child { margin-bottom: 0; }
.p-meter-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 14px; }
.p-meter-line strong { font-size: 15px; color: var(--p-heading); }
.p-meter-line span { color: var(--p-muted); font-size: 13px; }
.p-track { height: 10px; border-radius: 999px; background: var(--p-border); overflow: hidden; }
.p-track > span { display: block; height: 100%; border-radius: 999px; background: var(--p-teal); }
.p-rank { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.p-rank li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; font-size: 14px; }
.p-rank .p-track { grid-column: 1 / -1; grid-row: 2; height: 8px; }
.p-rank b { font-weight: 700; color: var(--p-heading); min-width: 2ch; text-align: right; }
.p-sub-line { margin-bottom: 16px; font-size: 14px; color: var(--p-text-2); }
.p-sub-line strong { font-size: 22px; letter-spacing: -.02em; color: var(--p-heading); margin-right: 4px; }
.p-note { margin-top: 22px; padding: 14px 18px; border-radius: var(--radius); background: var(--info-bg); border: 1px solid var(--info-line); color: var(--info-fg); font-size: 14px; }
.p-note a { color: inherit; font-weight: 600; }
.p-stat-label { font-size: 13px; color: var(--p-muted); font-weight: 600; }
.p-stat-value { font-size: 38px; font-weight: 700; color: var(--p-heading); line-height: 1.05; margin: 4px 0 8px; }
.p-stat-split { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--p-muted); }

/* ---- 5. Pills, flags, buttons -------------------------------------------------------------------------------- */
.p-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; background: var(--neutral-bg); color: var(--neutral-fg); font-size: 12px; font-weight: 600; white-space: nowrap; }
.p-pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.p-pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.p-pill.bad { background: var(--bad-bg); color: var(--bad-fg); }
.p-pill.info { background: var(--info-bg); color: var(--info-fg); }
.p-pill.ok::before, .p-pill.warn::before, .p-pill.bad::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.p-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; background: var(--p-teal); color: #fff; transition: background .12s; }
body.partner-body .p-btn { color: #fff; }
.p-btn:hover { background: var(--p-teal-dark); }
.p-btn.ghost, body.partner-body .p-btn.ghost { background: var(--p-card); color: var(--p-text-2); border-color: var(--p-border-strong); }
.p-btn.ghost:hover { background: var(--p-card-2); border-color: var(--p-teal-line); }
.p-btn.danger, body.partner-body .p-btn.danger { background: var(--p-card); color: var(--p-danger); border-color: var(--bad-line); }
.p-btn.danger:hover { background: var(--bad-bg); }
.p-btn[disabled] { opacity: .55; cursor: not-allowed; }
.p-btn.small { padding: 5px 12px; font-size: 13px; border-radius: 7px; }
.p-btn:focus-visible, .p-nav a:focus-visible, .p-table a:focus-visible, .p-tabs a:focus-visible, .p-back:focus-visible, a.p-attn:focus-visible, .p-logout:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Values the partner cannot see */
.p-hidden { display: inline-block; white-space: nowrap; padding: 1px 8px; border-radius: 5px; background: var(--bad-bg); color: var(--bad-fg); font-size: 13px; font-weight: 600; }
.p-hidden.p-unshared { background: var(--bad-bg); color: var(--bad-fg); }
.p-flag { display: inline-block; padding: 2px 9px; border-radius: 5px; background: var(--bad-bg); color: var(--bad-fg); font-size: 12px; font-weight: 700; margin-right: 6px; }
.p-flag-msg { margin: 4px 0 6px; padding: 5px 9px; border-left: 3px solid var(--row-red-edge); background: var(--p-card); color: var(--p-text); font-size: 13px; font-style: italic; overflow-wrap: anywhere; border-radius: 0 6px 6px 0; }

/* ---- 6. Tables and lists ------------------------------------------------------------------------------------- */
.p-scroll { overflow-x: auto; }
.p-card.p-scroll { padding: 0; overflow: hidden; overflow-x: auto; }
.p-card.p-scroll > p { padding: 28px 22px; }
.p-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; table-layout: auto; }
.p-table th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--p-muted); padding: 12px 10px; background: var(--p-card-2); border-bottom: 1px solid var(--p-border); line-height: 1.3; }
.p-table td { padding: 13px 12px; border-bottom: 1px solid var(--p-border); vertical-align: middle; overflow-wrap: break-word; }
.p-table tr:last-child td { border-bottom: 0; }
.p-table tbody tr:hover td { background: var(--p-card-2); }
.p-table td strong { color: var(--p-heading); font-weight: 650; }
.p-table td .p-btn.ghost { padding: 6px 14px; }
.p-table .p-num { text-align: center; white-space: nowrap; width: 1%; letter-spacing: .04em; }
.p-table td { padding-left: 10px; padding-right: 10px; }
.p-table td.p-email { overflow-wrap: normal; word-break: normal; min-width: 150px; }
.p-vchip { display: inline-block; margin-top: 4px; font-size: 11.5px; font-weight: 600; }
.p-vchip.ok { color: var(--ok-fg); }
.p-vchip.ok::before { content: "\2713  "; }
.p-vchip.warn { color: var(--warn-fg); }
.p-vchip.muted { color: var(--p-muted); font-weight: 500; }
.p-vchip.muted::before { content: none; }
.p-vrow { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.p-table td.p-wrap { min-width: 200px; overflow-wrap: break-word; }
.p-access { min-width: 120px; }
.p-rowlink { color: var(--p-heading); text-decoration: none; }
.p-rowlink:hover strong { text-decoration: underline; color: var(--p-teal-dark); }

/* RED row: everything is hidden or not shared. GREY row with red marks: only some details are hidden. */
.p-table tr.p-row-unshared td { background: var(--row-red-bg); }
.p-table tr.p-row-unshared td:first-child { box-shadow: inset 4px 0 0 var(--row-red-edge); }
.p-table tbody tr.p-row-unshared:hover td { background: var(--row-red-hover); }
.p-table tr.p-row-hidden td { background: var(--row-grey-bg); }
.p-table tr.p-row-hidden td:first-child { box-shadow: inset 4px 0 0 var(--row-grey-edge); }
.p-table tbody tr.p-row-hidden:hover td { background: var(--row-grey-hover); }

.p-name { display: flex; align-items: center; gap: 12px; min-width: 170px; }
.p-avatar { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--p-teal-soft); color: var(--p-teal-dark); font-size: 12.5px; font-weight: 700; border: 1px solid var(--p-teal-line); }
.p-avatar.muted { background: var(--neutral-bg); color: var(--p-muted); border-color: var(--p-border-strong); }
.p-avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.p-name-text { min-width: 0; }

.p-meter { width: 56px; height: 8px; border-radius: 999px; background: var(--p-border); overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.p-meter-bar { display: block; height: 100%; background: var(--p-teal); border-radius: 999px; }
.p-progress { height: 10px; background: var(--p-border); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.p-progress span { display: block; height: 100%; background: var(--p-teal); }

.p-legend { margin: 0 0 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 8px 14px; background: var(--p-card); border: 1px solid var(--p-border); border-radius: 8px; width: fit-content; max-width: 100%; }
.p-legend-item { display: inline-flex; align-items: center; gap: 8px; }
.p-legend-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 3px; background: var(--row-red-bg); box-shadow: inset 0 0 0 1px var(--bad-line), inset 4px 0 0 var(--row-red-edge); }
.p-legend-swatch.grey { background: var(--row-grey-bg); box-shadow: inset 0 0 0 1px var(--p-border-strong), inset 4px 0 0 var(--row-grey-edge); }

.p-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; padding: 12px; background: var(--p-card); border: 1px solid var(--p-border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.p-filters input[type=text], .p-filters select { padding: 9px 12px; border: 1px solid var(--p-border-strong); border-radius: 8px; font: inherit; background: var(--p-card); color: var(--p-text); min-width: 180px; }
.p-filters input:focus, .p-filters select:focus { outline: 3px solid var(--focus); border-color: var(--p-teal); }
.p-filters .p-btn:last-child { margin-left: auto; }
.p-search { position: relative; flex: 1 1 260px; display: flex; }
.p-search svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--p-muted); pointer-events: none; }
.p-search input[type=text] { width: 100%; padding-left: 38px; }
.p-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; padding: 10px; }
.p-pager .p-btn { padding: 8px 16px; }

.p-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; padding: 4px; width: fit-content; max-width: 100%; background: var(--p-card); border: 1px solid var(--p-border); border-radius: 10px; }
.p-tabs a { padding: 7px 14px; border-radius: 7px; color: var(--p-muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.p-tabs a:hover { color: var(--p-text); background: var(--p-card-2); }
.p-tabs a.active { background: var(--p-teal); color: #fff; }
.p-tab-count { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: rgba(107, 114, 128, .18); font-size: 12px; text-align: center; }
.p-tabs a.active .p-tab-count { background: rgba(255, 255, 255, .26); }

/* ---- 7. Record pages ------------------------------------------------------------------------------------------ */
.p-crumb { margin: 0; }
.p-record-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.p-record-head h1 { margin: 0; }
.p-main > .p-lead { margin-bottom: 20px; }
.p-dl { margin: 0; display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 14px 18px; font-size: 14px; }
.p-dl dt { color: var(--p-muted); font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding-top: 3px; }
.p-dl dd { margin: 0; overflow-wrap: anywhere; color: var(--p-text); }
.p-dl dd a { color: var(--p-teal); font-weight: 650; text-decoration: none; }
.p-dl dd a:hover { text-decoration: underline; }
.p-terms { padding-left: 20px; line-height: 1.7; }
.p-check { display: flex; gap: 10px; align-items: flex-start; margin: 18px 0 14px; font-weight: 600; font-size: 14px; }

/* ---- 8. Forms, composer, modals --------------------------------------------------------------------------------- */
.p-field { margin-bottom: 16px; }
.p-field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--p-text); }
.p-field small { color: var(--p-muted); font-size: 12px; font-weight: 400; }
.p-field input[type=text], .p-field input[type=email], .p-field input[type=url], .p-field input[type=password], .p-field input[type=number], .p-field textarea, .p-field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--p-border-strong); border-radius: 8px; font: inherit; background: var(--p-card); color: var(--p-text);
}
.p-field input:focus, .p-field textarea:focus, .p-field select:focus { outline: 3px solid var(--focus); border-color: var(--p-teal); }
.p-field textarea { min-height: 260px; resize: vertical; }
.p-field.has-error input, .p-field.has-error textarea { border-color: var(--row-red-edge); }
.p-error { color: var(--p-danger); font-size: 13px; margin-top: 4px; }
.p-flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; font-size: 14px; border: 1px solid transparent; }
.p-flash.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-line); }
.p-flash.bad { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-line); }
.p-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
details.p-details { margin-top: 18px; }
details.p-details summary { cursor: pointer; font-weight: 600; color: var(--p-teal); }
.p-perms { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px 18px; margin: 12px 0 16px; }
.p-perm { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.p-perm small { display: block; color: var(--p-muted); font-size: 12px; }
.p-choices, .p-audience { border: 1px solid var(--p-border); border-radius: var(--radius); padding: 14px 16px; background: var(--p-card-2); }
.p-choices legend, .p-audience legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
.p-choice { display: block; font-weight: 500; margin: 4px 0; }
.p-audience-topics { margin: 4px 0 8px 26px; display: grid; gap: 2px; }
.p-topic-input { width: 100%; min-width: 140px; padding: 7px 10px; border: 1px solid var(--p-border-strong); border-radius: 8px; font: inherit; background: var(--p-card); color: var(--p-text); }

.p-composer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.p-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.p-toolbar button { border: 1px solid var(--p-border-strong); background: var(--p-card); color: var(--p-text); border-radius: 7px; padding: 5px 11px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.p-toolbar button:hover { background: var(--p-card-2); border-color: var(--p-teal-line); }
.p-preview { position: sticky; top: calc(var(--top-h) + 16px); }
.p-preview iframe { width: 100%; height: 720px; border: 1px solid var(--p-border); border-radius: var(--radius); background: #f4f4f5; }
.p-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.p-test-row { display: flex; gap: 8px; flex-wrap: wrap; }
.p-test-row input { flex: 1; min-width: 200px; }
.p-status { font-size: 13px; color: var(--p-muted); }
.p-modal { position: fixed; inset: 0; background: rgba(17, 24, 39, .55); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 60; }
.p-modal.open { display: flex; }
.p-modal-card { background: var(--p-card); color: var(--p-text); border: 1px solid var(--p-border); border-radius: 14px; padding: 28px; max-width: 480px; width: 100%; box-shadow: var(--shadow-3); }
.p-modal-card h2 { margin: 0 0 8px; color: var(--p-heading); }
.p-logo-preview { max-height: 90px; max-width: 280px; display: block; margin: 8px 0 14px; background: #fff; border: 1px solid var(--p-border); border-radius: 8px; padding: 8px; }

/* ---- 9. Messages: a two-pane inbox -------------------------------------------------------------------------------- */
.p-live-banner { position: sticky; top: calc(var(--top-h) + 8px); z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 16px; padding: 11px 16px; border-radius: var(--radius); background: var(--info-bg); border: 1px solid var(--info-line); color: var(--info-fg); font-size: 14px; font-weight: 600; }
.p-live-banner button { margin-left: auto; }

/* ---- 10. Sign-in --------------------------------------------------------------------------------------------------- */
.p-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--p-bg); }
.p-login-card { background: var(--p-card); width: 100%; max-width: 420px; border-radius: 14px; padding: 34px; border: 1px solid var(--p-border); box-shadow: var(--shadow-1); border-top: 4px solid var(--p-teal); }
.p-login-card h1 { margin: 16px 0 4px; font-size: 24px; color: var(--p-heading); }
.p-login-card .p-logo-chip { display: inline-block; }
.p-login-card .p-btn { padding: 11px 18px; font-size: 15px; }

/* ---- 11. Smaller screens ----------------------------------------------------------------------------------------- */
@media (max-width: 1400px) {
  .p-meter { display: none; }
  .p-table th.p-num { letter-spacing: .02em; font-size: 11px; }
}
@media (max-width: 960px) {
  .p-shell { display: block; }
  .p-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--p-border); }
  .p-brand { flex-direction: row; align-items: center; padding: 0; border: 0; gap: 12px; }
  .p-nav { order: 3; flex: 1 1 100%; display: flex; gap: 4px; overflow-x: auto; padding: 4px 0 0; }
  .p-nav-group { display: none; }
  .p-nav a { white-space: nowrap; margin: 0; }
  .p-nav a.active::before { display: none; }
  .p-side-foot { margin-left: auto; padding: 0; border: 0; }
  .p-top { position: static; padding: 0 16px; height: 48px; }
  .p-main { padding: 22px 16px 56px; }
  .p-table th { position: static; }
  .p-composer { grid-template-columns: 1fr; }
  .p-preview { position: static; }
  .p-two { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .p-kpis { grid-template-columns: 1fr; }
  .p-kpis > .p-kpi, .p-kpis > .p-kpi:nth-child(n+4) { grid-column: span 1; }
  .p-main h1 { font-size: 23px; }
  .p-dl { grid-template-columns: 1fr; gap: 2px; }
  .p-dl dd { margin-bottom: 12px; }
  .p-filters .p-btn:last-child { margin-left: 0; }
}


/* ---- 12. Welcome panel, rings, trend chart, list summary ---------------------------------------------------------- */
.p-welcome { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 32px; margin-bottom: 22px; padding: 32px 36px; background: var(--p-teal-soft); border: 1px solid var(--p-teal-line); border-radius: 16px; }
.p-welcome-art { position: absolute; right: -8px; bottom: -26px; width: 560px; max-width: 70%; height: auto; color: var(--p-teal); opacity: .14; pointer-events: none; }
.p-welcome-main, .p-rings { position: relative; z-index: 1; }
.p-welcome h1 { margin: 0 0 10px; font-size: 30px; letter-spacing: -.02em; }
.p-welcome-sub { margin: 0; max-width: 58ch; color: var(--p-text-2); font-size: 15.5px; line-height: 1.6; }
.p-welcome-sub strong { color: var(--p-heading); }
.p-welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.p-rings { display: flex; gap: 26px; padding: 18px 24px; background: var(--p-card); border: 1px solid var(--p-teal-line); border-radius: 14px; }
.p-ring { margin: 0; text-align: center; }
.p-ring-dial { position: relative; width: 92px; height: 92px; margin: 0 auto; }
.p-ring-dial svg { width: 100%; height: 100%; display: block; }
.p-ring .trk, .p-ring .val { fill: none; stroke-width: 8; }
.p-ring .trk { stroke: var(--p-teal-soft); }
.p-ring .val { stroke: var(--p-teal); stroke-linecap: round; stroke-dasharray: calc(var(--pct) * 2.2619px) 226.19px; }
.p-ring-dial b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 19px; font-weight: 700; color: var(--p-heading); }
.p-ring figcaption { margin-top: 8px; max-width: 96px; font-size: 12.5px; font-weight: 600; line-height: 1.3; color: var(--p-text-2); }

.p-three { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.p-three > .p-card, .p-main .p-three > .p-card + .p-card { display: flex; flex-direction: column; margin: 0; }
.p-three > .p-growth { grid-column: 1 / -1; }
@media (min-width: 1280px) {
  .p-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .p-three > .p-growth { grid-column: auto; }
}

.p-bars { position: relative; display: flex; align-items: stretch; gap: 14px; height: 150px; margin-top: 12px; border-bottom: 1px solid var(--p-border-strong); }
.p-bar { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; outline: 0; }
.p-bar-col { position: relative; display: block; width: 62%; max-width: 54px; min-height: 0; height: calc((100% - 52px) * var(--h) / 100); border-radius: 7px 7px 0 0; background: var(--p-teal); transition: background .12s; }
.p-bar:hover .p-bar-col, .p-bar:focus-visible .p-bar-col { background: var(--p-teal-dark); }
.p-bar-val { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); padding-bottom: 5px; font-size: 13px; font-weight: 700; color: var(--p-heading); }
.p-bar-lab { position: absolute; top: 100%; margin-top: 7px; font-size: 12px; font-weight: 600; color: var(--p-muted); }
.p-bars { margin-bottom: 30px; }
.p-bar::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 5; width: max-content; max-width: 200px; padding: 7px 10px; border-radius: 8px; background: var(--p-heading); color: #fff; font-size: 12px; font-weight: 500; line-height: 1.4; text-align: center; opacity: 0; pointer-events: none; transition: opacity .12s; }
.p-bar:first-child::after { left: 0; transform: none; text-align: left; }
.p-bar:last-child::after { left: auto; right: 0; transform: none; text-align: right; }
.p-bar:hover::after, .p-bar:focus-visible::after { opacity: 1; }
.p-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.p-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; background: var(--p-card); border: 1px solid var(--p-border); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.p-summary > div { padding: 14px 20px; }
.p-summary > div + div { border-left: 1px solid var(--p-border); }
.p-summary b { display: block; font-size: 22px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; color: var(--p-heading); }
.p-summary span { font-size: 13px; color: var(--p-muted); }

@media (max-width: 1100px) {
  .p-welcome { grid-template-columns: 1fr; }
  .p-rings { justify-content: space-between; }
}
@media (max-width: 640px) {
  .p-welcome { padding: 22px 18px; }
  .p-welcome h1 { font-size: 24px; }
  .p-rings { gap: 12px; padding: 14px; }
  .p-ring-dial { width: 76px; height: 76px; }
  .p-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .p-summary > div:nth-child(3) { border-left: 0; }
  .p-summary > div:nth-child(n+3) { border-top: 1px solid var(--p-border); }
}


/* ---- 13. Inbox ------------------------------------------------------------------------------------------------------ */
.p-inbox { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 20px; align-items: start; }
.p-inbox-list { background: var(--p-card); border: 1px solid var(--p-border); border-radius: var(--radius); box-shadow: var(--shadow-1); max-height: calc(100vh - 250px); min-height: 320px; overflow-y: auto; }
.p-mi { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--p-border); color: inherit; text-decoration: none; transition: background .12s; }
.p-mi:last-of-type { border-bottom: 0; }
.p-mi:hover { background: var(--p-card-2); }
.p-mi.is-selected { background: var(--p-teal-soft); }
.p-mi.is-selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--p-teal); }
.p-mi .p-avatar { width: 40px; height: 40px; }
.p-avatar.sq { border-radius: 10px; }
.p-mi-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.p-mi-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.p-mi-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; font-weight: 600; color: var(--p-heading); }
.p-mi.is-unread .p-mi-top strong { font-weight: 750; }
.p-mi.is-unread .p-mi-top strong::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--p-teal); vertical-align: 1px; }
.p-mi-top time { flex: none; font-size: 12px; color: var(--p-muted); }
.p-mi-snippet { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13.5px; line-height: 1.45; color: var(--p-text-2); }
.p-mi-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.p-chip { display: inline-flex; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--p-border-strong); background: var(--p-card); color: var(--p-muted); font-size: 12px; font-weight: 600; }

.p-reading { background: var(--p-card); border: 1px solid var(--p-border); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.p-read-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; background: var(--p-card-2); border-bottom: 1px solid var(--p-border); }
.p-read-pos { font-size: 13px; font-weight: 600; color: var(--p-muted); }
.p-read-nav { display: flex; gap: 6px; }
.p-iconbtn { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--p-border-strong); border-radius: 8px; background: var(--p-card); color: var(--p-text-2); text-decoration: none; transition: background .12s, border-color .12s; }
.p-iconbtn:hover { background: var(--p-teal-soft); border-color: var(--p-teal-line); }
.p-iconbtn.is-off { opacity: .4; pointer-events: none; }
.p-iconbtn svg { width: 16px; height: 16px; }
.p-read-head { display: flex; align-items: center; gap: 16px; padding: 20px 24px 8px; }
.p-read-who { flex: 1; min-width: 0; }
.p-read-who h2 { margin: 0 0 4px; padding: 0; border: 0; font-size: 20px; }
.p-read-body { padding: 8px 24px 24px; }
.p-read-when { margin: 0 0 10px; font-size: 13px; color: var(--p-muted); }
.p-bubble { padding: 18px 20px; border: 1px solid var(--p-border); border-radius: 12px; background: var(--p-card-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.65; color: var(--p-text); }

.p-follow { padding: 18px 24px 22px; border-top: 1px solid var(--p-border); }
.p-follow-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.p-follow-top h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--p-heading); }
.p-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--p-text); }
.p-switch small { font-weight: 500; color: var(--p-muted); }
.p-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.p-switch-track { position: relative; flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--p-border-strong); transition: background .15s; }
.p-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(17, 24, 39, .3); transition: transform .15s; }
.p-switch input:checked + .p-switch-track { background: var(--p-ok); }
.p-switch input:checked + .p-switch-track::after { transform: translateX(18px); }
.p-switch input:focus-visible + .p-switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.p-follow textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--p-border-strong); border-radius: 10px; font: inherit; line-height: 1.55; background: var(--p-card); color: var(--p-text); resize: vertical; }
.p-follow textarea:focus { outline: 3px solid var(--focus); border-color: var(--p-teal); }
.p-follow-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }

.p-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; }
.p-empty-icon { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 14px; border-radius: 18px; background: var(--p-teal-soft); color: var(--p-teal); }
.p-empty-icon svg { width: 30px; height: 30px; }
.p-empty h2 { margin: 0 0 6px; padding: 0; border: 0; }
.p-empty p { max-width: 46ch; margin: 0; }

@media (max-width: 1100px) {
  .p-inbox { grid-template-columns: 1fr; }
  .p-inbox-list { max-height: 340px; }
}
@media (max-width: 640px) {
  .p-read-head { flex-wrap: wrap; padding: 16px 16px 6px; }
  .p-read-body { padding: 6px 16px 18px; }
  .p-follow { padding: 16px; }
  .p-follow-actions { flex-direction: column; align-items: stretch; }
}
