:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --ink: #17211b;
  --muted: #5d6a64;
  --line: #d9ded6;
  --blue: #285d8f;
  --green: #2f6f4e;
  --gold: #936c22;
  --red: #9b352f;
  --shadow: 0 12px 32px rgba(20, 31, 25, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.1;
}

h2 {
  font-size: 16px;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 32px 40px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.token-field {
  display: grid;
  gap: 4px;
  min-width: 180px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.token-field input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 0 10px;
  text-transform: none;
}

button,
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 0 14px;
  text-decoration: none;
}

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

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

.link-button {
  display: inline;
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: inherit;
  font-weight: 700;
  padding: 0;
  text-align: left;
  text-decoration: underline;
}

.button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

.status-grid article {
  min-height: 86px;
  padding: 16px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-grid strong {
  display: block;
  margin-top: 12px;
  font-size: 22px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 18px;
}

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

.studies-panel {
  margin-bottom: 18px;
}

.study-summary {
  padding: 16px;
}

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

.study-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.study-summary dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
}

.generated-panel,
.evidence-panel {
  margin-top: 18px;
}

.saved-studies {
  padding: 16px;
}

.saved-study-list {
  display: grid;
  gap: 10px;
}

.saved-study {
  display: grid;
  min-height: auto;
  justify-items: start;
  gap: 4px;
  width: 100%;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  padding-block: 12px;
  text-align: left;
}

.saved-study span,
.saved-study small {
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.followup-panel {
  margin-top: 18px;
}

.generated-outputs {
  padding: 16px;
}

.generated-outputs dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px 18px;
  margin: 0;
}

.generated-outputs dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.generated-outputs dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.panel {
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.count {
  min-width: 32px;
  border-radius: 999px;
  background: #e7ece5;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  padding: 4px 8px;
  text-align: center;
}

.issue-list {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
  padding: 14px;
}

.followup-list {
  padding: 16px;
}

.followup-list ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.followup-list li {
  line-height: 1.45;
}

.evidence-list {
  padding: 16px;
}

.evidence-list ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.evidence-list li {
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.supporting-files {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.file-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf6;
  padding: 12px;
}

.file-list ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.file-list li {
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.pricing-summary {
  margin: 16px 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf6;
  padding: 12px;
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.pricing-summary.empty {
  color: var(--muted);
  font-weight: 600;
}

.panel-actions {
  display: flex;
  justify-content: flex-start;
  padding: 12px 16px 0;
}

.issue {
  border-left: 4px solid var(--gold);
  background: #fbf8ef;
  padding: 10px 12px;
}

.issue.error {
  border-left-color: var(--red);
  background: #fff1ef;
}

.issue strong {
  display: block;
  font-size: 13px;
}

.issue p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.empty {
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f1f4f0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #e9f1eb;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
}

.pill.warn {
  background: #fbf1d9;
  color: var(--gold);
}

select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 6px 8px;
}

input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 6px 8px;
}

.form-layout {
  display: grid;
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.component-forms {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.component-form {
  display: grid;
  grid-template-columns: 110px repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.component-form legend {
  align-self: center;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  padding: 0;
}

.form-status {
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
  min-height: 22px;
}

.empty-cell {
  color: var(--muted);
  height: 120px;
  text-align: center;
  vertical-align: middle;
}

@media (max-width: 900px) {
  .app-header,
  main {
    padding-inline: 16px;
  }

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

  .actions {
    justify-content: flex-start;
  }

  .status-grid,
  .study-summary dl,
  .workspace,
  .form-grid,
  .component-form {
    grid-template-columns: 1fr;
  }
}
