:root {
  color-scheme: light;
  --ink: #173b3d;
  --ink-strong: #102f31;
  --teal: #173f41;
  --teal-soft: #e8f0ed;
  --teal-pale: #f2f6f3;
  --paper: #f4f6f3;
  --surface: #ffffff;
  --surface-warm: #fbfaf6;
  --muted: #617273;
  --line: #d8e0dc;
  --line-strong: #bdcbc5;
  --gold: #a87327;
  --gold-dark: #76501c;
  --gold-soft: #f4ead7;
  --shadow: 0 18px 48px rgba(23, 59, 61, 0.08);
  --shadow-soft: 0 8px 22px rgba(23, 59, 61, 0.06);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 92% 0%, rgba(168, 115, 39, 0.08), transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 1rem;
  line-height: 1.55;
}

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

button,
.action-link {
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.action-link:focus-visible {
  outline: 3px solid rgba(168, 115, 39, 0.3);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--gold-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.04em;
}

h3,
h4 {
  color: var(--ink-strong);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(390px, 0.92fr) minmax(470px, 1.08fr);
  background: var(--surface);
}

.auth-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2.5rem, 7vw, 7rem);
}

.brand-logo {
  display: block;
  width: min(350px, 82%);
  height: auto;
}

.auth-content .brand-logo {
  margin-bottom: clamp(3rem, 7vh, 5.5rem);
}

.auth-content h1 {
  max-width: 650px;
  margin-bottom: 1rem;
  font-size: clamp(3rem, 5vw, 5.1rem);
  line-height: 0.98;
}

.lede {
  max-width: 590px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.auth-form {
  max-width: 500px;
  display: grid;
  gap: 0.85rem;
  margin-top: 2rem;
}

.auth-form label,
.details label {
  display: grid;
  gap: 0.5rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
}

.auth-form input,
.details textarea,
.details select,
.details input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(23, 59, 61, 0.03);
}

.auth-form input {
  min-height: 56px;
  padding: 0 1rem;
  font-size: 1rem;
}

.auth-form input:focus,
.details textarea:focus,
.details select:focus,
.details input:focus {
  border-color: var(--gold);
}

.primary,
.outline,
.text {
  min-height: 48px;
  border-radius: var(--radius-sm);
  padding: 0 1rem;
  font-weight: 800;
}

.primary {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
  box-shadow: 0 8px 18px rgba(23, 63, 65, 0.14);
}

.primary:hover:not(:disabled),
.actions button.primary-action:hover:not(:disabled) {
  background: var(--ink-strong);
  border-color: var(--ink-strong);
  transform: translateY(-1px);
}

.outline {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.outline:hover:not(:disabled) {
  border-color: var(--teal);
  background: var(--teal-pale);
}

.text {
  border: 0;
  background: transparent;
  color: var(--gold-dark);
}

.text:hover:not(:disabled) {
  color: var(--ink);
}

.message {
  min-height: 1.6rem;
  margin: 0.85rem 0 0;
  color: var(--gold-dark);
}

.auth-story {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: clamp(2.5rem, 7vw, 7rem);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.05), transparent 45%),
    var(--teal);
  color: #fff;
}

.auth-story::before,
.auth-story::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(233, 201, 133, 0.2);
  border-radius: 50%;
}

.auth-story::before {
  width: 28rem;
  height: 28rem;
  top: -16rem;
  right: -10rem;
}

.auth-story::after {
  width: 18rem;
  height: 18rem;
  bottom: -10rem;
  left: -7rem;
}

.auth-story-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 660px);
  min-height: min(68vh, 690px);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: clamp(1.5rem, 4vh, 2.75rem);
  padding: clamp(2rem, 5vw, 4.25rem);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 28px 80px rgba(6, 30, 31, 0.28);
}

