:root {
  color-scheme: light;
  --bg: #f8faf8;
  --surface: #ffffff;
  --surface-muted: #f1f4f2;
  --ink: #1f2523;
  --muted: #4f5b56;
  --line: #d5ddd8;
  --accent: #2f6f63;
  --accent-dark: #24564d;
  --accent-soft: #dfeeea;
  --danger: #a63d34;
  --danger-soft: #f6e3e0;
  --warning: #8a5a00;
  --warning-soft: #fff4d6;
  --shadow: 0 8px 22px rgba(31, 37, 35, 0.06);
  --font-ui: "IBM Plex Sans", "Avenir Next", "Aptos", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: "Avenir Next", "IBM Plex Sans", "Aptos Display", Inter,
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-data: "IBM Plex Mono", "SF Mono", "Roboto Mono", Menlo, Monaco,
    Consolas, monospace;
}

/* v0.1.2: the manually selected stage drives this accessible visual; records never auto-advance it. */
.project-stage-visual {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 32px;
  margin-bottom: 24px;
  padding: 28px 34px;
  overflow: visible;
  border: 1px solid rgba(166, 116, 255, 0.34);
  border-radius: 24px;
  background:
    radial-gradient(circle at 88% 16%, rgba(146, 91, 255, 0.24), transparent 34%),
    linear-gradient(135deg, rgba(23, 19, 40, 0.98), rgba(36, 24, 61, 0.98));
  box-shadow: 0 20px 60px rgba(10, 7, 20, 0.28);
}

.project-stage-copy h2 {
  margin: 8px 0;
  font-size: clamp(1.45rem, 2.6vw, 2.15rem);
}

.project-stage-copy p {
  max-width: 600px;
  margin: 0 0 18px;
  color: var(--muted-text, #b9b3c9);
}

.project-stage-control-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: nowrap;
}

.project-stage-control-row .project-overall-control {
  margin: 0;
}

.project-stage-visual .project-overview-status-dropdown {
  width: max-content;
}

.project-stage-visual .project-overview-status-menu {
  top: calc(100% + 8px);
  right: auto;
  left: 0;
  z-index: 40;
}

.project-beaker {
  position: relative;
  width: 112px;
  height: 138px;
  justify-self: center;
  overflow: hidden;
  border: 5px solid rgba(243, 238, 255, 0.9);
  border-top: 0;
  border-radius: 10px 10px 32px 32px;
  filter: drop-shadow(0 14px 24px rgba(5, 2, 15, 0.36));
}

.project-beaker::before {
  content: "";
  position: absolute;
  z-index: 3;
  top: 0;
  left: -15px;
  width: 132px;
  height: 10px;
  border: 5px solid rgba(243, 238, 255, 0.9);
  border-radius: 999px;
  background: transparent;
}

