:root {
  --bg: #eef2f0;
  --ink: #17231f;
  --muted: #5d6b66;
  --card: #ffffff;
  --line: #d5ddd8;
  --accent: #0b6b52;
  --accent-soft: #e6f5ef;
  --warn: #9a5b00;
  --warn-soft: #fff3df;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #3730a3;
  --info-soft: #eef0ff;
  --shadow: 0 10px 30px rgba(23, 35, 31, 0.06);
  --radius: 16px;
  --font: "Manrope", sans-serif;
  --serif: "Source Serif 4", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 0% 0%, rgba(11, 107, 82, 0.08), transparent 42%),
    linear-gradient(180deg, #f5f7f6 0%, var(--bg) 100%);
}

.hidden { display: none !important; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 6px;
}
h1, h2, h3 { font-family: var(--serif); margin: 0 0 10px; letter-spacing: -0.02em; }
.lede, .lede-sm { color: var(--muted); line-height: 1.55; }
.lede { margin-bottom: 20px; }
.lede-sm { margin: 0 0 18px; font-size: 14px; }
.meta { color: var(--muted); font-size: 13px; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  padding: 36px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

label, .compact-label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}
input, select, button { font: inherit; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
}
button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
button.ghost, .tab {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.small { padding: 7px 12px; font-size: 12px; }
button:disabled { opacity: 0.55; cursor: wait; }
.error { color: var(--danger); font-size: 14px; }

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: grid; gap: 4px; }
.ai-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 2px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

main { padding: 20px; max-width: 1280px; margin: 0 auto; }
.panel {
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-flush { padding: 0; overflow: hidden; }
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: start;
  margin-bottom: 8px;
}
.ai-card {
  min-width: min(320px, 100%);
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fffc, #fff);
}
.ai-card strong { display: block; font-size: 14px; margin-bottom: 4px; }
.ai-card code {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  background: #f1f5f3;
  padding: 8px 10px;
  border-radius: 8px;
  word-break: break-all;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.card {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fbfcfb;
}
.card strong { display: block; font-size: 26px; margin-top: 4px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  margin: 0;
}
.result-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f7faf8;
  min-height: 64px;
  font-size: 14px;
  line-height: 1.5;
}
.result-box.ok { border-color: #9fd0bc; background: var(--accent-soft); }
.result-box.err { border-color: #f0b4ae; background: var(--danger-soft); }

/* Bank master-detail */
.bank-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  min-height: 72vh;
}
.bank-sidebar {
  border-right: 1px solid var(--line);
  padding: 16px;
  background: #f9fbfa;
  display: flex;
  flex-direction: column;
  min-height: 72vh;
}
.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.sidebar-head h2 { margin: 0; font-size: 22px; }
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}
.chip.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.bank-count { margin: 0 0 8px; }
.bank-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
  flex: 1;
}
.item-card {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  display: grid;
  gap: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.item-card:hover { border-color: #9fc9b8; }
.item-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(11, 107, 82, 0.12);
}
.item-card .title-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}
.item-card .preview {
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.badge.soft { background: var(--warn-soft); color: var(--warn); }
.badge.exported { background: var(--info-soft); color: var(--info); }
.badge.rejected { background: var(--danger-soft); color: var(--danger); }
.badge.retired { background: #eceff1; color: #455a64; }

.detail-pane {
  padding: 20px 22px;
  overflow: auto;
  background: #fff;
}
.empty-detail {
  max-width: 420px;
  margin: 12vh auto 0;
  text-align: center;
  color: var(--muted);
}
.empty-detail h3 { color: var(--ink); }

.detail-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: start;
  margin-bottom: 14px;
}
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f1f5f3;
  font-size: 12px;
  font-weight: 700;
}
.section-label {
  margin: 18px 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 800;
}
.stem {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f4faf7;
  line-height: 1.55;
}
.stem p { margin: 0 0 10px; }
.stem p:last-child { margin-bottom: 0; }
.choices { display: grid; gap: 10px; }
.choice {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  align-items: start;
}
.choice .rank {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}
.choice.best {
  border-color: #8fcdb6;
  background: #f1faf6;
}
.choice.best .rank { color: var(--accent); }
.justification {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fafafa;
  border: 1px solid var(--line);
  line-height: 1.55;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.85), #fff 40%);
  padding-bottom: 4px;
}
.actions button.reject { background: var(--danger); }
.actions button.soft { background: var(--warn); }

@media (max-width: 920px) {
  .bank-layout { grid-template-columns: 1fr; }
  .bank-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    min-height: auto;
    max-height: 42vh;
  }
  .topbar { align-items: flex-start; flex-direction: column; }
}
