:root {
  color-scheme: light;
  --aqua-0: #f4fffd;
  --aqua-1: #e7faf7;
  --aqua-2: #d4f2ee;
  --aqua-3: #b6e6df;
  --ink: #16313a;
  --muted: #698087;
  --glass: rgba(255,255,255,.80);
  --glass-strong: rgba(255,255,255,.93);
  --hairline: rgba(28,72,80,.10);
  --hairline-strong: rgba(28,72,80,.16);
  --teal: #0f8f83;
  --teal-dark: #0a736a;
  --coral: #ff6b4a;
  --coral-dark: #ec5738;
  --blue: #3276f5;
  --green: #21875b;
  --green-bg: #ecfaf3;
  --amber: #9a6813;
  --amber-bg: #fff8e9;
  --red: #c44848;
  --red-bg: #fff1f1;
  --shadow: 0 22px 55px rgba(37, 101, 104, .12);
  --shadow-soft: 0 10px 28px rgba(37, 101, 104, .085);
  --shadow-float: 0 14px 30px rgba(37, 101, 104, .13), 0 2px 8px rgba(37,101,104,.07);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(circle at 14% -6%, rgba(255,255,255,.95) 0 10%, transparent 31%),
    radial-gradient(circle at 91% 0%, rgba(105,214,202,.28), transparent 27%),
    linear-gradient(145deg, var(--aqua-0) 0%, var(--aqua-1) 42%, #def6f2 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,.26), rgba(255,255,255,0) 180px);
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.page-shell {
  position: relative;
  width: min(970px, calc(100% - 30px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.card {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,.92);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(25px) saturate(150%);
  -webkit-backdrop-filter: blur(25px) saturate(150%);
}

.login-card {
  width: min(410px, 100%);
  margin: 10vh auto 0;
  padding: 34px;
  box-shadow: var(--shadow);
}

.brand-mark, .app-icon, .section-badge {
  color: white;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #26b9a9, #0b857a);
  box-shadow: 0 10px 22px rgba(15,143,131,.24), inset 0 1px 0 rgba(255,255,255,.26);
}

.brand-mark {
  width: 50px;
  height: 50px;
  border-radius: 15px;
  margin-bottom: 22px;
}
.brand-mark svg { width: 27px; height: 27px; stroke-width: 1.7; }

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 4px;
  font-size: clamp(1.9rem, 4vw, 2.4rem);
  letter-spacing: -.045em;
  line-height: 1.04;
  font-weight: 725;
}
h2 {
  margin-bottom: 3px;
  font-size: 1.1rem;
  letter-spacing: -.018em;
  font-weight: 690;
}
h3 {
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 680;
}

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

.eyebrow {
  font-size: .67rem;
  font-weight: 720;
  letter-spacing: .105em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 4px;
}

.optional { color: var(--muted); font-weight: 450; }

.stack { display: grid; gap: 14px; margin-top: 24px; }

label {
  display: grid;
  gap: 6px;
  font-size: .83rem;
  font-weight: 640;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: rgba(255,255,255,.91);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  box-shadow: inset 0 1px 1px rgba(30,77,83,.02), 0 1px 1px rgba(255,255,255,.5);
  transition: border-color .14s ease, box-shadow .14s ease, transform .1s ease;
}

input::placeholder, textarea::placeholder { color: #9aacb0; }

input:focus, select:focus, textarea:focus {
  border-color: rgba(15,143,131,.45);
  box-shadow: 0 0 0 4px rgba(15,143,131,.10), 0 5px 14px rgba(15,143,131,.06);
  background: #fff;
}

textarea { resize: vertical; }

.primary, .secondary, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 11px;
  border: 1px solid transparent;
  padding: 9px 13px;
  font-weight: 670;
  transition: transform .1s ease, box-shadow .14s ease, background .14s ease;
}

.primary:active, .secondary:active, .ghost:active, .danger:active { transform: scale(.975); }

.primary {
  background: linear-gradient(180deg, #ff7658, var(--coral));
  color: white;
  box-shadow: 0 7px 18px rgba(255,107,74,.24), inset 0 1px 0 rgba(255,255,255,.22);
}
.primary:hover {
  background: linear-gradient(180deg, #ff6d4d, var(--coral-dark));
  box-shadow: 0 9px 22px rgba(255,107,74,.29);
}
.primary:disabled { opacity: .48; cursor: not-allowed; }

.secondary {
  background: rgba(15,143,131,.09);
  color: var(--teal-dark);
  border-color: rgba(15,143,131,.09);
}
.secondary:hover { background: rgba(15,143,131,.14); }

.ghost {
  background: rgba(255,255,255,.72);
  color: var(--ink);
  border-color: var(--hairline);
  box-shadow: 0 4px 10px rgba(30,76,81,.04);
}
.ghost:hover { background: #fff; box-shadow: 0 7px 16px rgba(30,76,81,.07); }

.small { padding: 7px 10px; font-size: .81rem; }
.button-icon { width: 16px; height: 16px; flex: 0 0 auto; }

.error-text { color: var(--red); font-weight: 630; margin: 0; }

/* Header */
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 13px;
  padding: 14px 16px;
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(255,255,255,.95);
  border-radius: 20px;
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
}

.app-icon {
  width: 39px;
  height: 39px;
  border-radius: 12px;
}
.app-icon svg { width: 22px; height: 22px; }
.topbar h1 { font-size: 1.62rem; margin-bottom: 0; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.signed-in {
  font-size: .79rem;
  color: var(--teal-dark);
  font-weight: 620;
  background: rgba(15,143,131,.08);
  border: 1px solid rgba(15,143,131,.08);
  border-radius: 999px;
  padding: 6px 9px;
}

/* Upload glass sheet */
.upload-card {
  padding: 16px;
  margin-bottom: 13px;
  display: grid;
  grid-template-columns: minmax(220px, .72fr) minmax(0, 1.28fr);
  grid-template-areas:
    "head head"
    "drop fields"
    "drop note"
    "file actions";
  gap: 10px 14px;
  align-items: start;
  box-shadow: var(--shadow);
}

.upload-card .section-heading { grid-area: head; }
.upload-card .drop-zone { grid-area: drop; }
.upload-card .chosen-file { grid-area: file; }
.upload-card .form-grid { grid-area: fields; }
.upload-card > label { grid-area: note; }
.upload-card .button-row { grid-area: actions; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-badge {
  width: 34px;
  height: 34px;
  border-radius: 11px;
}
.section-badge svg { width: 19px; height: 19px; }

.drop-zone {
  border: 1px dashed rgba(15,143,131,.30);
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.84), transparent 55%),
    rgba(239,253,250,.83);
  min-height: 126px;
  height: 100%;
  border-radius: 17px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  text-align: center;
  color: var(--muted);
  margin: 0;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.drop-zone strong { color: var(--ink); font-size: .91rem; font-weight: 680; }
.drop-zone span { font-size: .76rem; }
.drop-zone:hover, .drop-zone.dragging {
  transform: translateY(-1px);
  border-color: var(--teal);
  box-shadow: 0 10px 22px rgba(15,143,131,.09), inset 0 1px 0 rgba(255,255,255,.8);
}

.drop-icon {
  width: 35px;
  height: 35px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: white;
  color: var(--teal);
  box-shadow: 0 7px 18px rgba(31,111,108,.11);
  margin-bottom: 3px;
}
.drop-icon svg { width: 20px; height: 20px; }

.chosen-file {
  padding: 8px 10px;
  background: rgba(15,143,131,.075);
  border-radius: 10px;
  font-size: .78rem;
  color: var(--teal-dark);
  font-weight: 620;
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1.5fr .7fr;
  gap: 10px;
  margin: 0;
}
.button-row { margin: 0; display: flex; justify-content: flex-end; align-self: end; }

/* Floating segmented control */
.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 13px;
  padding: 6px;
  background: rgba(255,255,255,.52);
  border: 1px solid rgba(255,255,255,.88);
  border-radius: 17px;
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255,255,255,.72);
  backdrop-filter: blur(18px);
}

.status-card {
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 9px 11px;
  min-height: 51px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  box-shadow: none;
  transition: background .13s ease, box-shadow .13s ease, transform .12s ease;
}
.status-card:hover { background: rgba(255,255,255,.55); transform: translateY(-1px); }
.status-card.active {
  background: rgba(255,255,255,.97);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(38,100,103,.11), 0 1px 3px rgba(38,100,103,.07);
}

.status-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .79rem;
  font-weight: 650;
  line-height: 1.15;
}
.status-icon { width: 18px; height: 18px; color: var(--teal); stroke-width: 1.7; }

.status-card.yes .status-icon,
.status-card.yes .count { color: var(--green); }
.status-card.maybe .status-icon,
.status-card.maybe .count { color: var(--amber); }
.status-card.no .status-icon,
.status-card.no .count { color: var(--red); }

.count {
  font-size: .89rem;
  line-height: 1;
  font-weight: 740;
  background: rgba(27,81,85,.065);
  border-radius: 999px;
  min-width: 25px;
  padding: 5px 7px;
  text-align: center;
}

/* List */
.list-card {
  padding: 16px;
  box-shadow: var(--shadow);
}

.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 12px;
}

.search {
  width: min(275px, 100%);
  background: rgba(255,255,255,.73);
  border-color: rgba(28,72,80,.07);
}

.yes-notice {
  background: linear-gradient(135deg, rgba(236,250,243,.96), rgba(242,255,249,.9));
  border: 1px solid rgba(33,135,91,.12);
  color: #236d4b;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 11px;
  font-size: .81rem;
  font-weight: 590;
  line-height: 1.42;
}

.referral-list { display: grid; gap: 8px; }

.referral-row {
  border: 1px solid rgba(28,72,80,.08);
  border-radius: 14px;
  padding: 11px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: rgba(255,255,255,.77);
  box-shadow: 0 4px 12px rgba(31,87,90,.035);
  transition: background .12s ease, border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.referral-row:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,.98);
  border-color: rgba(15,143,131,.14);
  box-shadow: 0 10px 22px rgba(31,87,90,.07);
}

.referral-name { font-size: .92rem; font-weight: 700; margin-bottom: 3px; letter-spacing: -.01em; }
.referral-meta { color: var(--muted); font-size: .75rem; }
.referral-preview-note { color: #62787e; font-size: .8rem; margin-top: 6px; white-space: pre-wrap; }

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

.danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(196,72,72,.12);
  color: var(--red);
  background: var(--red-bg);
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 650;
  font-size: .79rem;
}

.linkish {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  padding: 3px 0 0;
  color: var(--teal);
  font-weight: 620;
  font-size: .74rem;
  text-decoration: none;
}
.linkish:hover { text-decoration: underline; }

.empty-state { text-align: center; padding: 34px 16px; color: var(--muted); }

/* PDF viewer - preserved sizing/function, polished */
.viewer-dialog {
  width: calc(100vw - 24px);
  max-width: 1400px;
  height: calc(100vh - 24px);
  max-height: none;
  border: 0;
  padding: 0;
  border-radius: 23px;
  overflow: hidden;
  box-shadow: 0 32px 95px rgba(13,61,64,.30);
}
.viewer-dialog::backdrop {
  background: rgba(17,54,58,.34);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.viewer-shell {
  height: 100%;
  overflow: auto;
  background: linear-gradient(145deg, #eaf9f6, #def3ef);
  padding: 12px;
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  background: rgba(255,255,255,.90);
  border: 1px solid rgba(255,255,255,.96);
  padding: 13px 15px;
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
}

.decision-panel {
  background: rgba(255,255,255,.90);
  border: 1px solid rgba(255,255,255,.96);
  border-radius: 16px;
  padding: 11px 14px;
  margin: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-soft);
}
.decision-question { font-size: .97rem; font-weight: 700; letter-spacing: -.01em; }
.decision-buttons { display: flex; gap: 7px; }
.decision {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 8px 16px;
  font-weight: 720;
  font-size: .81rem;
}
.decision.yes { background: var(--green-bg); color: var(--green); border-color: rgba(33,135,91,.10); }
.decision.maybe { background: var(--amber-bg); color: var(--amber); border-color: rgba(154,104,19,.11); }
.decision.no { background: var(--red-bg); color: var(--red); border-color: rgba(196,72,72,.10); }

.pdf-wrap {
  position: relative;
  min-height: 70vh;
  background: #31484e;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: 0 14px 32px rgba(24,70,74,.16);
}
#pdfFrame {
  width: 100%;
  height: 76vh;
  min-height: 680px;
  border: 0;
  display: block;
  background: white;
}
.pdf-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: #31484e;
  color: white;
  font-weight: 650;
}
.pdf-loading[hidden] { display: none !important; }