.project-beaker-fill {
  --beaker-fill: 12%;
  position: absolute;
  inset: auto 0 0;
  height: var(--beaker-fill);
  background:
    radial-gradient(circle at 25% 18%, rgba(255, 255, 255, 0.75) 0 3px, transparent 4px),
    radial-gradient(circle at 67% 38%, rgba(255, 255, 255, 0.55) 0 2px, transparent 3px),
    linear-gradient(180deg, #b98cff, #7545ef 62%, #5330bd);
  box-shadow: 0 -8px 22px rgba(175, 119, 255, 0.48);
  transition: height 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.project-beaker-fill::before {
  content: "";
  position: absolute;
  top: -7px;
  left: -5%;
  width: 110%;
  height: 14px;
  border-radius: 50%;
  background: #c8a6ff;
  animation: formul8r-beaker-wave 3s ease-in-out infinite;
}

.project-beaker-shine {
  position: absolute;
  z-index: 2;
  top: 22px;
  left: 16px;
  width: 9px;
  height: 74px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

@keyframes formul8r-beaker-wave {
  0%, 100% { transform: translateX(-2px) rotate(-1deg); }
  50% { transform: translateX(2px) rotate(1deg); }
}

.project-details-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}

.project-details-form > fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 16px;
  min-width: 0;
  margin: 0;
  padding: 20px;
  border: 1px solid rgba(166, 116, 255, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.project-details-form > fieldset > legend {
  padding: 0 8px;
  color: #d8c3ff;
  font-weight: 800;
}

/* Previous misalignment: the helper-text row stretched sibling label grids, shifting the launch-date control down; pin both row fields to the top. */
.project-details-form > fieldset > label,
.project-details-form > fieldset > .project-size-field { align-self: start; }

.project-details-form label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted-text, #b9b3c9);
  font-size: 0.82rem;
  font-weight: 700;
}

.project-details-form input,
.project-details-form textarea {
  width: 100%;
}

.project-size-field { display: grid; gap: 7px; min-width: 0; color: var(--muted-text, #b9b3c9); font-size: 0.82rem; font-weight: 700; }
.project-size-field > label { display: block; }
.project-size-controls { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 10px; min-width: 0; }
.project-size-field small { color: var(--muted-text, #a9a3b7); font-size: 0.72rem; font-weight: 400; }
.project-size-unit-dropdown { min-width: 0; }
.project-details-form .project-size-unit-dropdown .project-status-trigger { box-sizing: border-box; width: 100%; min-height: var(--control-h-md); padding: 0 14px; border: 1px solid rgba(231, 237, 234, 0.16); border-radius: var(--radius-control); background: rgba(5, 6, 7, 0.72); color: var(--ink); font: inherit; font-weight: 500; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025); transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease; }
.project-details-form .project-size-unit-dropdown .project-status-trigger:focus-visible,
.project-details-form .project-size-unit-dropdown.is-open .project-status-trigger { border-color: rgba(35, 201, 133, 0.76); outline: none; box-shadow: 0 0 0 3px rgba(35, 201, 133, 0.14); }
.project-size-unit-dropdown .project-status-menu { z-index: 50; }

.project-details-field-wide,
.project-details-actions {
  grid-column: 1 / -1;
}

.project-classification-field {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}

.project-classification-field legend {
  padding: 0 5px;
  color: var(--muted-text, #b9b3c9);
  font-size: 0.82rem;
  font-weight: 700;
}

.project-classification-field label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.project-classification-field input {
  width: auto;
}

.project-details-assignment {
  display: grid;
  gap: 5px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(146, 91, 255, 0.09);
}

.project-details-assignment span,
.project-details-assignment small {
  color: var(--muted-text, #b9b3c9);
}

.project-details-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

@media (max-width: 900px) {
  .project-stage-visual {
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 18px;
    padding: 24px;
  }

  .project-details-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .project-stage-visual {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .project-stage-visual .project-overview-status-dropdown {
    margin-inline: auto;
  }

  .project-stage-visual .project-overview-status-menu {
    right: 50%;
    left: auto;
    transform: translateX(50%);
  }

  .project-beaker {
    grid-row: 1;
  }

  .project-details-form > fieldset {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .project-details-field-wide,
  .project-details-actions {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .project-beaker-fill {
    transition: none;
  }

  .project-beaker-fill::before {
    animation: none;
  }
}

/* Two-page dashboard/project UI. Previous success: keep AJ-New-Code self-contained
   and do not edit the professional formul8r folder for demo-only UI changes. */
/* Success: use local font stacks only so the demo's lab-tech typography does
   not depend on Google Fonts, CDNs, or any external request during client demos. */
.app-page-header {
  max-width: 1320px;
  margin: 0 auto;
}

.dashboard-section,
.project-page > .project-tab-list,
.project-page > .project-panel {
  max-width: 1320px;
  margin-right: auto;
  margin-left: auto;
}

.project-page-header {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0 24px;
  border-bottom: 1px solid var(--line);
}

.project-page-header h1 {
  margin: 8px 0 0;
  font-size: 2.35rem;
  line-height: 1.08;
}

.project-page-header p:last-child {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
}

.back-link {
  min-height: auto;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
}

.project-tab-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 20px 0 0;
}

.project-tab {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.project-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.project-tab.is-locked {
  border-style: dashed;
  background: #f6f8f7;
  color: #8b9691;
}

.project-panel {
  padding: 22px 0 40px;
}

.panel-heading {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.65rem;
}

.panel-heading p {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
}

.brief-form,
.feedback-form {
  max-width: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 37, 35, 0.28);
}

.modal-card {
  width: min(100%, 440px);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 46px rgba(31, 37, 35, 0.16);
}

.modal-card h2 {
  margin: 0 0 18px;
  font-size: 1.45rem;
}

.modal-kicker {
  margin: 0 0 8px;
  color: var(--warning);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.privacy-modal-card {
  width: min(100%, 520px);
}

.feedback-saved-card {
  width: min(100%, 500px);
}

.privacy-modal-copy,
.privacy-modal-warning {
  margin: 0 0 16px;
  color: var(--muted);
  font-weight: 650;
  line-height: 1.5;
}

.privacy-modal-warning {
  padding: 12px 14px;
  border: 1px solid rgba(138, 90, 0, 0.24);
  border-radius: 6px;
  background: var(--warning-soft);
  color: var(--warning);
}

.privacy-modal-actions {
  justify-content: flex-end;
}

#unsaved-changes-modal {
  /* Previous F8-022: the task modal at 1200 concealed the discard confirmation at 1000. */
  z-index: 1300;
}

.unsaved-changes-card > p:not(.modal-kicker) {
  color: var(--muted);
  line-height: 1.5;
}

.unsaved-changes-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-heading-row {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
}

.modal-close-action {
  flex: 0 0 auto;
}

.aio-feedback-card {
  width: min(100%, 760px);
  max-height: min(86vh, 760px);
  overflow: auto;
}

.aio-feedback-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.feedback-empty-state {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-weight: 800;
}

.aio-feedback-project {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  overflow: hidden;
}

.aio-feedback-project-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.aio-feedback-project-header h3 {
  margin: 0;
  font-size: 1rem;
}

.aio-feedback-project-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-weight: 750;
}

.aio-feedback-items {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.aio-feedback-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
}

.aio-feedback-score {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.aio-feedback-score strong {
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1;
}

.aio-feedback-score span,
.feedback-saved-at {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.aio-feedback-copy {
  min-width: 0;
}

.feedback-saved-at {
  margin: 0 0 8px;
}

.aio-feedback-copy dl {
  display: grid;
  gap: 9px;
  margin: 0;
}

.aio-feedback-copy dt {
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

.aio-feedback-copy dd {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.modal-card label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.modal-card input,
.modal-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}

.modal-card input {
  min-height: 48px;
  padding: 0 13px;
}

.modal-card textarea {
  padding: 12px 13px;
}

.related-formula-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.related-formula-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.related-formula-card h3,
.feedback-question h3 {
  margin: 6px 0 0;
  font-size: 1.1rem;
}

.related-formula-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.feedback-question {
  display: grid;
  gap: 8px;
}

.feedback-question textarea {
  width: 100%;
  min-height: 108px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}

.rating-control {
  align-items: center;
}

@media (max-width: 840px) {
  .project-tab-list,
  .project-card,
  .project-record-main,
  .related-formula-card {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .project-page-header {
    display: grid;
  }
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body:has(#dashboard-screen:not(.hidden)) {
  background: #f3f6f4;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: 100%;
  margin: 0 auto;
  padding: 24px 28px;
}

.auth-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: calc(100vh - 72px);
}

.auth-stack {
  width: min(100%, 460px);
  margin: 0 auto;
}

.auth-page-title,
.dashboard-header h1 {
  max-width: 720px;
  margin: 0;
  font-size: 2.05rem;
  line-height: 1.12;
  letter-spacing: 0;
  text-align: center;
}

.auth-page-title {
  margin-bottom: 22px;
  font-size: 2.4rem;
}

.detail-header h1 {
  margin: 0;
  font-size: 2.05rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.auth-intro p,
.dashboard-header p {
  max-width: 620px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.demo-note {
  display: grid;
  gap: 4px;
  width: min(100%, 420px);
  margin-top: 30px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
}

.demo-note strong {
  color: var(--ink);
}

.auth-panel,
.project-card,
.placeholder-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.auth-panel {
  padding: 30px;
}

.auth-panel .auth-form {
  margin-top: 24px;
}

.demo-credentials {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
  text-align: center;
}

.demo-credentials strong {
  color: var(--ink);
}

.tab-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.tab-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab-button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.auth-text-action {
  width: fit-content;
  margin: -4px auto 0;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 750;
  text-decoration: none;
}

.auth-form label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-form input,
.brief-form input[type="file"],
.brief-form textarea,
.feedback-form textarea,
.editor-notes-panel textarea,
.assistant-prompt-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
}

.auth-form input {
  min-height: 46px;
  padding: 0 13px;
}

.brief-form input[type="file"] {
  min-height: 48px;
  padding: 12px;
}

.brief-form textarea {
  min-height: 280px;
  padding: 15px;
  resize: vertical;
}

.feedback-form textarea {
  min-height: 112px;
  padding: 14px;
  resize: vertical;
}

.editor-notes-panel textarea,
.assistant-prompt-panel textarea {
  min-height: 104px;
  padding: 12px;
  resize: vertical;
}

.assistant-prompt-panel textarea {
  background: #f6f8f7;
  color: var(--muted);
}

.auth-form input:focus-visible,
.brief-form input[type="file"]:focus-visible,
.brief-form textarea:focus-visible,
.feedback-form textarea:focus-visible,
.feedback-form input:focus-visible,
.editor-notes-panel textarea:focus-visible,
.assistant-prompt-panel textarea:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(47, 111, 99, 0.28);
  outline-offset: 2px;
}

.primary-action,
.secondary-action,
.text-action {
  min-height: 48px;
  border-radius: 6px;
  font-weight: 800;
}

.primary-action {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.primary-action:disabled {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--muted);
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-action:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.secondary-action:disabled,
.secondary-action:disabled:hover {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--muted);
}

.disabled-action,
.disabled-action:hover {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--muted);
}

.text-action {
  width: fit-content;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.92rem;
}

.error-message {
  color: var(--danger);
}

.error-message:not(:empty) {
  padding: 10px 12px;
  border: 1px solid rgba(166, 61, 52, 0.24);
  border-radius: 6px;
  background: var(--danger-soft);
}

.success-message:not(:empty),
.warning-message:not(:empty) {
  padding: 10px 12px;
  border-radius: 6px;
}

.success-message:not(:empty) {
  border: 1px solid rgba(47, 111, 99, 0.24);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.warning-message:not(:empty) {
  border: 1px solid rgba(138, 90, 0, 0.26);
  background: var(--warning-soft);
  color: var(--warning);
}

.hidden {
  display: none !important;
}

.notification-region {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1200;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.app-notification {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid rgba(184, 248, 221, 0.14);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  background: rgba(15, 18, 20, 0.96);
  color: var(--ink);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
  pointer-events: auto;
}

.app-notification strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.app-notification p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.app-notification.is-warning {
  border-left-color: var(--warning);
}

.app-notification.is-error {
  border-left-color: var(--danger);
}

.app-notification-dismiss {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(184, 248, 221, 0.14);
  border-radius: 999px;
  background: rgba(238, 248, 243, 0.06);
  color: var(--muted);
  font-weight: 900;
}

.dashboard,
.detail-screen {
  min-height: calc(100vh - 72px);
}

.dashboard-header,
.detail-header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 26px 0 34px;
  border-bottom: 1px solid var(--line);
}

.dashboard-header {
  align-items: center;
  padding: 18px 0 24px;
}

.workflow-progress {
  padding: 14px 0 0;
}

.workflow-step-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  margin: 0;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
  list-style: none;
}

.workflow-step {
  display: flex;
  gap: 7px;
  align-items: center;
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.workflow-step span {
  display: grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 900;
}

.workflow-step strong {
  overflow-wrap: anywhere;
  font-size: 0.84rem;
}

.workflow-step.is-complete {
  background: transparent;
  color: var(--accent-dark);
}

.workflow-step.is-complete span {
  border-color: var(--accent-soft);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.workflow-step.is-current {
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}

.workflow-step.is-current span {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.dashboard-header .primary-action,
.dashboard-header .secondary-action,
.detail-header .secondary-action {
  min-width: 110px;
  padding: 0 18px;
}

.dashboard-section {
  padding: 22px 0 34px;
}

.section-heading {
  display: flex;
  gap: 20px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0;
}

.section-heading p {
  max-width: 400px;
  margin: 0;
  color: var(--muted);
}

.project-list,
.placeholder-grid,
.workspace-preview,
.related-formula-list,
.assistant-suggestion-list {
  display: grid;
  gap: 18px;
}

.project-list {
  grid-template-columns: 1fr;
  gap: 10px;
}

.project-card,
.placeholder-panel {
  padding: 22px;
  box-shadow: none;
}

.project-card {
  display: grid;
  grid-template-columns: minmax(170px, 0.25fr) minmax(0, 1fr) minmax(160px, auto);
  gap: 18px;
  align-items: center;
  min-height: 112px;
  padding: 18px 20px;
  background: #ffffff;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.project-card:hover {
  border-color: rgba(47, 111, 99, 0.32);
  box-shadow: 0 10px 24px rgba(31, 37, 35, 0.06);
  transform: translateY(-1px);
}

.project-card-topline {
  display: grid;
  gap: 10px;
  align-items: start;
  justify-content: start;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-chip {
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid #bfd7e6;
  border-radius: 999px;
  background: #ecf6fb;
  color: #2e5c73;
  font-weight: 800;
}

.project-updated {
  color: var(--muted);
  font-weight: 700;
}

.project-record-main {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.project-card h3,
.placeholder-panel h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.project-card p,
.placeholder-panel p,
.detail-header p {
  color: var(--muted);
}

.project-card p {
  margin: 0;
}

.project-category {
  color: var(--accent-dark) !important;
  font-size: 0.9rem;
  font-weight: 800;
}

.project-record-footer {
  display: grid;
  gap: 10px;
  justify-items: end;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.project-card .text-action {
  width: auto;
  min-width: 118px;
  margin: 0;
  background: var(--accent-soft);
}

.placeholder-grid,
.brief-layout,
.feedback-layout,
.workspace-preview {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 28px 0;
}

.placeholder-panel {
  min-height: 220px;
}

.placeholder-panel p {
  margin: 12px 0 0;
}

.brief-layout {
  display: grid;
  gap: 18px;
}

.feedback-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
}

.brief-form,
.feedback-form,
.brief-guidance {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.brief-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

#manual-brief-button {
  border-color: rgba(35, 201, 133, 0.55);
  background: rgba(35, 201, 133, 0.16);
  color: var(--accent-dark);
  font-weight: 900;
}

#manual-brief-button:hover,
#manual-brief-button:focus-visible {
  border-color: rgba(35, 201, 133, 0.78);
  background: rgba(35, 201, 133, 0.24);
  color: var(--ink);
}

.manual-brief-card {
  width: min(94vw, 1080px);
  max-height: min(90vh, 820px);
  overflow: auto;
}

.manual-brief-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.manual-brief-grid label:first-child,
.manual-brief-grid label:nth-child(6) {
  grid-column: 1 / -1;
}

.manual-brief-grid label {
  display: grid;
  gap: 9px;
  margin: 0;
}

.manual-brief-grid span {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 850;
}

.manual-brief-grid input,
.manual-brief-grid textarea {
  font-size: 1rem;
  line-height: 1.45;
}

.manual-brief-grid textarea {
  min-height: 132px;
  resize: vertical;
}

@media (max-width: 720px) {
  .manual-brief-grid {
    grid-template-columns: 1fr;
  }
}

/* Success: the login is one centered card on a full-screen canvas, without the workspace's outer modal frame. */
.app-shell:has(#auth-screen:not(.hidden)) {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  padding: 0;
}

#auth-screen.auth-layout:not(.hidden) {
  min-height: 100vh;
  padding: 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.feedback-form {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.brief-form label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 800;
}

.brief-upload-field {
  display: grid;
  gap: 8px;
}

.file-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.download-brief-file {
  justify-self: start;
  min-height: 40px;
  padding: 0 14px;
}

.feedback-question {
  display: grid;
  gap: 10px;
  margin: 0;
}

.feedback-question h2 {
  margin: 8px 0 0;
  font-size: 1.2rem;
  letter-spacing: 0;
}

.feedback-question label,
.trust-fieldset legend,
.rating-control label {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 800;
}

.rating-control {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(160px, 2fr) 48px;
  gap: 12px;
  align-items: center;
}

.rating-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.rating-range-wrap {
  display: grid;
  gap: 6px;
}

.rating-scale-labels {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.rating-control output {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 1.1rem;
  font-weight: 900;
}

.trust-fieldset {
  padding: 0;
  border: 0;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.radio-card {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: #f6fbf9;
  box-shadow: 0 0 0 3px rgba(47, 111, 99, 0.12);
}

.field-help {
  margin: 0 0 12px;
  color: var(--muted);
}

.review-summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.review-summary-strip article {
  min-height: auto;
  padding: 12px 14px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
}

.review-summary-strip article:last-child {
  border-right: 0;
}

.review-summary-strip span,
.feedback-preview dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.review-summary-strip strong,
.feedback-preview dd {
  display: block;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 800;
}

.brief-analysis-results {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 16px;
}

.brief-analysis-heading {
  display: grid;
  gap: 4px;
}

.brief-analysis-heading strong {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

.brief-analysis-results span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.brief-analysis-results p {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.45;
}

.brief-analysis-meta,
.brief-analysis-facts,
.brief-analysis-lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.brief-analysis-meta article,
.brief-analysis-facts article,
.brief-analysis-facts div {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.brief-analysis-meta strong {
  color: var(--ink);
}

.brief-analysis-facts ul,
.brief-analysis-lists ul {
  min-height: 40px;
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-weight: 700;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-actions .primary-action,
.form-actions .secondary-action {
  padding: 0 18px;
}

.brief-guidance {
  align-self: start;
  padding: 22px;
}

.brief-guidance h2 {
  margin: 12px 0 0;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.brief-guidance ul {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  padding-left: 20px;
  color: var(--ink);
}

.brief-guidance p {
  margin: 0;
  color: var(--muted);
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(270px, 0.78fr) minmax(0, 1.7fr);
  gap: 20px;
  padding: 28px 0;
  align-items: start;
}

.workspace-context,
.workspace-workbench {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.workspace-context {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.workspace-context h2,
.workbench-heading h2,
.formula-editor-summary h3,
.context-group h3 {
  margin: 0;
  letter-spacing: 0;
}

.workspace-context h2,
.workbench-heading h2 {
  margin-top: 10px;
  font-size: 1.35rem;
}

.workspace-status-line {
  margin: 0;
  color: var(--accent-dark);
  font-weight: 800;
}

.workspace-context p,
.workbench-heading p,
.related-formula-card p,
.assistant-suggestion-card p,
.editor-notes-panel p,
.assistant-prompt-panel p,
.assistant-selected-panel p {
  margin: 0;
  color: var(--muted);
}

.brief-summary-box {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.brief-summary-box span,
.formula-total-box span,
.context-group h3 {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.context-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 18px;
}

.spec-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.spec-item {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.spec-item span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.spec-item strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.workspace-workbench {
  padding: 22px;
}

.workbench-heading,
.formula-editor-summary {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
}

.formula-heading-actions {
  display: flex;
  gap: 12px;
  align-items: stretch;
  justify-content: flex-end;
}

.formula-heading-actions #generate-formula-button {
  min-width: 190px;
  min-height: 70px;
  padding: 0 18px;
  white-space: nowrap;
}

.formula-editor-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.formula-editor-actions .primary-action {
  min-width: 132px;
  padding: 0 16px;
}

.workspace-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 20px 0;
  padding: 5px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.workspace-tab {
  display: grid;
  gap: 2px;
  min-height: 56px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.tab-detail {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.workspace-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

.workspace-tab.active .tab-detail {
  color: var(--accent-dark);
}

.workspace-panel {
  min-height: 430px;
}

.related-formula-list,
.assistant-suggestion-list {
  grid-template-columns: 1fr;
  gap: 12px;
}

.related-formula-card,
.assistant-suggestion-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.related-formula-card,
.assistant-suggestion-card {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: auto;
  padding: 16px;
}

.related-formula-card {
  cursor: pointer;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.related-formula-card:hover {
  border-color: rgba(47, 111, 99, 0.45);
  transform: translateY(-1px);
}

.related-formula-card.selected {
  border-color: var(--accent);
  background: #f6fbf9;
  box-shadow: 0 0 0 3px rgba(47, 111, 99, 0.14);
}

.related-formula-header {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.formula-rank-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.rank-label {
  padding: 5px 8px;
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  background: #f6fbf9;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.match-score {
  min-width: 54px;
  color: var(--accent-dark);
  font-size: 1.2rem;
  text-align: right;
}

.formula-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.formula-tag {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.related-formula-card.selected .formula-tag {
  border-color: var(--accent-soft);
  color: var(--accent-dark);
}

.related-formula-card h3,
.assistant-suggestion-card h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.assistant-note {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.formula-total-box {
  min-width: 130px;
  padding: 12px 14px;
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.formula-total-box.is-valid {
  border-color: rgba(47, 111, 99, 0.28);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.formula-total-box.is-warning {
  border-color: rgba(138, 90, 0, 0.34);
  background: var(--warning-soft);
  color: var(--warning);
}

.formula-total-box strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
}

.formula-editor-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.formula-editor-metrics article {
  min-height: auto;
  padding: 12px 14px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
}

.formula-editor-metrics article:last-child {
  border-right: 0;
}

.formula-editor-metrics span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.formula-editor-metrics strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.editor-notes-panel,
.assistant-prompt-panel,
.assistant-selected-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.editor-notes-panel {
  display: grid;
  gap: 12px;
  margin: 12px 0 0;
  padding: 16px;
}

.editor-notes-panel h3,
.assistant-prompt-panel h3,
.assistant-selected-panel h3 {
  margin: 6px 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.assistant-placeholder-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.assistant-prompt-panel,
.assistant-selected-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
}

.assistant-selected-panel {
  background: var(--surface-muted);
}

.assistant-suggestion-card.selected {
  border-color: var(--accent);
  background: #f6fbf9;
  box-shadow: 0 0 0 3px rgba(47, 111, 99, 0.14);
}

.formula-validation-status {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.formula-ingredient-list {
  margin-top: 12px;
  overflow-x: auto;
}

.formula-ingredient-list:empty {
  display: none;
}

.formula-empty-state,
.generated-formula-preview,
.formula-version-empty,
.formula-version-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.formula-empty-state {
  display: grid;
  gap: 8px;
  padding: 22px;
  color: var(--muted);
}

.formula-empty-state strong {
  color: var(--ink);
}

.generated-formula-preview {
  display: grid;
  gap: 16px;
  margin: 16px 0;
  padding: 18px;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.generated-formula-preview .form-actions {
  margin: 0;
}

.formula-version-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.formula-version-empty,
.formula-version-card {
  padding: 12px;
  color: var(--muted);
}

.formula-version-card {
  display: grid;
  gap: 4px;
}

.formula-version-card strong {
  color: var(--ink);
}

.formula-version-card p {
  margin: 0;
}

.formula-editor-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border: 1px solid var(--line);
  border-radius: 8px;
  border-spacing: 0;
  background: var(--surface);
  overflow: hidden;
}

.formula-editor-table th,
.formula-editor-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.formula-editor-table th {
  background: #f4f7f5;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.formula-editor-table tr:last-child td {
  border-bottom: 0;
}

.formula-editor-table td:first-child {
  width: 15%;
}

.formula-editor-table td:nth-child(4) {
  width: 27%;
}

.formula-editor-table td:nth-child(5) {
  width: 12%;
}

.formula-editor-table input,
.formula-editor-table textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.formula-editor-table input {
  min-height: 42px;
  padding: 0 10px;
  text-align: right;
}

.formula-editor-table textarea {
  min-width: 0;
  min-height: 62px;
  padding: 9px 10px;
  resize: vertical;
}

.formula-editor-table input[aria-invalid="true"] {
  border-color: var(--warning);
  background: var(--warning-soft);
}

.ingredient-inci {
  color: var(--accent-dark) !important;
  font-size: 0.9rem;
  font-weight: 800;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.45fr);
  gap: 20px;
  padding: 28px 0;
  align-items: start;
}

.review-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
  padding: 22px;
}

.review-panel h2,
.review-panel h3 {
  margin: 10px 0 0;
  letter-spacing: 0;
}

.review-panel h2 {
  font-size: 1.35rem;
}

.review-panel h3 {
  font-size: 1.05rem;
}

.review-panel p,
.review-formula-row p,
.review-checkpoint-note,
.feedback-learning-note,
.feedback-guidance p {
  color: var(--muted);
}

.review-checkpoint-note,
.feedback-learning-note {
  margin: 8px 0 0;
}

.chemist-checklist {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  background: #f6fbf9;
}

.chemist-checklist ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.chemist-checklist li {
  color: var(--ink);
}

.review-panel-heading {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
}

.review-formula-summary-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.review-summary-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
}

.review-formula-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.review-percent {
  color: var(--accent-dark);
  font-size: 1rem;
  text-align: right;
}

.review-actions {
  margin-top: 18px;
}

.feedback-preview {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.feedback-preview h2 {
  margin: 6px 0 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.feedback-preview dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.feedback-preview dl div {
  min-height: auto;
  padding: 10px 12px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
}

.feedback-preview dl div:last-child {
  border-right: 0;
}

.feedback-preview dd {
  margin-left: 0;
}

.feedback-guidance {
  max-width: 620px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding: 0 18px;
}

.workspace-card {
  display: flex;
  flex-direction: column;
  min-height: 280px;
  padding: 22px;
  box-shadow: none;
}

.card-kicker {
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace-card h2 {
  margin: 12px 0 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.workspace-card p {
  margin: 12px 0 20px;
  color: var(--muted);
}

.workspace-card .text-action {
  margin-top: auto;
}

.session-list {
  display: grid;
  gap: 12px;
  margin: auto 0 0;
}

.session-list div {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.session-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.session-list dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 24px, 680px);
    padding: 24px 0;
  }

  .auth-layout {
    min-height: calc(100vh - 48px);
  }

  .auth-page-title,
  .dashboard-header h1 {
    font-size: 2.35rem;
  }

  .detail-header h1 {
    font-size: 1.9rem;
  }

  .dashboard-header {
    display: grid;
  }

  .detail-header {
    display: grid;
  }

  .header-actions,
  .dashboard-header .primary-action,
  .dashboard-header .secondary-action,
  .detail-header .secondary-action {
    width: 100%;
  }

  .header-actions {
    display: grid;
  }

  .project-list,
  .placeholder-grid,
  .brief-layout,
  .feedback-layout,
  .formula-editor-metrics,
  .review-summary-strip,
  .feedback-preview dl,
  .workspace-preview,
  .workspace-layout,
  .assistant-placeholder-layout,
  .related-formula-list,
  .assistant-suggestion-list {
    grid-template-columns: 1fr;
  }

  .project-card,
  .project-record-main {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .project-record-footer {
    justify-items: start;
  }

  .workflow-step-list {
    gap: 8px 12px;
  }

  .formula-editor-metrics article,
  .review-summary-strip article,
  .feedback-preview dl div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .formula-editor-metrics article:last-child,
  .review-summary-strip article:last-child,
  .feedback-preview dl div:last-child {
    border-bottom: 0;
  }

  .section-heading {
    display: grid;
    align-items: start;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .workbench-heading,
  .formula-editor-summary,
  .review-panel-heading {
    display: grid;
  }

  .formula-heading-actions {
    justify-content: stretch;
  }

  .formula-heading-actions #generate-formula-button,
  .formula-heading-actions .formula-total-box {
    width: 100%;
  }

  .formula-editor-actions,
  .review-layout {
    grid-template-columns: 1fr;
  }

  .formula-editor-actions {
    display: grid;
  }

  .rating-control,
  .choice-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .auth-panel {
    padding: 22px;
  }

  .auth-page-title {
    font-size: 2rem;
  }

  .dashboard-header .secondary-action,
  .dashboard-header .primary-action,
  .detail-header .secondary-action {
    width: 100%;
  }

  .project-card-topline {
    display: grid;
    justify-content: start;
  }

  .status-chip {
    max-width: 100%;
  }

  .workspace-tabs {
    grid-template-columns: 1fr;
  }

  .formula-heading-actions {
    display: grid;
  }

  .workflow-step-list {
    grid-template-columns: 1fr;
  }

  .review-formula-row,
  .spec-grid {
    grid-template-columns: 1fr;
  }

  .formula-ingredient-list {
    overflow-x: visible;
  }

  .formula-editor-table {
    min-width: 0;
    border: 0;
    background: transparent;
  }

  .formula-editor-table thead {
    display: none;
  }

  .formula-editor-table,
  .formula-editor-table tbody,
  .formula-editor-table tr,
  .formula-editor-table td {
    display: block;
    width: 100%;
  }

  .formula-editor-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
  }

  .formula-editor-table td {
    display: grid;
    grid-template-columns: minmax(94px, 0.36fr) minmax(0, 1fr);
    gap: 10px;
    border-bottom: 1px solid var(--line);
  }

  .formula-editor-table td:last-child {
    border-bottom: 0;
  }

  .formula-editor-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  .formula-editor-table input {
    text-align: left;
  }

  .review-percent {
    text-align: left;
  }
}

/* Final overrides for the two-page dashboard/project rebuild. */
.dashboard-section,
.project-page > .project-tab-list,
.project-page > .project-panel,
.app-page-header {
  max-width: 1320px;
  margin-right: auto;
  margin-left: auto;
}

.project-page-header {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0 24px;
  border-bottom: 1px solid var(--line);
}

.project-tab-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 20px 0 0;
}

.project-tab {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.project-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.project-tab.is-locked {
  border-style: dashed;
  background: #f6f8f7;
  color: #8b9691;
}

.project-panel {
  padding: 22px 0 40px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 37, 35, 0.28);
}

.modal-card {
  width: min(100%, 440px);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 46px rgba(31, 37, 35, 0.16);
}

.modal-card input,
.feedback-question textarea {
  width: 100%;
}

.related-formula-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 840px) {
  .project-tab-list,
  .project-card,
  .project-record-main,
  .related-formula-card {
    grid-template-columns: 1fr;
  }
}

/* Clean lab software pass. */
@keyframes surfaceIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

h1,
h2,
h3,
.auth-page-title,
.dashboard-header h1,
.project-page-header h1,
.panel-heading h2,
.section-heading h2 {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font-family: var(--font-ui);
}

.eyebrow,
.status-chip,
.project-updated,
.project-category,
.project-record-footer,
.review-summary-strip span,
.feedback-preview dt,
.brief-summary-box span,
.formula-total-box span,
.context-group h3,
.spec-item span,
.rank-label,
.formula-tag,
.formula-editor-metrics span,
.formula-validation-status,
.formula-editor-table th,
.ingredient-row label,
.review-formula-table th {
  font-family: var(--font-data);
  font-weight: 650;
  letter-spacing: 0;
}

.match-score,
.formula-total-box strong,
.formula-editor-metrics strong,
.rating-control output,
.formula-editor-table input,
.review-percent,
.review-formula-table td:last-child {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

.dashboard:not(.hidden),
.project-page:not(.hidden),
.auth-layout:not(.hidden) {
  animation: surfaceIn 180ms ease-out;
}

.app-shell {
  background: #f7faf8;
}

.dashboard-header,
.project-page-header {
  padding-top: 16px;
  padding-bottom: 18px;
}

.dashboard-header h1,
.project-page-header h1 {
  font-size: clamp(2rem, 3.3vw, 3rem);
}

.dashboard-section {
  padding-top: 22px;
}

.section-heading {
  margin-bottom: 12px;
}

.dashboard-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 190px;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.dashboard-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-controls input,
.dashboard-controls select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  text-transform: none;
}

.dashboard-controls input {
  padding: 0 12px;
}

.dashboard-controls select {
  padding: 0 10px;
}

.section-heading h2 {
  font-size: 1.35rem;
}

.project-list {
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.project-card {
  grid-template-columns: 180px minmax(0, 1fr) 138px;
  min-height: 86px;
  padding: 16px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
  transform: none;
}

.project-card:last-child {
  border-bottom: 0;
}

.project-card.is-archived {
  background: #fafafa;
}

.project-card:hover,
.project-card:focus-visible {
  background: #fbfdfc;
  border-color: var(--line);
  box-shadow: none;
  transform: none;
}

.project-card-topline {
  gap: 8px;
}

.status-chip {
  width: fit-content;
  border-radius: 999px;
  background: #eef7f5;
  color: var(--accent-dark);
}

.project-record-main {
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 24px;
}

.project-card h3 {
  font-size: 1.08rem;
}

.project-card p {
  font-size: 0.96rem;
}

.project-record-footer {
  justify-items: end;
}

.project-card .text-action {
  min-height: 38px;
  min-width: 112px;
  padding: 0 12px;
  border: 1px solid transparent;
  background: #e8f3f0;
}

.project-card .archive-project {
  background: #f5f2ef;
  color: #7a5b3f;
}

.project-card .text-action:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.project-empty-state {
  padding: 20px;
  color: var(--muted);
  font-weight: 800;
}

.related-formula-loading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--ink);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  margin-top: 2px;
  flex: 0 0 24px;
  border: 3px solid #d8e8e4;
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: formula-loading-spin 850ms linear infinite;
}

.related-formula-loading-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.related-formula-loading-copy strong {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 1rem;
}

.related-formula-loading-copy > span {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.loading-dots {
  display: inline-flex;
  gap: 3px;
}

.loading-dots span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
  animation: formula-loading-dot 1s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 140ms;
}

.loading-dots span:nth-child(3) {
  animation-delay: 280ms;
}

@keyframes formula-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes formula-loading-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner,
  .loading-dots span {
    animation: none;
  }
}

.project-page-status,
#project-page-status {
  display: inline-flex;
  width: fit-content;
  margin: 0 0 8px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef7f5;
  color: var(--accent-dark);
  letter-spacing: 0;
  text-transform: none;
}

.project-tab-list {
  display: flex;
  gap: 24px;
  padding: 16px 0 0;
  border-bottom: 1px solid var(--line);
}

.project-tab {
  min-height: 42px;
  padding: 0 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  transition:
    color 140ms ease,
    box-shadow 140ms ease;
}

.project-tab.active {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.project-tab.is-locked {
  background: transparent;
  color: #9aa4a0;
  box-shadow: none;
}

.project-panel {
  padding-top: 22px;
  animation: surfaceIn 160ms ease-out;
}

.panel-heading {
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-size: 1.45rem;
}

.panel-heading p,
.feedback-panel .panel-heading p {
  display: none;
}

.brief-form {
  gap: 14px;
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(290px, 0.8fr) minmax(0, 1.35fr);
  gap: 16px;
  padding: 0;
  align-items: start;
}

.related-formula-pane,
.workspace-workbench,
.workspace-context,
.workspace-notes {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.generate-side-panel {
  display: grid;
  gap: 14px;
}

.workspace-side-panel {
  display: grid;
  gap: 14px;
}

.brief-logs-card {
  margin-top: 16px;
}

.workspace-context,
.workspace-notes,
.generation-logs-card {
  margin-top: 0;
}

.generation-logs-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.workspace-notes textarea {
  width: 100%;
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}

.pane-heading,
.workbench-heading {
  margin-bottom: 14px;
}

.pane-heading h3,
.workbench-heading h3 {
  margin: 0;
  font-size: 1.1rem;
}

.pane-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.generation-log-list {
  display: grid;
  gap: 8px;
}

.generation-log-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.generation-log-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.generation-log-item span,
.generation-log-item small,
.generation-log-item em {
  color: var(--muted);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.generation-log-item strong {
  display: block;
  margin: 3px 0;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.25;
}

.generation-log-item em {
  min-width: 78px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-align: center;
}

.log-detail-action {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(35, 201, 133, 0.42);
  border-radius: 999px;
  background: rgba(35, 201, 133, 0.12);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.log-detail-action:disabled {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.58;
}

.log-detail-action.is-empty {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.generation-log-item.is-active {
  border-color: rgba(35, 201, 133, 0.55);
  background: rgba(35, 201, 133, 0.11);
}

.generation-log-item.is-active em,
.generation-log-item.is-complete em {
  color: var(--accent);
}

.generation-log-item.is-complete {
  border-color: rgba(35, 201, 133, 0.22);
}

.generation-log-item.is-error {
  border-color: rgba(166, 61, 52, 0.45);
  background: rgba(166, 61, 52, 0.08);
}

.generation-log-item.is-error em {
  color: var(--danger);
}

.ai-debug-log-card {
  width: min(94vw, 1180px);
  max-height: min(88vh, 860px);
  overflow: hidden;
}

.ai-debug-log-content {
  display: grid;
  gap: 14px;
  max-height: calc(88vh - 148px);
  overflow: auto;
  padding-right: 4px;
}

.ai-debug-call-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.ai-debug-empty-card {
  border-color: rgba(232, 192, 91, 0.46);
  background: rgba(232, 192, 91, 0.08);
}

.ai-debug-call-heading span,
.ai-debug-call-heading small {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ai-debug-call-heading strong {
  display: block;
  margin: 4px 0;
  color: var(--ink);
  font-size: 1rem;
}

.ai-debug-section {
  display: grid;
  gap: 7px;
}

.ai-debug-section h4 {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ai-debug-section pre {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070b0a;
  color: #dfe9e4;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre;
}

.related-formula-list {
  display: grid;
  gap: 10px;
}

.related-formula-card {
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

.related-formula-card:hover {
  transform: translateY(-1px);
}

.related-formula-card.is-selected {
  border-color: var(--accent);
  background: #f2faf8;
}

.related-formula-card .secondary-action {
  width: fit-content;
  min-height: 36px;
  padding: 0 12px;
}

.related-formula-content {
  display: grid;
  gap: 10px;
}

.related-reason-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.related-warning-list {
  display: grid;
  gap: 6px;
}

.related-warning-list span {
  border: 1px solid #e3b7a9;
  border-radius: 6px;
  padding: 8px 10px;
  color: #8a3e2e;
  background: #fff3ef;
  font-size: 0.86rem;
}

.related-score-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.related-score-breakdown span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.formula-editor-metrics {
  margin-bottom: 14px;
}

.formula-ingredient-list {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ingredient-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.ingredient-row:last-child {
  border-bottom: 0;
}

.ingredient-row h3 {
  margin: 2px 0 0;
  font-size: 0.98rem;
}

.ingredient-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.ingredient-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ingredient-row input {
  min-height: 38px;
  padding: 0 8px;
  text-align: right;
}

.review-layout {
  grid-template-columns: minmax(240px, 0.55fr) minmax(0, 1.45fr);
  gap: 16px;
  padding: 0;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 0;
}

.review-panel h3,
.review-panel h4 {
  margin-top: 6px;
}

.review-formula-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.review-formula-table th,
.review-formula-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.review-formula-table th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.review-formula-table td {
  color: var(--ink);
  font-size: 0.92rem;
}

.review-formula-table td span {
  display: block;
  margin-top: 3px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.review-formula-table tr:last-child td {
  border-bottom: 0;
}

.feedback-form {
  gap: 16px;
  max-width: 860px;
}

.feedback-question h3 {
  margin: 0;
}

.panel-heading h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.project-panel[data-project-panel="brief"] .panel-heading,
.project-panel[data-project-panel="feedback"] .panel-heading {
  height: 0;
  margin: 0;
  overflow: hidden;
}

.project-panel[data-project-panel="workspace"] .panel-heading,
.project-panel[data-project-panel="generate"] .panel-heading,
.project-panel[data-project-panel="finalized"] .panel-heading {
  justify-content: flex-end;
}

.project-tab:focus-visible {
  outline: 0;
  box-shadow: 0 2px 0 rgba(47, 111, 99, 0.3);
}

.project-tab.active:focus-visible {
  box-shadow: inset 0 -2px 0 var(--accent), 0 2px 0 rgba(47, 111, 99, 0.2);
}

.historical-formulas-screen:not(.hidden) {
  max-width: 1320px;
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  padding: 36px 0 48px;
}

.historical-formulas-header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 0 24px;
  border-bottom: 1px solid var(--line);
}

.historical-formulas-header h1 {
  margin: 8px 0 0;
  font-size: 2.35rem;
  line-height: 1.08;
}

.historical-page-header {
  align-items: center;
}

.historical-page-header h1 {
  margin: 0;
}

.raw-materials-header {
  align-items: center;
}

.raw-materials-header h1 {
  margin: 0;
}

.historical-formulas-header p:last-child {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
}

.historical-formulas-section {
  padding: 22px 0 0;
}

.history-notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(138, 90, 0, 0.24);
  border-radius: 6px;
  background: var(--warning-soft);
  color: var(--warning);
  font-weight: 800;
}

.historical-formulas-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 0.75fr);
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

.historical-formula-list {
  display: grid;
  gap: 10px;
}

.historical-formula-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, auto);
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.historical-formula-card:hover,
.historical-formula-card:focus-visible,
.historical-formula-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(31, 37, 35, 0.06);
}

.historical-formula-card.is-selected {
  background: var(--accent-soft);
}

.historical-card-main {
  min-width: 0;
}

.historical-card-main h3 {
  margin: 5px 0 0;
  font-size: 1.08rem;
}

.historical-card-main p {
  margin: 5px 0 0;
  color: var(--muted);
}

.historical-card-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  color: var(--muted);
  font-family: var(--font-data);
}

.historical-card-meta strong {
  color: var(--ink);
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.historical-formula-detail {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 116px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-empty-state {
  padding: 28px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.historical-detail-header h2 {
  margin: 6px 0 0;
  font-size: 1.45rem;
}

.historical-detail-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.history-detail-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.history-detail-summary article {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-right: 1px solid var(--line);
}

.history-detail-summary article:last-child {
  border-right: 0;
}

.history-detail-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.history-detail-summary strong {
  font-family: var(--font-data);
}

.historical-detail-tags {
  margin-bottom: 16px;
}

.historical-ingredient-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.historical-ingredient-table th,
.historical-ingredient-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.historical-ingredient-table th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.historical-ingredient-table td:last-child {
  width: 76px;
  font-family: var(--font-data);
  font-weight: 800;
  text-align: right;
}

.raw-material-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.raw-material-actions .secondary-action {
  display: inline-flex;
  width: 220px;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-transform: none;
}

.raw-material-actions .raw-material-upload-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.15;
  text-transform: none;
  cursor: pointer;
}

.raw-materials-screen .historical-formulas-section {
  padding-top: 18px;
}

.raw-materials-screen .section-heading {
  align-items: start;
  margin-bottom: 8px;
}

.raw-materials-screen .raw-material-controls {
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  margin-bottom: 12px;
}

.raw-material-controls .raw-material-actions .secondary-action,
.raw-material-controls .raw-material-actions .raw-material-upload-control {
  min-height: var(--control-h-md);
}

.historical-formulas-screen:not(.raw-materials-screen) .historical-formulas-section {
  padding-top: 18px;
}

.historical-formulas-screen:not(.raw-materials-screen) .section-heading {
  align-items: start;
  margin-bottom: 8px;
}

.historical-formulas-screen:not(.raw-materials-screen) .historical-formula-controls {
  grid-template-columns: minmax(220px, 1fr) 220px;
  align-items: end;
  margin-bottom: 12px;
}

.historical-filter-control {
  display: grid;
  gap: 4px;
  min-width: 220px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.historical-filter-control select {
  width: 220px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 6, 7, 0.58);
  color: var(--ink);
  font: inherit;
  text-transform: none;
}

/* Success: keep raw-materials overflow inside panels so the page cannot pan into empty horizontal space. */
.raw-materials-screen:not(.hidden) {
  max-width: 100%;
  overflow-x: clip;
}

.raw-materials-screen .historical-formulas-section,
.raw-materials-screen .historical-formulas-layout,
.raw-materials-screen .historical-formula-list,
.raw-materials-screen .historical-formula-detail,
.raw-materials-screen .historical-formula-card,
.raw-materials-screen .historical-card-main,
.raw-materials-screen .historical-card-meta,
.raw-materials-screen .history-detail-summary,
.raw-materials-screen .raw-material-detail-table {
  min-width: 0;
  max-width: 100%;
}

.raw-materials-screen .historical-formulas-layout {
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 0.75fr);
}

.raw-materials-screen .historical-card-main h3,
.raw-materials-screen .historical-card-main p,
.raw-materials-screen .historical-card-meta strong,
.raw-materials-screen .historical-card-meta span,
.raw-materials-screen .historical-detail-header h2,
.raw-materials-screen .historical-detail-header p,
.raw-materials-screen .history-detail-summary strong,
.raw-materials-screen .raw-material-detail-table th,
.raw-materials-screen .raw-material-detail-table td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.raw-materials-screen .raw-material-detail-table {
  table-layout: fixed;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.raw-material-detail-table th {
  width: 132px;
}

.raw-material-detail-table td:last-child {
  width: auto;
  font-family: inherit;
  font-weight: 700;
  text-align: left;
}

.modal-card {
  animation: modalIn 140ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 900px) {
  .dashboard-controls {
    grid-template-columns: 1fr;
  }

  .project-card,
  .project-record-main,
  .historical-formulas-header,
  .historical-formulas-layout,
  .historical-formula-card,
  .history-detail-summary,
  .workspace-layout,
  .generate-layout,
  .review-layout,
  .brief-analysis-meta,
  .brief-analysis-facts,
  .brief-analysis-lists,
  .ingredient-row {
    grid-template-columns: 1fr;
  }

  .project-tab-list {
    gap: 14px;
    overflow-x: auto;
  }
}

/* Dark product UI pass. Previous success: keep this final layer additive so ticket-specific behavior stays intact. */
:root {
  color-scheme: dark;
  --bg: #07100e;
  --surface: #0f1c18;
  --surface-muted: #152720;
  --surface-raised: #13231f;
  --surface-strong: #182c25;
  --ink: #eef8f3;
  --muted: #93a8a0;
  --line: rgba(184, 248, 221, 0.16);
  --border: var(--line);
  --accent: #23c985;
  --accent-dark: #72e6b6;
  --accent-soft: rgba(35, 201, 133, 0.14);
  --danger: #ff887c;
  --danger-soft: rgba(255, 136, 124, 0.13);
  --warning: #f6c96d;
  --warning-soft: rgba(246, 201, 109, 0.14);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

html {
  background: #050b09;
}

body,
body:has(#dashboard-screen:not(.hidden)) {
  background:
    linear-gradient(120deg, rgba(35, 201, 133, 0.09), transparent 34%),
    linear-gradient(180deg, #0a1512 0%, #07100e 48%, #050b09 100%);
  color: var(--ink);
}

body::selection {
  background: rgba(35, 201, 133, 0.34);
}

.app-shell {
  position: relative;
  width: min(100%, 1600px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 34px 48px;
  background: transparent;
}

.dashboard:not(.hidden),
.project-page:not(.hidden),
.historical-formulas-screen:not(.hidden),
.auth-layout:not(.hidden) {
  position: relative;
  max-width: none;
  min-height: calc(100vh - 56px);
  padding: 30px;
  border: 1px solid rgba(184, 248, 221, 0.13);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(18, 36, 30, 0.88), rgba(8, 18, 15, 0.92)),
    #0b1512;
  box-shadow: var(--shadow);
}

.auth-layout:not(.hidden) {
  align-items: center;
}

.dashboard-section,
.project-page > .project-tab-list,
.project-page > .project-panel,
.app-page-header,
.historical-formulas-screen:not(.hidden) .app-page-header,
.historical-formulas-section {
  max-width: none;
}

.dashboard-header,
.project-page-header,
.historical-formulas-header {
  padding: 0 0 24px;
  border-bottom: 1px solid var(--line);
}

.dashboard-header h1,
.project-page-header h1,
.historical-formulas-header h1,
.auth-page-title {
  color: var(--ink);
  font-weight: 720;
}

.dashboard-header h1,
.project-page-header h1,
.historical-formulas-header h1 {
  text-align: left;
}

.auth-page-title {
  text-align: center;
}

.dashboard-header p,
.project-page-header p:last-child,
.historical-formulas-header p:last-child,
.section-heading p,
.panel-heading p,
.project-card p,
.workspace-context p,
.workbench-heading p,
.related-formula-card p,
.review-panel p,
.historical-card-main p,
.historical-detail-header p,
.demo-credentials,
.privacy-modal-copy {
  color: var(--muted);
}

.header-actions {
  align-items: center;
}

.primary-action,
.secondary-action,
.text-action {
  border-radius: 12px;
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    color 150ms ease,
    transform 150ms ease,
    box-shadow 150ms ease;
}

.primary-action {
  border-color: rgba(35, 201, 133, 0.72);
  background: linear-gradient(135deg, #22c982, #189d69);
  color: #03110c;
  box-shadow: 0 12px 28px rgba(35, 201, 133, 0.18);
}

.primary-action:hover {
  background: linear-gradient(135deg, #43dda0, #23c985);
  transform: translateY(-1px);
}

.secondary-action,
.text-action,
.back-link {
  border-color: rgba(184, 248, 221, 0.14);
  background: rgba(238, 248, 243, 0.06);
  color: var(--ink);
}

.secondary-action:hover,
.text-action:hover,
.back-link:hover {
  border-color: rgba(35, 201, 133, 0.48);
  background: rgba(35, 201, 133, 0.12);
  color: var(--accent-dark);
}

.primary-action:disabled,
.secondary-action:disabled,
.secondary-action:disabled:hover {
  border-color: var(--line);
  background: rgba(238, 248, 243, 0.05);
  color: rgba(238, 248, 243, 0.42);
  box-shadow: none;
  transform: none;
}

.dashboard-controls input,
.dashboard-controls select,
.auth-form input,
.modal-card input,
.brief-form input[type="file"],
.brief-form textarea,
.feedback-form textarea,
.workspace-notes textarea,
.formula-editor-table input,
.formula-editor-table textarea,
.ingredient-row input,
textarea,
input,
select {
  border-color: rgba(184, 248, 221, 0.14);
  background: rgba(5, 13, 10, 0.48);
  color: var(--ink);
}

.dashboard-controls input::placeholder,
.auth-form input::placeholder,
.brief-form textarea::placeholder,
.feedback-form textarea::placeholder,
.workspace-notes textarea::placeholder {
  color: rgba(147, 168, 160, 0.72);
}

.auth-form input:focus-visible,
.dashboard-controls input:focus-visible,
.dashboard-controls select:focus-visible,
.brief-form input[type="file"]:focus-visible,
.brief-form textarea:focus-visible,
.feedback-form textarea:focus-visible,
.feedback-form input:focus-visible,
.workspace-notes textarea:focus-visible,
.formula-editor-table input:focus-visible,
.formula-editor-table textarea:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(35, 201, 133, 0.25);
  outline-offset: 2px;
}

.auth-panel,
.modal-card,
.project-list,
.project-card,
.placeholder-panel,
.brief-analysis-results,
.related-formula-pane,
.workspace-workbench,
.workspace-context,
.workspace-notes,
.generation-logs-card,
.review-panel,
.feedback-question,
.feedback-preview,
.historical-formula-card,
.historical-formula-detail,
.history-detail-summary,
.formula-editor-metrics,
.formula-ingredient-list,
.review-formula-table,
.brief-summary-box,
.spec-item,
.assistant-note,
.editor-notes-panel,
.assistant-prompt-panel,
.assistant-selected-panel {
  border-color: var(--line);
  background: rgba(15, 28, 24, 0.84);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.18);
}

.project-list {
  gap: 0;
  overflow: hidden;
  border-radius: 18px;
}

.project-card {
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(35, 201, 133, 0.06), transparent 38%),
    rgba(15, 28, 24, 0.82);
}

.project-card:hover,
.project-card:focus-visible {
  background:
    linear-gradient(90deg, rgba(35, 201, 133, 0.12), transparent 42%),
    rgba(21, 39, 32, 0.96);
}

.project-card.is-archived {
  background: rgba(14, 22, 19, 0.78);
}

.project-card h3,
.historical-card-main h3,
.related-formula-card h3,
.review-panel h3,
.feedback-question h3 {
  color: var(--ink);
}

.status-chip,
.project-page-status,
#project-page-status,
.rank-label,
.formula-tag {
  border-color: rgba(35, 201, 133, 0.25);
  background: rgba(35, 201, 133, 0.12);
  color: var(--accent-dark);
}

/* Success: keep formula/material ID kicker text green without the old filled highlight block. */
.card-kicker {
  background: transparent;
  color: var(--accent-dark);
}

.project-category,
.ingredient-inci,
.review-formula-table td span,
.workspace-status-line {
  color: var(--accent-dark) !important;
}

.project-card .text-action,
.project-card .archive-project {
  border-color: rgba(184, 248, 221, 0.13);
  background: rgba(238, 248, 243, 0.06);
  color: var(--ink);
}

.project-card .archive-project {
  color: #e6c896;
}

.dashboard-controls label,
.auth-form label,
.modal-card label,
.ingredient-row label,
.rating-control label,
.file-status,
.project-updated,
.historical-card-meta,
.formula-editor-metrics span,
.brief-analysis-results span,
.brief-analysis-meta span,
.brief-analysis-facts span,
.brief-analysis-lists span,
.history-detail-summary span,
.historical-ingredient-table th,
.review-formula-table th {
  color: var(--muted);
}

.project-tab-list {
  gap: 10px;
  padding: 18px 0;
  border-bottom-color: var(--line);
}

.project-tab {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(184, 248, 221, 0.12);
  border-radius: 999px;
  background: rgba(238, 248, 243, 0.05);
  color: var(--muted);
}

.project-tab.active {
  border-color: rgba(35, 201, 133, 0.5);
  background: rgba(35, 201, 133, 0.14);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(35, 201, 133, 0.08);
}

.project-tab.is-locked {
  background: rgba(238, 248, 243, 0.03);
  color: rgba(147, 168, 160, 0.58);
}

.brief-form,
.feedback-form {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(15, 28, 24, 0.72);
}

.brief-analysis-results {
  border-radius: 16px;
}

.brief-analysis-meta article,
.brief-analysis-facts article,
.brief-analysis-facts div,
.history-detail-summary article,
.feedback-preview dl div,
.formula-editor-metrics article,
.ingredient-row,
.review-formula-table th,
.review-formula-table td,
.historical-ingredient-table th,
.historical-ingredient-table td {
  border-color: var(--line);
}

.brief-analysis-meta article,
.brief-analysis-facts article,
.brief-analysis-facts div,
.spec-item,
.formula-editor-metrics article,
.history-detail-summary article {
  background: rgba(238, 248, 243, 0.035);
}

.brief-analysis-facts ul,
.brief-analysis-lists ul,
.chemist-checklist li,
.session-list dd,
.historical-card-meta strong,
.history-detail-summary strong,
.formula-editor-metrics strong,
.brief-analysis-meta strong,
.brief-analysis-facts strong,
.review-formula-table td,
.historical-ingredient-table td {
  color: var(--ink);
}

.workspace-layout {
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.36fr);
  gap: 18px;
}

.generate-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.36fr) minmax(280px, 0.72fr);
  gap: 18px;
  align-items: start;
}

.selection-status {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.related-formula-pane,
.workspace-workbench,
.workspace-context,
.workspace-notes,
.generation-logs-card,
.review-panel,
.historical-formula-detail {
  border-radius: 18px;
}

.related-formula-card,
.assistant-suggestion-card,
.historical-formula-card {
  border-color: rgba(184, 248, 221, 0.13);
  border-radius: 16px;
  background: rgba(238, 248, 243, 0.045);
}

.related-formula-card:hover,
.historical-formula-card:hover,
.historical-formula-card:focus-visible {
  border-color: rgba(35, 201, 133, 0.46);
  background: rgba(35, 201, 133, 0.08);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.2);
}

.related-formula-card.is-selected,
.related-formula-card.selected,
.assistant-suggestion-card.selected,
.historical-formula-card.is-selected {
  border-color: rgba(35, 201, 133, 0.62);
  background: rgba(35, 201, 133, 0.13);
  box-shadow: 0 0 0 3px rgba(35, 201, 133, 0.1);
}

.related-warning-list span,
.privacy-modal-warning,
.history-notice,
.warning-message:not(:empty) {
  border-color: rgba(246, 201, 109, 0.24);
  background: var(--warning-soft);
  color: var(--warning);
}

.success-message:not(:empty),
.assistant-note {
  border-color: rgba(35, 201, 133, 0.24);
  background: rgba(35, 201, 133, 0.1);
  color: var(--accent-dark);
}

.error-message:not(:empty) {
  border-color: rgba(255, 136, 124, 0.24);
  background: var(--danger-soft);
  color: var(--danger);
}

.formula-total-box,
.formula-total-box.is-valid {
  border-color: rgba(35, 201, 133, 0.32);
  background: rgba(35, 201, 133, 0.12);
  color: var(--accent-dark);
}

.formula-total-box.is-warning,
.formula-editor-table input[aria-invalid="true"] {
  border-color: rgba(246, 201, 109, 0.34);
  background: var(--warning-soft);
  color: var(--warning);
}

.formula-ingredient-list,
.review-formula-table {
  background: rgba(5, 13, 10, 0.28);
}

.ingredient-row {
  background: transparent;
}

.ingredient-row label {
  min-width: 0;
}

.ingredient-row input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.formula-editor-table th,
.review-formula-table th {
  background: rgba(238, 248, 243, 0.04);
}

.related-formula-loading {
  border-color: rgba(35, 201, 133, 0.2);
  border-radius: 16px;
  background: rgba(35, 201, 133, 0.08);
  color: var(--ink);
}

.loading-spinner {
  border-color: rgba(35, 201, 133, 0.18);
  border-top-color: var(--accent);
}

.loading-dots span {
  background: var(--accent);
}

.modal-backdrop {
  background: rgba(2, 7, 5, 0.68);
  backdrop-filter: blur(10px);
}

.modal-card {
  border-radius: 20px;
  background: rgba(15, 28, 24, 0.96);
}

.historical-formulas-layout {
  gap: 18px;
}

.historical-formula-detail {
  top: 28px;
}

.rating-control input[type="range"] {
  accent-color: var(--accent);
}

@media (max-width: 980px) {
  .app-shell {
    padding: 18px;
  }

  .dashboard:not(.hidden),
  .project-page:not(.hidden),
  .historical-formulas-screen:not(.hidden),
  .auth-layout:not(.hidden) {
    min-height: calc(100vh - 36px);
    padding: 20px;
    border-radius: 20px;
  }

  .dashboard-header,
  .project-page-header,
  .historical-formulas-header {
    display: grid;
  }

  .header-actions {
    flex-wrap: wrap;
  }
}

/* Neutral charcoal correction. Previous failure: page-level green tints made dark mode feel green instead of black/charcoal with green accents. */
:root {
  --bg: #060708;
  --surface: #121416;
  --surface-muted: #181b1d;
  --surface-raised: #1d2022;
  --surface-strong: #23282a;
  --ink: #f3f5f4;
  --muted: #9ea8aa;
  --line: rgba(231, 237, 234, 0.14);
  --border: var(--line);
  --accent: #23c985;
  --accent-dark: #62dca8;
  --accent-soft: rgba(35, 201, 133, 0.12);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

html {
  background: #050607;
}

body,
body:has(#dashboard-screen:not(.hidden)) {
  background:
    radial-gradient(circle at 85% 5%, rgba(255, 255, 255, 0.035), transparent 32%),
    linear-gradient(180deg, #101214 0%, #070809 48%, #050607 100%);
}

.dashboard:not(.hidden),
.project-page:not(.hidden),
.historical-formulas-screen:not(.hidden),
.auth-layout:not(.hidden) {
  border-color: rgba(231, 237, 234, 0.12);
  background:
    linear-gradient(180deg, rgba(24, 26, 28, 0.93), rgba(9, 10, 11, 0.96)),
    #0d0f10;
}

.auth-panel,
.modal-card,
.project-list,
.project-card,
.placeholder-panel,
.brief-analysis-results,
.related-formula-pane,
.workspace-workbench,
.workspace-context,
.workspace-notes,
.generation-logs-card,
.review-panel,
.feedback-question,
.feedback-preview,
.historical-formula-card,
.historical-formula-detail,
.history-detail-summary,
.formula-editor-metrics,
.formula-ingredient-list,
.review-formula-table,
.brief-summary-box,
.spec-item,
.assistant-note,
.editor-notes-panel,
.assistant-prompt-panel,
.assistant-selected-panel {
  background: rgba(18, 20, 22, 0.88);
}

.dashboard-controls input,
.dashboard-controls select,
.auth-form input,
.modal-card input,
.brief-form input[type="file"],
.brief-form textarea,
.feedback-form textarea,
.workspace-notes textarea,
.formula-editor-table input,
.formula-editor-table textarea,
.ingredient-row input,
textarea,
input,
select {
  border-color: rgba(231, 237, 234, 0.14);
  background: rgba(5, 6, 7, 0.58);
}

.secondary-action,
.text-action,
.back-link,
.project-card .text-action {
  border-color: rgba(231, 237, 234, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.project-card,
.project-card:hover,
.project-card:focus-visible,
.project-card.is-archived {
  background: rgba(18, 20, 22, 0.9);
}

.project-card:hover,
.project-card:focus-visible,
.historical-formula-card:hover,
.historical-formula-card:focus-visible,
.related-formula-card:hover {
  border-color: rgba(35, 201, 133, 0.42);
  background: rgba(25, 28, 30, 0.96);
}

.related-formula-card,
.assistant-suggestion-card,
.historical-formula-card,
.ingredient-row {
  background: rgba(255, 255, 255, 0.035);
}

.project-tab,
.workspace-tab,
.tab-button {
  background: rgba(255, 255, 255, 0.045);
}

.project-tab.active,
.workspace-tab.active,
.tab-button.active,
.related-formula-card.is-selected,
.related-formula-card.selected,
.assistant-suggestion-card.selected,
.historical-formula-card.is-selected {
  background: rgba(35, 201, 133, 0.1);
}

.related-formula-loading,
.success-message:not(:empty),
.assistant-note,
.formula-total-box,
.formula-total-box.is-valid {
  background: rgba(35, 201, 133, 0.09);
}

.formula-editor-table th,
.review-formula-table th,
.brief-analysis-meta article,
.spec-item,
.formula-editor-metrics article,
.history-detail-summary article {
  background: rgba(255, 255, 255, 0.035);
}

.modal-card {
  background: rgba(18, 20, 22, 0.97);
}

.aio-feedback-card {
  width: min(100%, 760px);
  max-height: min(86vh, 760px);
  overflow: auto;
}

@media (max-width: 640px) {
  .modal-heading-row,
  .aio-feedback-project-header,
  .aio-feedback-item {
    grid-template-columns: 1fr;
  }

  .modal-heading-row,
  .aio-feedback-project-header {
    display: grid;
  }

  .modal-close-action {
    width: 100%;
  }
}

/* Previous decision: remove the side rail so the project workspace has full horizontal room. */
.app-shell {
  padding-left: 34px;
}

/* Success: dashboard and project workspace should read as full pages, not rounded cards inside another dark page. */
.app-shell:has(#dashboard-screen:not(.hidden)),
.app-shell:has(#project-page:not(.hidden)) {
  width: 100%;
  padding: 24px 44px 48px;
}

#dashboard-screen.dashboard:not(.hidden),
#project-page.project-page:not(.hidden) {
  min-height: calc(100vh - 72px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#dashboard-screen .dashboard-section {
  padding-top: 18px;
}

/* Success: keep workflow next actions in the top-right tab row so each project page has the same navigation target. */
#project-page .project-navigation-row {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

#project-page .project-navigation-row .project-tab-list {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border-bottom: 0;
}

#project-page .project-step-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  min-width: 220px;
}

#project-page .project-step-action {
  min-width: 220px;
}

/* Success: project account actions now sit together in the top-right header area. */
#project-page .project-page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
}

#project-page .project-header-title {
  min-width: 0;
}

#project-page .project-header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

/* Success: project header actions now match dashboard action sizing instead of the oversized fixed columns. */
#project-page .project-header-actions .text-action,
#project-page .project-header-actions .secondary-action {
  width: auto;
  min-width: 110px;
  min-height: 48px;
  margin: 0;
  padding: 0 18px;
}

/* Success: downstream screens no longer display the project brief; saved brief data still powers matching and generation. */
#workspace-panel .workspace-layout {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.42fr);
}

#review-panel .review-layout {
  grid-template-columns: minmax(0, 1fr);
}

/* Success: Brief and Generate Formula now mirror the Review Related Formulas pattern with logs in the right column. */
#brief-panel .brief-workflow-layout,
#generate-panel .generate-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.42fr);
  gap: 18px;
  align-items: start;
}

#brief-panel .brief-side-panel,
#generate-panel .generate-side-panel {
  display: grid;
  gap: 14px;
}

#brief-panel .brief-logs-card {
  margin-top: 0;
}

/* Success: the brief upload area now uses a custom picker instead of the default browser file input. */
#brief-panel .brief-upload-field {
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(231, 237, 234, 0.12);
  border-radius: 16px;
  background: rgba(5, 13, 10, 0.38);
}

#brief-panel .brief-upload-heading {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

#brief-panel .brief-upload-title,
#brief-panel .brief-upload-actions {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

#brief-panel .brief-upload-title {
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 1rem;
  text-transform: none;
}

#brief-panel .brief-upload-help {
  display: block;
  max-width: 560px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

#brief-panel .brief-upload-actions {
  flex: 0 0 auto;
  display: grid;
  justify-items: end;
}

#brief-panel .brief-file-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

#project-brief-file.visually-hidden {
  width: 1px !important;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
}

#project-brief-file.visually-hidden:focus-visible + .brief-file-select-control {
  outline: 3px solid rgba(35, 201, 133, 0.26);
  outline-offset: 2px;
}

#brief-panel .brief-file-select-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Success: keep the two brief-entry actions compact so the upload card reads as supporting UI. */
  width: 190px;
  min-height: 46px;
  margin: 0;
  padding: 0 16px;
  border: 1px solid rgba(35, 201, 133, 0.78);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(35, 201, 133, 0.96), rgba(24, 174, 114, 0.96));
  color: #06120d;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 950;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
  white-space: nowrap;
}

#brief-panel .brief-file-select-control:hover {
  border-color: rgba(100, 239, 179, 0.9);
  background: linear-gradient(135deg, rgba(100, 239, 179, 0.98), rgba(35, 201, 133, 0.98));
  transform: translateY(-1px);
}

#brief-panel .brief-file-status-shell {
  /* Success: the file list well matches the adjacent manual entry action height. */
  display: flex;
  align-items: center;
  height: 52px;
  min-height: 52px;
  padding: 7px 16px;
  border: 1px solid rgba(231, 237, 234, 0.1);
  border-radius: 14px;
  background: rgba(18, 20, 22, 0.78);
}

#brief-panel .brief-file-status-shell ul {
  display: grid;
  gap: 2px;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

#brief-panel .brief-file-status-shell li {
  display: grid;
  gap: 2px;
  min-width: 0;
}

#brief-panel .brief-file-status-shell strong {
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#brief-panel .brief-file-status-shell span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

#brief-panel .brief-file-picker #manual-brief-button {
  width: 190px;
  min-height: 46px;
  padding: 0 16px;
  font-size: 0.92rem;
  white-space: nowrap;
}

@media (min-width: 901px) {
  /* Previous issue: stacked dashboard actions were 102px tall inside an 86px project row, so they overlapped the next project. */
  #dashboard-screen .project-card {
    grid-template-columns: 180px minmax(0, 1fr) auto;
    height: 86px;
    min-height: 86px;
    overflow: hidden;
  }

  /* Success: compact metadata stays inside the existing row height without changing the project-card size. */
  #dashboard-screen .project-card-topline {
    gap: 5px;
    min-width: 0;
    overflow: hidden;
  }

  #dashboard-screen .status-chip {
    max-width: 100%;
    padding: 3px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #dashboard-screen .project-updated,
  #dashboard-screen .project-card h3,
  #dashboard-screen .project-category {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #dashboard-screen .project-record-main,
  #dashboard-screen .project-record-main > div {
    min-width: 0;
    overflow: hidden;
  }

  /* Previous issue: a long project summary expanded to 276px and rendered across multiple fixed-height rows. */
  #dashboard-screen .project-record-main > p {
    display: -webkit-box;
    max-height: 46px;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  #dashboard-screen .project-record-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: max-content;
    height: auto;
    overflow: hidden;
  }

  #dashboard-screen .project-card .text-action {
    min-width: 0;
    white-space: nowrap;
  }
}

#brief-panel .download-brief-file {
  width: fit-content;
  min-height: 34px;
  padding: 0 12px;
}

#generate-panel #formula-total-message:empty {
  display: none;
}

#generate-panel .workspace-workbench {
  display: grid;
  gap: 16px;
}

#generate-panel .workspace-workbench .workspace-notes {
  margin-top: 0;
}

/* Success: feedback should feel like a centered workspace, not a small card floating on a wide page. */
#feedback-panel {
  display: grid;
  justify-items: center;
}

#feedback-panel .feedback-form {
  width: min(100%, 820px);
  max-width: 820px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  /* Success: feedback prompt cards are stacked vertically for easier review on narrower Chrome windows. */
  grid-template-columns: 1fr;
  align-items: stretch;
}

#feedback-panel .feedback-question {
  min-height: 230px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(18, 20, 22, 0.88);
}

#feedback-panel .feedback-question textarea {
  min-height: 142px;
}

#feedback-panel .feedback-control-row,
#feedback-panel .form-message {
  grid-column: 1 / -1;
}

