:root {
  --brand-navy: #163d7a;
  --brand-navy-dark: #0c2348;
  --brand-gold: #f5c242;
  --brand-gold-soft: #fbe7a6;
  --surface: #fffdf8;
  --surface-alt: #f4f7fb;
  --surface-card: #ffffff;
  --panel-border: #d7e0ed;
  --text-primary: #20324a;
  --text-secondary: #6a778b;
  --success: #2c7a57;
  --danger: #b33a3a;
  --info: #2457a6;
  --neutral: #8b95a5;
  --shadow-soft: 0 22px 58px rgba(22, 61, 122, 0.1);
  --shadow-card: 0 18px 40px rgba(12, 35, 72, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(245, 194, 66, 0.22), transparent 32%),
    linear-gradient(180deg, var(--surface) 0%, var(--surface-alt) 100%);
  color: var(--text-primary);
  font-family: "Aptos", "Segoe UI", "Helvetica Neue", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

img {
  max-width: 100%;
  display: block;
}

.app-shell {
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  margin-bottom: 18px;
}

.hero-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  padding: 24px;
  background: linear-gradient(315deg, #ffffff 0%, #fff7e6 100%);
  box-shadow: var(--shadow-soft);
}

.hero-panel::after {
  content: "";
  position: absolute;
  inset: auto -60px -90px auto;
  width: 240px;
  height: 240px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(22, 61, 122, 0.15), transparent 68%);
  pointer-events: none;
}

.brand-row {
  display: flex;
  gap: 22px;
  align-items: center;
}

.logo-plate {
  flex: 0 0 228px;
  padding: 14px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 247, 251, 0.92));
  box-shadow: 0 16px 28px rgba(22, 61, 122, 0.12);
}

.brand-logo {
  width: 100%;
  object-fit: contain;
}

.brand-copy {
  flex: 1;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-navy);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  font-weight: 800;
}

.brand-copy h1,
.panel-head h2,
.editor-hero h2,
.welcome-panel h2 {
  margin: 0;
  color: var(--brand-navy);
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", sans-serif;
  line-height: 1.08;
}

.brand-copy h1 {
  font-size: clamp(1.8rem, 2.8vw, 2.8rem);
  max-width: 14ch;
}

.subtitle,
.panel-head p,
.welcome-panel p,
.editor-summary,
.inline-help,
.history-meta,
.attachment-note,
.question-card textarea::placeholder {
  color: var(--text-secondary);
}

.subtitle {
  margin: 10px 0 0;
  max-width: 64ch;
  line-height: 1.55;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.stat-card {
  padding: 15px 16px;
  border-radius: 20px;
  background: #fff8e9;
}

.stat-card__label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.stat-card__value {
  margin-top: 6px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand-navy);
}

.workspace {
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.sidebar,
.content {
  min-width: 0;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}

.action-panel,
.history-panel,
.welcome-panel,
.editor-shell,
.metadata-panel,
.category-panel {
  padding: 18px;
}

.history-panel {
  margin-top: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head p {
  margin: 6px 0 0;
  line-height: 1.45;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff1cc;
  color: var(--brand-navy);
  font-size: 0.82rem;
  font-weight: 700;
}

.flow-grid {
  display: grid;
  gap: 12px;
}

.flow-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  text-align: left;
  border-radius: 20px;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.flow-card strong {
  font-size: 1.05rem;
}

.flow-card small {
  color: inherit;
  opacity: 0.88;
  line-height: 1.4;
}

.flow-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(12, 35, 72, 0.14);
}

.flow-card--navy {
  color: #ffffff;
  background: linear-gradient(90deg, var(--brand-navy) 0%, var(--brand-navy-dark) 100%);
}

.flow-card--gold {
  color: var(--brand-navy-dark);
  background: linear-gradient(90deg, var(--brand-gold) 0%, #e0ae36 100%);
}

.flow-card__kicker {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.9;
}

.history-list {
  display: grid;
  gap: 12px;
}

.record-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid #e3eaf3;
  background: #ffffff;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.record-card:hover,
.record-card.is-active {
  transform: translateY(-1px);
  border-color: rgba(22, 61, 122, 0.32);
  box-shadow: 0 14px 28px rgba(12, 35, 72, 0.08);
}

.record-card__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.record-card__title {
  font-weight: 800;
  color: var(--brand-navy);
}

.record-card__type {
  padding: 6px 10px;
  border-radius: 12px;
  background: #e7eef8;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--brand-navy);
}

.record-card__summary,
.record-card__meta,
.record-card__progress {
  margin-top: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #e9eef6;
  margin-top: 10px;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-navy) 0%, var(--brand-gold) 100%);
}

