:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #627084;
  --line: #d8dee8;
  --accent: #0f7b6c;
  --accent-strong: #095f54;
  --warn: #a34500;
  --bad: #b42318;
  --good: #087443;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.loginBody {
  min-height: 100vh;
  background: #eef2f7;
}

.loginShell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loginPanel {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(20, 31, 45, 0.12);
}

.loginPanel p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.loginForm {
  margin-top: 22px;
  display: grid;
  gap: 14px;
}

.ssoBox {
  margin-top: 20px;
  display: grid;
  gap: 8px;
}

.ssoButton {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
}

.ssoButton.disabled {
  border-color: #9aa8b5;
  background: #9aa8b5;
  cursor: not-allowed;
}

#ssoNote,
.adminLoginTitle {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.loginForm button,
#logoutButton {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.loginForm button:disabled {
  border-color: #9aa8b5;
  background: #9aa8b5;
  cursor: wait;
}

#loginStatus {
  min-height: 18px;
  color: var(--bad);
  font-size: 13px;
}

button,
input,
select,
textarea {
  font: inherit;
}

.appShell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.appHeader {
  min-height: 72px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.viewNav,
.filterBar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewTab,
.ghostButton {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: #324154;
  font-weight: 700;
  cursor: pointer;
}

.viewTab {
  min-width: 92px;
}

.viewTab.active {
  border-color: var(--accent);
  background: #eefaf7;
  color: var(--accent-strong);
}

.ghostButton {
  padding: 0 14px;
  color: var(--accent-strong);
}

.appView {
  display: none;
}

.appView.active {
  display: block;
}

#creatorView.active {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(520px, 0.95fr) minmax(420px, 1.05fr);
  gap: 0;
}

.workspace,
.results {
  padding: 24px;
}

.workspace {
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.topbar,
.panelTitle,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.accessProof {
  margin: 0;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  border: 1px solid var(--line);
  border-left: 0;
  border-right: 0;
  border-radius: 8px;
  background: #f8fafc;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto minmax(160px, 1fr);
  gap: 10px;
  align-items: end;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.pageTitle {
  padding: 22px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pageTitle p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

#connectionText,
#proofText {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

#connectionText.ok {
  color: var(--good);
}

#connectionText.bad {
  color: var(--bad);
}

.formGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  color: #2d3746;
  font-size: 13px;
  font-weight: 650;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fbfcfe;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 118px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 108, 0.13);
}

.actions {
  justify-content: flex-start;
  margin-top: 4px;
}

#proofButton {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #eefaf7;
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
}

#logoutButton {
  background: #ffffff;
  color: var(--accent-strong);
}

.results {
  overflow: auto;
}

.metricGrid {
  padding: 18px 24px 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.metricCard {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.metricCard span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metricCard strong {
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.metricCard em {
  color: var(--good);
  font-size: 12px;
  font-style: normal;
}

.splitLayout {
  padding: 18px 24px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.8fr);
  gap: 16px;
}

.workPanel {
  margin: 18px 24px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.splitLayout .workPanel {
  margin: 0;
}

.workPanel .panelTitle {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.stageBoard {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
  overflow-x: auto;
}

.stageColumn {
  min-height: 260px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.stageColumn h3 {
  margin: 0 0 10px;
  color: #2d3746;
  font-size: 13px;
}

.clientMiniCard,
.actionItem {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.clientMiniCard {
  cursor: pointer;
}

.clientMiniCard:focus,
.clientMiniCard:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 108, 0.1);
  outline: none;
}

.clientMiniCard + .clientMiniCard,
.actionItem + .actionItem {
  margin-top: 8px;
}

.clientMiniCard strong,
.actionItem strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clientMiniCard span,
.actionItem span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.actionList {
  padding: 12px;
  max-height: 368px;
  overflow: auto;
}

.clientDetailPanel {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.clientDetailHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.clientDetailHeader h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
}

.clientDetailHeader p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.clientFacts div {
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.clientFacts span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.clientFacts strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
}

.clientProgress {
  padding: 10px;
  border: 1px solid #d7ebdf;
  border-radius: 8px;
  background: #f2fbf6;
  color: #254333;
  font-size: 13px;
  line-height: 1.45;
}

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

.quickActions button,
.instructionBox button,
.rowAction {
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #eefaf7;
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
}

.quickActions button:disabled,
.instructionBox button:disabled {
  border-color: var(--line);
  background: #eef2f6;
  color: #8a97a8;
  cursor: not-allowed;
}

.instructionBox {
  display: grid;
  gap: 8px;
}

.instructionBox textarea {
  min-height: 96px;
}

.instructionBox button {
  width: 132px;
}

.instructionStatus {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.rowAction {
  min-width: 78px;
  min-height: 32px;
  padding: 0 9px;
  font-size: 12px;
}

.selectedRow {
  background: #f3fbf8;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #39475a;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.warn {
  background: #fff4e5;
  color: var(--warn);
}

.tag.good {
  background: #eaf8f1;
  color: var(--good);
}

.tag.bad {
  background: #feeceb;
  color: var(--bad);
}

.tableWrap {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

td strong {
  display: block;
  margin-bottom: 3px;
}

td small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.pipelineBars {
  padding: 14px;
  display: grid;
  gap: 13px;
}

.pipelineRow {
  display: grid;
  grid-template-columns: 84px 1fr 36px;
  align-items: center;
  gap: 10px;
  color: #344256;
  font-size: 13px;
  font-weight: 700;
}

.barTrack {
  height: 10px;
  border-radius: 999px;
  background: #e8edf4;
  overflow: hidden;
}

.barFill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

#agentSubmitButton {
  min-width: 140px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: #315c9f;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

#agentSubmitButton:disabled {
  background: #9aa8b5;
  cursor: wait;
}

.imageDropZone {
  position: relative;
  min-height: 112px;
  border: 1px dashed #aab6c5;
  border-radius: 8px;
  background: #fbfcfe;
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.imageDropZone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.imageDropZone:focus,
.imageDropZone.dragging {
  border-color: var(--accent);
  background: #eefaf7;
  box-shadow: 0 0 0 3px rgba(15, 123, 108, 0.13);
}

.dropText {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 500;
}

.dropText strong {
  color: var(--accent-strong);
  font-size: 15px;
}

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

.imagePreviewList.hasImages {
  display: grid;
}

.imagePreviewItem {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  min-width: 0;
}

.imagePreviewItem img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #eef2f6;
}

.imagePreviewMeta {
  padding: 8px;
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.imagePreviewMeta strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.imagePreviewItem button {
  width: 100%;
  min-height: 32px;
  border: 0;
  border-top: 1px solid var(--line);
  background: #f8fafc;
  color: var(--bad);
  font-weight: 700;
  cursor: pointer;
}

.agentOutput {
  min-height: 120px;
  max-height: 280px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.45;
}

.resultItem {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.resultItem img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #eef2f6;
}

.resultMeta {
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.resultMeta a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.emptyState {
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
}

@media (max-width: 980px) {
  .appHeader,
  .pageTitle {
    align-items: stretch;
    flex-direction: column;
  }

  .viewNav,
  .filterBar {
    overflow-x: auto;
  }

  #creatorView.active,
  .splitLayout {
    grid-template-columns: 1fr;
  }

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

  .workspace {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .formGrid {
    grid-template-columns: 1fr;
  }

  .accessProof {
    grid-template-columns: 1fr;
  }

  .agentForm {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .metricGrid {
    grid-template-columns: 1fr;
  }

  .stageBoard {
    grid-template-columns: repeat(5, 220px);
  }
}
