/* ══════════════════════════════════════════════════════════════════════
   PRODUCER VIEW — the four-screen interface clients see by default.

   The owner workspace (sidebar, full top nav, every analysis tab) is
   untouched; body.producer-view hides it and body.owner-view shows it.
   Everything here is prefixed .p- so it cannot collide with styles.css.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Shell switching ─────────────────────────────────────────────────── */
body.producer-view .free-period-banner,
body.producer-view .top-nav,
body.producer-view .sidebar,
body.producer-view .sidebar-backdrop,
body.producer-view .rms-feedback-fab,
body.producer-view > footer { display: none !important; }

body.producer-view .app-shell { display: block; min-height: 0; }
body.producer-view .main-content { padding: 0 var(--page-gutter) 2.5rem; }
body.producer-view .main-content-wide { max-width: 1180px; }
/* Old pages reachable from the producer footer (About, How it works, Feedback, full report) */
body.producer-view .tab-content:not([id^="tab-p"]) { padding-top: 18px; }

/* The producer bar and screens only exist in the producer view */
body:not(.producer-view) .p-bar,
body:not(.producer-view) .p-footer,
body:not(.producer-view) #tab-pweek,
body:not(.producer-view) #tab-pnumbers,
body:not(.producer-view) #tab-pcycle,
body:not(.producer-view) #tab-preport { display: none !important; }

/* Owner-only controls inside the producer view */
.p-owner-only { display: none; }
body.owner-mode .p-owner-only { display: inline-flex; }

/* The "Producer view" button at the top of the owner sidebar: only in owner view */
.nav-producer-btn { display: none; }
body.owner-view .nav-producer-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 10px 12px 2px; min-height: 40px; padding: 0 12px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.08);
  color: var(--white); font: 600 0.82rem/1 var(--font-body); cursor: pointer;
}
.nav-producer-btn:hover { background: rgba(255,255,255,0.16); }

/* ── Producer bar ────────────────────────────────────────────────────── */
.p-bar {
  position: sticky; top: 0; z-index: 150;
  background: var(--white);
  border-bottom: 1px solid var(--cream-border);
}
.p-bar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 var(--page-gutter);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 60px; flex-wrap: wrap;
}
.p-brand {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 8px 0; cursor: pointer;
  font-family: var(--font-heading); font-weight: 700; font-size: 1.15rem; color: var(--forest);
}
.p-brand img { height: 44px; width: auto; display: block; }
.p-tabs { display: flex; gap: 2px; }
.p-tab {
  background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 18px 14px 15px; cursor: pointer;
  font: 500 0.9rem/1 var(--font-body); color: var(--stone); white-space: nowrap;
}
.p-tab:hover { color: var(--forest); }
.p-tab.active { color: var(--forest); font-weight: 600; border-bottom-color: var(--forest); }
.p-bar-right { display: flex; align-items: center; gap: 10px; }
.p-date { font-size: 0.8rem; color: var(--stone); white-space: nowrap; }
.p-owner-btn {
  min-height: 36px; padding: 0 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--cream-border); background: var(--white);
  color: var(--forest); font: 600 0.8rem/1 var(--font-body);
  align-items: center; gap: 6px;
}
.p-owner-btn:hover { background: var(--cream-dark); }

@media (max-width: 760px) {
  .p-bar-inner { padding: 0 0 0 var(--page-gutter); min-height: 0; gap: 0; }
  .p-brand { padding: 8px 0; }
  .p-brand img { height: 36px; }
  .p-bar-right { padding-right: var(--page-gutter); }
  .p-date { display: none; }
  .p-tabs {
    order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-top: 1px solid var(--cream-border); scrollbar-width: none;
  }
  .p-tabs::-webkit-scrollbar { display: none; }
  .p-tab { flex: 1 0 auto; padding: 13px 12px 11px; font-size: 0.85rem; text-align: center; }
}