/* Success: feedback rating and actions now share one horizontal row instead of stacking. */
#feedback-panel .feedback-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  width: 100%;
}

#feedback-panel .feedback-control-row .rating-control {
  grid-template-columns: minmax(130px, auto) minmax(240px, 1fr) 48px;
}

#feedback-panel .feedback-control-row .form-actions {
  justify-content: flex-end;
  margin: 0;
}

/* Success: keep brief-needed workflow state in data, but remove the redundant header chip and summary copy. */
#project-page-status,
#project-page-summary {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 18px;
  }

  .app-shell:has(#dashboard-screen:not(.hidden)),
  .app-shell:has(#project-page:not(.hidden)) {
    padding: 18px;
  }

  #project-page .project-navigation-row {
    display: grid;
    gap: 12px;
  }

  #project-page .project-step-actions,
  #project-page .project-step-action {
    width: 100%;
    min-width: 0;
  }

  #project-page .project-step-actions {
    display: grid;
  }

  #project-page .project-page-header {
    grid-template-columns: 1fr;
  }

  #project-page .project-header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #project-page .project-header-actions .text-action,
  #project-page .project-header-actions .secondary-action {
    width: 100%;
    min-width: 0;
  }

  #brief-panel .brief-workflow-layout,
  #generate-panel .generate-layout,
  #feedback-panel .feedback-form {
    grid-template-columns: 1fr;
  }

  #brief-panel .brief-file-picker {
    grid-template-columns: 1fr;
  }

  #brief-panel .brief-upload-heading {
    display: grid;
  }

  #brief-panel .brief-upload-actions,
  #brief-panel .brief-upload-actions .brief-file-select-control {
    width: 100%;
  }

  #brief-panel .brief-file-picker #manual-brief-button {
    width: 100%;
  }

  #feedback-panel .feedback-question {
    min-height: 0;
  }

  #feedback-panel .feedback-control-row {
    grid-template-columns: 1fr;
  }

  #feedback-panel .feedback-control-row .form-actions {
    justify-content: center;
  }
}

