:root {
  --bg: #f2efe8;
  --surface: #fffaf3;
  --surface-strong: #fff;
  --line: #ddd2bf;
  --ink: #1c2430;
  --muted: #57606f;
  --accent: #0f766e;
  --accent-strong: #0f766e;
  --accent-soft: #d2f1eb;
  --warn: #a16207;
  --warn-soft: #f8e6bf;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --success: #166534;
  --success-soft: #dcfce7;
  --shadow: 0 12px 28px rgba(28, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, #f7f3eb 0%, var(--bg) 100%);
  background-size: 28px 28px, auto;
  scroll-behavior: smooth;
}

button,
input {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  transform: none;
}

.page-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.app-header,
.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 28px;
  margin-bottom: 24px;
  border-top: 4px solid var(--accent);
}

.eyebrow,
.mini-label {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

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

h1 {
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  line-height: 0.96;
  margin-bottom: 0;
}

h2 {
  font-size: 1.45rem;
  margin-bottom: 6px;
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

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

.section-nav {
  position: sticky;
  top: 10px;
  z-index: 10;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.section-nav a {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  background: #f8fafc;
  border: 1px solid var(--line);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.section-nav a:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.38);
  box-shadow: 0 10px 22px rgba(28, 36, 48, 0.12);
}

.panel {
  padding: 24px;
}

.anchor-panel {
  scroll-margin-top: 96px;
}

.wide-panel {
  grid-column: 1 / -1;
}

.controls-panel {
  background: var(--surface);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.section-head p {
  color: var(--muted);
  margin-bottom: 14px;
  max-width: 62ch;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

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

.secondary-btn {
  background: #fff;
  border-color: var(--line);
}

.ghost-btn {
  background: transparent;
  border-color: var(--line);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(28, 36, 48, 0.12);
}

.export-dialog {
  border: none;
  border-radius: 24px;
  padding: 0;
  width: min(760px, calc(100vw - 32px));
  box-shadow: 0 30px 80px rgba(12, 18, 28, 0.32);
  background: transparent;
}

.export-dialog::backdrop {
  background: rgba(12, 18, 28, 0.48);
  backdrop-filter: blur(2px);
}

.export-dialog-panel {
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
}

.export-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 20px;
}

.export-choice-card {
  text-align: left;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 18px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.export-choice-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1rem;
}

.export-choice-card span {
  color: var(--muted);
  line-height: 1.5;
}

.export-choice-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(28, 36, 48, 0.12);
  border-color: rgba(33, 97, 167, 0.28);
}

.export-dialog-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 760px) {
  .export-choice-grid {
    grid-template-columns: 1fr;
  }
}

.intake-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
  align-items: stretch;
}

.intake-grid > * {
  min-width: 0;
}

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

.upload-grid > * {
  min-width: 0;
}

.upload-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: #f8fafc;
}

.upload-card input {
  padding: 10px 0;
}

.upload-title {
  font-weight: 700;
}

.upload-subtitle,
.status-value,
.criterion-source,
.result-reason {
  color: var(--muted);
  word-break: break-word;
  overflow-wrap: break-word;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f8fafc;
}

.status-strip > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 4px;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: #f8fafc;
}

.tender-rejection {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--danger) 20%, var(--line));
  border-radius: 18px;
  background: linear-gradient(180deg, #fff6f5 0%, #fff 100%);
}

.tender-rejection h3 {
  margin-bottom: 6px;
}

.tender-rejection .queue-top {
  align-items: flex-start;
}

.approval-section {
  display: grid;
  gap: 16px;
  margin-top: 24px;
  padding: 18px;
  border: 2px solid var(--accent);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.05) 0%, #fff 100%);
}

.approval-status {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.approval-status .mini-label {
  margin-bottom: 0;
  white-space: nowrap;
}

.approval-status .status-value {
  font-weight: 700;
}

.approval-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.approval-buttons .primary-btn,
.approval-buttons .secondary-btn {
  flex: 1;
  min-width: 160px;
}

.rejection-status {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.08) 0%, #fff 100%);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line));
}

.rejection-status .mini-label {
  margin-bottom: 0;
}

.rejection-badge {
  font-weight: 700;
  color: var(--danger);
}

.rejection-reason {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
}

.review-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--muted);
  word-break: break-word;
  overflow-wrap: break-word;
}

.tender-rejection-detail {
  border: 1px solid color-mix(in srgb, var(--danger) 18%, var(--line));
  background: #fff;
}