.notes-panel {
  background: rgba(255,255,255,.90);
  border: 1px solid rgba(255,255,255,.96);
  border-radius: 16px;
  padding: 14px 15px;
  box-shadow: var(--shadow-soft);
}
.notes-list { display: grid; gap: 8px; margin-bottom: 12px; }
.note {
  background: rgba(231,250,247,.70);
  border: 1px solid rgba(15,143,131,.07);
  border-radius: 12px;
  padding: 10px 11px;
}
.note-head { font-size: .73rem; color: var(--muted); font-weight: 620; margin-bottom: 4px; }
.note-body { white-space: pre-wrap; line-height: 1.42; font-size: .85rem; }
.add-note-box { border-top: 1px solid var(--hairline); padding-top: 12px; display: grid; gap: 10px; }

.toast {
  position: fixed;
  z-index: 9999;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  background: rgba(19,57,61,.92);
  backdrop-filter: blur(18px);
  color: white;
  border-radius: 12px;
  padding: 10px 13px;
  font-weight: 630;
  font-size: .81rem;
  transition: .18s ease;
  box-shadow: 0 14px 36px rgba(16,63,67,.22);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 14px, 970px); padding-top: 10px; }

  .topbar,
  .list-toolbar,
  .decision-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions { justify-content: space-between; }

  .upload-card { display: block; }
  .upload-card .drop-zone { min-height: 100px; margin: 12px 0 10px; }
  .upload-card .form-grid { margin-bottom: 10px; }
  .upload-card > label { margin-bottom: 10px; }

  .form-grid, .status-grid { grid-template-columns: 1fr 1fr; }

  .status-grid { background: rgba(255,255,255,.45); }
  .status-card { min-height: 54px; }

  .referral-row { grid-template-columns: 1fr; }
  .row-actions { justify-content: flex-start; }
  .search { width: 100%; }

  .decision-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .viewer-shell { padding: 8px; }
  .viewer-dialog {
    width: calc(100vw - 8px);
    height: calc(100vh - 8px);
    border-radius: 14px;
  }

  #pdfFrame { height: 72vh; min-height: 520px; }
}

@media (max-width: 480px) {
  .form-grid, .status-grid { grid-template-columns: 1fr; }
}


/* v7 email notification state */
.decision:disabled {
  opacity: .5;
  cursor: wait;
  transform: none !important;
}