/* Previous failure: later modal-card overrides collapsed the manual brief modal back to a narrow 440px card. */
#manual-brief-modal {
  padding: 24px;
}

/* Success: the brief stays readable at normal zoom with a compact, content-aware width cap. */
#manual-brief-modal .manual-brief-card {
  width: min(100%, 1040px) !important;
  box-sizing: border-box;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(22px, 3vw, 32px);
  border-color: rgba(184, 248, 221, 0.13);
  background: linear-gradient(145deg, rgba(39, 44, 54, 0.99), rgba(27, 32, 40, 0.99));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255, 255, 255, 0.025);
}

#manual-brief-modal .modal-heading-row {
  align-items: center;
  margin-bottom: 22px;
}

#manual-brief-modal .modal-heading-row h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.65rem);
  letter-spacing: -0.025em;
}

#manual-brief-modal .manual-brief-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 18px 22px;
}

#manual-brief-modal .manual-brief-grid label:first-child {
  grid-column: 1 / -1;
}

#manual-brief-modal .manual-brief-grid label {
  min-width: 0;
  gap: 7px;
}

#manual-brief-modal .manual-brief-grid label > span {
  color: #dce3e0;
  font-size: 0.82rem;
  font-weight: 760;
  letter-spacing: 0.005em;
}

#manual-brief-modal .manual-brief-grid input,
#manual-brief-modal .manual-brief-grid textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  border-color: rgba(231, 237, 234, 0.18);
  border-radius: 10px;
  background: rgba(10, 12, 15, 0.76);
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.45;
}

#manual-brief-modal .manual-brief-grid input {
  min-height: 46px;
  padding: 0 14px;
}

/* Success: the brief category now uses the app's custom option menu and expands a matching custom-name field on demand. */
#manual-brief-modal .manual-category-field {
  position: relative;
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 7px;
}

#manual-brief-modal .manual-category-field > span,
#manual-brief-modal .manual-category-custom-field > span {
  color: #dce3e0;
  font-size: 0.82rem;
  font-weight: 760;
  letter-spacing: 0.005em;
}

#manual-brief-modal .manual-category-dropdown .project-status-trigger {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid rgba(184, 248, 221, 0.18);
  border-radius: var(--radius-control);
  background: rgba(5, 13, 10, 0.72);
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 560;
  text-align: left;
  cursor: pointer;
}

#manual-brief-modal .manual-category-dropdown .project-status-trigger:hover {
  border-color: rgba(35, 201, 133, 0.48);
  background: rgba(8, 20, 15, 0.9);
}

#manual-brief-modal .manual-category-dropdown .project-status-trigger:focus-visible,
#manual-brief-modal .manual-category-dropdown.is-open .project-status-trigger {
  border-color: rgba(35, 201, 133, 0.72);
  outline: 3px solid rgba(35, 201, 133, 0.2);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px rgba(35, 201, 133, 0.12);
}

#manual-brief-modal .manual-category-trigger-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#manual-brief-modal .manual-category-custom-field {
  display: grid;
  min-width: 0;
  gap: 7px;
  margin-top: 2px;
}

#manual-brief-modal .manual-category-custom-field.hidden {
  display: none;
}

#manual-brief-modal .manual-category-custom-field input {
  width: 100%;
  min-height: 46px;
}

#manual-brief-modal .manual-category-add-option {
  margin-top: 6px;
  border-top: 1px solid rgba(231, 237, 234, 0.1);
  border-radius: 0 0 9px 9px;
  color: #c6f3dc;
}

#manual-brief-modal .manual-category-add-option > span:first-child {
  color: var(--accent);
  font-size: 1.1rem;
}

#manual-brief-modal .manual-brief-grid textarea {
  min-height: 112px;
  padding: 12px 14px;
}

#manual-brief-modal .manual-brief-grid input::placeholder,
#manual-brief-modal .manual-brief-grid textarea::placeholder {
  color: rgba(243, 245, 244, 0.46);
}

@media (max-width: 900px) {
  #manual-brief-modal .manual-brief-grid {
    grid-template-columns: 1fr;
  }

  #manual-brief-modal .manual-brief-card {
    width: min(94vw, 760px) !important;
    padding: 26px;
  }
}

/* Previous failure: the desktop sidebar reduced the modal backdrop without reducing the card width, clipping the brief form beneath navigation. */
@media (min-width: 901px) {
  body:has(.app-navigation:not(.hidden)) #manual-brief-modal {
    inset: 0 0 0 var(--app-sidebar-width);
  }

  body:has(.app-navigation:not(.hidden)) #manual-brief-modal .manual-brief-card {
    width: min(calc(100vw - var(--app-sidebar-width) - 48px), 1040px) !important;
  }
}

/* Success: RL-191 keeps new consistency work in one final layer so future UI cleanup has a clear contract to extend. */
:root {
  --page-max: 1680px;
  --page-gutter: clamp(24px, 3vw, 48px);
  --surface-panel: rgba(18, 20, 22, 0.88);
  --surface-panel-strong: rgba(18, 20, 22, 0.96);
  --control-h-sm: 40px;
  --control-h-md: 48px;
  --control-h-lg: 52px;
  --radius-control: 12px;
  --radius-panel: 18px;
  --radius-card: 16px;
  --shadow-panel: 0 18px 44px rgba(0, 0, 0, 0.18);
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.app-shell,
.app-shell:has(#dashboard-screen:not(.hidden)),
.app-shell:has(#project-page:not(.hidden)) {
  width: 100%;
  max-width: var(--page-max);
  padding: var(--page-gutter);
}

.dashboard:not(.hidden),
.project-page:not(.hidden),
.historical-formulas-screen:not(.hidden) {
  min-height: calc(100vh - 72px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.app-page-header,
.page-header,
.dashboard-header,
.project-page-header,
.historical-formulas-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(16px, 2vw, 28px);
  align-items: center;
  max-width: none;
  padding: 0 0 24px;
  border-bottom: 1px solid var(--line);
}

.dashboard-header h1,
.project-page-header h1,
.historical-formulas-header h1 {
  margin: 0;
  font-size: clamp(2.15rem, 4vw, 3.5rem);
  line-height: 1;
}

.page-actions,
.header-actions,
.project-header-actions,
.raw-material-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

.primary-action,
.secondary-action,
.text-action,
.back-link,
.raw-material-upload-control,
.brief-file-select-control {
  display: inline-flex;
  min-height: var(--control-h-md);
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: var(--radius-control);
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  text-transform: none;
  white-space: nowrap;
}

.header-actions .primary-action,
.header-actions .secondary-action,
.project-header-actions .text-action,
.project-header-actions .secondary-action,
.historical-formulas-header .back-link {
  min-width: 120px;
  min-height: var(--control-h-md);
  margin: 0;
}

/* Previous issue: the compact RL-209 override and inherited auto margins centered and shrank this grid-page header. */
.historical-page-header {
  width: 100%;
  margin: 0;
  gap: clamp(16px, 2vw, 28px);
  padding-bottom: 24px;
}

.historical-page-header h1 {
  font-size: clamp(2.15rem, 4vw, 3.5rem);
  line-height: 1;
}

.historical-formulas-screen:not(.raw-materials-screen) .historical-formulas-section {
  padding-top: 18px;
}

.project-header-actions #back-dashboard-button {
  min-width: 150px;
}

.project-header-actions #project-logout-button,
.dashboard-header #new-project-button,
.dashboard-header #logout-button {
  min-width: 118px;
}

.dashboard-header .secondary-action,
.dashboard-header .primary-action {
  min-height: var(--control-h-md);
}

.project-navigation-row,
.workflow-nav-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.project-tab-list,
.workflow-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
}

.project-tab {
  min-height: 46px;
  padding: 0 18px;
}

.project-step-actions,
.workflow-next-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.project-step-action,
#project-page .project-step-action {
  min-width: 220px;
  min-height: var(--control-h-lg);
}

.library-section,
.historical-formulas-section {
  padding-top: 22px;
}

.section-heading,
.library-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 10px;
}

.section-heading h2,
.library-toolbar h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
}

.section-heading p,
.library-toolbar p {
  margin-top: 6px;
}

.historical-formulas-section .dashboard-controls,
.raw-materials-screen .dashboard-controls,
.historical-formulas-screen:not(.raw-materials-screen) .dashboard-controls {
  margin-bottom: 18px;
}

.raw-material-actions .secondary-action,
.raw-material-actions .raw-material-upload-control {
  width: auto;
  min-width: 220px;
  min-height: var(--control-h-lg);
  font-size: 0.95rem;
}

.historical-formulas-layout {
  grid-template-columns: minmax(0, 0.95fr) minmax(380px, 0.72fr);
  gap: 20px;
  width: 100%;
  min-width: 0;
}

/* Success: desktop Historical Formulas keeps search/detail fixed while only the result list scrolls. */
@media (min-width: 1121px) {
  /* Success: RL-248 keeps the Projects title, actions, search, and status fixed while only project rows scroll. */
  #dashboard-screen.dashboard:not(.hidden) {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: calc(100vh - (var(--page-gutter) * 2));
    min-height: 0;
    overflow: hidden;
  }

  #dashboard-screen .dashboard-section {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    padding-bottom: 0;
    overflow: hidden;
  }

  #dashboard-screen .project-list {
    min-height: 0;
    align-content: start;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Success: RL-248 keeps project identity and workflow navigation fixed while only the active step scrolls. */
  #project-page.project-page:not(.hidden) {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: calc(100vh - (var(--page-gutter) * 2));
    min-height: 0;
    overflow: hidden;
  }

  #project-page > .project-panel:not(.hidden) {
    /* Previous issue: the legacy centered 1320px panel cap left large empty margins inside the fixed workspace. */
    width: 100%;
    max-width: none;
    margin-right: 0;
    margin-left: 0;
    min-height: 0;
    padding-right: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #project-page > #feedback-panel:not(.hidden) {
    display: block;
  }

  #project-page > #feedback-panel:not(.hidden) .feedback-form {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .historical-formulas-screen:not(.raw-materials-screen):not(.hidden) {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: calc(100vh - (var(--page-gutter) * 2));
    overflow: hidden;
  }

  .historical-formulas-screen:not(.raw-materials-screen) .historical-formulas-section {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
  }

  .historical-formulas-screen:not(.raw-materials-screen) .historical-formula-controls {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
  }

  .historical-formulas-screen:not(.raw-materials-screen) .historical-formulas-layout {
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
  }

  .historical-formulas-screen:not(.raw-materials-screen) .historical-formula-list {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 6px;
    align-content: start;
  }

  .historical-formulas-screen:not(.raw-materials-screen) .historical-formula-detail {
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Success: RL-248 keeps the Raw Materials controls and selected detail visible while only the result list scrolls. */
  .raw-materials-screen:not(.hidden) {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: calc(100vh - (var(--page-gutter) * 2));
    overflow: hidden;
  }

  .raw-materials-screen .historical-formulas-section {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
  }

  .raw-materials-screen .historical-formulas-layout {
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
  }

  .raw-materials-screen .historical-formula-list {
    min-height: 0;
    padding-right: 6px;
    align-content: start;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .raw-materials-screen .historical-formula-detail {
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.historical-formula-card,
.historical-formula-detail,
.related-formula-pane,
.workspace-workbench,
.generation-logs-card,
.review-panel,
.brief-form,
.feedback-question,
.formula-editor-metrics,
.formula-ingredient-list,
.review-formula-table,
.brief-analysis-results,
.brief-upload-field {
  border-radius: var(--radius-panel);
  background: var(--surface-panel);
  box-shadow: var(--shadow-panel);
}

.historical-formula-card,
.related-formula-card,
.aio-feedback-project,
.aio-feedback-item,
.formula-editor-metrics article,
.history-detail-summary article,
.brief-analysis-facts article,
.brief-analysis-facts div,
.spec-item {
  border-radius: var(--radius-card);
}

.workflow-grid,
#brief-panel .brief-workflow-layout,
#workspace-panel .workspace-layout,
#generate-panel .generate-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.42fr);
  gap: 20px;
  align-items: start;
}

.workflow-grid-single,
#review-panel .review-layout {
  grid-template-columns: minmax(0, 1fr);
}

.brief-side-panel,
.workspace-side-panel,
.generate-side-panel,
.generation-logs-card {
  min-width: 0;
}

.generation-logs-card {
  position: sticky;
  top: 18px;
}

.workbench-heading,
.review-panel-heading,
.brief-upload-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.formula-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

.formula-total-box {
  min-width: 128px;
  min-height: 96px;
  border-radius: var(--radius-control);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.form-actions .primary-action,
.form-actions .secondary-action {
  min-height: var(--control-h-md);
}

.dashboard-controls input,
.dashboard-controls select,
.auth-form input,
.modal-card input,
.modal-card select,
.brief-form textarea,
.feedback-form textarea,
textarea,
input,
select {
  min-height: var(--control-h-md);
  border-radius: var(--radius-control);
}

textarea,
.brief-form textarea,
.feedback-form textarea,
.modal-card textarea {
  line-height: 1.45;
}

.modal-card {
  width: min(100%, 520px);
  border-radius: var(--radius-panel);
}

.modal-card.modal-sm {
  width: min(100%, 500px);
}

.modal-card.modal-md {
  width: min(100%, 600px);
}

.modal-card.modal-lg {
  width: min(100%, 860px);
}

.modal-card.modal-xl {
  width: min(88vw, 1440px);
}

.modal-heading-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
}

#manual-brief-modal .manual-brief-card {
  width: min(100%, 1040px) !important;
}

#feedback-panel {
  display: grid;
  justify-items: center;
}

#feedback-panel .feedback-form {
  width: min(100%, 900px);
  max-width: 900px;
  gap: 18px;
}

#feedback-panel .feedback-question {
  min-height: 0;
}

#feedback-panel .feedback-question textarea {
  min-height: 150px;
}

.notification-region {
  right: var(--page-gutter);
  bottom: var(--page-gutter);
}

@media (max-width: 1120px) {
  .raw-materials-screen .raw-material-controls {
    grid-template-columns: 1fr;
  }

  .app-page-header,
  .page-header,
  .dashboard-header,
  .project-page-header,
  .historical-formulas-header,
  .section-heading,
  .library-toolbar,
  .project-navigation-row,
  .workflow-nav-row,
  .workbench-heading,
  .review-panel-heading,
  .brief-upload-heading {
    grid-template-columns: 1fr;
  }

  .page-actions,
  .header-actions,
  .project-header-actions,
  .raw-material-actions,
  .project-step-actions,
  .workflow-next-actions,
  .formula-heading-actions {
    justify-content: flex-start;
  }

  .workflow-grid,
  #brief-panel .brief-workflow-layout,
  #workspace-panel .workspace-layout,
  #generate-panel .generate-layout,
  .historical-formulas-layout,
  .raw-materials-screen .historical-formulas-layout {
    grid-template-columns: 1fr;
  }

  .generation-logs-card,
  .historical-formula-detail {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell,
  .app-shell:has(#dashboard-screen:not(.hidden)),
  .app-shell:has(#project-page:not(.hidden)) {
    padding: 18px;
  }

  .primary-action,
  .secondary-action,
  .text-action,
  .back-link,
  .raw-material-upload-control,
  .brief-file-select-control,
  .project-step-action,
  #project-page .project-step-action,
  .raw-material-actions .secondary-action,
  .raw-material-actions .raw-material-upload-control {
    width: 100%;
    min-width: 0;
  }

  .project-tab-list,
  .workflow-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .brief-file-picker,
  #brief-panel .brief-file-picker,
  #feedback-panel .feedback-control-row,
  #feedback-panel .feedback-control-row .rating-control {
    grid-template-columns: 1fr;
  }

  .modal-backdrop,
  #manual-brief-modal {
    padding: 18px;
  }

  .modal-heading-row {
    grid-template-columns: 1fr;
  }
}

/* Success: RL-191 keeps dashboard navigation compact and passive metadata labels as text, not filled chips. */
.dashboard-header {
  grid-template-columns: minmax(max-content, 1fr) auto;
  gap: 14px;
}

.dashboard-header h1 {
  max-width: 100%;
  font-size: clamp(2.1rem, 3.3vw, 3.15rem);
  white-space: nowrap;
}

.dashboard-header .page-actions {
  flex-wrap: nowrap;
  gap: 8px;
}

.dashboard-header .primary-action,
.dashboard-header .secondary-action {
  min-width: 0;
  padding-inline: 14px;
  font-size: 0.88rem;
}

.card-kicker {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
}

/* Previous failure: a 1400px breakpoint pushed primary actions below page titles on ordinary laptop screens. */
@media (max-width: 720px) {
  .dashboard-header {
    grid-template-columns: 1fr;
  }

  .dashboard-header h1 {
    white-space: normal;
  }

  .dashboard-header .page-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

/* Success: keep the generate action and Total status card visually paired without making the action button taller. */
#generate-panel .formula-heading-actions {
  align-items: center;
}

#generate-panel .formula-heading-actions #generate-formula-button,
#generate-panel .formula-total-box {
  min-height: 70px;
}

#generate-panel .formula-total-box {
  height: 70px;
  min-width: 128px;
  padding: 7px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#generate-panel .formula-total-box span {
  font-size: 0.72rem;
  line-height: 1;
}

#generate-panel .formula-total-box strong {
  margin: 3px 0;
  font-size: 1.18rem;
  line-height: 1;
}

/* Success: RL-249 keeps authenticated navigation in a persistent left rail while preserving the mobile drawer. */
:root {
  --app-sidebar-width: 280px;
}

.app-shell:has(.app-navigation:not(.hidden)) {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--page-gutter);
  padding-left: calc(var(--app-sidebar-width) + var(--page-gutter));
  /* Previous issue: transparent page shells exposed different shades of the body gradient at different page heights. */
  background: var(--bg);
}

/* Previous issue: older ID-specific page rules overrode the sidebar offset and allowed dashboard/project content underneath the rail. */
.app-shell:has(.app-navigation:not(.hidden)):has(#dashboard-screen:not(.hidden)),
.app-shell:has(.app-navigation:not(.hidden)):has(#project-page:not(.hidden)) {
  max-width: none;
  margin: 0;
  padding: var(--page-gutter);
  padding-left: calc(var(--app-sidebar-width) + var(--page-gutter));
}

.app-navigation {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 200;
  display: flex;
  width: var(--app-sidebar-width);
  min-height: 100vh;
  flex-direction: column;
  align-items: stretch;
  margin: 0;
  padding: 24px 16px 18px;
  border-right: 1px solid var(--line);
  background: rgba(10, 14, 13, 0.97);
  box-shadow: 18px 0 42px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px);
  overflow-y: auto;
}

.app-nav-brand,
.app-nav-drawer-header strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.app-nav-brand {
  margin-bottom: 18px;
  padding: 6px 10px 24px;
  border-bottom: 1px solid var(--line);
}

.app-nav-menu {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.app-nav-group {
  display: grid;
  gap: 6px;
}

.app-nav-section-label {
  padding: 0 12px;
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.5;
  text-transform: uppercase;
}

.app-nav-link,
.app-nav-menu-button,
.app-nav-close-button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.app-nav-link {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: flex-start;
  padding: 0 14px;
  text-align: left;
  white-space: nowrap;
}

.app-task-due-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 21px; height: 21px; margin-left: auto; padding: 0 5px; border-radius: 999px; color: #081b14; background: #70dcb3; font-size: 11px; line-height: 1; font-weight: 800; box-sizing: border-box; }
.app-task-due-badge.hidden { display: none; }
.related-stability-reports { margin-top: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-muted); }
.related-stability-reports h4 { margin: 0 0 12px; }
.related-stability-report { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.related-stability-report span { overflow-wrap: anywhere; }

.app-nav-link:hover,
.app-nav-link:focus-visible {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--ink);
}

.app-nav-link.active,
.app-nav-link[aria-current="page"] {
  border-color: rgba(35, 201, 133, 0.34);
  background: var(--accent-soft);
  color: var(--accent);
}

.app-nav-link.app-nav-logout {
  /* Success: the logout action is centered while navigation destinations remain left aligned. */
  justify-content: center;
  margin-top: auto;
  border-color: var(--line);
  text-align: center;
}

.app-nav-menu-button,
.app-nav-drawer-header,
.app-nav-scrim {
  display: none;
}

.app-nav-menu-icon {
  display: grid;
  gap: 4px;
}

.app-nav-menu-icon span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.aio-feedback-screen:not(.hidden) {
  min-height: calc(100vh - (var(--page-gutter) * 2));
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.aio-feedback-page-header h1 {
  margin: 0;
  font-size: clamp(2.15rem, 4vw, 3.5rem);
  line-height: 1;
}

.aio-feedback-page-header p:last-child {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
}

.aio-feedback-page-section {
  padding-top: 22px;
}

.aio-feedback-page-section .aio-feedback-list {
  gap: 18px;
  max-height: none;
  margin-top: 0;
  overflow: visible;
}

.aio-feedback-page-section .aio-feedback-project {
  background: var(--surface-panel);
}

.general-feedback-modal-card {
  width: min(100%, 720px);
}

.general-feedback-form-fields {
  display: grid;
  gap: 18px;
}

.general-feedback-form-fields label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.general-feedback-form-fields input,
.general-feedback-form-fields textarea {
  width: 100%;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(6, 8, 9, 0.92);
  color: var(--ink);
  caret-color: var(--accent);
}

.general-feedback-form-fields input::placeholder,
.general-feedback-form-fields textarea::placeholder {
  color: rgba(238, 242, 240, 0.48);
}

.general-feedback-form-fields input:hover,
.general-feedback-form-fields textarea:hover {
  border-color: rgba(35, 201, 133, 0.48);
}

.general-feedback-form-fields input:focus-visible,
.general-feedback-form-fields textarea:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgba(35, 201, 133, 0.24);
  outline-offset: 2px;
}