.criteria-grid,
.bidder-grid,
.dashboard-grid,
.queue-grid {
  display: grid;
  gap: 12px;
}

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

.dashboard-grid > * {
  min-width: 0;
}

.criterion-card,
.bidder-card,
.result-card,
.audit-item,
.summary-card,
.queue-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.criterion-card {
  padding: 18px;
}

.criterion-top,
.result-head,
.bidder-header,
.queue-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.criterion-badge,
.criterion-tag,
.result-chip,
.overall-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

.criterion-badge {
  background: var(--accent-soft);
  color: var(--accent);
}

.criterion-tag {
  background: #efe8dc;
  color: #6f5a3f;
}

.criterion-title {
  margin: 14px 0 8px;
  word-break: break-word;
  overflow-wrap: break-word;
}

.summary-card,
.queue-card {
  padding: 18px;
}

.summary-card p,
.queue-card p {
  margin-bottom: 0;
}

.summary-value {
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--ink);
  word-break: break-word;
  overflow-wrap: break-word;
}

.criterion-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin-bottom: 0;
}

.criterion-meta > * {
  min-width: 0;
}

.criterion-meta div {
  padding: 10px 12px;
  border-radius: 14px;
  background: #f8fafc;
  word-break: break-word;
  overflow-wrap: break-word;
}

.criterion-meta dt {
  margin-bottom: 4px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  word-break: break-word;
  overflow-wrap: break-word;
}

.criterion-meta dd {
  margin: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

.bidder-card {
  padding: 20px;
}

.bidder-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.metric-pill {
  border-radius: 999px;
  padding: 7px 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  font-size: 0.86rem;
}

.criteria-results {
  display: grid;
  gap: 12px;
}

.result-card {
  padding: 16px;
}

.result-title {
  margin-bottom: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

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

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.override-status {
  margin: 0;
  color: var(--muted);
  word-break: break-word;
  overflow-wrap: break-word;
}

.override-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.override-button-row .secondary-btn,
.override-button-row .ghost-btn {
  min-width: 140px;
}

.result-detail-grid > * {
  min-width: 0;
}

.queue-title {
  margin: 12px 0 6px;
  font-weight: 700;
}

.queue-reason,
.queue-empty {
  color: var(--muted);
  word-break: break-word;
  overflow-wrap: break-word;
}

.detail-box {
  padding: 10px 12px;
  border-radius: 14px;
  background: #f8fafc;
  word-break: break-word;
  overflow-wrap: break-word;
}

.detail-box strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.status-eligible {
  background: var(--success-soft);
  color: var(--success);
}

.status-ineligible {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-review {
  background: var(--warn-soft);
  color: var(--warn);
}

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

.audit-item {
  padding: 16px;
}

.audit-item p {
  margin-bottom: 0;
}

/* Amendment/Corrigenda styling */
.amendment-badge {
  display: inline-block;
  padding: 6px 10px;
  background-color: #fff3cd;
  border-left: 3px solid #ffc107;
  font-size: 0.85rem;
  margin-top: 8px;
  border-radius: 2px;
}

.amendment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.amendment-item {
  padding: 12px;
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.amendment-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.version-badge {
  display: inline-block;
  padding: 4px 8px;
  background-color: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: bold;
  font-size: 0.85rem;
  border-radius: 3px;
  min-width: 40px;
  text-align: center;
}

.version-name {
  font-weight: 500;
  color: var(--ink);
  word-break: break-word;
}

.version-date {
  font-size: 0.85rem;
  color: var(--muted);
}

.amendment-changes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
  background-color: rgba(0, 0, 0, 0.02);
  border-radius: 2px;
}

.change-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.change-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.change-group.added .change-label {
  color: var(--success);
}

.change-group.modified .change-label {
  color: var(--warn);
}

.change-group.removed .change-label {
  color: var(--danger);
}

.change-item {
  padding: 4px 6px;
  font-size: 0.85rem;
  margin-left: 12px;
  border-left: 2px solid currentColor;
  padding-left: 8px;
}

.change-group.added .change-item {
  color: var(--success);
}

.change-group.modified .change-item {
  color: var(--warn);
}

.change-group.removed .change-item {
  color: var(--danger);
  text-decoration: line-through;
}

@media (max-width: 1024px) {
  .app-header,
  .main-grid,
  .intake-grid,
  .upload-grid,
  .status-strip,
  .dashboard-grid,
  .criterion-meta,
  .result-detail-grid {
    grid-template-columns: 1fr;
  }
}