.auth-story-topline {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.auth-mark {
  display: grid;
  place-items: center;
}

.story-icon {
  display: block;
  width: clamp(108px, 14vw, 176px);
  height: auto;
  margin: 0;
  filter: drop-shadow(0 24px 46px rgba(6, 30, 31, 0.3));
}

.auth-story-statement {
  margin: 0;
  color: #fff;
  font-size: clamp(2.15rem, 4vw, 4.15rem);
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 0.99;
}

.auth-story-statement em {
  color: #efd19a;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
}

.auth-story-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.auth-story-notes span {
  padding: 1.1rem 0.65rem 0 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.78rem;
  line-height: 1.4;
}

.app header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 78px;
  display: grid;
  grid-template-columns: auto minmax(420px, 1fr) auto;
  align-items: center;
  gap: 1.5rem;
  padding: 0.8rem clamp(1.25rem, 3vw, 2.5rem);
  border-bottom: 1px solid rgba(189, 203, 197, 0.78);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.brand.compact {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  color: var(--ink-strong);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.brand.compact img {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.brand.compact em {
  padding-left: 0.8rem;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-style: normal;
  font-weight: 650;
}

nav {
  display: flex;
  justify-content: center;
  gap: 0.2rem;
  min-width: 0;
}

nav button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 0 0.85rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
  white-space: nowrap;
}

nav button:hover,
nav button.active {
  background: var(--teal-soft);
  color: var(--ink-strong);
}

nav button.active {
  box-shadow: inset 0 -2px 0 var(--gold);
}

.shell {
  width: min(1180px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) 0 7rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: reveal 200ms ease-out;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
}

.page-head > div {
  max-width: 760px;
}

.page-head h1 {
  margin-bottom: 0.55rem;
  font-size: clamp(2.75rem, 5vw, 4.75rem);
  line-height: 0.98;
}

.page-head p:not(.eyebrow) {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.summary-card {
  min-height: 124px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow-soft);
}

.summary-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.summary-card span {
  max-width: 10rem;
  color: var(--muted);
  font-weight: 750;
}

.summary-card strong {
  color: var(--ink-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.2rem;
  font-weight: 500;
  line-height: 0.8;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: -0.5rem 0 1.25rem;
}

.filter-row button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 1rem;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 750;
}

.filter-row button:hover,
.filter-row button.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.stack {
  display: grid;
  gap: 1rem;
}

.card {
  position: relative;
  overflow: hidden;
  padding: clamp(1.25rem, 2.5vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: transparent;
  content: "";
}

.card.priority::before {
  background: var(--gold);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

.card-head > div:first-child {
  min-width: 0;
  flex: 1;
}

.card h3 {
  margin: 0.8rem 0 0.4rem;
  font-size: clamp(1.1rem, 2vw, 1.28rem);
  line-height: 1.35;
}

.card p {
  max-width: 850px;
  margin-bottom: 0.55rem;
}

.card p:last-child {
  margin-bottom: 0;
}

.record-meta,
.muted {
  color: var(--muted);
}

.record-meta {
  font-size: 0.88rem;
}

.meta,
.review-state {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.review-state {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.25rem 0.65rem;
  border: 1px solid #dde5e1;
  border-radius: 999px;
  background: var(--teal-pale);
  color: #526767;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
}

.pill.attention {
  border-color: #e3cca5;
  background: var(--gold-soft);
  color: var(--gold-dark);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.actions button,
.action-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 780;
  line-height: 1.2;
  text-decoration: none;
}

.actions button:hover:not(:disabled),
.action-link:hover {
  border-color: var(--teal);
  background: var(--teal-pale);
}

.actions button.primary-action {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.details {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.details label {
  margin-top: 0.9rem;
}

.details textarea,
.details select,
.details input {
  padding: 0.75rem;
}

.details textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.55;
}

.form-grid,
.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.fact-grid {
  margin: 0 0 1.15rem;
}

.fact-grid > div {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--teal-pale);
}

.fact-grid dt {
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.fact-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.prep-note,
.readout-panel {
  margin-top: 1rem;
  border-radius: var(--radius-md);
}

.prep-note {
  padding: 1rem 1.1rem;
  border: 1px solid #dfc79e;
  border-left: 4px solid var(--gold);
  background: var(--gold-soft);
}

.prep-note p {
  margin: 0.25rem 0 0;
}

.readout-panel {
  padding: clamp(1.1rem, 2.4vw, 1.6rem);
  border: 1px solid var(--line);
  background: var(--surface-warm);
}

.readout-copy {
  white-space: pre-wrap;
  line-height: 1.65;
}

.readout-list {
  margin: 0;
  padding-left: 1.3rem;
}

.structured-readout {
  display: grid;
  gap: 1rem;
}

.structured-readout section {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.structured-readout section:first-child {
  padding-top: 0;
  border-top: 0;
}

.structured-readout h4 {
  margin: 0 0 0.45rem;
  font-size: 0.98rem;
}

.empty,
.load-status {
  padding: 1.4rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  text-align: center;
}

.load-status {
  margin: 0 0 1.25rem;
  border-style: solid;
  background: var(--teal-soft);
  color: var(--ink);
  text-align: left;
}

.load-status.error-state,
.empty.error-state {
  border-color: #d8bc89;
  background: var(--gold-soft);
  color: var(--gold-dark);
}

.toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 20;
  max-width: 360px;
  padding: 0.85rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: var(--ink-strong);
  color: #fff;
  box-shadow: 0 18px 45px rgba(16, 47, 49, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.editor-panel {
  display: grid;
  gap: 1.15rem;
  margin: 0 0 1.5rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-heading,
.section-title-row,
.editor-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.editor-heading h2,
.section-title-row h3 {
  margin-bottom: 0;
}

.editor-panel label {
  display: grid;
  gap: 0.45rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
}

.editor-panel input,
.editor-panel textarea,
.editor-panel select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 0.75rem 0.85rem;
}

.editor-panel input,
.editor-panel select {
  min-height: 48px;
}

.editor-panel textarea {
  min-height: 112px;
  resize: vertical;
}

.editor-panel input:focus,
.editor-panel textarea:focus,
.editor-panel select:focus {
  border-color: var(--gold);
}

.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.section-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.section-editor label:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.triage-workflow {
  position: relative;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-warm);
}

.triage-workflow .workflow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.triage-workflow .workflow-grid .wide {
  grid-column: 1 / -1;
}

.compact-stack {
  gap: 0.9rem;
}

.delivery-note {
  padding: 0.85rem 1rem;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: var(--gold-soft);
  color: var(--gold-dark);
}

.editor-footer {
  align-items: center;
  padding-top: 0.3rem;
}

.editor-footer .message {
  margin: 0;
}

@media (max-width: 1080px) {
  .app header {
    grid-template-columns: auto 1fr auto;
    gap: 0.8rem;
  }

  .brand.compact > span {
    display: none;
  }

  .brand.compact em {
    padding-left: 0;
    border-left: 0;
    color: var(--ink);
    font-weight: 800;
  }

  nav button {
    padding-inline: 0.6rem;
  }
}

@media (max-width: 860px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-story {
    display: none;
  }

  .auth-content {
    min-height: 100vh;
    padding: 2.5rem 1.4rem;
  }

  .auth-content .brand-logo {
    margin-bottom: 3.25rem;
  }

  .app header {
    position: static;
    grid-template-columns: 1fr auto;
    padding: 0.85rem 1rem;
  }

  nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 0.25rem 0 0.15rem;
    scrollbar-width: thin;
  }

  nav button {
    flex: 0 0 auto;
    min-height: 44px;
    padding-inline: 0.9rem;
  }

  .shell {
    width: min(100% - 1.5rem, 1180px);
    padding-top: 2rem;
  }

  .page-head {
    align-items: flex-start;
  }

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

  .summary-card {
    min-height: 92px;
  }

  .three-up,
  .section-editor,
  .triage-workflow .workflow-grid {
    grid-template-columns: 1fr;
  }

  .section-editor label,
  .triage-workflow .workflow-grid .wide {
    grid-column: auto;
  }

  .card-head {
    display: block;
  }

  .review-state {
    justify-content: flex-start;
    margin-top: 0.85rem;
  }
}

@media (max-width: 620px) {
  .page-head {
    display: block;
  }

  .page-head > .outline {
    width: 100%;
    margin-top: 1rem;
  }

  .page-head h1 {
    font-size: clamp(2.5rem, 13vw, 3.4rem);
  }

  .form-grid,
  .fact-grid {
    grid-template-columns: 1fr;
  }

  .editor-heading,
  .section-title-row,
  .editor-footer {
    display: grid;
  }

  .actions button,
  .actions a {
    flex: 1 1 150px;
  }

  .brand-logo {
    width: min(320px, 88%);
  }

  .toast {
    right: 0.75rem;
    bottom: 0.75rem;
    left: 0.75rem;
    max-width: none;
  }
}

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