.general-feedback-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-panel);
}

.general-feedback-record-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
}

.general-feedback-record-header h3,
.general-feedback-record-header p,
.general-feedback-email {
  margin: 0;
}

.general-feedback-record-header p,
.general-feedback-record-header time,
.general-feedback-email {
  color: var(--muted);
}

.general-feedback-record-details {
  display: grid;
  gap: 16px;
  margin: 0;
}

.general-feedback-record-details div {
  display: grid;
  gap: 6px;
}

.general-feedback-record-details dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.general-feedback-record-details dd {
  margin: 0;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  .general-feedback-record-header {
    display: grid;
  }
}

/* Success: narrow screens use the familiar hamburger-and-drawer pattern without hiding destinations behind a custom interaction. */
@media (max-width: 900px) {
  body.app-nav-open {
    overflow: hidden;
  }

  .app-shell:has(.app-navigation:not(.hidden)) {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 18px;
  }

  .app-shell:has(.app-navigation:not(.hidden)):has(#dashboard-screen:not(.hidden)),
  .app-shell:has(.app-navigation:not(.hidden)):has(#project-page:not(.hidden)) {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 18px;
  }

  .app-navigation {
    position: sticky;
    inset: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    width: auto;
    min-height: 58px;
    margin-bottom: 20px;
    padding: 8px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(6, 7, 8, 0.94);
    box-shadow: none;
    /* Previous failure: inherited backdrop blur trapped the fixed drawer inside the 58px mobile header. */
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    overflow: visible;
  }

  .app-nav-brand {
    margin: 0;
    padding: 0;
    border: 0;
  }

  .app-nav-menu-button {
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-color: var(--line);
    background: var(--surface-panel);
    color: var(--ink);
  }

  .app-nav-menu-button:hover,
  .app-nav-menu-button:focus-visible,
  .app-nav-close-button:hover,
  .app-nav-close-button:focus-visible {
    border-color: rgba(35, 201, 133, 0.45);
    color: var(--accent);
  }

  .app-nav-menu {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 230;
    width: min(86vw, 340px);
    min-width: 0;
    flex-direction: column;
    gap: 18px;
    align-items: stretch;
    padding: 20px;
    border-right: 1px solid var(--line);
    background: var(--surface-panel-strong);
    box-shadow: 24px 0 56px rgba(0, 0, 0, 0.4);
    overflow-y: auto;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 180ms ease;
  }

  .app-nav-menu.is-open {
    transform: translateX(0);
    visibility: visible;
  }

  .app-nav-drawer-header {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
  }

  .app-nav-close-button {
    min-height: 40px;
    padding: 0 12px;
    border-color: var(--line);
    color: var(--ink);
  }

  .app-nav-link {
    width: 100%;
    min-height: 52px;
    justify-content: flex-start;
    padding: 0 16px;
    text-align: left;
  }

  .app-nav-logout {
    margin-top: auto;
    border-color: var(--line);
  }

  .app-nav-scrim:not(.hidden) {
    position: fixed;
    inset: 0;
    z-index: 220;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.62);
  }

  .aio-feedback-page-header {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-nav-menu {
    transition: none;
  }
}

/* Success: Historical Formulas is the canonical heading contract for every authenticated page. */
.app-page-header {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 24px;
  border-bottom: 1px solid var(--line);
}

.app-page-header h1 {
  max-width: none;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2.15rem, 4vw, 3.5rem);
  font-weight: 720;
  line-height: 1;
  letter-spacing: 0;
  text-align: left;
  white-space: normal;
}

/* Success: primary library/dashboard titles stay uniform without dominating the working content below them. */
#dashboard-title,
#raw-materials-title,
#historical-formulas-title,
#aio-feedback-title {
  font-size: clamp(2rem, 2.8vw, 2.65rem);
}

/* Success: equal-width historical-formula actions sit at the true end of the detail card without obscuring ingredients. */
.historical-detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.historical-detail-actions .secondary-action,
.historical-detail-actions .danger-action {
  width: 100%;
}

.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h-md);
  padding: 0 20px;
  border: 1px solid rgba(255, 136, 124, 0.5);
  border-radius: var(--radius-control);
  background: var(--danger-soft);
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.danger-action:hover:not(:disabled) {
  border-color: var(--danger);
  background: rgba(255, 136, 124, 0.2);
  transform: translateY(-1px);
}

.danger-action:focus-visible {
  outline: 3px solid rgba(255, 136, 124, 0.25);
  outline-offset: 2px;
}

.danger-action:disabled {
  cursor: wait;
  opacity: 0.6;
}

.historical-formula-delete-card h2 {
  margin: 0;
  line-height: 1.25;
}

.historical-formula-delete-actions {
  justify-content: flex-end;
  margin-top: 24px;
}

/* Previous failure: centering this modal across the full viewport put its left edge beneath the persistent sidebar. */
#historical-formula-edit-modal {
  box-sizing: border-box;
}

/* Success: desktop editing is centered inside the usable content area while navigation remains visible. */
@media (min-width: 901px) {
  body:has(.app-navigation:not(.hidden)) #historical-formula-edit-modal {
    inset: 0 0 0 var(--app-sidebar-width);
  }
}

/* Success: metadata and core ingredient editing stays contained in one scrollable, keyboard-accessible modal. */
.historical-formula-edit-card {
  box-sizing: border-box;
  width: min(calc(100vw - 48px), 860px) !important;
  max-width: 860px;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Previous failure: an older high-specificity modal textarea rule left Source Note white in the dark editor. */
.historical-formula-edit-card textarea {
  border-color: rgba(231, 237, 234, 0.14);
  background: rgba(5, 6, 7, 0.58);
  color: var(--ink);
}

.historical-formula-edit-card textarea::placeholder {
  color: rgba(147, 168, 160, 0.72);
}

.historical-formula-edit-card textarea:focus-visible {
  outline: 3px solid rgba(35, 201, 133, 0.25);
  outline-offset: 2px;
}

.historical-edit-heading h2,
.historical-edit-section-heading h3 {
  margin: 0;
}

.historical-edit-heading .privacy-modal-copy {
  margin-bottom: 0;
}

.historical-edit-body {
  display: grid;
  gap: 24px;
  margin-top: 22px;
}

.historical-edit-metadata,
.historical-edit-ingredient-section {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface-strong);
}

.historical-edit-section-heading {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.historical-edit-section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.historical-edit-metadata-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.historical-edit-metadata-grid label,
.historical-edit-ingredient label {
  margin: 0;
}

.historical-edit-metadata-grid label > span,
.historical-edit-ingredient label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.historical-edit-field-wide {
  grid-column: 1 / -1;
}

.historical-formula-edit-card input[readonly] {
  color: var(--muted);
  background: var(--surface-muted);
  cursor: not-allowed;
}

.historical-edit-total {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.historical-edit-total div {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.historical-edit-total span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.historical-edit-total strong {
  font-family: var(--font-mono);
  font-size: 1.15rem;
}

.historical-edit-total-status.is-balanced {
  color: var(--accent);
}

.historical-edit-ingredients {
  display: grid;
  gap: 10px;
}

.historical-edit-ingredient {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(160px, 1fr) minmax(105px, 0.35fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.historical-edit-row-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.historical-edit-row-actions .secondary-action {
  min-height: var(--control-h-md);
  padding-inline: 10px;
}

.remove-historical-ingredient {
  color: var(--danger);
}

.historical-edit-empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-control);
  color: var(--muted);
  text-align: center;
}

.historical-edit-error {
  min-height: 1.5em;
  margin: 14px 0 0;
}

.historical-formula-edit-actions {
  justify-content: flex-end;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

@media (max-width: 820px) {
  .historical-edit-metadata-grid,
  .historical-edit-ingredient {
    grid-template-columns: 1fr;
  }

  .historical-edit-field-wide {
    grid-column: auto;
  }

  .historical-edit-section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .historical-edit-row-actions {
    flex-wrap: wrap;
  }

  .historical-edit-row-actions .secondary-action {
    flex: 1;
  }
}

@media (max-width: 900px) {
  /* Success: the compact navigation remains available without covering the responsive editor. */
  #historical-formula-edit-modal {
    inset: 76px 0 0;
    padding: 18px;
  }

  .historical-formula-edit-card {
    width: min(calc(100vw - 36px), 860px) !important;
    max-height: calc(100dvh - 94px);
  }
}

/* Success: RL-253 places project management around the existing formulation flow without replacing any workflow screen. */
.project-overview-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.project-overview-header-meta > span:not(:last-child) {
  position: relative;
}

.project-overview-header-meta > span:not(:last-child)::after {
  position: absolute;
  top: 50%;
  right: -10px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(231, 237, 234, 0.26);
  content: "";
  transform: translateY(-50%);
}

.project-overview-status {
  color: var(--accent-dark);
}

.project-overview-status::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(35, 201, 133, 0.11);
  content: "";
}

.project-preview-label {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(246, 201, 109, 0.28);
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  font-family: var(--font-data);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

#project-page .project-overview-panel {
  padding-top: 24px;
}

.project-overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.72fr);
  gap: 20px;
  align-items: stretch;
}

.project-overview-main {
  display: grid;
  gap: 20px;
}

.project-overview-card {
  padding: clamp(20px, 2.2vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.025), transparent 48%),
    var(--surface-panel);
  box-shadow: var(--shadow-panel);
}

.project-overview-section-heading {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.project-overview-section-heading h2 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: clamp(1.2rem, 1.8vw, 1.55rem);
  line-height: 1.2;
}

.project-overview-kicker {
  margin: 0;
  color: var(--accent-dark);
  font-family: var(--font-data);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.project-overview-fact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.project-overview-fact-grid article {
  min-width: 0;
  padding: 8px 22px 20px 0;
  border-bottom: 1px solid var(--line);
}

.project-overview-fact-grid article:nth-child(3n + 2),
.project-overview-fact-grid article:nth-child(3n + 3) {
  padding-left: 22px;
  border-left: 1px solid var(--line);
}

.project-overview-fact-grid article:nth-last-child(-n + 3) {
  padding-top: 22px;
  padding-bottom: 4px;
  border-bottom: 0;
}

.project-overview-fact-grid span,
.project-activity-list div > span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0.02em;
}

.project-overview-fact-grid strong {
  display: block;
  margin-top: 7px;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(0.96rem, 1.3vw, 1.12rem);
  line-height: 1.3;
  text-overflow: ellipsis;
}

/* Previous failure avoided: the full-width edit dropdown must not stretch the inline overview status anchor. */
.project-status-dropdown.project-overview-status-dropdown {
  flex: 0 0 auto;
  width: fit-content;
  max-width: 100%;
}