/* ── Screens ─────────────────────────────────────────────────────────── */
.p-screen { padding: 18px 0 0; display: flex; flex-direction: column; gap: 16px; }
.p-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.p-grid > .p-col-main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.p-grid > .p-col-side { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.p-card {
  background: var(--white); border: 1px solid var(--cream-border);
  border-radius: 16px; padding: 20px 22px;
  display: flex; flex-direction: column; gap: 12px;
}
.p-card h2, .p-kicker {
  margin: 0; font: 600 0.72rem/1.2 var(--font-body);
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--stone);
}
.p-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.p-card-head a, .p-link { font-size: 0.85rem; font-weight: 500; color: var(--forest); }
.p-muted { color: var(--stone); font-size: 0.82rem; }
.p-small { font-size: 0.8rem; }
.p-note { margin: 0; font-size: 0.9rem; color: var(--ink); }
.p-fine { margin: 0; font-size: 0.78rem; color: var(--stone); border-top: 1px solid var(--cream-dark); padding-top: 10px; }
.p-num { font-family: var(--font-heading); font-weight: 700; color: var(--forest); line-height: 1; }

/* Verdict band */
.p-verdict {
  background: var(--forest); color: var(--white); border-radius: 16px;
  padding: 24px 26px; display: flex; flex-wrap: wrap; gap: 24px; align-items: center;
}
.p-verdict .p-kicker { color: var(--amber-light); }
.p-verdict-text { flex: 999 1 400px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.p-verdict h1 {
  margin: 0; font-family: var(--font-heading); font-weight: 700;
  font-size: clamp(1.6rem, 2.6vw, 2.2rem); line-height: 1.15; color: var(--white);
}
.p-verdict p { margin: 0; font-size: 0.95rem; line-height: 1.5; color: #E8EFEA; max-width: 640px; }
.p-phase { flex: 1 1 280px; display: flex; flex-direction: column; gap: 8px; }
.p-phase-bars, .p-phase-labels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.p-phase-bars span { height: 8px; border-radius: 4px; background: #2E6B52; display: block; }
.p-phase-bars span.on { background: var(--amber-light); }
.p-phase-labels span { font-size: 0.7rem; color: #B9CCC2; text-align: center; }
.p-phase-labels span.on { color: var(--amber-light); font-weight: 600; }
.p-phase-foot { font-size: 0.75rem; color: #B9CCC2; text-align: center; margin-top: 2px; }
.p-verdict .p-stamp { font-size: 0.75rem; color: #B9CCC2; }

/* Signal */
.p-signal-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.p-signal-row .p-num { font-size: 3.6rem; }
.p-pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 5px 12px; font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}
.p-pill .p-dot { width: 9px; height: 9px; }
.p-band { position: relative; height: 46px; margin-top: 4px; }
.p-band-track { position: absolute; left: 0; right: 0; top: 10px; height: 14px; border-radius: 7px; overflow: hidden; display: flex; }
.p-band-track span { display: block; height: 100%; }
.p-band-marker {
  position: absolute; top: 2px; width: 4px; height: 30px; margin-left: -2px;
  background: var(--charcoal); border-radius: 2px;
}
.p-band-marker.prev { background: transparent; border-left: 2px dashed var(--mist); width: 0; margin-left: -1px; }
.p-band-tick { position: absolute; top: 28px; font-size: 0.7rem; color: var(--stone); transform: translateX(-50%); white-space: nowrap; }
@media (max-width: 700px) { .p-tick-long { display: none; } }

/* Lights */
.p-dot { display: inline-block; border-radius: 50%; width: 10px; height: 10px; flex: none; }
.p-red    { color: var(--oxblood); }
.p-amber  { color: var(--warning); }
.p-green  { color: var(--success); }
.p-dot.p-red    { background: var(--oxblood); }
.p-dot.p-amber  { background: var(--amber); }
.p-dot.p-green  { background: var(--success); }
.p-pill.p-red   { background: var(--danger-bg); }
.p-pill.p-amber { background: var(--warning-bg); }
.p-pill.p-green { background: var(--success-bg); }

.p-lights { display: flex; flex-direction: column; }
.p-light { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--cream-dark); }
.p-light:first-child { border-top: 0; padding-top: 2px; }
.p-light .p-dot { margin-top: 5px; }
.p-light b { font-weight: 600; }
.p-light .p-level { font-weight: 600; margin-left: 4px; }
.p-light .p-light-note { font-size: 0.82rem; color: var(--stone); }

/* Three numbers */
.p-numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.p-numbers > div { border-top: 3px solid var(--forest); padding-top: 10px; min-width: 0; }
.p-numbers > div.p-amber-top { border-top-color: var(--amber); }
.p-numbers > div.p-red-top { border-top-color: var(--oxblood); }
.p-numbers .p-label { font-size: 0.85rem; font-weight: 600; }
.p-numbers .p-num { font-size: 1.9rem; margin: 6px 0 4px; }
.p-numbers .p-sub { font-size: 0.78rem; color: var(--stone); }
.p-numbers .p-trip { font-size: 0.78rem; font-weight: 500; margin-top: 6px; }
@media (max-width: 560px) {
  .p-numbers { grid-template-columns: 1fr; gap: 0; }
  .p-numbers > div { border-top: 1px solid var(--cream-dark); padding: 10px 0; display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center; }
  .p-numbers > div:first-child { border-top: 0; padding-top: 0; }
  .p-numbers .p-num { grid-column: 2; grid-row: 1 / span 2; font-size: 1.5rem; margin: 0; text-align: right; }
  .p-numbers .p-sub { grid-column: 1; }
  .p-numbers .p-trip { grid-column: 1 / span 2; margin-top: 4px; }
}

/* Actions */
.p-actions { display: flex; flex-direction: column; gap: 10px; }
.p-action { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; }
.p-action svg { flex: none; margin-top: 2px; }
.p-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--forest); color: var(--white); font: 600 0.9rem/1 var(--font-body);
  text-decoration: none;
}
.p-btn:hover { background: var(--forest-mid); }
.p-btn.p-btn-ghost { background: var(--white); color: var(--forest); border: 1.5px solid var(--cream-border); }
.p-btn.p-btn-ghost:hover { background: var(--cream-dark); }
.p-btn[disabled] { opacity: 0.6; cursor: default; }

/* Your numbers */
.p-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.p-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.p-field label { font-size: 0.8rem; color: var(--stone); }
.p-field input, .p-field select, .p-field textarea {
  box-sizing: border-box; width: 100%; min-height: 44px;
  border: 1px solid var(--cream-border); border-radius: 8px; padding: 8px 12px;
  font: 400 1rem/1.3 var(--font-body); color: var(--charcoal); background: var(--cream);
}
.p-field textarea { min-height: 72px; resize: vertical; }
.p-field input:focus, .p-field select:focus, .p-field textarea:focus { outline: 2px solid var(--forest); outline-offset: 1px; }
.p-field .p-help { font-size: 0.75rem; color: var(--mist); }

.p-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.p-table th { text-align: left; font: 600 0.7rem/1.2 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--mist); padding: 0 6px 8px 0; }
.p-table td { padding: 10px 6px 10px 0; border-top: 1px solid var(--cream-dark); vertical-align: middle; }
.p-table th.r, .p-table td.r { text-align: right; padding-right: 0; }
.p-table tr.hl td { background: var(--success-bg); color: var(--success); font-weight: 600; }
.p-table tr.hl td:first-child { border-radius: 8px 0 0 8px; padding-left: 8px; }
.p-table tr.hl td:last-child { border-radius: 0 8px 8px 0; padding-right: 8px; }
.p-table .p-dim { color: var(--stone); font-weight: 400; }

.p-q { display: flex; flex-direction: column; gap: 8px; }
.p-q-text { font-size: 0.92rem; }
.p-q-text b { margin-right: 4px; }
.p-choice { display: flex; gap: 8px; }
.p-choice button {
  flex: 1; min-height: 44px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--cream-border); background: var(--white); color: var(--ink);
  font: 600 0.9rem/1 var(--font-body);
}
.p-choice button.on { border-color: var(--forest); background: var(--forest); color: var(--white); }
.p-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.p-answer { background: var(--forest); color: var(--white); border-radius: 10px; padding: 14px 16px; }
.p-answer .p-answer-title { font-family: var(--font-heading); font-weight: 700; font-size: 1.25rem; margin-bottom: 4px; }
.p-answer p { margin: 0; font-size: 0.88rem; color: #E8EFEA; }
.p-answer.p-answer-warn { background: var(--oxblood); }
.p-card.p-card-cull { background: var(--warning-bg); border-color: #F0D9A0; }
.p-card.p-card-cull h2 { color: var(--warning); }

/* The cycle */
.p-chart-wrap { position: relative; height: 340px; }
@media (max-width: 600px) { .p-chart-wrap { height: 260px; } }
.p-events { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 18px; font-size: 0.82rem; }
.p-events div { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
.p-events .p-n {
  flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--forest); color: var(--white);
  font-size: 0.7rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px;
}
.p-events .p-when { color: var(--stone); }
.p-clock-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.p-clock { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 0.82rem; }
.p-clock th, .p-clock td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--cream-dark); vertical-align: top; }
.p-clock th { font: 600 0.7rem/1.2 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--mist); border-top: 0; }
.p-clock td:first-child { font-weight: 600; white-space: nowrap; }
.p-clock .on { background: var(--warning-bg); }
.p-clock th.on { color: var(--warning); }
.p-predict { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.p-predict > div { border-top: 3px solid var(--cream-border); padding-top: 8px; }
.p-predict .p-num { font-size: 1.6rem; margin: 4px 0; }
.p-predict .p-sub { font-size: 0.75rem; color: var(--stone); }
@media (max-width: 560px) { .p-predict { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Report */
.p-check { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.p-check td { padding: 10px 8px 10px 0; border-top: 1px solid var(--cream-dark); vertical-align: top; }
.p-check td:first-child { width: 28px; font-weight: 700; color: var(--forest); }
.p-check .p-val { font-weight: 600; white-space: nowrap; }
.p-check .p-read { color: var(--stone); }
@media (max-width: 560px) {
  .p-check td { display: block; padding: 2px 0; border-top: 0; }
  .p-check tr { display: block; padding: 10px 0; border-top: 1px solid var(--cream-dark); }
  .p-check td:first-child { display: inline; width: auto; }
  .p-check td:nth-child(2) { display: inline; }
}
.p-subscribe { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.p-subscribe .p-field { flex: 1 1 180px; }
.p-subscribe-status { font-size: 0.85rem; color: var(--stone); min-height: 1.2em; }

/* Owner edit panel */
.p-edit { border: 2px dashed var(--amber); background: var(--warning-bg); }
.p-edit h2 { color: var(--warning); }
.p-edit .p-form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.p-edit .p-span { grid-column: 1 / -1; }
.p-edit .p-light-row { display: grid; grid-template-columns: 110px 110px 1fr; gap: 8px; align-items: center; }
.p-edit .p-light-row label { font-size: 0.85rem; font-weight: 600; }
.p-edit-status { font-size: 0.85rem; color: var(--stone); }
@media (max-width: 700px) {
  .p-edit .p-form-grid { grid-template-columns: 1fr; }
  .p-edit .p-light-row { grid-template-columns: 1fr; }
}

/* Footer */
.p-footer {
  max-width: 1180px; margin: 28px auto 0; padding: 18px var(--page-gutter) 28px;
  border-top: 1px solid var(--cream-border);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 20px;
  font-size: 0.78rem; color: var(--mist);
}
.p-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.p-footer button, .p-footer a {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: 500 0.8rem/1.4 var(--font-body); color: var(--stone); text-decoration: none;
}
.p-footer button:hover, .p-footer a:hover { color: var(--forest); text-decoration: underline; }

/* First-visit strip */
.p-intro {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--white); border: 1px solid var(--cream-border); border-radius: 12px; padding: 10px 16px;
  font-size: 0.85rem; color: var(--stone);
}
.p-intro b { color: var(--forest); }
.p-intro button { background: none; border: 0; padding: 4px; cursor: pointer; color: var(--mist); font-size: 1rem; line-height: 1; }

@media print {
  .p-bar, .p-footer, .p-owner-only, .p-btn { display: none !important; }
}

/* Judgement lights that have not been rated for three weeks */
.p-grey { color: var(--mist); }
.p-dot.p-grey { background: var(--cream-border); border: 1px solid var(--mist); }
.p-pill.p-grey { background: var(--cream-dark); }

/* Outlook card on This week */
.p-outlook-chart { position: relative; height: 190px; }
@media (max-width: 560px) { .p-outlook-chart { height: 160px; } }

/* Weaner / A2/3 switch on the outlook card */
.p-seg { display: inline-flex; border: 1px solid var(--cream-border); border-radius: 999px; padding: 2px; background: var(--cream); }
.p-seg button { min-height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: none; cursor: pointer; font: 600 0.8rem/1 var(--font-body); color: var(--stone); }
.p-seg button.on { background: var(--forest); color: var(--white); }

/* Tripwire crossings under the cycle chart */
.p-trips { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; border-top: 1px solid var(--cream-dark); padding-top: 10px; }
.p-trips-head { display: flex; align-items: center; gap: 8px; color: var(--stone); flex-wrap: wrap; }
.p-trips-head b { color: var(--oxblood); }
.p-tri { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid var(--oxblood); }
.p-trips .p-when { font-weight: 600; color: var(--ink); }
