:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --line: #d9e0ea;
  --text: #172033;
  --muted: #667085;
  --blue: #1769e0;
  --blue-dark: #0f54b8;
  --green-bg: #eaf7ee;
  --green: #247a3a;
  --amber-bg: #fff6db;
  --amber: #8a6100;
  --red-bg: #fff0f0;
  --red: #b42318;
  --shadow: 0 18px 45px rgba(24, 39, 75, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: 100%;
  min-height: 100vh;
  padding: 32px 18px;
}

.workspace {
  width: min(960px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.mode-badge {
  min-width: 88px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-panel,
.action-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-panel {
  margin-bottom: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}

.summary-grid > div {
  min-height: 92px;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}

.summary-grid > div:last-child {
  border-right: 0;
}

.field-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.35;
}

.action-panel {
  padding: 20px;
}

.institution-row {
  display: grid;
  grid-template-columns: 132px minmax(180px, 280px);
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.institution-row label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(23, 105, 224, 0.12);
}

.manual-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.manual-form label {
  display: grid;
  gap: 8px;
}

.manual-form span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.message {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
}

.message.success {
  background: var(--green-bg);
  color: var(--green);
}

.message.warning {
  background: var(--amber-bg);
  color: var(--amber);
}

.message.error {
  background: var(--red-bg);
  color: var(--red);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

button {
  min-width: 150px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button:hover:not(:disabled) {
  background: var(--blue-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.secondary {
  min-width: 96px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button.secondary:hover:not(:disabled) {
  background: #eef3fa;
}

.payload-preview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.payload-preview dt,
.payload-preview dd {
  min-height: 38px;
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.payload-preview dt {
  background: #f7f9fc;
  color: var(--muted);
  font-weight: 700;
}

.payload-preview dd {
  overflow-wrap: anywhere;
}

.payload-preview dt:nth-last-child(-n + 2),
.payload-preview dd:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.payload-preview.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 760px) {
  .page-shell {
    padding: 20px 12px;
  }

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

  .summary-grid,
  .payload-preview,
  .manual-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-grid > div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .institution-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 26px;
  }

  .summary-grid,
  .payload-preview,
  .manual-form {
    grid-template-columns: 1fr;
  }

  .summary-grid > div:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .summary-grid > div:last-child {
    border-bottom: 0;
  }

  button {
    width: 100%;
  }
}