.project-overview-status-trigger {
  display: inline-flex;
  min-height: 34px;
  min-width: 128px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 7px 10px;
  border: 1px solid #70dcb326;
  border-radius: 8px;
  background: #70dcb30b;
  color: #70dcb3;
  box-shadow: none;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.project-overview-status-trigger::before {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.project-overview-status-trigger:hover,
.project-overview-status-trigger:focus-visible,
.project-overview-status-dropdown.is-open .project-overview-status-trigger {
  color: #70dcb3;
  border-color: #70dcb3;
  outline: 0;
  background: #70dcb30b;
  box-shadow: none;
  transform: none;
}

.project-overview-status-trigger .project-status-chevron {
  width: 5px;
  height: 5px;
  margin: -3px 2px 0 auto;
  overflow: visible;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  stroke: none;
  transform: rotate(45deg);
}

.project-overview-status-trigger .project-status-chevron path {
  display: none;
}

.project-overview-status-dropdown.is-open .project-overview-status-trigger .project-status-chevron {
  transform: rotate(225deg);
}

.project-overview-status-dropdown .project-overview-status-menu {
  right: 0;
  left: auto;
  width: min(270px, calc(100vw - 48px));
}

/* Previous failure: the generic right anchor pulled this wider menu beneath the fixed sidebar. */
.project-stage-visual .project-overview-status-dropdown .project-overview-status-menu {
  right: auto;
  left: 0;
  transform: none;
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.project-progress-steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.project-progress-steps li {
  position: relative;
  display: grid;
  gap: 10px;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}

.project-progress-steps li:not(:last-child)::after {
  position: absolute;
  top: 17px;
  left: calc(50% + 20px);
  z-index: 0;
  width: calc(100% - 40px);
  height: 2px;
  background: var(--line);
  content: "";
}

.project-progress-steps li.is-complete:not(:last-child)::after {
  background: var(--accent);
}

.project-progress-marker {
  position: relative;
  z-index: 1;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.78rem;
  font-weight: 900;
}

.project-progress-steps li.is-complete .project-progress-marker {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.project-progress-steps li.is-current .project-progress-marker {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 6px var(--accent-soft);
}

.project-progress-steps li.is-complete strong,
.project-progress-steps li.is-current strong {
  color: var(--ink);
}

.project-progress-steps strong {
  min-width: 0;
  max-width: 100%;
  padding: 0 4px;
  font-size: clamp(0.68rem, 0.78vw, 0.8rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.project-activity-card {
  display: flex;
  min-height: 100%;
  flex-direction: column;
}

.project-activity-list {
  display: grid;
}

.project-activity-list article {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.project-activity-marker {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(35, 201, 133, 0.3);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-family: var(--font-data);
  font-weight: 900;
}

.project-activity-list strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.35;
}

.project-activity-list time {
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.72rem;
  white-space: nowrap;
}

.project-activity-note {
  margin: auto 0 0;
  padding-top: 20px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

/* Success: RL-258 keeps human-authored project notes separate from automatic workflow activity. */
.project-updates-heading {
  align-items: center;
  margin-bottom: 14px;
}

.project-updates-heading h2 {
  margin: 0;
}

.project-update-create-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.project-update-list {
  min-height: 220px;
  max-height: min(520px, calc(100dvh - 370px));
  overflow-y: auto;
  padding-right: 6px;
  overscroll-behavior: contain;
  scrollbar-color: rgba(35, 201, 133, 0.42) transparent;
}

.project-update-entry {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.project-update-entry:first-child {
  padding-top: 8px;
}

.project-update-entry:last-of-type {
  border-bottom: 0;
}

.project-update-entry h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.project-update-description {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.project-update-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.7rem;
  line-height: 1.4;
}

.project-update-author {
  color: var(--accent-dark);
  overflow-wrap: anywhere;
}

.project-update-meta time::before {
  margin-right: 10px;
  color: rgba(231, 237, 234, 0.26);
  content: "•";
}

.project-update-empty,
.project-update-loading,
.project-update-error-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  margin: 0;
  padding: 24px;
  border: 1px dashed rgba(231, 237, 234, 0.12);
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
  text-align: center;
}

.project-update-error-state {
  border-color: rgba(255, 119, 119, 0.24);
  color: #f2aaaa;
}

.project-update-load-more {
  display: grid;
  padding: 16px 0 4px;
}

.project-update-load-more .secondary-action {
  width: 100%;
  min-height: 40px;
}

.project-update-form-fields {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

/* Previous failure: the generic modal textarea rule overrode the dark theme and rendered Description white. */
.project-update-modal-card input,
.project-update-modal-card textarea {
  box-sizing: border-box;
  border-color: rgba(184, 248, 221, 0.18);
  background: rgba(5, 13, 10, 0.62);
  color: var(--ink);
  font: inherit;
  caret-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.project-update-modal-card textarea {
  min-height: 150px;
  resize: vertical;
}

.project-update-modal-card input::placeholder,
.project-update-modal-card textarea::placeholder {
  color: rgba(147, 168, 160, 0.7);
}

.project-update-modal-card input:hover,
.project-update-modal-card textarea:hover {
  border-color: rgba(184, 248, 221, 0.28);
}

.project-update-modal-card input:focus-visible,
.project-update-modal-card textarea:focus-visible {
  border-color: rgba(35, 201, 133, 0.72);
  outline: 3px solid rgba(35, 201, 133, 0.2);
  outline-offset: 2px;
  background: rgba(5, 13, 10, 0.82);
  box-shadow: 0 0 0 1px rgba(35, 201, 133, 0.12);
}

.project-update-form-actions {
  justify-content: flex-end;
  margin-top: 6px;
}

/* Success: Customer Information uses its own full-width card between the overview row and Tasks. */
.project-customer-information-card {
  margin-top: 20px;
}

.project-customer-information-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 0;
}

.project-customer-information-list > div {
  min-width: 0;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.project-customer-information-list > div:nth-child(3n + 1) {
  padding-left: 0;
  border-left: 0;
}

.project-customer-information-list > div:nth-child(-n + 3) {
  padding-top: 8px;
}

.project-customer-information-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0.02em;
}

.project-customer-information-list dd {
  margin: 7px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

.project-customer-information-list .project-customer-information-address {
  grid-column: span 2;
}

.project-customer-information-list .project-customer-information-notes {
  grid-column: 1 / -1;
  padding-right: 0;
  padding-bottom: 4px;
  padding-left: 0;
  border-bottom: 0;
  border-left: 0;
}

/* Success: RL-267 keeps supporting files full-width between customer context and project tasks. */
.project-files-card {
  margin-top: 20px;
}

.project-files-heading {
  align-items: center;
  margin-bottom: 12px;
}

.project-files-heading h2 {
  margin-top: 0;
}

.project-files-heading p {
  max-width: 660px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.project-file-upload-control {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
}

.project-file-upload-control.is-disabled {
  pointer-events: none;
  opacity: 0.55;
}

.project-file-status {
  min-height: 20px;
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  line-height: 1.45;
}

.project-file-list {
  display: grid;
  gap: 10px;
}

.project-file-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 17px 18px;
  border: 1px solid rgba(231, 237, 234, 0.1);
  border-radius: 13px;
  background: rgba(4, 10, 8, 0.4);
}

.project-file-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.project-file-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-file-copy span {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.project-file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.project-file-actions button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 0.75rem;
}

.project-file-empty,
.project-file-error-state {
  display: grid;
  min-height: 92px;
  place-items: center;
  margin: 0;
  padding: 20px;
  border: 1px dashed rgba(231, 237, 234, 0.12);
  border-radius: 13px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

.project-file-error-state {
  gap: 12px;
  border-color: rgba(255, 119, 119, 0.24);
  color: #f2aaaa;
}

.project-file-error-state p {
  margin: 0;
}

.project-file-form-actions {
  justify-content: flex-end;
}

/* Success: RL-259 keeps project tasks full-width and independent from Updates and workflow progress. */
.project-tasks-card {
  margin-top: 20px;
}

.project-tasks-heading {
  align-items: center;
  margin-bottom: 20px;
}

.project-tasks-heading h2 {
  margin-top: 4px;
}

.project-task-create-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.project-task-section {
  min-width: 0;
}

.project-task-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.project-task-section-title-row h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-task-count {
  display: inline-grid;
  min-width: 28px;
  min-height: 24px;
  place-items: center;
  padding: 0 8px;
  border: 1px solid rgba(184, 248, 221, 0.12);
  border-radius: 999px;
  background: rgba(35, 201, 133, 0.07);
  color: var(--accent-dark);
  font-family: var(--font-data);
  font-size: 0.68rem;
  font-weight: 900;
}

.project-task-list {
  display: grid;
  gap: 10px;
}

.project-task-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 17px 18px;
  border: 1px solid rgba(231, 237, 234, 0.1);
  border-radius: 13px;
  background: rgba(4, 10, 8, 0.4);
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.project-task-entry:hover {
  border-color: rgba(184, 248, 221, 0.18);
  background: rgba(7, 17, 13, 0.58);
}

.project-task-entry.is-overdue {
  border-color: rgba(246, 201, 109, 0.3);
  box-shadow: inset 3px 0 0 rgba(246, 201, 109, 0.78);
}

.project-task-entry.is-completed {
  background: rgba(4, 10, 8, 0.26);
}

.project-task-copy {
  min-width: 0;
}

.project-task-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.project-task-title-row h4 {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.project-task-due-chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(184, 248, 221, 0.13);
  border-radius: 999px;
  background: rgba(184, 248, 221, 0.055);
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.66rem;
  font-weight: 850;
  white-space: nowrap;
}

.project-task-due-chip.is-overdue {
  border-color: rgba(246, 201, 109, 0.32);
  background: rgba(246, 201, 109, 0.1);
  color: #efd58f;
}

.project-task-description {
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.project-task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.7rem;
  line-height: 1.45;
}

.project-task-assignee strong {
  color: var(--accent-dark);
  overflow-wrap: anywhere;
}

.project-task-meta time {
  color: #aeb9b4;
}

.project-task-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.project-task-actions button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 0.74rem;
}

.project-task-history {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid rgba(112, 220, 179, 0.18);
  border-radius: 11px;
  background: rgba(8, 18, 14, 0.72);
}

.project-task-history-heading { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.project-task-history-heading h5 { margin: 0; color: var(--ink); font-size: 0.84rem; }
.project-task-history-heading span, .project-task-history-status { color: var(--muted); font-size: 0.72rem; }
.project-task-history-status { margin: 0; }
.project-task-history-status.is-error { color: #f0b3ad; }
.project-task-history-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.project-task-history-event { padding-left: 12px; border-left: 2px solid rgba(112, 220, 179, 0.3); }
.project-task-history-event > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; }
.project-task-history-event > div > strong { color: var(--ink); font-size: 0.78rem; }
.project-task-history-event > div > span { color: var(--muted); font-family: var(--font-data); font-size: 0.66rem; }
.project-task-history-event > p { margin: 7px 0 0; color: #dfe7e3; font-size: 0.78rem; white-space: pre-wrap; }
.project-task-history-changes { display: grid; gap: 5px; margin: 8px 0 0; padding: 0; list-style: none; }
.project-task-history-changes li { display: grid; grid-template-columns: minmax(100px, .35fr) minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; color: var(--muted); font-size: 0.72rem; overflow-wrap: anywhere; }
.project-task-history-changes strong { color: #cbd5d0; }
.project-task-note-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: end; }
.project-task-note-form textarea { width: 100%; min-height: 58px; resize: vertical; padding: 10px 12px; border: 1px solid rgba(231, 237, 234, 0.16); border-radius: 9px; background: #080b0a; color: var(--ink); font: inherit; box-sizing: border-box; }
.project-task-note-form textarea:focus-visible { outline: 2px solid rgba(112, 220, 179, 0.6); outline-offset: 2px; }

.project-task-complete-action,
.project-task-reopen-action {
  border-color: rgba(35, 201, 133, 0.32);
  background: rgba(35, 201, 133, 0.12);
  color: #8be4bd;
}

.project-task-completed-details {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.project-task-completed-details summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 850;
  cursor: pointer;
  list-style: none;
}

.project-task-completed-details summary::-webkit-details-marker {
  display: none;
}

.project-task-completed-details summary::after {
  margin-left: auto;
  color: var(--muted);
  content: "⌄";
  font-size: 1rem;
  transition: transform 150ms ease;
}

.project-task-completed-details[open] summary::after {
  transform: rotate(180deg);
}

.project-task-completed-list {
  max-height: 460px;
  overflow-y: auto;
  margin-top: 10px;
  padding-right: 6px;
  overscroll-behavior: contain;
  scrollbar-color: rgba(35, 201, 133, 0.42) transparent;
}

.project-task-empty,
.project-task-loading,
.project-task-error-state {
  display: grid;
  min-height: 88px;
  place-items: center;
  margin: 0;
  padding: 20px;
  border: 1px dashed rgba(231, 237, 234, 0.12);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

.project-task-error-state {
  border-color: rgba(255, 119, 119, 0.24);
  color: #f2aaaa;
}

.project-task-error-state p {
  margin: 0 0 12px;
}

.project-task-load-more {
  display: grid;
  padding-top: 4px;
}

.project-task-load-more .secondary-action {
  width: 100%;
  min-height: 40px;
}

.project-task-form-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.72fr);
  gap: 18px;
  margin-top: 24px;
}

body.project-task-modal-open {
  overflow: hidden;
}

#project-task-modal {
  /* Previous issue: sidebar z-index 200 sat above the task backdrop at 20. */
  z-index: 1200;
  overflow: hidden;
  overscroll-behavior: contain;
}

/* Previous short-viewport failure fixed: the task form scrolls internally without moving the page behind it. */
.project-task-modal-card {
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.project-task-field-wide {
  grid-column: 1 / -1;
}

.project-task-modal-card input,
.project-task-modal-card textarea {
  box-sizing: border-box;
  width: 100%;
  border-color: rgba(184, 248, 221, 0.18);
  background: rgba(5, 13, 10, 0.62);
  color: var(--ink);
  font: inherit;
  caret-color: var(--accent);
  color-scheme: dark;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.project-task-modal-card textarea {
  min-height: 132px;
  padding: 12px 13px;
  resize: vertical;
}

.project-task-modal-card input::placeholder,
.project-task-modal-card textarea::placeholder {
  color: rgba(147, 168, 160, 0.7);
}

.project-task-modal-card input:focus-visible,
.project-task-modal-card textarea:focus-visible {
  border-color: rgba(35, 201, 133, 0.72);
  outline: 3px solid rgba(35, 201, 133, 0.2);
  outline-offset: 2px;
  background: rgba(5, 13, 10, 0.82);
}

.project-task-form-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

.project-task-delete-card {
  width: min(100%, 480px);
}

.project-task-delete-card h2 {
  margin: 6px 0 12px;
}

.project-task-delete-card .privacy-modal-copy strong {
  color: var(--ink);
}

/* Success: RL-265 renders one shared, date-complete task timeline while keeping project ownership independent. */
.task-management-timeline {
  display: grid;
  gap: 26px;
  min-width: 0;
}

.task-management-loading,
.task-management-error-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  margin: 0;
  padding: 28px;
  border: 1px dashed rgba(231, 237, 234, 0.14);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

.task-management-error-state {
  gap: 14px;
  border-color: rgba(255, 119, 119, 0.28);
  color: #f2aaaa;
}

.task-management-error-state p {
  margin: 0;
}

.task-management-day {
  min-width: 0;
}

.task-management-day-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.task-management-day-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.35;
}

.task-management-overdue-badge,
.task-management-today-badge,
.task-management-status-badge,
.task-management-archived-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  font-family: var(--font-data);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Previous failure removed: RL-272 replaces the empty yellow overdue panel and card accent with one red date pill. */
.task-management-overdue-badge {
  min-height: 30px;
  padding: 0 13px;
  border: 1px solid rgba(255, 119, 119, 0.58);
  background: rgba(255, 119, 119, 0.14);
  color: #ff9d9d;
  font-size: 0.72rem;
}

.task-management-overdue-days,
.task-management-days {
  display: grid;
}

.task-management-day {
  display: grid;
  gap: 12px;
  min-height: 74px;
  padding: 18px 0;
  border-top: 1px solid rgba(231, 237, 234, 0.1);
}

.task-management-today-badge,
.task-management-status-badge {
  border: 1px solid rgba(35, 201, 133, 0.28);
  background: rgba(35, 201, 133, 0.1);
  color: #8be4bd;
}

.task-management-archived-badge {
  border: 1px solid rgba(246, 201, 109, 0.28);
  background: rgba(246, 201, 109, 0.09);
  color: #efd58f;
}

.task-management-day-cards {
  display: grid;
  gap: 10px;
}

.task-management-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 18px;
  border: 1px solid rgba(231, 237, 234, 0.11);
  border-radius: 13px;
  background: rgba(4, 10, 8, 0.42);
  transition:
    border-color 150ms ease,
    background 150ms ease;
}

.task-management-card:hover {
  border-color: rgba(184, 248, 221, 0.2);
  background: rgba(7, 17, 13, 0.58);
}

.task-management-card-copy {
  min-width: 0;
}

.task-management-card-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.task-management-card-title-row h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.task-management-card-copy > p {
  margin: 8px 0 11px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.task-management-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 18px;
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.7rem;
  line-height: 1.45;
}

.task-management-card-meta strong {
  color: var(--accent-dark);
}

.task-management-card-meta time {
  color: inherit;
}

.task-management-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 390px;
}

.task-management-card-actions button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 0.73rem;
}

.task-management-inline-error {
  margin: -10px 0 0;
  color: #f2aaaa;
  font-size: 0.8rem;
  text-align: center;
}

.task-management-load-more {
  display: grid;
}

.task-management-load-more .secondary-action {
  width: 100%;
  min-height: 48px;
}

/* Previous failure removed: the native project picker escaped the task modal's visual system and filled the screen. */
.project-task-project-field {
  min-width: 0;
}

.project-task-field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 850;
}

.project-task-project-dropdown {
  position: relative;
  z-index: 1;
  width: 100%;
}

.project-task-project-dropdown.is-open {
  z-index: 8;
}

.project-task-project-trigger {
  display: flex;
  width: 100%;
  min-height: var(--control-h-md);
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid rgba(184, 248, 221, 0.18);
  border-radius: var(--radius-control);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    rgba(5, 13, 10, 0.72);
  color: var(--muted);
  font: inherit;
  font-weight: 780;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.project-task-project-trigger.has-selection {
  color: var(--ink);
}

.project-task-project-trigger:hover:not(:disabled) {
  border-color: rgba(35, 201, 133, 0.48);
  background: rgba(8, 20, 15, 0.9);
}

.project-task-project-trigger:focus-visible,
.project-task-project-dropdown.is-open .project-task-project-trigger {
  border-color: rgba(35, 201, 133, 0.72);
  outline: 3px solid rgba(35, 201, 133, 0.2);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px rgba(35, 201, 133, 0.12);
}

.project-task-project-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.project-task-project-trigger-copy,
.project-task-project-option-copy {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

#project-task-project-value,
.project-task-project-option-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-task-project-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid rgba(234, 190, 108, 0.26);
  border-radius: 999px;
  background: rgba(234, 190, 108, 0.1);
  color: #eabe6c;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.project-task-project-chevron {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 150ms ease;
}

.project-task-project-dropdown.is-open .project-task-project-chevron {
  transform: rotate(180deg);
}

.project-task-project-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  box-sizing: border-box;
  width: 100%;
  padding: 9px;
  border: 1px solid rgba(231, 237, 234, 0.16);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 46%),
    #151817;
  box-shadow:
    0 24px 54px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(0, 0, 0, 0.24);
}

.project-task-modal-card .project-task-project-search {
  min-height: 42px;
  margin-bottom: 8px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(4, 8, 7, 0.78);
  font-size: 0.84rem;
}

.project-task-project-list {
  display: grid;
  max-height: min(270px, 36vh);
  gap: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.project-task-project-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #b8c0bc;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 760;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.project-task-project-option:hover,
.project-task-project-option:focus-visible {
  border-color: rgba(231, 237, 234, 0.09);
  outline: 0;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

.project-task-project-option[aria-selected="true"] {
  border-color: rgba(35, 201, 133, 0.3);
  background: rgba(35, 201, 133, 0.12);
  color: #f0f8f4;
}

.project-task-project-check {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 950;
  opacity: 0;
}

.project-task-project-option[aria-selected="true"] .project-task-project-check {
  opacity: 1;
}

.project-task-project-empty {
  margin: 0;
  padding: 18px 12px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

/* Previous free-text failure removed: task assignees now come from the active Admin/Chemist directory while saved names remain durable. */
.project-task-assignee-field,
.project-task-due-date-field {
  min-width: 0;
}

.project-task-assignee-dropdown,
.project-task-due-date-dropdown {
  position: relative;
  z-index: 1;
  width: 100%;
}

.project-task-assignee-dropdown.is-open,
.project-task-due-date-dropdown.is-open {
  z-index: 9;
}

.project-task-control-trigger {
  display: flex;
  width: 100%;
  min-height: var(--control-h-md);
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid rgba(184, 248, 221, 0.18);
  border-radius: var(--radius-control);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    rgba(5, 13, 10, 0.72);
  color: var(--muted);
  font: inherit;
  font-weight: 780;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.project-task-control-trigger.has-selection {
  color: var(--ink);
}

.project-task-control-trigger:hover {
  border-color: rgba(35, 201, 133, 0.48);
  background: rgba(8, 20, 15, 0.9);
}

.project-task-control-trigger:focus-visible,
.project-task-assignee-dropdown.is-open .project-task-control-trigger,
.project-task-due-date-dropdown.is-open .project-task-control-trigger {
  border-color: rgba(35, 201, 133, 0.72);
  outline: 3px solid rgba(35, 201, 133, 0.2);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px rgba(35, 201, 133, 0.12);
}

.project-task-control-chevron,
.project-task-calendar-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.project-task-control-chevron {
  transition: transform 150ms ease;
}

.project-task-assignee-dropdown.is-open .project-task-control-chevron {
  transform: rotate(180deg);
}

.project-task-assignee-menu,
.project-task-calendar-popover {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  box-sizing: border-box;
  padding: 9px;
  border: 1px solid rgba(231, 237, 234, 0.16);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 46%),
    #151817;
  box-shadow:
    0 24px 54px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(0, 0, 0, 0.24);
}

.project-task-assignee-menu {
  right: 0;
  left: 0;
  width: 100%;
}

.project-task-assignee-dropdown.opens-upward .project-task-assignee-menu,
.project-task-due-date-dropdown.opens-upward .project-task-calendar-popover {
  top: auto;
  bottom: calc(100% + 8px);
}

.project-task-modal-card .project-task-assignee-search {
  min-height: 42px;
  margin-bottom: 8px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(4, 8, 7, 0.78);
  font-size: 0.84rem;
}

.project-task-assignee-list {
  display: grid;
  max-height: min(250px, 34vh);
  gap: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.project-task-assignee-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  min-height: 50px;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #b8c0bc;
  font: inherit;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

/* Previous QA failure fixed: explicit hidden styling must beat the custom options' grid display during search. */
.project-task-project-option[hidden],
.project-task-assignee-option[hidden] {
  display: none !important;
}

.project-task-assignee-option:hover,
.project-task-assignee-option:focus-visible {
  border-color: rgba(231, 237, 234, 0.09);
  outline: 0;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

.project-task-assignee-option[aria-selected="true"] {
  border-color: rgba(35, 201, 133, 0.3);
  background: rgba(35, 201, 133, 0.12);
  color: #f0f8f4;
}

.project-task-assignee-option-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.project-task-assignee-option-copy strong,
.project-task-assignee-option-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-task-assignee-option-copy strong {
  font-size: 0.84rem;
}

.project-task-assignee-option-copy small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 720;
}

.project-task-control-check {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 950;
  opacity: 0;
}

.project-task-assignee-option[aria-selected="true"] .project-task-control-check {
  opacity: 1;
}

.project-task-control-empty {
  margin: 0;
  padding: 18px 12px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

/* Previous native-control inconsistency removed: due dates now use one Formul8r calendar across supported browsers. */
.project-task-calendar-popover {
  right: 0;
  width: min(320px, 100%);
  padding: 12px;
}

.project-task-calendar-heading {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.project-task-calendar-heading strong {
  color: var(--ink);
  font-size: 0.88rem;
  text-align: center;
}

.project-task-calendar-nav {
  display: grid;
  width: 36px;
  min-height: 34px;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(231, 237, 234, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink);
  font: inherit;
  font-size: 1.35rem;
  cursor: pointer;
}

.project-task-calendar-nav:hover,
.project-task-calendar-nav:focus-visible {
  border-color: rgba(35, 201, 133, 0.48);
  outline: 0;
  background: rgba(35, 201, 133, 0.1);
}

.project-task-calendar-weekdays,
.project-task-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.project-task-calendar-weekdays {
  margin-bottom: 5px;
}

.project-task-calendar-weekdays span {
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.58rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.project-task-calendar-day {
  display: grid;
  min-width: 0;
  min-height: 35px;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #c4ccc8;
  font: inherit;
  font-size: 0.73rem;
  font-weight: 780;
  cursor: pointer;
}

.project-task-calendar-day.is-outside-month {
  color: rgba(147, 168, 160, 0.48);
}

.project-task-calendar-day.is-today {
  border-color: rgba(35, 201, 133, 0.46);
}

.project-task-calendar-day:hover:not(:disabled),
.project-task-calendar-day:focus-visible {
  border-color: rgba(231, 237, 234, 0.13);
  outline: 0;
  background: rgba(255, 255, 255, 0.065);
  color: var(--ink);
}

.project-task-calendar-day[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #03100b;
}

.project-task-calendar-day:disabled {
  color: rgba(147, 168, 160, 0.25);
  cursor: not-allowed;
  text-decoration: line-through;
}

/* Success: the title-only popup remains compact after moving assignments into Project Details. */
.project-overview-edit-card {
  box-sizing: border-box;
  width: min(calc(100vw - 48px), 560px) !important;
  max-width: 560px;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.project-overview-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.project-overview-edit-grid label,
.project-overview-field {
  min-width: 0;
  margin: 0;
}

.project-overview-edit-grid label > span,
.project-overview-field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.project-overview-field-wide {
  grid-column: 1 / -1;
}

.project-responsibility-field {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 8px;
}

.project-responsibility-help {
  margin: -1px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.project-responsibility-manual {
  margin-top: 4px !important;
}

.project-team-field {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.project-team-field legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.project-team-field > p,
.project-team-empty {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
}

.project-team-dropdown {
  position: relative;
  z-index: 1;
  width: 100%;
}

.project-team-dropdown.is-open {
  z-index: 20;
}

.project-team-trigger {
  display: flex;
  width: 100%;
  min-height: var(--control-h-md);
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid rgba(184, 248, 221, 0.18);
  border-radius: var(--radius-control);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    rgba(5, 13, 10, 0.72);
  color: var(--muted);
  font: inherit;
  font-weight: 780;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.project-team-trigger.has-selection {
  color: var(--ink);
}

.project-team-trigger:hover:not(:disabled) {
  border-color: rgba(35, 201, 133, 0.48);
  background: rgba(8, 20, 15, 0.9);
}

.project-team-trigger:focus-visible,
.project-team-dropdown.is-open .project-team-trigger {
  border-color: rgba(35, 201, 133, 0.72);
  outline: 3px solid rgba(35, 201, 133, 0.2);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px rgba(35, 201, 133, 0.12);
}

.project-team-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.project-team-chevron {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 150ms ease;
}

.project-team-dropdown.is-open .project-team-chevron {
  transform: rotate(180deg);
}

.project-team-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  box-sizing: border-box;
  width: 100%;
  padding: 9px;
  border: 1px solid rgba(231, 237, 234, 0.16);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 46%),
    #151817;
  box-shadow:
    0 24px 54px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(0, 0, 0, 0.24);
}

.project-overview-edit-card .project-team-search {
  min-height: 42px;
  margin-bottom: 8px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(4, 8, 7, 0.78);
  font-size: 0.84rem;
}

.project-team-options {
  display: grid;
  max-height: min(250px, 34vh);
  gap: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.project-team-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  min-height: 50px;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #b8c0bc;
  font: inherit;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.project-team-option[hidden] {
  display: none !important;
}

.project-team-option:hover,
.project-team-option:focus-visible {
  border-color: rgba(231, 237, 234, 0.09);
  outline: 0;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

.project-team-option[aria-selected="true"] {
  border-color: rgba(35, 201, 133, 0.3);
  background: rgba(35, 201, 133, 0.12);
  color: #f0f8f4;
}

.project-team-option-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.project-team-option-copy strong,
.project-team-option-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-team-option-copy strong {
  font-size: 0.84rem;
}

.project-team-option-copy small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 720;
}

.project-team-check {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 950;
  opacity: 0;
}

.project-team-option[aria-selected="true"] .project-team-check {
  opacity: 1;
}

.project-team-menu .project-team-empty {
  margin: 0;
  padding: 18px 12px;
  text-align: center;
}

.project-overview-edit-card input,
.project-overview-edit-card select {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--control-h-md);
  border-color: var(--line);
  border-radius: 12px;
  background: rgba(5, 6, 7, 0.58);
  color: var(--ink);
  color-scheme: dark;
  font: inherit;
}

.project-overview-edit-card select {
  padding: 0 42px 0 14px;
  cursor: pointer;
}

.project-overview-edit-card select option {
  background: #151817;
  color: var(--ink);
}

.project-overview-edit-card input:focus-visible,
.project-overview-edit-card select:focus-visible {
  outline: 3px solid rgba(35, 201, 133, 0.25);
  outline-offset: 2px;
}

/* Previous issue avoided: native select menus ignored the modal's width, alignment, and dark interaction styling. */
.project-status-dropdown {
  position: relative;
  width: 100%;
}

.project-overview-edit-card .project-status-trigger,
#rnd-event-type-trigger {
  display: flex;
  width: 100%;
  min-height: var(--control-h-md);
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    rgba(5, 6, 7, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 820;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.project-overview-edit-card .project-status-trigger:hover,
#rnd-event-type-trigger:hover:not(:disabled) {
  border-color: rgba(35, 201, 133, 0.48);
  background: rgba(12, 17, 15, 0.92);
}

.project-overview-edit-card .project-status-trigger:focus-visible,
#rnd-event-type-trigger:focus-visible,
.project-status-dropdown.is-open .project-status-trigger {
  border-color: rgba(35, 201, 133, 0.72);
  outline: 3px solid rgba(35, 201, 133, 0.18);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px rgba(35, 201, 133, 0.12);
}

.project-status-trigger-copy {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.project-status-dot,
.project-status-option-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(35, 201, 133, 0.1);
}

.project-status-chevron {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 150ms ease;
}

.project-status-dropdown.is-open .project-status-chevron {
  transform: rotate(180deg);
}

.project-status-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  box-sizing: border-box;
  width: 100%;
  max-height: min(336px, 46vh);
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(231, 237, 234, 0.14);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 46%),
    #151817;
  box-shadow:
    0 22px 48px rgba(0, 0, 0, 0.52),
    0 0 0 1px rgba(0, 0, 0, 0.24);
}

.project-status-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #b8c0bc;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 760;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.project-status-option:hover,
.project-status-option:focus-visible {
  border-color: rgba(231, 237, 234, 0.08);
  outline: 0;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

.project-status-option[aria-selected="true"] {
  border-color: rgba(35, 201, 133, 0.28);
  background: rgba(35, 201, 133, 0.12);
  color: #f0f8f4;
}

.project-status-option-dot {
  width: 7px;
  height: 7px;
  background: #69736e;
  box-shadow: none;
}

.project-status-option[aria-selected="true"] .project-status-option-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(35, 201, 133, 0.1);
}

.project-status-check {
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 950;
  opacity: 0;
}

.project-status-option[aria-selected="true"] .project-status-check {
  opacity: 1;
}

.project-overview-edit-actions {
  justify-content: flex-end;
  margin-top: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

@media (min-width: 901px) {
  body:has(.app-navigation:not(.hidden)) #project-overview-edit-modal {
    inset: 0 0 0 var(--app-sidebar-width);
  }
}

@media (max-width: 1180px) {
  .project-overview-layout {
    grid-template-columns: 1fr;
  }

  .project-activity-card {
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .project-overview-header-meta > span::after {
    display: none;
  }

  .project-overview-section-heading,
  .project-overview-edit-grid {
    grid-template-columns: 1fr;
  }

  .project-team-options {
    grid-template-columns: 1fr;
  }

  .project-overview-section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .project-stage-control-row {
    justify-content: center;
    gap: 8px;
  }

  .project-status-dropdown.project-overview-status-dropdown,
  .project-overview-status-trigger {
    width: auto;
  }

  .project-overview-status-dropdown .project-overview-status-menu {
    width: min(270px, calc(100vw - 48px));
  }

  .project-overview-status-dropdown .project-overview-status-menu {
    right: 0;
    left: 0;
  }

  /* Success: on narrow screens the stage menu stays aligned to the full-width trigger. */
  .project-stage-visual .project-overview-status-dropdown .project-overview-status-menu {
    right: 0;
    left: 0;
    transform: none;
  }

  .project-overview-fact-grid {
    grid-template-columns: 1fr;
  }

  .project-customer-information-list {
    grid-template-columns: 1fr;
  }

  .project-customer-information-list > div,
  .project-customer-information-list > div:nth-child(3n + 1),
  .project-customer-information-list > div:nth-child(-n + 3) {
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
    border-left: 0;
  }

  .project-customer-information-list .project-customer-information-address {
    grid-column: auto;
  }

  .project-customer-information-list .project-customer-information-notes {
    grid-column: auto;
    padding-bottom: 0;
    border-bottom: 0;
  }

  .project-overview-fact-grid article,
  .project-overview-fact-grid article:nth-child(3n + 2),
  .project-overview-fact-grid article:nth-child(3n + 3),
  .project-overview-fact-grid article:nth-last-child(-n + 3) {
    padding: 16px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    border-left: 0;
  }

  .project-overview-fact-grid article:last-child {
    border-bottom: 0;
  }

  .project-progress-steps {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .project-progress-steps li {
    grid-template-columns: auto minmax(0, 1fr);
    justify-items: start;
    align-items: center;
    text-align: left;
  }

  .project-progress-steps li::after {
    display: none;
  }

  .project-overview-field-wide {
    grid-column: auto;
  }

  .project-activity-list article {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .project-activity-list time {
    grid-column: 2;
  }

  .project-file-entry {
    grid-template-columns: 1fr;
  }

  .project-file-actions {
    justify-content: flex-start;
  }

  .project-file-actions button,
  .project-file-upload-control {
    flex: 1 1 auto;
  }

  .project-tasks-heading,
  .project-task-entry {
    align-items: stretch;
  }

  .project-task-entry {
    grid-template-columns: 1fr;
  }

  .project-task-actions {
    justify-content: flex-start;
  }

  .project-task-form-fields {
    grid-template-columns: 1fr;
  }

  .project-task-field-wide {
    grid-column: auto;
  }

  .project-task-modal-card {
    max-height: calc(100dvh - 32px);
  }
}

@media (max-width: 900px) {
  #project-overview-edit-modal {
    inset: 76px 0 0;
    padding: 18px;
  }

  .project-overview-edit-card {
    width: min(calc(100vw - 36px), 560px) !important;
    max-height: calc(100dvh - 94px);
  }
}

/* Previous production issue: the 100% desktop view used 75%-zoom proportions, which wrapped workflow tabs and hid useful project context below the fold. */
@media (min-width: 1181px) {
  :root {
    --app-sidebar-width: 232px;
    --page-gutter: clamp(20px, 2.25vw, 36px);
    --control-h-md: 42px;
    --control-h-lg: 46px;
  }

  .app-navigation {
    padding: 20px 14px 16px;
  }

  .app-nav-brand {
    margin-bottom: 15px;
    padding: 4px 9px 19px;
    font-size: 0.82rem;
  }

  .app-nav-menu {
    gap: 14px;
  }

  .app-nav-group {
    gap: 4px;
  }

  .app-nav-section-label {
    padding-inline: 10px;
    font-size: 0.62rem;
  }

  .app-nav-link {
    min-height: 42px;
    padding-inline: 12px;
    font-size: 0.86rem;
  }

  #project-page .project-page-header {
    gap: 16px;
    padding-bottom: 19px;
  }

  #project-page .project-page-header h1 {
    font-size: clamp(2.35rem, 3vw, 2.8rem);
  }

  #project-page .project-overview-header-meta {
    gap: 8px 16px;
    margin-top: 10px;
    font-size: 0.8rem;
  }

  #project-page .project-header-actions {
    gap: 10px;
  }

  #project-page .project-header-actions .primary-action,
  #project-page .project-header-actions .text-action,
  #project-page .project-header-actions .secondary-action {
    min-width: 0;
    min-height: 42px;
    padding-inline: 15px;
    font-size: 0.86rem;
  }

  #project-page .project-header-actions #back-dashboard-button {
    min-width: 132px;
  }

  #project-page .project-navigation-row {
    gap: 14px;
    padding: 14px 0;
  }

  #project-page .project-tab-list {
    flex-wrap: nowrap;
    gap: 8px;
  }

  #project-page .project-tab {
    min-height: 40px;
    padding-inline: 14px;
    font-size: 0.84rem;
  }

  #project-page .project-overview-panel {
    padding-top: 20px;
  }

  #project-page .project-overview-layout,
  #project-page .project-overview-main {
    gap: 16px;
  }

  #project-page .project-overview-card {
    padding: clamp(18px, 1.65vw, 24px);
  }

  #project-page .project-overview-section-heading {
    gap: 14px;
    margin-bottom: 18px;
  }

  #project-page .project-overview-section-heading h2 {
    font-size: clamp(1.12rem, 1.45vw, 1.35rem);
  }

  #project-page .project-overview-kicker {
    font-size: 0.61rem;
  }

  #project-page .project-overview-fact-grid article {
    padding: 7px 18px 16px 0;
  }

  #project-page .project-overview-fact-grid article:nth-child(3n + 2),
  #project-page .project-overview-fact-grid article:nth-child(3n + 3) {
    padding-left: 18px;
  }

  #project-page .project-overview-fact-grid article:nth-last-child(-n + 3) {
    padding-top: 18px;
    padding-bottom: 2px;
  }

  #project-page .project-overview-fact-grid span {
    font-size: 0.7rem;
  }

  #project-page .project-overview-fact-grid strong {
    margin-top: 5px;
    font-size: clamp(0.9rem, 1vw, 1rem);
  }

  #project-page .project-progress-marker {
    width: 32px;
    height: 32px;
    font-size: 0.71rem;
  }

  #project-page .project-progress-steps li:not(:last-child)::after {
    top: 15px;
    left: calc(50% + 18px);
    width: calc(100% - 36px);
  }

  #project-page .project-progress-steps strong {
    font-size: clamp(0.62rem, 0.68vw, 0.72rem);
  }

  #project-page .project-update-create-button,
  #project-page .project-task-create-button {
    min-height: 34px;
    padding-inline: 13px;
    font-size: 0.72rem;
  }

  #project-page .project-update-list,
  #project-page .project-update-empty,
  #project-page .project-update-loading,
  #project-page .project-update-error-state {
    min-height: 190px;
  }

  #project-page .project-tasks-card {
    margin-top: 16px;
  }
}

