:root {
  --paper: #f6f7f4;
  --surface: #ffffff;
  --ink: #17201c;
  --muted: #627069;
  --line: #d5dbd7;
  --green: #166447;
  --green-soft: #e6f1eb;
  --blue: #245fa8;
  --blue-soft: #e8f0fa;
  --amber: #8a5a00;
  --amber-soft: #fff1d3;
  --red: #a33b37;
  --red-soft: #fae9e7;
  --charcoal: #2f3733;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--blue); }
button, input, textarea { font: inherit; }
button, .app-link {
  min-height: 42px;
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--green);
  color: white;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}
button.secondary { background: var(--surface); color: var(--green); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #e3a92d;
  outline-offset: 2px;
}

.topbar {
  min-height: 58px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--charcoal);
  color: white;
}
.brand { color: white; text-decoration: none; font-weight: 760; flex: 1; }
.principal { color: #dce3df; font-size: 14px; }
.topbar form { margin: 0; }
.text-button { min-height: auto; border: 0; padding: 5px; background: transparent; color: white; font-weight: 500; }
.boundary-banner {
  padding: 8px 24px;
  text-align: center;
  background: var(--amber-soft);
  color: #583a00;
  border-bottom: 1px solid #e5c778;
  font-size: 13px;
}
main { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 70px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 34px; line-height: 1.1; margin-bottom: 8px; letter-spacing: 0; }
h2 { font-size: 19px; line-height: 1.25; letter-spacing: 0; }
.eyebrow { margin-bottom: 5px; color: var(--green); font-size: 12px; font-weight: 760; text-transform: uppercase; letter-spacing: 0; }
.lede { max-width: 650px; color: var(--muted); font-size: 17px; }
.page-head, .request-head, .section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; }
.app-link { white-space: nowrap; }

.status-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 24px 0 34px;
  border-block: 1px solid var(--line);
}
.status-band div { padding: 14px 18px; border-right: 1px solid var(--line); }
.status-band div:last-child { border-right: 0; }
.status-band span { display: block; color: var(--muted); font-size: 12px; }
.status-band strong { font-size: 18px; font-variant-numeric: tabular-nums; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 42px; }
.primary-column, .resources, .reply-panel, .attachments { min-width: 0; }
.new-request { position: relative; }
.new-request > summary {
  list-style: none;
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 6px;
  background: var(--green);
  color: white;
  font-weight: 650;
  cursor: pointer;
}
.new-request > summary::-webkit-details-marker { display: none; }
.new-request[open] { width: min(620px, calc(100vw - 32px)); }
.new-request[open] form {
  position: absolute;
  right: 0;
  z-index: 2;
  width: 100%;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 12px 36px rgba(32, 45, 38, .16);
}
.stack-form { display: grid; gap: 14px; }
.stack-form label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; font-weight: 650; }
.stack-form input, .stack-form textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #aeb9b2;
  border-radius: 5px;
  background: white;
  color: var(--ink);
}
.stack-form textarea { resize: vertical; min-height: 100px; }
.stack-form button { justify-self: start; }
.stack-form .check-row { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.stack-form .check-row input { width: auto; }
.stack-form .check-row input[type="checkbox"] { width: 24px; height: 24px; flex: 0 0 24px; }
.hint { font-weight: 400; }

.request-list { list-style: none; padding: 0; margin: 18px 0 0; border-top: 1px solid var(--line); }
.request-row { border-bottom: 1px solid var(--line); }
.request-row > a { display: flex; justify-content: space-between; gap: 20px; padding: 17px 4px; color: var(--ink); text-decoration: none; }
.request-row > a:hover .request-title { color: var(--blue); }
.request-title { font-weight: 690; }
.request-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.status, .andrew-mark, .model { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 720; text-transform: uppercase; }
.status-open, .status-claimed { color: var(--blue); background: var(--blue-soft); }
.status-returned { color: var(--amber); background: var(--amber-soft); }
.status-needs_revision { color: var(--red); background: var(--red-soft); }
.status-accepted { color: var(--green); background: var(--green-soft); }
.status-closed { color: var(--muted); background: #ecefed; }
.andrew-mark { color: white; background: var(--charcoal); }
.model { color: var(--muted); background: #ecefed; text-transform: none; }
.empty-state { padding: 24px 0; color: var(--muted); border-block: 1px solid var(--line); }
.empty-state.compact { border: 0; padding: 0; }
.resources { padding-left: 24px; border-left: 1px solid var(--line); }
.resources ul { padding: 0; list-style: none; }
.resources li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.resources li p { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.resource-add { margin-top: 18px; }
.resource-add > summary { color: var(--blue); cursor: pointer; font-weight: 650; }
.resource-add form { margin-top: 12px; }

.login-panel { width: min(440px, 100%); margin: 9vh auto; padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.back-link { display: inline-block; margin-bottom: 20px; }
.byline { color: var(--muted); }
.decision-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.decision-actions form { margin: 0; }
.conversation { margin: 30px 0; border-top: 1px solid var(--line); }
.message { padding: 20px 0; border-bottom: 1px solid var(--line); }
.message-agent { padding-left: 18px; border-left: 4px solid var(--green); }
.message-head { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 8px; }
.message-head time { color: var(--muted); font-size: 12px; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.attachments, .reply-panel { margin: 30px 0; }
.attachments ul { padding: 0; list-style: none; }
.attachments li { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.attachments span { color: var(--muted); font-size: 12px; }
.history { margin-top: 36px; color: var(--muted); }
.history summary { cursor: pointer; color: var(--ink); font-weight: 650; }
.history li { padding: 4px 0; font-size: 13px; }
.flash { margin-bottom: 16px; padding: 11px 14px; border: 1px solid; border-radius: 5px; }
.flash-error { color: var(--red); background: var(--red-soft); }

@media (max-width: 760px) {
  .topbar { padding: 0 14px; }
  .boundary-banner { padding-inline: 14px; }
  main { width: min(100% - 24px, 1120px); padding-top: 22px; }
  h1 { font-size: 28px; }
  .page-head, .request-head, .section-head { align-items: stretch; flex-direction: column; }
  .app-link { align-self: flex-start; }
  .status-band { grid-template-columns: 1fr 1fr; }
  .status-band div:nth-child(2) { border-right: 0; }
  .status-band div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .workspace-grid { grid-template-columns: 1fr; gap: 32px; }
  .resources { padding-left: 0; padding-top: 24px; border-left: 0; border-top: 1px solid var(--line); }
  .new-request[open] { width: 100%; }
  .new-request[open] form { position: static; margin-top: 8px; }
  .request-row > a { display: grid; gap: 7px; }
  .request-meta { white-space: normal; flex-wrap: wrap; }
  .message-head, .attachments li { flex-direction: column; gap: 4px; }
  .message-agent { padding-left: 12px; }
}
