:root {
  --paper: #f8f4ec;
  --paper-2: #efe7d9;
  --white: #fffdf8;
  --ink: #1c1f1d;
  --muted: #6d706a;
  --line: rgba(28, 31, 29, 0.12);
  --red: #e51c2a;
  --red-deep: #b61320;
  --green: #23745a;
  --green-soft: #e0efe5;
  --gold: #b77a26;
  --gold-soft: #f2e2c6;
  --blue: #315d83;
  --shadow: 0 20px 56px rgba(67, 48, 35, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(229, 28, 42, 0.08), transparent 34%),
    linear-gradient(235deg, rgba(35, 116, 90, 0.1), transparent 30%),
    var(--paper);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 24px 18px;
  background: rgba(255, 253, 248, 0.9);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 13px;
  align-items: center;
}

.brand img {
  width: 62px;
  height: 62px;
  object-fit: contain;
  background: #fff;
  border: 1px solid rgba(229, 28, 42, 0.2);
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(229, 28, 42, 0.12);
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.brand span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  color: var(--ink);
  background: var(--paper-2);
  border-color: var(--line);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  color: var(--red);
  background: rgba(229, 28, 42, 0.08);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.side-card {
  margin-top: auto;
  padding: 18px;
  color: var(--white);
  background: linear-gradient(145deg, var(--red-deep), var(--ink));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.side-card .label {
  color: rgba(255, 253, 248, 0.72);
}

.side-card strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
  line-height: 1;
}

.side-card p {
  margin: 12px 0 0;
  color: rgba(255, 253, 248, 0.76);
  line-height: 1.6;
  font-size: 13px;
}

.workspace {
  position: relative;
  min-width: 0;
  padding: 28px 86px 28px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p,
strong {
  overflow-wrap: anywhere;
}

h1 {
  margin: 5px 0 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin: 5px 0 0;
  font-size: 21px;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 17px;
}

.top-actions,
.filter-row,
.job-tools,
.segmented,
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.profile-button,
.chip,
.segmented button {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  color: var(--white);
  background: var(--red);
  border-color: rgba(229, 28, 42, 0.18);
  box-shadow: 0 10px 24px rgba(229, 28, 42, 0.18);
}

.secondary-button {
  padding: 0 13px;
  color: var(--ink);
  background: var(--white);
}

.ghost-button {
  padding: 0 13px;
  color: var(--muted);
  background: transparent;
}

.icon-button {
  width: 40px;
  color: var(--ink);
  background: var(--white);
}

.profile-button {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 20;
  padding: 0 16px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 10px 28px rgba(67, 48, 35, 0.12);
}

.profile-popover {
  position: fixed;
  top: 68px;
  right: 22px;
  z-index: 21;
  width: min(330px, calc(100vw - 32px));
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.profile-head {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 11px;
  align-items: center;
  margin-bottom: 12px;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: var(--white);
  background: var(--red);
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 900;
}

.profile-info {
  display: grid;
  gap: 8px;
}

.profile-info div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: var(--paper);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.profile-info strong {
  color: var(--ink);
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.profile-button:hover,
.chip:hover,
.segmented button:hover {
  transform: translateY(-1px);
}

.wide {
  width: 100%;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metrics article,
.panel {
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(67, 48, 35, 0.08);
}

.metrics article {
  min-height: 108px;
  padding: 16px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 9px;
  font-size: 31px;
  line-height: 1;
}

.metrics em {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.4;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.role-panel {
  display: none;
}

.role-panel.is-visible {
  display: block;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-head,
.column-title,
.board-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  color: var(--blue);
  background: rgba(49, 93, 131, 0.1);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.green {
  color: var(--green);
  background: var(--green-soft);
}

.status-pill.amber {
  color: var(--gold);
  background: var(--gold-soft);
}

.status-pill.red {
  color: var(--red);
  background: rgba(229, 28, 42, 0.1);
}

.ai-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.76fr) minmax(360px, 1.08fr) minmax(330px, 0.92fr);
  gap: 14px;
  align-items: start;
}

.query-column,
.match-column,
.message-column {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.actor-card,
.fund-board,
.empty-state,
.message-card,
.contact-card,
.job-card,
.my-job-card,
.case-card,
.create-job {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.actor-card,
.fund-board,
.empty-state,
.message-card,
.contact-card,
.job-card,
.my-job-card,
.case-card {
  padding: 14px;
}

.actor-card strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.actor-card p,
.empty-state p,
.message-card p,
.contact-card p,
.job-card p,
.my-job-card p,
.case-card p,
.job-tools p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.search-box {
  display: grid;
  gap: 8px;
}

input,
textarea,
select {
  width: 100%;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(229, 28, 42, 0.45);
  box-shadow: 0 0 0 3px rgba(229, 28, 42, 0.1);
}

.chip {
  padding: 0 11px;
  color: var(--muted);
  background: transparent;
}

.chip.is-active {
  color: var(--red-deep);
  background: rgba(229, 28, 42, 0.09);
}

.rank-list,
.match-list,
.message-stack,
.job-list,
.my-job-list,
.case-list,
.activity-list {
  display: grid;
  gap: 10px;
}

.rank-list.large {
  gap: 12px;
}

.rank-list.large .rank-item {
  min-height: 72px;
  grid-template-columns: 36px 1fr auto;
  padding: 14px;
}

.rank-list.large .rank-item b {
  width: 36px;
  height: 36px;
}

.rank-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--paper);
  border-radius: 7px;
}

.rank-item b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--white);
  background: var(--red);
  border-radius: 6px;
  font-size: 12px;
}

.rank-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.rank-item strong:last-child {
  color: var(--gold);
}

.match-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.match-card strong {
  display: block;
  font-size: 17px;
}

.match-card p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.score {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: var(--red-deep);
  background: rgba(229, 28, 42, 0.08);
  border-radius: 50%;
  font-weight: 900;
}

.match-card footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.match-tags,
.badge-list,
.job-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.match-tags span,
.badge-list span,
.job-meta span {
  padding: 5px 8px;
  color: var(--muted);
  background: var(--paper);
  border-radius: 6px;
  font-size: 12px;
}

.message-card {
  border-left: 4px solid var(--gold);
}

.message-card header,
.job-card header,
.my-job-card header,
.case-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.message-card .card-actions {
  margin-top: 12px;
}

.contact-card {
  border-color: rgba(35, 116, 90, 0.25);
  background: linear-gradient(180deg, rgba(35, 116, 90, 0.08), var(--white) 42%);
}

.contact-head {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.contact-logo {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  color: var(--white);
  background: var(--green);
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 900;
}

.contact-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.contact-title-row h3 {
  margin: 0;
}

.member-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  color: var(--green);
  background: rgba(35, 116, 90, 0.12);
  border: 1px solid rgba(35, 116, 90, 0.2);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.contact-info {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.contact-info div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: var(--paper);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}

.contact-info strong {
  color: var(--ink);
}

.achievement {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  background: var(--gold-soft);
  border-radius: var(--radius);
}

.achievement span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.achievement p {
  margin: 6px 0 0;
}

.jobs-layout,
.oversight-grid,
.charity-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.segmented {
  padding: 3px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.segmented button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.segmented button.is-active {
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 4px 14px rgba(67, 48, 35, 0.08);
}

.job-tools {
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--paper);
  border-radius: var(--radius);
}

.job-tools p {
  margin: 0;
}

.create-job {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.full-field {
  margin-top: 12px;
}

.job-card,
.my-job-card,
.case-card,
.activity-card {
  display: grid;
  gap: 11px;
}

.activity-card {
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
}

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

.activity-card p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.job-card.is-signed {
  border-color: rgba(35, 116, 90, 0.25);
}

.my-job-card {
  border-left: 4px solid var(--green);
}

.case-card {
  border-left: 4px solid var(--red);
}

@media (max-width: 1220px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(0, 1.1fr);
    align-items: center;
    padding: 14px;
  }

  .side-card {
    display: none;
  }

  .nav-list {
    display: flex;
    justify-content: flex-end;
    overflow-x: auto;
  }

  .nav-item {
    white-space: nowrap;
  }

  .ai-layout,
  .jobs-layout,
  .oversight-grid,
  .charity-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 76px 16px 16px;
  }

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

  .brand {
    grid-template-columns: 52px 1fr;
  }

  .brand img {
    width: 52px;
    height: 52px;
  }

  .topbar,
  .panel-head,
  .job-tools,
  .message-card header,
  .job-card header,
  .my-job-card header,
  .case-card header,
  .activity-card header,
  .match-card footer {
    align-items: stretch;
    flex-direction: column;
  }

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

  .match-card,
  .contact-head,
  .achievement {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .top-actions button,
  .card-actions button,
  .segmented {
    width: 100%;
  }
}