@media (max-width: 900px) {
  .task-management-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .task-management-card-actions {
    justify-content: flex-start;
    max-width: none;
  }
}
/* Success: RL-315 keeps all eight CCMI lifecycle sections visible and usable without a gated wizard. */
.ccmi-workflow-sections,
.formula-variation-list {
  display: grid;
  gap: 18px;
  margin-bottom: 24px;
}

.ccmi-workflow-section {
  scroll-margin-top: 24px;
}

/* Success: v0.1.2 keeps Stability inside the single numbered R&D area instead of presenting a fourth major workflow area. */
.ccmi-workflow-area {
  display: grid;
  gap: 18px;
}

.rnd-stability-section {
  border-color: rgba(166, 116, 255, 0.3);
}

.ccmi-record-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

/* Previous: the variations editor floated across the full page while neighboring workflow steps used contained cards. */
#variations-panel .formula-variation-save-form {
  max-width: 1100px;
  padding: 20px;
  border: 1px solid rgba(231, 237, 234, .14);
  border-radius: 16px;
  background: #181a1c;
}
#variations-panel .formula-variation-save-form h3 { margin: 0 0 2px; color: var(--ink); font-size: 1rem; }

.ccmi-record-form label {
  display: grid;
  gap: 7px;
  color: var(--muted-text, #a8a5b5);
  font-size: 0.84rem;
  font-weight: 650;
}

.ccmi-record-form input,
.ccmi-record-form select,
.ccmi-record-form textarea {
  width: 100%;
}

/* Previous: shared form sizing stretched the approved-report checkbox into a large empty square. */
.ccmi-record-form .ccmi-approved-report { display: flex; align-items: center; gap: 10px; }
.ccmi-record-form .ccmi-approved-report input[type="checkbox"] { box-sizing: border-box; flex: 0 0 16px; width: 16px; height: 16px; min-height: 16px; margin: 0; padding: 0; accent-color: #8de9c6; }

.ccmi-field-wide {
  grid-column: 1 / -1;
}

.ccmi-record-list,
.formula-candidate-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.ccmi-record-card,
.formula-variation-card,
.formula-candidate-card {
  padding: 16px;
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-radius: 14px;
  background: rgba(18, 17, 24, 0.55);
}

.ccmi-record-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}

.ccmi-record-card dt {
  color: var(--muted-text, #a8a5b5);
  text-transform: capitalize;
}

.ccmi-record-card dd {
  margin: 3px 0 0;
  white-space: pre-wrap;
}

.ccmi-record-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.formula-candidate-comparison {
  container-type: inline-size;
  margin: 18px 0;
  padding: 18px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 16px;
}

/* Success: RL-317 keeps full formula tables readable beside the logs by stacking until the comparison itself is genuinely wide. */
.formula-candidate-list {
  grid-template-columns: minmax(0, 1fr);
}

.formula-candidate-card {
  min-width: 0;
  overflow: hidden;
}

.formula-candidate-card h4,
.formula-candidate-card label {
  overflow-wrap: anywhere;
}

.formula-candidate-card .review-formula-table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.formula-candidate-card .review-formula-table th,
.formula-candidate-card .review-formula-table td {
  min-width: 96px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.formula-candidate-card .review-formula-table th:nth-child(3),
.formula-candidate-card .review-formula-table td:nth-child(3) {
  min-width: 220px;
}

@container (min-width: 1800px) {
  .formula-candidate-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.formula-candidate-card .review-formula-table,
.formula-variation-card .review-formula-table {
  margin: 12px 0;
}

@media (max-width: 980px) {
  .formula-candidate-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .ccmi-record-form,
  .ccmi-record-card dl {
    grid-template-columns: 1fr;
  }

  .ccmi-field-wide {
    grid-column: auto;
  }
}

.approved-formula-summary {
  display: grid;
  gap: 8px;
  margin: 18px 0 24px;
  padding: 18px 20px;
  border: 1px solid rgba(166, 116, 255, 0.22);
  border-radius: 16px;
  background: rgba(146, 91, 255, 0.07);
}

.approved-formula-summary h3 {
  margin: 0;
}

.approved-formula-summary dl,
.rnd-event-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.approved-formula-summary dl div,
.rnd-event-card dl div {
  display: grid;
  gap: 3px;
}

.approved-formula-summary dt,
.rnd-event-card dt {
  color: var(--muted-text, #a9a2ba);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.approved-formula-summary dd,
.rnd-event-card dd {
  margin: 0;
}

.rnd-event-timeline {
  position: relative;
  display: grid;
  gap: 18px;
  padding-left: 30px;
}

.rnd-event-timeline::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 9px;
  width: 2px;
  background: linear-gradient(#9a6cff, rgba(154, 108, 255, 0.12));
}

.rnd-event-card {
  position: relative;
  min-width: 0;
}

.rnd-event-marker {
  position: absolute;
  top: 21px;
  left: -28px;
  width: 14px;
  height: 14px;
  border: 3px solid #2b1a48;
  border-radius: 50%;
  background: #b38aff;
  box-shadow: 0 0 0 3px rgba(179, 138, 255, 0.2);
}

.rnd-event-card-body {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
}

.rnd-event-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.rnd-event-card-heading h3 {
  margin: 4px 0 0;
}

.rnd-event-files {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rnd-event-file {
  padding: 6px 10px;
  border: 1px solid rgba(166, 116, 255, 0.3);
  border-radius: 999px;
  color: #d9c7ff;
  background: rgba(146, 91, 255, 0.1);
  cursor: pointer;
}

/* Previous QA failure: the unbounded R&D dialog hid Save below laptop/mobile viewports and behind mobile navigation. */
#rnd-event-modal {
  z-index: 1100;
  padding: 16px;
  overflow: hidden;
}

#rnd-event-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
  min-height: 0;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
}

#rnd-event-form .modal-heading-row {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

#rnd-event-form .modal-close-action {
  width: 42px;
  min-width: 42px;
}

#rnd-event-form .rnd-event-form-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 3px 6px 6px 3px;
}

/* Previous failure: textarea overrides and the custom dropdown bypassed the shared charcoal modal field styling. */
#rnd-event-form input,
#rnd-event-form select,
#rnd-event-form textarea,
#rnd-event-form .project-status-trigger {
  background: #1b2027;
  color: #f2f5f8;
  border: 1px solid #58616e;
  border-radius: 10px;
}

#rnd-event-form textarea {
  resize: vertical;
}

/* Previous: text-input padding left the native file button against the top edge; even padding centers the picker. */
#rnd-event-form #rnd-event-files {
  box-sizing: border-box;
  min-width: 0;
  padding: 8px;
  color: #aab3bf;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}

#rnd-event-files::file-selector-button {
  margin: 0 12px 0 0;
  padding: 7px 12px;
  border: 1px solid #58616e;
  border-radius: 6px;
  background: #303741;
  color: #f2f5f8;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

#rnd-event-files::file-selector-button:hover {
  background: #3b4551;
  border-color: #79d6a1;
}

#rnd-event-form #rnd-event-type-trigger:hover:not(:disabled) {
  background: #1b2027;
}

#rnd-event-form input::placeholder,
#rnd-event-form textarea::placeholder {
  color: #aab3bf;
  opacity: 1;
}

#rnd-event-form input:focus-visible,
#rnd-event-form select:focus-visible,
#rnd-event-form textarea:focus-visible,
#rnd-event-form .project-status-trigger:focus-visible {
  border-color: #79d6a1;
  outline: 2px solid rgba(121, 214, 161, 0.45);
  outline-offset: 1px;
}

#rnd-event-form > .form-actions {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#rnd-event-error {
  flex: 0 0 auto;
  max-height: 5em;
  overflow-y: auto;
  margin: 0;
}

#rnd-event-error:empty {
  display: none;
}

.rnd-event-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.rnd-event-form-grid label,
.rnd-event-type-field {
  display: grid;
  gap: 7px;
}

.rnd-event-type-field {
  align-content: start;
  min-width: 0;
}

/* Success: removing the nested label's extra modal margin aligns Event Type with Date Sent. */
.rnd-event-type-field > label {
  margin-bottom: 0;
}

#rnd-event-type-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

#rnd-event-type-menu .project-status-option {
  grid-template-columns: minmax(0, 1fr) auto;
}

.rnd-event-field-wide {
  grid-column: 1 / -1;
}

#rnd-event-submitted-formula-field,
#rnd-event-submitted-formula {
  min-width: 0;
  width: 100%;
}

#rnd-event-submitted-formula-help {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.rnd-event-submission-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.rnd-event-submission-fields > p {
  grid-column: 1 / -1;
  margin: 0;
}

@media (max-width: 720px) {
  .approved-formula-summary dl,
  .rnd-event-card dl,
  .rnd-event-form-grid,
  .rnd-event-submission-fields {
    grid-template-columns: 1fr;
  }

  .rnd-event-field-wide {
    grid-column: 1;
  }

  #rnd-event-form {
    padding: 16px;
  }

  #rnd-event-form .modal-heading-row h2 {
    font-size: 1.3rem;
  }

  #rnd-event-form .modal-heading-row p {
    margin-bottom: 0;
    font-size: 0.875rem;
  }

  #rnd-event-form > .form-actions {
    flex-direction: row;
  }

  #rnd-event-form > .form-actions > button {
    flex: 1;
    min-width: 0;
  }
}

.stability-study-form {
  margin-bottom: 18px;
}

.stability-study-card {
  display: grid;
  gap: 16px;
}

.stability-study-actions,
.stability-checkpoint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stability-checkpoint-section {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.stability-checkpoint-section h4 {
  margin: 0;
}

.stability-checkpoint-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(166, 116, 255, 0.22);
  border-radius: 14px;
  background: rgba(146, 91, 255, 0.055);
}

.stability-checkpoint-card > div:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.stability-checkpoint-card p {
  margin: 0;
}

.stability-checkpoint-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 24px;
  padding: 24px;
  border: 1px solid rgba(166, 116, 255, 0.24);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(71, 42, 117, 0.16), rgba(20, 18, 27, 0.98));
}

/* Previous spacing failure: checkpoint labels were inline and controls shrank to their contents. */
.stability-checkpoint-form > label {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  color: var(--muted-text, #a8a5b5);
  font-size: 0.84rem;
  font-weight: 650;
}

.stability-checkpoint-form input,
.stability-checkpoint-form select,
.stability-checkpoint-form textarea {
  width: 100%;
  min-width: 0;
  margin: 0;
  font: inherit;
  font-weight: 400;
}

.stability-checkpoint-form input,
.stability-checkpoint-form select {
  min-height: 44px;
}

.stability-checkpoint-form textarea {
  min-height: 104px;
  resize: vertical;
}

.stability-checkpoint-form > .form-error {
  margin: 0;
}

.stability-checkpoint-form > .form-error:empty {
  display: none;
}

.stability-checkpoint-form > .form-actions {
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  justify-content: flex-end;
}

.stability-checkpoint-form-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stability-checkpoint-form-heading > strong {
  font-size: 1rem;
}

.stability-checkpoint-form-heading > button {
  flex-shrink: 0;
}

.status-pill.status-pending {
  background: rgba(220, 181, 71, 0.14);
  color: #f2d889;
}

.status-pill.status-passed {
  background: rgba(65, 190, 118, 0.14);
  color: #8de2b0;
}

.status-pill.status-failed {
  background: rgba(225, 76, 76, 0.14);
  color: #ffaaa7;
}

@media (max-width: 720px) {
  .stability-checkpoint-form {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 18px;
  }

  .stability-checkpoint-form > .form-actions > button {
    width: 100%;
  }
}

.production-record-form {
  margin-bottom: 18px;
}

/* Success: a separate type row keeps formula/date, batch details, and approval fields paired evenly. */
.production-record-form .lifecycle-type-picker.ccmi-field-wide {
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.production-record-form .lifecycle-type-picker > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 420px);
}

.production-record-form .lifecycle-type-picker label {
  justify-content: center;
}

.production-record-list {
  display: grid;
  gap: 14px;
}

.production-record-card {
  display: grid;
  gap: 12px;
  border-left: 3px solid rgba(166, 116, 255, 0.66);
}

.production-record-card > p {
  margin: 0;
}

/* Success: the call-requested type radios show both choices while preserving one choice per record. */
.ccmi-record-form .lifecycle-type-picker {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.lifecycle-type-picker legend {
  margin-bottom: 8px;
  padding: 0;
  color: #b8bdc1;
  font-size: 0.86rem;
  font-weight: 650;
}
.lifecycle-type-picker > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ccmi-record-form .lifecycle-type-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(184, 248, 221, 0.2);
  border-radius: 10px;
  background: #0b0d0f;
  color: #f3f5f4;
  cursor: pointer;
}
.ccmi-record-form .lifecycle-type-picker input {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: #79d6a1;
}
.lifecycle-type-picker label:has(input:checked) {
  border-color: #79d6a1;
  background: rgba(121, 214, 161, 0.12);
}
.lifecycle-type-picker label:has(input:focus-visible) {
  outline: 2px solid #79d6a1;
  outline-offset: 2px;
}
.lifecycle-type-picker label:has(input:disabled) {
  cursor: default;
  opacity: 0.65;
}

