:root {
  --bg: #f5ecdc;
  --bg-deep: #ead7bd;
  --paper: #fffdfa;
  --surface: rgba(255, 252, 247, 0.76);
  --surface-strong: rgba(255, 250, 242, 0.94);
  --ink: #1d2f36;
  --muted: #58656d;
  --line: rgba(29, 47, 54, 0.12);
  --accent: #d96b3a;
  --accent-deep: #ab4f27;
  --teal: #2d7f72;
  --honey: #e4b550;
  --shadow: 0 28px 80px rgba(36, 40, 39, 0.14);
  
  --severity-color: #43a047;

  font-family: "Manrope", "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(228, 181, 80, 0.28), transparent 34%),
    linear-gradient(180deg, #f8f1e7 0%, #f3eadf 40%, #efe4d5 100%);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: transparent;
}

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

button {
  cursor: pointer;
}

button:disabled, input:disabled, select:disabled, textarea:disabled {
  cursor: not-allowed;
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 3vw, 2rem) 3rem;
}

.hero {
  margin-bottom: 1.5rem;
}

.module-bar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
  align-items: center;
}

.suite-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(29, 47, 54, 0.08);
  color: var(--teal);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.hero-copy, .panel, .preview-toolbar, .report-sheet {
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow);
}

.hero-copy, .panel, .preview-toolbar {
  background: var(--surface);
  backdrop-filter: blur(18px);
}

.hero-copy {
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-radius: 32px;
}

.eyebrow, .panel-kicker, .report-kicker, .meta-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  font-weight: 800;
}

.eyebrow, .panel-kicker, .report-kicker {
  color: var(--accent-deep);
}

.hero h1, .panel h2, .preview-toolbar h2, .report-title {
  margin: 0;
  font-family: "Fraunces", "Iowan Old Style", Georgia, serif;
  line-height: 1;
}

.hero h1 {
  margin-top: 0.55rem;
  font-size: clamp(2.6rem, 7vw, 4.8rem);
  max-width: 12ch;
}

.mockup-banner {
  display: grid;
  gap: 0.6rem;
  margin-top: 1.1rem;
  padding: 0.95rem 1rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(29, 47, 54, 0.08);
}

.mockup-banner strong {
  font-size: 0.95rem;
}

.mockup-banner span {
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

.mockup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 480px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.editor-form {
  display: grid;
  gap: 1rem;
}

.panel {
  border-radius: 32px;
  padding: 1.5rem;
}

.panel-section {
  border: none;
  margin: 0;
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.panel-kicker {
  margin-bottom: 1rem;
}

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

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}

.form-field input[type="text"],
.form-field input[type="date"],
.form-field input[type="time"],
.form-field select,
.form-field textarea {
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  outline: none;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(217, 107, 58, 0.15);
}

/* Checkbox field styling */
.checkbox-field {
  flex-direction: row;
  align-items: center;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: 0.5rem;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 2.4rem;
  height: 1.3rem;
  background-color: var(--line);
  transition: .3s;
  border-radius: 99px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 1rem;
  width: 1rem;
  left: 0.15rem;
  bottom: 0.15rem;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--teal);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(1.1rem);
}

.toggle-text {
  font-size: 0.88rem;
  font-weight: 600;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

/* Pill selector buttons */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill-btn {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.pill-btn:hover {
  background: rgba(255, 255, 255, 0.9);
}

.pill-btn.is-active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

/* Severity styles overrides */
.severity-group .pill-btn.is-active.severity-btn-1 { background-color: #43a047; border-color: #43a047; }
.severity-group .pill-btn.is-active.severity-btn-2 { background-color: #7cb342; border-color: #7cb342; }
.severity-group .pill-btn.is-active.severity-btn-3 { background-color: #ffa726; border-color: #ffa726; }
.severity-group .pill-btn.is-active.severity-btn-4 { background-color: #ef5350; border-color: #ef5350; }
.severity-group .pill-btn.is-active.severity-btn-5 { background-color: #c62828; border-color: #c62828; }

.counter {
  align-self: flex-end;
  font-size: 0.72rem;
  color: var(--muted);
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
  border: none;
  transition: all 0.2s ease;
}

.button-primary {
  background: var(--accent);
  color: #fff;
}

.button-primary:hover {
  background: var(--accent-deep);
}

.button-ghost {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  color: var(--teal);
}

.button-ghost:hover {
  background: #fff;
}

/* Preview Column */
.preview-column {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-radius: 24px;
}

.preview-toolbar h2 {
  font-size: 1.4rem;
}

.draft-status {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.preview-actions {
  display: flex;
  gap: 0.5rem;
}

/* Report Sheet (Official/Formal document look) */
.report-sheet {
  background: var(--paper);
  border-radius: 24px;
  padding: 2.2rem;
  min-height: 10.5in;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 1.2rem;
  border-top: 10px solid var(--severity-color) !important; /* Visual severity accent */
  transition: border-top-color 0.2s ease;
}

.report-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.report-badge-confidential {
  font-size: 0.75rem;
  font-weight: 800;
  color: #c2463f;
  background: rgba(194, 70, 63, 0.1);
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  letter-spacing: 0.08em;
  border: 1px solid rgba(194, 70, 63, 0.2);
}

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 0.3rem;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.5rem;
}

.report-title {
  font-size: 1.8rem;
}

.report-number-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.meta-card {
  background: rgba(29, 47, 54, 0.02);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}

.meta-card strong {
  display: block;
  font-size: 0.9rem;
  margin-top: 0.15rem;
}

.severity-indicator-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  margin-right: 0.5rem;
}

.document-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-block {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.8rem;
}

.preview-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.preview-block .meta-label {
  color: var(--accent-deep);
  margin-bottom: 0.4rem;
  display: block;
}

.report-copy {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.report-copy.placeholder {
  color: var(--muted);
  font-style: italic;
}

.affected-body, .discovery-source, .list-item {
  font-size: 0.88rem;
  margin: 0.35rem 0 0;
}

.first-aid-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.first-aid-badge {
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(45, 127, 114, 0.08);
  color: var(--teal);
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(45, 127, 114, 0.15);
}

.first-aid-badge-none {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}

.follow-up-box {
  margin-top: 0.6rem;
  background: rgba(228, 181, 80, 0.08);
  border: 1px solid rgba(228, 181, 80, 0.2);
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.form-grid-three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
}

.signature-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--line);
}

.sig-line {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.sig-underline {
  border-bottom: 1px solid var(--ink);
  height: 1.8rem;
}

.report-footer {
  text-align: center;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.3;
}

/* Theme Toggle button override */
html[data-theme="dark"] .suite-link {
  background: rgba(40, 36, 30, 0.74);
  border-color: rgba(240, 230, 213, 0.08);
  color: var(--cn-accent);
}

/* Print view rules */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  
  .app-shell {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .hero, .panel, .preview-toolbar, .lang-switcher {
    display: none !important;
  }

  .workspace {
    display: block !important;
  }

  .preview-column {
    display: block !important;
  }

  .report-sheet {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-height: 0 !important;
    max-height: 100vh;
    aspect-ratio: auto;
    background: transparent !important;
  }

  /* Force page size to portrait Letter */
  @page {
    size: letter portrait;
    margin: 0.4in;
  }
  
  .preview-block {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* Mobile responsive rules */
@media (max-width: 760px) {
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .signature-section {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}
