:root {
  --ink: #1c2430;
  --muted: #5c6775;
  --paper: #f3efe6;
  --panel: #fff;
  --line: #e2dacb;
  --line-strong: #c9c0b2;
  --brand: #14202b;
  --gold: #d7a15a;
  --accent: #0f6e6e;
  --accent-soft: #eef6f6;
  --ok-bg: #e5f6ec;
  --ok: #0d6b3d;
  --no-bg: #fdecec;
  --no: #8d2a2a;
  --warn-bg: #fff4d8;
  --warn: #8a5a00;
  --unclear-bg: #eef1f4;
  --unclear: #3d4a5c;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 36% at 50% -8%, rgba(15, 110, 110, 0.1), transparent 58%),
    radial-gradient(ellipse 50% 28% at 100% 0%, rgba(215, 161, 90, 0.08), transparent 45%),
    var(--paper);
}

.brand {
  background: var(--brand);
  color: #f7f4ee;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-inner {
  max-width: 52rem;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.app-chrome {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.nav-link {
  background: transparent;
  color: #c9c0b2;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-link:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-link[aria-current="page"] {
  background: rgba(215, 161, 90, 0.95);
  color: var(--brand);
}

.user-menu {
  position: relative;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(255, 255, 255, 0.08);
  color: #f7f4ee;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0.28rem 0.55rem 0.28rem 0.28rem;
  font-weight: 600;
  max-width: 16rem;
}

.user-chip:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.user-avatar {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-chip-text {
  display: grid;
  min-width: 0;
  text-align: left;
  line-height: 1.15;
}

.user-name {
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 0.7rem;
  color: #c9c0b2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.user-caret {
  width: 0.4rem;
  height: 0.4rem;
  margin-right: 0.2rem;
  border-right: 1.5px solid #c9c0b2;
  border-bottom: 1.5px solid #c9c0b2;
  transform: rotate(45deg);
  flex-shrink: 0;
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  min-width: 14rem;
  padding: 0.45rem;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(20, 32, 43, 0.16);
  z-index: 30;
}

.user-menu-email {
  margin: 0;
  padding: 0.45rem 0.65rem 0.55rem;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
  border-bottom: 1px solid var(--line);
}

.user-menu-panel button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
  font-weight: 600;
  text-align: left;
}

.user-menu-panel button:hover:not(:disabled) {
  background: #f3efe6;
}

.mark {
  width: 2.05rem;
  height: 2.05rem;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: var(--brand);
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.brand-name,
.brand-for {
  margin: 0;
}

.brand-name {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.brand-for {
  color: #c9c0b2;
  font-size: 0.82rem;
}

main {
  max-width: 52rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4.5rem;
}

.page-intro {
  margin-bottom: 1.4rem;
}

.eyebrow {
  margin: 0 0 0.45rem;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 650;
}

.page-intro h1 {
  margin: 0 0 0.4rem;
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 34rem;
  font-size: 1.02rem;
}

.piece-label {
  margin: 0 0 0.55rem;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: inherit;
  opacity: 0.72;
  font-weight: 650;
}

h1, h2, h3 {
  font-family: Georgia, "Iowan Old Style", serif;
  font-weight: 500;
}

h1 {
  font-size: clamp(1.95rem, 4vw, 2.55rem);
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 0.35rem;
  font-size: 1.28rem;
}

h3 {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.2rem 1.25rem 1.35rem;
  margin-bottom: 0.95rem;
  box-shadow: 0 1px 0 rgba(28, 36, 48, 0.03);
}

.login-panel {
  max-width: 26rem;
}

.panel-head {
  margin-bottom: 1.05rem;
}

.panel-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.field-note {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 400;
}

label {
  display: block;
  margin-bottom: 0.95rem;
  font-size: 0.92rem;
  font-weight: 550;
}

input, select, button {
  font: inherit;
}

input[type="email"],
input[type="password"],
select {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
button:focus-visible,
.tab:focus-visible,
.drop:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 110, 110, 0.18);
}

.form-grid {
  display: grid;
  gap: 0.15rem;
  margin-bottom: 0.35rem;
}

.form-grid.two {
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.check {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  font-weight: 500;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfaf7;
}

.check input {
  margin-top: 0.15rem;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 0.72rem 1.1rem;
  cursor: pointer;
  font-weight: 650;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

button:hover:not(:disabled) {
  background: #0c5c5c;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  font-weight: 600;
}

button.ghost:hover:not(:disabled) {
  background: #f7f4ee;
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.35rem;
}

.actions button {
  min-width: 10rem;
}

.sheet {
  width: min(26rem, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(20, 32, 43, 0.22);
}

.sheet::backdrop {
  background: rgba(20, 32, 43, 0.42);
}

.sheet form {
  margin: 0;
  padding: 1.15rem 1.2rem 1.25rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.sheet-head h2 {
  margin: 0;
}

.icon-close {
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 1.25rem;
  line-height: 1;
}

.icon-close:hover:not(:disabled) {
  background: #f3efe6;
  color: var(--ink);
}

.users-panel {
  padding: 0;
  overflow: hidden;
}

.users-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.2rem 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
}

.users-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.users-header h2 {
  margin: 0 0 0.3rem;
}

.users-header .panel-help {
  max-width: 28rem;
}

.users-table {
  width: 100%;
}

.users-head,
.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 7.5rem minmax(14rem, 1.2fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1.25rem;
}

.users-head {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
}

.users-body {
  display: grid;
}

.user-row {
  border-bottom: 1px solid var(--line);
}

.user-row:last-child {
  border-bottom: 0;
}

.user-row-person {
  min-width: 0;
}

.user-row-email {
  margin: 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.user-row-you {
  margin: 0.15rem 0 0;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 650;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.5rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
}

.role-pill.admin {
  background: #e8f3f3;
  color: var(--accent);
}

.role-pill.staff {
  background: #f0ebe3;
  color: var(--muted);
}

.users-panel .error,
.users-panel .note,
.users-panel .empty-list {
  margin: 0;
  padding: 0.85rem 1.25rem 1.1rem;
}

.note {
  min-height: 1.2rem;
  color: var(--ok);
  margin: 0 0 0.7rem;
}

.error {
  min-height: 1.2rem;
  color: var(--no);
  margin: 0 0 0.7rem;
}

.error:empty,
.note:empty {
  display: none;
}

.status {
  color: var(--muted);
  margin: 0 0 1rem;
}

.drops {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 1.05rem;
}

.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 10rem;
  margin: 0;
  padding: 1rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  background: #fbfaf7;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  font-weight: 500;
}

.drop:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop.dragover,
.drop.filled {
  border-style: solid;
}

.drop.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop.filled {
  border-color: #b7d8d8;
  background: #fff;
}

.drop-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.req,
.opt {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
}

.req {
  background: #e8f3f3;
  color: var(--accent);
}

.opt {
  background: #f0ebe3;
  color: var(--muted);
}

.drop-hint {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.drop img {
  display: block;
  width: 100%;
  max-height: 8.5rem;
  margin-top: auto;
  padding-top: 0.75rem;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
}

.drop img[hidden] {
  display: none;
}

.progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--accent-soft);
}

.progress-spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2.5px solid #cfe3e3;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.progress-title {
  margin: 0;
  font-weight: 650;
}

.progress .panel-help {
  margin: 0.15rem 0 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.result {
  animation: rise 0.3s ease;
}

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

.result-panel {
  border-left: 4px solid var(--accent);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.result-header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  min-width: 0;
}

.result-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.eligibility-badge {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}

.eligibility-badge.yes {
  background: var(--ok-bg);
  color: var(--ok);
}

.eligibility-badge.no {
  background: var(--no-bg);
  color: var(--no);
}

.eligibility-badge.except {
  background: var(--warn-bg);
  color: var(--warn);
}

.eligibility-badge.unclear {
  background: var(--unclear-bg);
  color: var(--unclear);
}

.insurance-call-alert {
  margin: 0 0 1.15rem;
  padding: 1rem 1.05rem;
  border-radius: 12px;
  border-left: 4px solid #d7a15a;
  background: var(--warn-bg);
  color: var(--warn);
}

.insurance-call-alert h3 {
  margin: 0 0 0.45rem;
  font-size: 0.98rem;
  font-weight: 700;
}

.insurance-call-alert p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
}

.result-section + .result-section {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.result-section h3 {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
  gap: 0.75rem;
}

.result-item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
}

.result-item-wide {
  grid-column: 1 / -1;
  background: var(--accent-soft);
  border-color: #cfe3e3;
}

.result-item-label {
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-item-value {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 550;
  line-height: 1.4;
  word-break: break-word;
}

.result-item-value.muted {
  color: var(--muted);
  font-weight: 500;
}

.result-item-value.value-yes {
  color: var(--ok);
  font-weight: 700;
}

.result-item-value.value-no {
  color: var(--no);
  font-weight: 700;
}

.result-item-value.value-unclear {
  color: var(--warn);
  font-weight: 700;
}

.reasoning {
  margin: 0;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.account-actions .ghost {
  padding: 0.45rem 0.7rem;
  font-size: 0.86rem;
}

.account-actions .danger {
  color: var(--no);
  border-color: #e2b6b6;
}

.account-actions .danger:hover:not(:disabled) {
  background: var(--no-bg);
}

.account-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.empty-list {
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 780px) {
  .brand-inner {
    flex-wrap: wrap;
  }

  .app-chrome {
    width: 100%;
    justify-content: space-between;
  }

  .user-chip-text {
    display: none;
  }

  .users-head {
    display: none;
  }

  .user-row {
    grid-template-columns: 1fr;
    gap: 0.55rem;
    padding: 1rem 1.1rem;
  }

  .account-actions {
    justify-content: stretch;
  }

  .account-actions .ghost {
    flex: 1 1 auto;
  }
}

@media (max-width: 640px) {
  main {
    padding: 1.45rem 1rem 3.25rem;
  }

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

  .actions,
  .result-toolbar,
  .users-header {
    justify-content: stretch;
    flex-direction: column;
    align-items: stretch;
  }

  .actions button,
  .result-toolbar button,
  .users-header button {
    width: 100%;
  }

  .detail-list {
    grid-template-columns: 1fr;
    gap: 0.15rem 0;
  }

  .detail-list dt {
    margin-top: 0.55rem;
  }

  .detail-list dt:first-child {
    margin-top: 0;
  }
}