.welcome-panel {
  min-height: 280px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 42px 24px;
}

.welcome-panel > * {
  max-width: 56ch;
}

.editor-shell {
  padding: 0;
  overflow: hidden;
}

.editor-hero {
  padding: 20px;
  background: linear-gradient(315deg, #ffffff 0%, #fff7e6 100%);
  border-bottom: 1px solid var(--panel-border);
}

.editor-summary {
  margin: 10px 0 0;
  line-height: 1.55;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.button {
  min-height: 46px;
  padding: 11px 16px;
  border-radius: 18px;
  font-weight: 700;
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button--primary {
  color: #ffffff;
  background: linear-gradient(90deg, var(--brand-navy) 0%, var(--brand-navy-dark) 100%);
}

.button--secondary {
  color: var(--brand-navy);
  background: #ffffff;
  border: 1px solid var(--brand-navy);
}

.button--gold {
  color: var(--brand-navy-dark);
  background: linear-gradient(90deg, var(--brand-gold) 0%, #e0ae36 100%);
}

.button--ghost {
  color: var(--brand-navy);
  background: #eff4fb;
}

.button--tiny {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 0.82rem;
}

.editor-body {
  padding: 18px;
}

.metadata-panel {
  margin-bottom: 16px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 0.84rem;
  color: var(--text-secondary);
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 12px 13px;
  background: #ffffff;
  color: var(--text-primary);
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid rgba(22, 61, 122, 0.16);
  border-color: rgba(22, 61, 122, 0.38);
}

.category-panel + .category-panel {
  margin-top: 16px;
}

.category-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.category-title {
  margin: 0;
  font-size: 1rem;
  color: var(--brand-navy);
}

.category-count {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.question-stack {
  display: grid;
  gap: 12px;
}

.question-card {
  border: 1px solid #e3eaf3;
  border-radius: 18px;
  padding: 14px;
  background: #ffffff;
}

.question-code {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 12px;
  background: #e7eef8;
  color: var(--brand-navy);
  font-size: 0.74rem;
  font-weight: 800;
}

.question-title {
  margin: 10px 0 0;
  line-height: 1.55;
  color: var(--text-primary);
}

.answer-group {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.answer-button {
  flex: 1;
  min-height: 42px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: #ffffff;
  color: var(--text-secondary);
  font-weight: 700;
}

.answer-button.is-active[data-answer="SI"] {
  border-color: var(--success);
  background: rgba(44, 122, 87, 0.12);
  color: var(--success);
}

.answer-button.is-active[data-answer="NO"] {
  border-color: var(--danger);
  background: rgba(179, 58, 58, 0.12);
  color: var(--danger);
}

.answer-button.is-active[data-answer="NA"] {
  border-color: var(--info);
  background: rgba(36, 87, 166, 0.12);
  color: var(--info);
}

.question-card textarea {
  min-height: 92px;
  resize: vertical;
  margin-top: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 12px;
}

.attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.attachment-status {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  font-size: 0.84rem;
}

.attachment-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.attachment-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f0f4fa;
  color: var(--brand-navy);
  font-weight: 700;
}

.evidence-preview {
  margin-top: 10px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  max-width: 280px;
}

.save-note {
  margin-top: 12px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(12, 35, 72, 0.96);
  color: #ffffff;
  box-shadow: 0 18px 38px rgba(12, 35, 72, 0.22);
  animation: fadeSlideIn 0.42s ease both;
}

.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.fade-slide-in {
  animation: fadeSlideIn 0.42s ease both;
}

.pulse-glow {
  animation: pulseGlow 0.9s ease-in-out 2 alternate;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseGlow {
  from {
    transform: scale(0.88);
    opacity: 0.78;
  }
  to {
    transform: scale(1.04);
    opacity: 1;
  }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .brand-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .logo-plate {
    width: min(100%, 260px);
    flex-basis: auto;
  }

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

@media (max-width: 640px) {
  .hero-stats {
    grid-template-columns: 1fr;
  }

  .answer-group {
    flex-direction: column;
  }

  .panel-head,
  .category-head,
  .record-card__top {
    flex-direction: column;
    align-items: flex-start;
  }
}