/* Previous: oversized outlined footer buttons and mismatched glyphs made utility actions compete with primary navigation; success: compact rows use one icon style and calm hover states. */
.app-nav-release-footer { margin-top:auto; display:grid; gap:3px; padding-top:12px; border-top:1px solid var(--line); }
.app-nav-release-footer .app-nav-link {
  justify-content:flex-start;
  gap:12px;
  min-height:42px;
  padding:0 12px;
  border:1px solid transparent;
  border-radius:10px;
  background:transparent;
  color:var(--muted);
  font-size:0.88rem;
  font-weight:750;
  text-align:left;
}
.app-nav-release-footer .app-nav-link:hover,
.app-nav-release-footer .app-nav-link:focus-visible {border-color:var(--line);background:var(--surface-muted);color:var(--ink);}
.app-nav-release-footer #open-chat-button[aria-expanded="true"] {border-color:rgba(35,201,133,.28);background:var(--accent-soft);color:var(--accent);}
.app-nav-release-footer .app-nav-logout {margin-top:0;}
.app-nav-utility-icon {display:grid;width:18px;height:18px;flex:0 0 18px;place-items:center;color:inherit;}
.app-nav-utility-icon svg {width:18px;height:18px;fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.8;}
.app-version { text-align:left; color:var(--muted); font-size:11px; padding:8px 12px 2px; }
.release-dialog { color: var(--text); background: #151719; border: 1px solid #41454a; border-radius: 18px; padding: 24px; width: min(1100px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-sizing: border-box; }
.release-dialog::backdrop { background: #000b; }
.bug-dialog { width: min(600px, calc(100vw - 32px)); }
.release-dialog header, .release-dialog footer { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.release-dialog header h2 { margin: 0; }
.release-dialog footer { margin-top:20px; flex-wrap:wrap; justify-content:flex-end; }
.release-dialog label { display:grid; gap:8px; margin:12px 0; font-size:14px; }
.release-dialog input, .release-dialog textarea, .release-dialog select { box-sizing:border-box; width:100%; min-width:0; padding:10px; color:#f3f5f4; background:#0c0e10; border:1px solid #454a50; border-radius:8px; font:inherit; }
.release-dialog textarea { resize:vertical; }
.release-dialog button { cursor:pointer; }
.release-dialog header > button { background:transparent; color:inherit; border:1px solid #555; border-radius:8px; width:36px; height:36px; flex-shrink:0; }
.release-dialog section { border-top:1px solid #363b40; margin-top:24px; padding-top:12px; }
.release-dialog [role=status] { white-space:pre-wrap; overflow-wrap:anywhere; }
.report-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.report-grid fieldset { min-width:0; border:1px solid #454a50; border-radius:10px; }
.report-table-scroll { overflow-x:auto; max-width:100%; margin:12px 0; }
.report-dialog table { border-collapse:collapse; width:100%; table-layout:fixed; min-width:600px; }
.report-dialog .readings-table { min-width:1060px; }
.report-dialog th, .report-dialog td { padding:10px; border:1px solid #41464c; text-align:left; vertical-align:top; font-size:13px; overflow-wrap:anywhere; }
.report-dialog th { background:#21252a; font-weight:600; }
.report-value { white-space:pre-wrap; overflow-wrap:anywhere; }
.report-dialog [data-report-files] { display:flex; flex-wrap:wrap; gap:8px; }
@media(max-width:640px) { .release-dialog {padding:16px;} .report-grid {grid-template-columns:1fr;gap:0;} .release-dialog footer {justify-content:stretch;} .release-dialog footer button {flex:1;} }
@media print {
  body > :not(.report-dialog) { display:none !important; }
  .report-dialog[open] { position:static; display:block; width:100%; max-height:none; overflow:visible; border:0; padding:0; background:white; color:black; }
  .report-dialog header button, .report-dialog footer, .report-dialog [data-report-status] {display:none !important;}
  .report-dialog .report-table-scroll {overflow:visible;}
  .report-dialog table, .report-dialog .readings-table {min-width:0;}
  .report-dialog th, .report-dialog td {color:black;background:white;font-size:8pt;padding:4px;}
  .report-dialog section {break-inside:avoid;}
  @page {size:landscape;margin:12mm;}
}

.report-dialog figure { margin:12px 0; max-width:460px; break-inside:avoid; }
.report-dialog figure img { max-width:100%; max-height:360px; object-fit:contain; }
.report-dialog figcaption {font-size:12px;overflow-wrap:anywhere;}
@media print { .report-dialog [data-evidence-download] {display:none;} .report-dialog figure {max-width:40%;} }

/* Previous QA failure: printing a scrolled native dialog omitted the report header and baseline. */
@media print {
  html, body {height:auto !important;overflow:visible !important;background:white !important;}
  .report-dialog[open] {height:auto;max-width:none;inset:auto;margin:0;box-shadow:none;}
}

/* Previous mobile QA failure: the sticky header stacked its drawer beneath the sibling scrim, intercepting every menu action. */
@media(max-width:900px) { #app-navigation:has(.app-nav-menu.is-open) {z-index:230;} }

/* Success: mobile icon close controls remain beside the heading rather than becoming a full-width action row. */
@media (max-width: 640px) {
  .modal-heading-row:has(.modal-close-action[aria-label]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
  }
  .modal-heading-row .modal-close-action[aria-label] {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    justify-self: end;
  }
}

/* Success: one body-level calendar avoids clipping inside Overview cards and scrolling dialogs. */
.overview-calendar { position: fixed; z-index: 100000; width: min(320px, calc(100vw - 16px)); padding: 14px; box-sizing: border-box; overflow: auto; color: #e8f2ed; background: #111c18; border: 1px solid #315345; border-radius: 16px; box-shadow: 0 16px 48px #0009; }
.overview-calendar[hidden] { display: none; }
.overview-calendar-heading, .overview-calendar-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.overview-calendar button { border: 1px solid transparent; border-radius: 8px; background: transparent; color: inherit; min-height: 36px; cursor: pointer; font: inherit; }
.overview-calendar button:hover:not(:disabled), .overview-calendar button:focus-visible { background: #234536; outline: 2px solid #35d59a; outline-offset: -2px; }
.overview-calendar button:disabled { opacity: .3; cursor: default; }
.overview-calendar-week, .overview-calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.overview-calendar-week { margin: 12px 0 6px; color: #a1b5ab; font-size: 12px; }
.overview-calendar-days .outside-month { color: #82958b; }
.overview-calendar-days [aria-current="date"] { border-color: #35d59a; }
.overview-calendar-days [aria-pressed="true"] { background: #20c68b; color: #061d12; font-weight: 700; }
.overview-calendar-footer { border-top: 1px solid #315345; margin-top: 10px; padding-top: 8px; color: #54dcaa; }
input[data-overview-date] { cursor: pointer; }

/* Personal task view uses a native toggle button for keyboard and screen-reader access. */
.task-management-only-mine {
  align-self: end;
  min-height: 44px;
}
.task-management-only-mine[aria-pressed="true"] {
  color: var(--mint, #67e8b7);
  background: rgba(32, 196, 142, 0.16);
  border-color: var(--mint, #67e8b7);
}

/* Project panels already manage their own scrolling, so extend them through the desktop viewport edge. */
@media (min-width: 1121px) {
  .app-shell:has(.app-navigation:not(.hidden)):has(#project-page:not(.hidden)) {
    padding-bottom: 0;
  }

  #project-page.project-page:not(.hidden) {
    height: calc(100vh - var(--page-gutter));
  }
}

/* Center the desktop wordmark within the sidebar header above its divider. */
@media (min-width: 901px) {
  .app-navigation { padding-top: 0; }
  .app-nav-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    box-sizing: border-box;
    padding: 20px 10px;
    text-align: center;
  }
}

/* Previous: boxed IDs looked like form inputs; plain secondary text keeps the title prominent. */
.project-number-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 10px;
}
/* Success: the header ID sits after the shared-record metadata without adding another row. */
.project-overview-header-meta > .project-number-line { margin: 0; }
.project-number-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.project-number-badge code {
  /* Previous: the project ID used tiny monospace text beside full-size project metadata. */
  font-family: var(--font-ui);
  /* Success: inherit the actual header metadata size, including its compact responsive override. */
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: 0;
  user-select: text;
  overflow-wrap: anywhere;
}
/* Success: scoped button dimensions keep global primary-action sizing out of project metadata. */
.project-number-badge .copy-project-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Success: the copy action no longer makes the metadata line taller than its neighboring text. */
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #8c969d;
  box-shadow: none;
  cursor: pointer;
}
.project-number-badge .copy-project-number:hover { background: #ffffff0d; color: #e4e8eb; }
.project-number-badge .copy-project-number:focus-visible { outline: 2px solid #70dcb3; outline-offset: 2px; }
.copy-project-number svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.copy-project-number .project-id-check-icon, .copy-project-number.is-copied .project-id-copy-icon { display: none; }
.copy-project-number.is-copied .project-id-check-icon { display: block; color: #70dcb3; }
.project-number-feedback { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Previous: fixed-height cards clipped added metadata; let content determine the final row height. */
#dashboard-screen .project-card { height: auto; min-height: 94px; }
/* Success: dashboard IDs share the lower metadata row without a copy action; the project header retains copying. */
#dashboard-screen .project-card h3 { margin: 0; min-width: 0; }
/* Previous: dashboard project IDs used smaller monospace text than neighboring metadata; success: inherit the shared metadata type style. */
.project-card-id code { font-family: inherit; font-size: inherit; font-weight: inherit; line-height: inherit; letter-spacing: inherit; color: inherit; user-select: text; overflow-wrap: anywhere; }
#dashboard-screen .project-card-meta { margin-top: 4px; }
#dashboard-screen .project-card-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: #909a9e; font-size: 12px; line-height: 1.5; }
.project-card-meta span + span::before { content: "·"; margin-right: 10px; color: #566065; }
@media (min-width: 901px) {
  #dashboard-screen .project-record-main { grid-template-columns: minmax(240px, 1fr) minmax(0, 1fr); }
}

/* Previous: Chrome autofill painted populated project fields blue-gray and the browser focus outline clashed with the dark form. */
.project-details-form input:not([type="checkbox"]),
.project-details-form textarea {
  border: 1px solid rgba(231, 237, 234, 0.16);
  outline: none;
  background: rgba(5, 6, 7, 0.72);
  color: var(--ink);
  caret-color: var(--ink);
  box-shadow: none;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.project-details-form input:not([type="checkbox"]):hover:not(:disabled),
.project-details-form textarea:hover:not(:disabled) {
  border-color: rgba(231, 237, 234, 0.28);
}

/* Success: every editable Project Details field now uses one restrained green focus treatment. */
.project-details-form input:not([type="checkbox"]):focus-visible,
.project-details-form textarea:focus-visible {
  border-color: rgba(35, 201, 133, 0.76);
  outline: none;
  background: rgba(5, 6, 7, 0.82);
  box-shadow: 0 0 0 3px rgba(35, 201, 133, 0.14);
}

/* Previous: autofill protection covered inputs only, leaving address textareas blue-gray after Chrome filled them. */
.project-details-form input:-webkit-autofill,
.project-details-form input:-webkit-autofill:hover,
.project-details-form textarea:-webkit-autofill,
.project-details-form textarea:-webkit-autofill:hover {
  border-color: rgba(231, 237, 234, 0.16);
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px #090b0c inset;
  box-shadow: 0 0 0 1000px #090b0c inset;
  transition: background-color 9999s ease-out 0s;
}

.project-details-form input:-webkit-autofill:focus,
.project-details-form textarea:-webkit-autofill:focus {
  border-color: rgba(35, 201, 133, 0.76);
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px #090b0c inset, 0 0 0 3px rgba(35, 201, 133, 0.14);
  box-shadow: 0 0 0 1000px #090b0c inset, 0 0 0 3px rgba(35, 201, 133, 0.14);
}

/* Previous mismatch: browser date hints and amount placeholders were gray while neighboring field values were white. */
.project-details-form input:not([type="checkbox"]),
.project-details-form textarea,
.project-details-form .project-size-unit-dropdown .project-status-trigger {
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
}
.project-details-form input::placeholder,
.project-details-form textarea::placeholder {
  color: var(--ink);
  opacity: 1;
}
.project-details-form input[type="date"]::-webkit-datetime-edit,
.project-details-form input[type="date"]::-webkit-datetime-edit-text,
.project-details-form input[type="date"]::-webkit-datetime-edit-month-field,
.project-details-form input[type="date"]::-webkit-datetime-edit-day-field,
.project-details-form input[type="date"]::-webkit-datetime-edit-year-field {
  color: var(--ink);
  font: inherit;
}
/* Success: amount and unit or currency values share one left edge, with the chevron pinned to the right. */
.project-details-form .project-size-unit-dropdown .project-status-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Previous: lifecycle selects used a 1px control border while neighboring inputs kept Chrome's 2px inset border and 2px padding. */
.ccmi-record-form input:not([type="radio"]):not([type="checkbox"]):not([type="file"]),
.ccmi-record-form textarea,
.ccmi-record-form .custom-choice-trigger {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--control-h-md, 42px);
  border: 1px solid rgba(231, 237, 234, .16);
  border-radius: var(--radius-control, 12px);
  background: rgba(5, 6, 7, .72);
  color: var(--ink, #f3f5f4);
  font-family: var(--font-ui);
  font-size: .84rem;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: none;
}
.ccmi-record-form input:not([type="radio"]):not([type="checkbox"]):not([type="file"]),
.ccmi-record-form .custom-choice-trigger { padding: 0 12px; }
.ccmi-record-form textarea { padding: 10px 12px; line-height: 1.45; resize: vertical; }
.ccmi-record-form input::placeholder,
.ccmi-record-form textarea::placeholder,
.ccmi-record-form .custom-choice-trigger[data-empty="true"] { color: var(--ink, #f3f5f4); opacity: 1; }
.ccmi-record-form input[type="date"]::-webkit-datetime-edit,
.ccmi-record-form input[type="date"]::-webkit-datetime-edit-text,
.ccmi-record-form input[type="date"]::-webkit-datetime-edit-month-field,
.ccmi-record-form input[type="date"]::-webkit-datetime-edit-day-field,
.ccmi-record-form input[type="date"]::-webkit-datetime-edit-year-field { color: var(--ink, #f3f5f4); font: inherit; }
.ccmi-record-form input:not([type="radio"]):not([type="checkbox"]):not([type="file"]):focus-visible,
.ccmi-record-form textarea:focus-visible,
.ccmi-record-form .custom-choice-trigger:focus-visible { outline: none; border-color: rgba(35, 201, 133, .76); box-shadow: 0 0 0 3px rgba(35, 201, 133, .14); }
/* Success: all enhanced choice controls pin the chevron at the far edge without changing the selected value or native select data. */
.custom-choice:not(.overall-status-choice) .custom-choice-trigger::after {
  content: "";
  flex: 0 0 6px;
  width: 6px;
  height: 6px;
  margin: -3px 2px 0 auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}
.custom-choice:not(.overall-status-choice) .custom-choice-trigger[aria-expanded="true"]::after { transform: rotate(225deg); margin-top: 3px; }

/* Success: the working formula keeps the existing dark controls and phase order; desktop is the supported QA surface for this feature. */
.formula-ingredient-list .ingredient-row { grid-template-columns: minmax(180px, 1fr) minmax(300px, 1fr); align-items: start; }
.ingredient-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ingredient-fields input { box-sizing: border-box; width: 100%; text-align: left; }
.ingredient-row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ingredient-row-actions .secondary-action { min-height: 34px; padding: 5px 10px; font-size: .78rem; }
.formula-edit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; color: var(--muted); font-size: .82rem; }
#save-working-variation-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
#save-working-variation-form label { display: grid; flex: 1 1 220px; gap: 6px; color: var(--muted); font-size: .8rem; font-weight: 700; }
#save-working-variation-form input { box-sizing: border-box; width: 100%; min-height: var(--control-h-md); }
#save-working-variation-form .form-message { flex: 1 0 100%; margin: 0; }
.material-form { display: grid; gap: 10px; max-height: min(90vh, 760px); overflow: auto; }
.material-form label, .formula-material-card label { display: grid; gap: 6px; }
.material-form input, .material-form textarea, .formula-material-card input { box-sizing: border-box; }
.formula-material-card { display: grid; gap: 12px; }
.formula-material-card p { margin: 0; color: var(--muted); }
.formula-material-results.project-status-menu { position: relative; inset: auto; max-height: min(350px, 42vh); box-shadow: none; }
.formula-material-results .project-status-option { display: block; }
.formula-material-results .project-status-option span { display: grid; gap: 3px; }
.formula-material-results .project-status-option small { color: var(--muted); font-size: .76rem; font-weight: 500; }
@media (max-width: 900px) { .formula-ingredient-list .ingredient-row { grid-template-columns: 1fr; } }

/* Success: candidate rows use the existing dark inputs, while the shared material picker stays a roomy modal. */
.working-formula-panel { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.working-formula-panel summary { cursor: pointer; font-weight: 700; }
.working-formula-panel[open] summary { margin-bottom: 14px; }
.candidate-table-scroll { width: 100%; overflow-x: auto; }
.formula-candidate-card .candidate-editor-table { display: table; width: 100%; min-width: 650px; table-layout: fixed; }
.candidate-editor-table th:nth-child(1), .candidate-editor-table td:nth-child(1) { width: 52px; min-width: 52px; white-space: nowrap; }
.candidate-editor-table th:nth-child(2), .candidate-editor-table td:nth-child(2) { width: 180px; min-width: 180px; }
.candidate-editor-table th:nth-child(3), .candidate-editor-table td:nth-child(3) { width: auto; min-width: 220px; }
.candidate-editor-table th:nth-child(4), .candidate-editor-table td:nth-child(4) { width: 140px; min-width: 140px; }
.candidate-editor-table th:nth-child(5), .candidate-editor-table td:nth-child(5) { width: 94px; min-width: 94px; }
.candidate-editor-table input { box-sizing: border-box; width: 100%; min-width: 0; text-align: left; }
.candidate-editor-table td small { display: block; margin-top: 3px; color: var(--muted); }
.candidate-material-button { padding: 0; border: 0; background: none; color: var(--accent); font-weight: 700; text-align: left; cursor: pointer; }
.candidate-material-button span { margin-left: 5px; color: var(--muted); font-size: .7rem; font-weight: 500; }
.candidate-material-button:hover { text-decoration: underline; }
.candidate-remove-button { padding: 5px 8px; font-size: .75rem; }
.candidate-edit-footer, .candidate-save-row { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-top: 12px; }
.candidate-edit-footer span { color: var(--muted); font-size: .85rem; }
.candidate-save-row label { display: grid; flex: 1 1 230px; gap: 6px; color: var(--muted); font-size: .8rem; }
.candidate-save-row input { box-sizing: border-box; width: 100%; min-height: var(--control-h-md); }
.formula-candidate-card [data-candidate-status] { margin: 10px 0 0; }
.candidate-warnings { margin-top: 14px; color: var(--muted); font-size: .82rem; }
.candidate-warnings summary { cursor: pointer; }
.candidate-warnings .warning-message { margin: 8px 0 0; }

/* Success: wrapping library tabs retain keyboard access on narrow screens. */
.formula-library-tabs { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 12px; }
.formula-library-tabs .tab-button { border: 1px solid var(--border-color, #34343f); border-radius: 9px; padding: 10px 18px; }
.formula-library-tabs .tab-button:focus-visible { outline: 2px solid #b6a0ff; outline-offset: 3px; }
.formula-library-notice { margin: 0 0 16px; color: var(--text-muted, #a3a3b3); font-size: 13px; }
#formula-library-panel { min-height: 0; display: flex; flex-direction: column; flex: 1; }

@media (min-width: 1121px) {
  .historical-formulas-screen:not(.raw-materials-screen) .historical-formulas-section { grid-template-rows: auto auto minmax(0, 1fr); }
  #formula-library-panel .historical-formulas-layout { flex: 1; }
}

/* Project destinations stay quiet; guided formulation steps live within Formulation. */
#project-page .project-navigation-row { padding: 8px 0 0; min-height: 60px; gap: 20px; }
#project-page .project-navigation-row .project-tab-list { gap: 26px; flex-wrap: nowrap; }
#project-page .project-navigation-row .project-tab {
  min-height: 54px; padding: 12px 2px; border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; background: transparent; box-shadow: none; color: var(--muted);
  font-size: .94rem; font-weight: 600; white-space: nowrap;
}
#project-page .project-navigation-row .project-tab.active { border-bottom-color: var(--accent); color: var(--ink); }
#project-page .project-step-actions { min-width: 0; padding-bottom: 8px; }
#project-page .project-step-action { min-width: 0; min-height: 38px; padding: 9px 15px; font-size: .82rem; box-shadow: none; }
#project-page .formulation-steps { display: flex; gap: 8px; flex-wrap: wrap; padding: 18px 0; border-bottom: 1px solid var(--line); }
#project-page .formulation-steps.hidden { display: none; }
#project-page .formulation-steps .project-tab { display: flex; align-items: center; gap: 9px; padding: 8px 13px; min-height: 40px; color: var(--muted); font-size: .82rem; font-weight: 500; border: 1px solid transparent; background: transparent; border-radius: 10px; box-shadow: none; }
#project-page .formulation-steps .project-tab span { display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid var(--line); border-radius: 50%; font-family: var(--font-ui); font-size: .72rem; }
#project-page .formulation-steps .project-tab.active { background: rgba(37,196,139,.09); color: var(--accent); border-color: rgba(37,196,139,.2); }
#project-page .formulation-steps .project-tab.active span { background: var(--accent); color: #062419; border-color: var(--accent); }
.formulation-steps small { color: var(--muted); font-size: .69rem; }
.formulation-intro { margin: 10px 0 28px; }
.formulation-intro h2 { margin: 8px 0; font-size: clamp(1.45rem,2vw,2rem); }
.formulation-intro p, .formula-resume p { color: var(--muted); margin: 6px 0 0; font-size: .9rem; }
.formula-start-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.formula-start-option { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding: 28px; min-height: 235px; border: 1px solid var(--line); border-radius: 18px; text-align: left; color: var(--ink); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.formula-start-option:hover:not(:disabled) { border-color: var(--accent); background: rgba(37,196,139,.04); }
.formula-start-option strong { font-size: 1.1rem; font-weight: 650; }
.formula-start-option > span:not(.start-symbol) { color: var(--muted); line-height: 1.55; font-size: .9rem; font-weight: 400; }
.formula-start-option em { margin-top: auto; padding-top: 12px; color: var(--accent); font-style: normal; font-size: .85rem; }
.start-symbol { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: rgba(37,196,139,.1); color: var(--accent); font-size: 1.4rem; }
.formula-start-option:disabled { opacity: .45; cursor: default; }
.formula-resume { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 20px 24px; margin: 0 0 20px; border-radius: 14px; border: 1px solid rgba(37,196,139,.25); background: rgba(37,196,139,.06); }
.formula-source-picker { margin-top: 24px; border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.formula-source-picker .pane-heading { display: flex; justify-content: space-between; align-items: center; }
.formula-source-picker label, #brief-requirements-editor label { display: grid; gap: 7px; font-size: .8rem; color: var(--muted); }
.formula-source-result { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.formula-source-result small, .formula-source-history small { display: block; margin-top: 5px; color: var(--muted); font-size: .77rem; overflow-wrap: anywhere; }
.formula-source-result button { flex-shrink: 0; }
#brief-panel .brief-workflow-layout, #workspace-panel .workspace-layout, #generate-panel .generate-layout { display: flex; flex-direction: column; gap: 18px; }
.brief-side-panel, .workspace-side-panel, .generate-side-panel { order: -1; width: 100%; }
#brief-panel .brief-form, .related-formula-pane, .workspace-workbench { width: 100%; min-width: 0; }
#project-page .generation-logs-card { position: static; padding: 14px 18px; box-shadow: none; border-radius: 12px; background: rgba(255,255,255,.015); }
.flow-summary { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.flow-summary h3 { margin: 0; font-size: .84rem; font-weight: 600; }
.flow-summary p { margin: 0; font-size: .82rem; color: var(--muted); }
.flow-log-details { margin-top: 8px; }
.flow-log-details > summary { width: fit-content; cursor: pointer; color: var(--accent); font-size: .76rem; }
.flow-log-details .generation-log-list { margin-top: 12px; display: flex; flex-direction: column; gap: 0; max-height: 240px; overflow-y: auto; scrollbar-gutter: stable; border-top: 1px solid var(--line); }
.flow-log-details .generation-log-item { flex-shrink: 0; grid-template-columns: minmax(0,1fr) 150px; gap: 20px; padding: 10px 8px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.flow-log-details .generation-log-copy { display: grid; grid-template-columns: 52px minmax(0,1fr) 120px; align-items: center; gap: 16px; min-width: 0; }
.flow-log-details .generation-log-item strong { margin: 0; font-family: var(--font-ui); font-size: .82rem; font-weight: 500; line-height: 1.45; }
.flow-log-details .generation-log-item span, .flow-log-details .generation-log-item small, .flow-log-details .generation-log-item em { font-family: var(--font-ui); font-size: .7rem; font-weight: 400; text-transform: none; }
.flow-log-details .generation-log-item span, .flow-log-details .generation-log-item em { white-space: nowrap; }
.flow-log-details .generation-log-item em { min-width: 70px; padding: 4px 7px; }
.flow-log-details .log-detail-action { min-height: 28px; padding: 4px 9px; font-family: var(--font-ui); font-size: .7rem; font-weight: 500; text-transform: none; }
.flow-log-details .generation-log-item.is-active { background: rgba(35,201,133,.06); }
.flow-log-details .generation-log-item.is-error { background: rgba(166,61,52,.06); }
@media (max-width: 760px) {
  .flow-log-details .generation-log-item { grid-template-columns: minmax(0,1fr) auto; gap: 12px; }
  .flow-log-details .generation-log-copy { grid-template-columns: 42px minmax(0,1fr); gap: 4px 10px; }
  .flow-log-details .generation-log-copy small { grid-column: 2; }
  .flow-log-details .generation-log-actions { gap: 4px; }
}
#brief-panel .brief-form { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 24px; align-items: start; }
.brief-source-column { display: grid; gap: 16px; min-width: 0; }
#brief-panel .brief-analysis-results { margin: 0; padding: 22px; min-width: 0; }
#brief-panel .brief-analysis-heading { gap: 10px; }
#brief-panel .brief-analysis-heading strong { font-weight: 600; }
#brief-panel .brief-analysis-heading button { justify-self: start; font-size: .78rem; min-height: 34px; }
#brief-panel #project-brief-text { min-height: 360px; }
/* Previous issue: the 1000px cap left blank space beside the full-width brief-analysis card. */
#brief-panel .brief-form:has(.brief-analysis-results.hidden) { grid-template-columns: minmax(0,1fr); max-width: none; }
#brief-requirements-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
#brief-requirements-editor .form-actions { grid-column: 1 / -1; }
#brief-requirements-editor input, #brief-requirements-editor textarea { width: 100%; min-width: 0; font-weight: 400; }
#brief-requirements-status { color: var(--muted); font-size: .8rem; }
#brief-requirements-status:empty { display: none; }
.formula-source-history { margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.formula-source-history summary { cursor: pointer; font-size: .82rem; color: var(--muted); }
.formula-source-history article { padding: 12px 0; font-size: .85rem; }
#project-page .project-panel > .panel-heading { display: block; margin: 8px 0 18px; }
#project-page .project-panel > .panel-heading h2 { font-size: 1.45rem; margin: 0 0 6px; }
#project-page .project-panel > .panel-heading p { color: var(--muted); font-size: .85rem; }
.formula-source-picker.hidden, .formula-resume.hidden, #brief-requirements-editor.hidden { display: none; }
@media (max-width: 1100px) {
  .formula-start-options { gap: 12px; }
  .formula-start-option { padding: 20px; }
  #brief-panel .brief-form { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  #project-page .project-navigation-row { flex-wrap: wrap; gap: 8px; }
  #project-page .project-navigation-row .project-tab-list { gap: 22px; }
  #project-page .project-step-actions { justify-content: flex-start; }
  .formula-start-options { grid-template-columns: 1fr; }
  .formula-start-option { min-height: 185px; }
  .formula-resume, .formula-source-result { align-items: flex-start; flex-direction: column; }
  #project-page .formulation-steps { gap: 4px; }
  #project-page .formulation-steps .project-tab { padding: 7px; font-size: .76rem; }
  #brief-requirements-editor { grid-template-columns: 1fr; }
}
@media (min-width: 1121px) {
  #project-page.project-page:not(.hidden):has(#formulation-steps:not(.hidden)) { grid-template-rows: auto auto auto minmax(0,1fr); }
}
/* Keep editing controls above the fold; supporting metadata remains available. */
#project-page .generation-logs-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 18px; align-items: center; }
.flow-log-details { margin: 0; }
.flow-log-details[open] { grid-column: 1 / -1; }
#generate-panel .workspace-workbench { gap: 14px; padding: 20px; }
#generate-panel .workbench-heading { margin: 0; padding: 0; }
#generate-panel .formula-source-history { margin: 0; padding-bottom: 10px; }
#generate-panel .formula-editor-metrics { display: flex; flex-wrap: wrap; gap: 20px; margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
#generate-panel .formula-editor-metrics article { padding: 0; border: 0; background: none; box-shadow: none; min-width: 130px; }
#generate-panel .formula-editor-metrics strong { font-size: .8rem; font-family: var(--font-ui); font-weight: 500; }
#generate-panel .formula-editor-metrics span { font-size: .65rem; }
#generate-panel .formula-total-box { min-height: 60px; padding: 8px 14px; }
#generate-panel #generate-formula-button { min-height: 38px; font-size: .82rem; }
#generate-panel .working-formula-panel { margin-top: 4px; }
.variation-save-details { margin-bottom: 22px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; }
.variation-save-details > summary { cursor: pointer; font-size: .88rem; color: var(--accent); }
.variation-save-details[open] > summary { margin-bottom: 16px; }

/* Four library facts should share the available width without orphaning a card. */
.modal-backdrop { z-index: 1000; }
.historical-formula-detail .history-detail-summary { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1px; background: var(--line); }
.historical-formula-detail .history-detail-summary article { min-width: 0; border: 0; border-radius: 0; background: var(--surface); }
.historical-formula-detail .history-detail-summary strong { overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .flow-log-details .generation-log-item { grid-template-columns: minmax(0,1fr); gap: 8px; }
  .flow-log-details .generation-log-actions { justify-content: flex-start; padding-left: 52px; }
  #generate-panel .ingredient-row-actions .secondary-action { width: auto; flex: 0 0 auto; }
}

/* Success: wrap workbook labels and warnings so long source names remain readable on phones. */
.workbook-brief-review { border: 1px solid var(--border-color, #555); border-radius: 12px; padding: 16px; overflow-wrap: anywhere; }
.workbook-brief-review fieldset { min-width: 0; margin: 12px 0; }
.workbook-brief-review [data-workbook-sheets] { display: grid; gap: 10px; }
.workbook-brief-review label { display: flex; align-items: flex-start; gap: 8px; }
.workbook-brief-review input[type="checkbox"] { width: auto; flex: 0 0 auto; margin-top: 4px; }
.workbook-brief-review [data-workbook-warnings] { padding-left: 20px; }

/* Success: the locked page never leaves formula rows or composition visible behind the password form. */
/* Previous failure: standalone archive card rules bypassed the compact New Project modal theme. */
.archive-dialog { width: min(500px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: var(--radius-panel); background: transparent; color: var(--ink); box-shadow: 0 28px 90px #000a; }
.archive-dialog::backdrop { background: rgba(2, 7, 5, 0.68); backdrop-filter: blur(10px); }
.archive-dialog .modal-card { width: 100%; }
.archive-dialog .form-message:empty { display: none; }
.archive-dialog .form-message:not(:empty) { margin: 12px 0 0; }
.archive-dialog .form-actions { margin-top: 20px; }
#historical-library-content { min-height: 0; flex: 1; display: flex; flex-direction: column; }
#historical-library-content.hidden { display: none; }

#historical-library-content > .historical-formulas-section { flex: 1; }

/* Success: completed work has its own compact section above the active timeline. */
.task-management-completed-details { margin: 0 0 28px; }
.task-management-completed-details > summary { font-size: 18px; }
.project-task-visibility-note { margin: -4px 0 0; color: var(--text-muted, #a8b1b0); font-size: 14px; line-height: 1.5; }

/* Previous: the project sidebar height clipped global task history; the page now owns this section's scrolling. */
.task-management-completed-details .project-task-completed-list { max-height: none; overflow: visible; display: grid; gap: 14px; padding-right: 0; }

/* Previous: two-row textareas left short values top-aligned; content sizing keeps one line centered and grows with wrapping. */
.project-details-form textarea.project-detail-autogrow {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: var(--control-h-md);
  height: auto;
  padding: calc((var(--control-h-md) - 1.35em - 2px) / 2) 14px;
  field-sizing: content;
  overflow-y: hidden;
  resize: none;
}

/* Previous: native inputs retained browser-default edge padding while auto-growing descriptions used a 14px inset. */
.project-details-form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.project-details-form textarea,
.project-details-form select,
.project-details-form .project-team-trigger,
.project-details-form .project-status-trigger,
.project-details-form .custom-choice-trigger {
  box-sizing: border-box;
  padding-left: 14px;
  padding-right: 14px;
}

/* Success: manual feedback uses a compact field directly below the picker, matching separate account-manager entry. */
#rnd-event-form textarea.manual-feedback-number {
  box-sizing: border-box;
  min-height: var(--control-h-md);
  height: var(--control-h-md);
  padding: calc((var(--control-h-md) - 1.35em - 2px) / 2) 14px;
  line-height: 1.35;
  resize: none;
}

.lab-review-scroll { max-width: 100%; min-width: 0; overflow-x: auto; }
@media (max-width: 600px) { .lab-review-scroll::before { content: "Scroll across for all columns"; display: block; } }
