:root {
  --paper: #faf8f3;
  --panel: #ffffff;
  --ink: #20242b;
  --ink-soft: #5b6472;
  --line: #ddd6c8;

  --seal: #8a6d3b;
  --seal-soft: #f1e7d3;

  --in-scope: #2f6e4f;
  --in-scope-bg: #e7f1ea;

  --gray-area: #92661f;
  --gray-area-bg: #f7ecd8;

  --out-scope: #a23b32;
  --out-scope-bg: #f6e6e3;

  --radius: 4px;

  --font-heading:
    Georgia,
    "Iowan Old Style",
    "Palatino Linotype",
    serif;

  --font-body:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
}


* {
  box-sizing: border-box;
}


body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}


h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  margin: 0;
}


/* ====================================================================== */
/* TOP BAR                                                                */
/* ====================================================================== */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 2rem 2.5rem 1.5rem;
  border-bottom: 1px solid var(--line);
}


.topbar-title {
  flex: 1 1 280px;
}


.topbar-title h1 {
  font-size: 1.9rem;
}


.subtitle {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}


/* ====================================================================== */
/* METRICS                                                                */
/* ====================================================================== */

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 1rem 1.75rem;
  margin: 0;
  flex: 1 1 600px;
}


.stat {
  min-width: 110px;
}


.stat dt {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-bottom: 0.15rem;
}


.stat dd {
  margin: 0;
  font-size: 1.35rem;
  font-family: var(--font-heading);
}


/* ====================================================================== */
/* LAYOUT                                                                 */
/* ====================================================================== */

.layout {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 1.5rem;
  padding: 1.75rem 2.5rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
}


.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
}


.panel-wide {
  grid-column: 1 / -1;
}


.panel h2 {
  font-size: 1.15rem;
  padding-bottom: 0.75rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}


.panel-description {
  margin: -0.4rem 0 1.1rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}


/* ====================================================================== */
/* FORM ELEMENTS                                                          */
/* ====================================================================== */

.form-group {
  margin-bottom: 0.9rem;
}


.field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--line);
}


.field-row:last-of-type {
  border-bottom: none;
}


.field-label {
  color: var(--ink-soft);
  font-size: 0.85rem;
  display: block;
  margin-bottom: 0.3rem;
}


.field-value {
  font-weight: 600;
}


textarea,
input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  resize: vertical;
}


textarea:focus,
input:focus,
button:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 1px;
}


/* ====================================================================== */
/* BUTTONS                                                                */
/* ====================================================================== */

.btn {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
}


.btn-primary {
  background: var(--seal);
  color: #fff;
  margin-top: 0.85rem;
}


.btn-primary:hover {
  background: #765a2c;
}


.btn-primary:disabled {
  background: var(--ink-soft);
  cursor: not-allowed;
}


.btn-outline {
  background: transparent;
  border-color: var(--ink);
  color: var(--ink);
}


.btn-outline:hover {
  background: var(--ink);
  color: #fff;
}


.btn-outline:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}


/* ====================================================================== */
/* AGREEMENT                                                              */
/* ====================================================================== */

.revision-block {
  margin-top: 0.5rem;
}


.revision-meter {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.4rem;
}


.revision-meter-fill {
  height: 100%;
  background: var(--seal);
  width: 0%;
  transition: width 0.4s ease;
}


.scope-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1.25rem;
}


.scope-heading {
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
}


.scope-heading-in {
  color: var(--in-scope);
}


.scope-heading-out {
  color: var(--out-scope);
}


.scope-list {
  list-style: none;
  margin: 0;
  padding: 0;
}


.scope-list li {
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.92rem;
}


.scope-list li:last-child {
  border-bottom: none;
}


/* ====================================================================== */
/* ERRORS                                                                 */
/* ====================================================================== */

.error-text {
  color: var(--out-scope);
  font-size: 0.88rem;
  margin-top: 0.5rem;
}


/* ====================================================================== */
/* ANALYSIS RESULT                                                        */
/* ====================================================================== */

.result {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  animation: reveal 0.25s ease;
}


@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


.result-empty {
  margin-top: 1.25rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
  border: 1px dashed var(--line);
}


.result-source {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
  margin-bottom: 0.9rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px dashed var(--line);
}


.source-label {
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 600;
}


.source-value {
  font-size: 0.85rem;
  color: var(--ink);
}


.result-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}


.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius);
}


.badge-in-scope {
  background: var(--in-scope-bg);
  color: var(--in-scope);
}


.badge-gray-area {
  background: var(--gray-area-bg);
  color: var(--gray-area);
}


.badge-out-of-scope {
  background: var(--out-scope-bg);
  color: var(--out-scope);
}


.risk-tag {
  font-size: 0.82rem;
  color: var(--ink-soft);
}


.reasoning {
  margin: 0 0 1.1rem;
}


/* ====================================================================== */
/* SOW MATCH                                                             */
/* ====================================================================== */

.analysis-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.1rem;
}


.analysis-detail {
  border: 1px solid var(--line);
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius);
  background: var(--paper);
}


.analysis-detail .field-label {
  margin-bottom: 0.25rem;
}


.analysis-detail-value {
  font-weight: 600;
}


.impact-row {
  display: flex;
  gap: 2.5rem;
  margin-bottom: 1.1rem;
}


.impact-value {
  font-family: var(--font-heading);
  font-size: 1.4rem;
}


/* ====================================================================== */
/* DECISION REASONING                                                    */
/* ====================================================================== */

.decision-reasoning {
  margin-bottom: 1.25rem;
  padding: 0.9rem 1rem;
  background: var(--seal-soft);
  border-left: 3px solid var(--seal);
}


.decision-reasoning-heading {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
}


.decision-reasoning-text {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}


/* ====================================================================== */
/* IN-SCOPE                                                              */
/* ====================================================================== */

.in-scope-note {
  background: var(--in-scope-bg);
  color: var(--in-scope);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.92rem;
}


/* ====================================================================== */
/* DECISION OPTIONS                                                       */
/* ====================================================================== */

.decision-heading {
  font-size: 1rem;
  margin-bottom: 0.85rem;
}


.decision-option {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
}


.decision-option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}


.decision-label {
  font-weight: 600;
}


.draft-message {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}


/* ====================================================================== */
/* CONFIRMATION                                                           */
/* ====================================================================== */

.decision-confirmation {
  background: var(--seal-soft);
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
}


.decision-confirmation p {
  margin-bottom: 0;
}


/* ====================================================================== */
/* HISTORY                                                                */
/* ====================================================================== */

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}


.history-table th {
  text-align: left;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
}


.history-table td {
  padding: 0.6rem 0.6rem;
  border-bottom: 1px dashed var(--line);
  vertical-align: top;
}


.history-empty {
  color: var(--ink-soft);
  text-align: center;
  padding: 1.5rem 0;
}


.source-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
}


/* ====================================================================== */
/* RESPONSIVE                                                             */
/* ====================================================================== */

@media (max-width: 1100px) {
  .stat-strip {
    justify-content: flex-start;
  }
}


@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .scope-columns {
    grid-template-columns: 1fr;
  }

  .analysis-detail-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 1.5rem;
  }

  .layout {
    padding: 1.5rem;
  }

  .stat-strip {
    justify-content: flex-start;
  }
}


@media (prefers-reduced-motion: reduce) {
  .result {
    animation: none;
  }

  .revision-meter-fill {
    transition: none;
  }
}