:root {
  color-scheme: light;
  --bg: #eef3f6;
  --panel: #ffffff;
  --ink: #08213f;
  --muted: #657184;
  --line: #cfd9e2;
  --accent: #007a78;
  --accent-dark: #005f5d;
  --warn: #9a2f2f;
  --danger: #b42318;
  --goae: #7a4b00;
  --goae-line: #e0c58d;
  --goae-bg: #fff8e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 16px;
}

.logout {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #f8fafb;
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 8px;
  padding: 8px;
  min-height: calc(100vh - 69px);
}

.input-side,
.output-side,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.input-side,
.output-side {
  display: flex;
  flex-direction: column;
  min-height: auto;
  padding: 10px;
}

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

.section-head span {
  color: var(--muted);
  font-size: 13px;
}

textarea {
  flex: 1;
  min-height: 220px;
  max-height: 360px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  color: var(--ink);
  line-height: 1.45;
  font-size: 15px;
}

textarea:focus,
input:focus {
  outline: 3px solid rgba(0, 122, 120, 0.22);
  border-color: var(--accent);
}

.notice {
  margin: 0 0 12px;
  color: var(--warn);
  background: #fff3f3;
  border: 1px solid #e8b4b4;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  line-height: 1.4;
}

.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

button {
  align-self: flex-start;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary-button {
  color: var(--ink);
  background: #e8eef2;
}

.secondary-button:hover {
  background: #dbe5ea;
}

.inline-status {
  color: var(--muted);
  font-size: 13px;
}

.inline-status.loading::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border: 2px solid #b8c6d1;
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 12px;
  line-height: 1.38;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

#recordOutput {
  flex: initial;
  min-height: 170px;
  max-height: 320px;
}

#diagnosisOutput {
  min-height: 80px;
  max-height: 220px;
  overflow: auto;
}

.diagnosis-output {
  display: grid;
  gap: 8px;
  margin: 0;
  border: 1px solid #a8cddd;
  border-radius: 8px;
  background: #eef7fb;
  padding: 8px;
  line-height: 1.32;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  white-space: normal;
}

.diagnosis-group {
  border: 1px solid #b7d7e4;
  border-radius: 7px;
  background: #f8fcfe;
  padding: 7px 9px 8px;
}

.diagnosis-group + .diagnosis-group {
  margin-top: 2px;
}

.diagnosis-group h3 {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.2;
}

.diagnosis-code {
  padding: 2px 0;
  color: var(--ink);
}

.copy-button {
  margin-top: 0;
}

.copy-button.compact {
  padding: 6px 9px;
  font-size: 13px;
}

.diagnosis-panel,
.goae-panel {
  margin-top: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #f2f9fc;
  border: 1px solid #bad9e6;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
}

.field-hint {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 30px;
}

.login-panel form {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

label {
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.error {
  color: var(--danger);
}

@media (max-width: 1180px) {
  .topbar {
    padding: 12px 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  h1 {
    font-size: 22px;
  }

  .eyebrow {
    font-size: 11px;
    margin-bottom: 3px;
  }

  .input-side,
  .output-side {
    min-height: auto;
    padding: 10px;
  }

  textarea {
    min-height: 220px;
  }

  #recordOutput {
    min-height: 170px;
  }
}

.goae-panel {
  background: var(--goae-bg);
  border-color: var(--goae-line);
  border-left-color: var(--goae);
}

.goae-panel .section-head span,
.goae-panel h2 {
  color: #5f3a00;
}

.goae-output {
  display: grid;
  gap: 7px;
  min-height: 80px;
  max-height: 240px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--goae-line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 8px;
  line-height: 1.32;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

.goae-intro {
  margin: 0 0 1px;
  color: #6f5a34;
  font-size: 13px;
}

.goae-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
  align-items: start;
  padding: 7px 8px;
  border: 1px solid #ead7ad;
  border-radius: 7px;
  background: #fffaf0;
}

.goae-item strong {
  color: #5f3a00;
  font-size: 15px;
  line-height: 1.25;
}

.goae-item span {
  color: var(--ink);
}

.goae-note {
  color: #6f5a34;
  font-size: 13px;
  line-height: 1.3;
}
