:root {
  --green: #268b6b;
  --green-d: #1c6b52;
  --green-soft: #e8f5f0;
  --slate: #495566;
  --slate-l: #5a6678;
  --ink: #1f2733;
  --muted: #6b7684;
  --line: #e2e7ee;
  --bg: #eef2f6;
  --card: #ffffff;
  --amber: #b7791f;
  --amber-bg: #fdf6e7;
  --amber-line: #f0e0b8;
  --red: #b42318;
  --red-bg: #fef3f2;
  --blue: #2f5f8f;
  --blue-bg: #eef4fb;
  --shadow: 0 10px 30px rgba(31, 39, 51, 0.08);
  --radius: 14px;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(ellipse 120% 80% at 0% 0%, rgba(38, 139, 107, 0.12), transparent 50%),
    radial-gradient(ellipse 90% 60% at 100% 0%, rgba(73, 85, 102, 0.10), transparent 45%),
    linear-gradient(180deg, #f7f9fb 0%, var(--bg) 40%, #e8edf3 100%);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green-d); }

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

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 600;
}

/* Auth */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth-shell {
  width: min(440px, 100%);
  animation: rise 0.45s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.auth-brand {
  text-align: center;
  margin-bottom: 22px;
}

.auth-logo {
  height: 72px;
  width: auto;
  display: block;
  margin: 0 auto 18px;
}

.auth-brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.65rem;
  color: var(--slate);
  font-weight: 700;
}

.auth-brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.auth-foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 18px 0 0;
}

.auth-demo-hint {
  margin: 4px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.auth-demo-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  color: var(--slate);
}

.fld {
  display: grid;
  gap: 6px;
}

.fld.is-hidden,
.fld[hidden] {
  display: none !important;
}

.fld span {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.fld input,
.fld select,
.fld textarea,
.inline-input {
  width: 100%;
  border: 1px solid #cdd5e0;
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

.fld input:focus,
.fld select:focus,
.fld textarea:focus,
.inline-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(38, 139, 107, 0.18);
}

.fld textarea { min-height: 88px; resize: vertical; }

.form-error {
  margin: 0;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid #f3c4c0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--green);
  color: #fff;
}

.btn.primary:hover:not(:disabled) { background: var(--green-d); }

.btn.ghost {
  background: #fff;
  color: var(--slate);
  border-color: #cdd5e0;
}

.btn.ghost:hover:not(:disabled) { border-color: var(--slate-l); }

.btn.danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: #f3c4c0;
}

.btn.warn {
  background: #fdf6e7;
  color: #9a6b12;
  border-color: #f0e0b8;
}

.btn.warn:hover:not(:disabled) {
  background: #f8edcf;
  border-color: #e5d09a;
  color: #7a5a12;
}

.btn.sm { padding: 7px 12px; font-size: 0.88rem; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* App chrome */
.topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-lockup img {
  height: 48px;
  width: auto;
}

.brand-copy {
  min-width: 0;
}

.brand-copy .org {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--slate);
  line-height: 1.2;
}

.brand-copy .app-name {
  color: var(--green-d);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-meta {
  text-align: right;
  font-size: 0.88rem;
}

.user-meta strong { display: block; color: var(--ink); }
.user-meta span { color: var(--muted); }

.account-menu {
  position: relative;
}

.account-menu > summary {
  list-style: none;
  cursor: pointer;
}

.account-menu > summary::-webkit-details-marker {
  display: none;
}

.account-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--slate);
}

.account-menu-toggle:hover {
  border-color: color-mix(in srgb, var(--green) 40%, var(--line));
}

.account-menu-caret {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
}

.account-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: grid;
  gap: 2px;
  z-index: 30;
}

.account-menu-item {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}

.account-menu-item:hover {
  background: var(--green-soft);
  color: var(--green-d);
}

.account-menu-item.danger {
  color: var(--red);
}

.account-menu-item.danger:hover {
  background: var(--red-bg);
  color: var(--red);
}

.user-form {
  display: grid;
  gap: 14px;
}

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

.form-success {
  margin: 0;
  color: var(--green-d);
  font-weight: 600;
}

@media (max-width: 720px) {
  .user-form-grid {
    grid-template-columns: 1fr;
  }
}

main.page {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 48px;
  animation: rise 0.35s ease-out;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.7rem;
  color: var(--slate);
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.chip {
  border: 1px solid #cdd5e0;
  background: #fff;
  color: var(--slate-l);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.chip.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.packet-grid {
  display: grid;
  gap: 12px;
}

.packet-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(20, 30, 50, 0.03);
  cursor: pointer;
  transition: 0.18s ease;
  display: grid;
  gap: 10px;
}

.packet-card:hover {
  border-color: rgba(38, 139, 107, 0.45);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

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

.packet-card h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--ink);
}

.packet-card .meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.progress-bar {
  height: 8px;
  background: #e7ecf2;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: rgb(38, 139, 107);
  border-radius: inherit;
  transition: width 0.35s ease, background-color 0.35s ease;
}

.detail-progress {
  margin-top: 14px;
}

.list-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px 12px;
  margin: 0 0 16px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.list-controls .ctl {
  display: grid;
  gap: 5px;
}

.list-controls .ctl > span {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.list-controls input,
.list-controls select {
  width: 100%;
  border: 1px solid #cdd5e0;
  border-radius: 10px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  grid-template-columns: none !important;
}

.checkbox-row input {
  width: auto;
}

.checkbox-row span {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

.progress-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status.in_progress { background: var(--blue-bg); color: var(--blue); }
.status.ready_for_review { background: var(--green-soft); color: var(--green-d); }
.status.query_pending { background: var(--amber-bg); color: var(--amber); }
.status.approved { background: #e8f8ef; color: #1b7f5a; }
.status.denied { background: var(--red-bg); color: var(--red); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
  background: rgba(255,255,255,0.65);
  border: 1px dashed #cdd5e0;
  border-radius: var(--radius);
}

/* Detail */
.detail-back {
  margin-bottom: 12px;
}

.detail-hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.detail-hero h2 {
  margin: 8px 0 4px;
  font-family: var(--display);
  font-size: 1.8rem;
  color: var(--slate);
}

.detail-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 16px;
}

.detail-title-row h2 {
  margin: 8px 0 4px;
}

.activity-link {
  border: 0;
  background: transparent;
  color: var(--green-d);
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0;
}

.activity-link:hover {
  color: var(--green);
}

.detail-hero .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  background: #f1f4f8;
  color: var(--slate);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.8rem;
  font-weight: 700;
}

.detail-hero .pill.provider-role {
  font-size: 0.95rem;
  padding: 6px 13px;
}

.section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.section-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.section-h.slate { background: var(--slate); }
.section-h.amber { background: var(--amber); }
.section-h.danger { background: var(--red); }

.section-b { padding: 16px 18px; }

.danger-zone {
  margin-top: 28px;
}

.danger-zone-copy {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.query-list {
  display: grid;
  gap: 14px;
}

.query-card {
  border: 1px solid #d7dee8;
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.query-card.open {
  border-color: var(--amber-line);
  background: linear-gradient(180deg, #fffdf8, #fff);
}

.query-card.resolved {
  background: #fbfcfd;
}

.query-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.query-card-head > div {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.query-card-head time {
  color: var(--muted);
  font-size: 0.82rem;
}

.query-response-form {
  display: grid;
  gap: 10px;
}

.concern-box p,
.resolution-box p {
  margin: 6px 0 0;
  white-space: pre-wrap;
}

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

.check-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  align-items: start;
  border: 1px solid #d7dee8;
  border-radius: 10px;
  padding: 12px 14px;
}

.check-row .label { font-weight: 700; font-size: 0.95rem; }
.check-row .notes {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
}

.notes-form {
  display: grid;
  gap: 12px;
}

.notes-readonly,
.notes-empty {
  margin: 0;
  color: var(--muted);
  white-space: pre-wrap;
}

.notes-empty {
  font-style: italic;
}

.notes-form textarea {
  min-height: 52px;
}

.item-status {
  display: inline-flex;
  gap: 6px;
}

.item-status button {
  border: 1px solid #cdd5e0;
  background: #fff;
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

.item-status button.on-complete {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.item-status button.on-na {
  background: var(--slate);
  border-color: var(--slate);
  color: #fff;
}

.item-status button.on-pending {
  background: var(--amber-bg);
  border-color: var(--amber-line);
  color: var(--amber);
}

.vote-grid {
  display: grid;
  gap: 12px;
}

.vote-card {
  border: 1px solid #d7dee8;
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.vote-card.mine {
  border-color: rgba(38, 139, 107, 0.5);
  background: linear-gradient(180deg, #f7fcfa, #fff);
}

.vote-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.vote-head strong { font-size: 1rem; }

.vote-choice {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
}

.vote-choice.yes { background: var(--green-soft); color: var(--green-d); }
.vote-choice.no { background: var(--red-bg); color: var(--red); }
.vote-choice.pause_for_query { background: var(--amber-bg); color: var(--amber); }
.vote-choice.none { background: #f1f4f8; color: var(--muted); }

.concern-box,
.resolution-box {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.concern-box {
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  color: #7a5a12;
}

.resolution-box {
  background: var(--blue-bg);
  border: 1px solid #d5e3f3;
  color: var(--blue);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 39, 51, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
  animation: fade 0.2s ease;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.modal h3 {
  margin: 0;
  font-family: var(--display);
  color: var(--slate);
}

.modal-wide {
  width: min(640px, 100%);
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.activity-timeline {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  gap: 0;
  border-left: 2px solid var(--line);
}

.activity-item {
  position: relative;
  padding: 0 0 18px 18px;
}

.activity-item::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
}

.activity-item.type-query_opened::before,
.activity-item.type-status_changed::before { background: var(--amber); }
.activity-item.type-query_resolved::before,
.activity-item.type-marked_ready::before { background: var(--blue); }
.activity-item.type-vote_cast::before { background: var(--slate); }

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 4px;
}

.activity-type {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--green-d);
  background: var(--green-soft);
  border-radius: 999px;
  padding: 2px 8px;
}

.activity-meta time {
  color: var(--muted);
  font-size: 0.82rem;
}

.activity-summary {
  font-weight: 700;
  color: var(--ink);
}

.activity-actor {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.activity-detail {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f6f8fb;
  border: 1px solid var(--line);
  color: var(--slate);
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.banner {
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.92rem;
}

.banner.warn {
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  color: #7a5a12;
}

.banner.info {
  background: var(--green-soft);
  border: 1px solid #bfe3d5;
  color: var(--green-d);
}

@media (max-width: 720px) {
  .topbar-inner { width: calc(100% - 24px); }
  main.page { width: calc(100% - 24px); }
  .brand-lockup img { height: 40px; }
  .brand-copy .org { font-size: 0.95rem; }
  .check-row { grid-template-columns: 1fr; }
  .auth-logo { height: 60px; }
}
