:root {
  --portal-ink: var(--fw-black-200);
  --portal-muted: var(--fw-black-500);
  --portal-line: color-mix(in srgb, var(--fw-black-950) 12%, transparent);
  --portal-surface: var(--fw-white-000);
  --portal-canvas: color-mix(in srgb, var(--primary-050) 48%, var(--fw-white-050));
  --portal-mint: #dff5ec;
  --portal-mint-ink: #17654d;
  --portal-peach: #fff0e5;
  --portal-peach-ink: #955124;
  --portal-lilac: #eeeafd;
  --portal-lilac-ink: #5b4ca4;
  --portal-danger: #a43f52;
  --portal-shadow: 0 14px 35px rgba(35, 67, 86, 0.08);
}

.portal-page,
.portal-page * {
  box-sizing: border-box;
}

.portal-page {
  min-height: 100vh;
  padding: 32px 0 72px;
  color: var(--portal-ink);
  background:
    radial-gradient(circle at 8% 0%, color-mix(in srgb, var(--primary-200) 45%, transparent), transparent 28rem),
    var(--portal-canvas);
}

.portal-shell {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
}

.portal-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
  padding: 34px;
  border: 1px solid var(--portal-line);
  border-radius: 24px;
  background: linear-gradient(135deg, var(--portal-surface), color-mix(in srgb, var(--primary-100) 48%, var(--portal-surface)));
  box-shadow: var(--portal-shadow);
}

.portal-hero::after {
  position: absolute;
  right: -70px;
  bottom: -105px;
  width: 260px;
  height: 260px;
  border: 40px solid color-mix(in srgb, var(--primary-300) 30%, transparent);
  border-radius: 50%;
  content: "";
}

.portal-hero > * {
  position: relative;
  z-index: 1;
}

.portal-eyebrow {
  margin: 0 0 8px;
  color: var(--primary-700);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.portal-hero h1 {
  max-width: 760px;
  margin: 0;
  color: var(--portal-ink);
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  line-height: 1.08;
}

.portal-hero p:not(.portal-eyebrow) {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--portal-muted);
  line-height: 1.65;
}

.portal-actions,
.portal-filter-bar,
.portal-meta,
.portal-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.portal-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--primary-600);
  border-radius: 12px;
  color: var(--fw-white-000) !important;
  background: var(--primary-700);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.portal-button:hover,
.portal-button.is-complete {
  background: var(--primary-800);
}

.portal-button.is-secondary {
  border-color: var(--portal-line);
  color: var(--portal-ink) !important;
  background: var(--portal-surface);
}

.portal-button.is-quiet {
  min-height: 36px;
  padding: 6px 10px;
  border-color: transparent;
  color: var(--primary-800) !important;
  background: transparent;
}

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

.portal-span-12 { grid-column: span 12; }
.portal-span-8 { grid-column: span 8; }
.portal-span-7 { grid-column: span 7; }
.portal-span-6 { grid-column: span 6; }
.portal-span-5 { grid-column: span 5; }
.portal-span-4 { grid-column: span 4; }
.portal-span-3 { grid-column: span 3; }

.portal-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--portal-line);
  border-radius: 18px;
  background: var(--portal-surface);
  box-shadow: 0 8px 24px rgba(35, 67, 86, 0.055);
}

.portal-card.is-accent {
  background: linear-gradient(145deg, color-mix(in srgb, var(--primary-100) 58%, var(--portal-surface)), var(--portal-surface));
}

.portal-card.is-mint { background: var(--portal-mint); }
.portal-card.is-peach { background: var(--portal-peach); }
.portal-card.is-lilac { background: var(--portal-lilac); }

.portal-card-header,
.portal-section-header,
.portal-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.portal-card-header {
  margin-bottom: 16px;
}

.portal-card h2,
.portal-card h3,
.portal-section-header h2 {
  margin: 0;
  color: var(--portal-ink);
}

.portal-card h2,
.portal-section-header h2 { font-size: 1.12rem; font-weight: 600; }
.portal-card h3 { font-size: 0.98rem; }

.portal-card p {
  color: var(--portal-muted);
  line-height: 1.55;
}

.portal-stat-value {
  display: block;
  margin: 8px 0 4px;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.portal-stat-label,
.portal-caption,
.portal-meta {
  color: var(--portal-muted);
  font-size: 0.78rem;
}

.portal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--portal-mint-ink);
  background: var(--portal-mint);
  font-size: 0.72rem;
  font-weight: 800;
}

.portal-badge.is-warning { color: var(--portal-peach-ink); background: var(--portal-peach); }
.portal-badge.is-info { color: var(--portal-lilac-ink); background: var(--portal-lilac); }
.portal-badge.is-neutral { color: var(--portal-muted); background: color-mix(in srgb, var(--portal-muted) 10%, transparent); }

.portal-progress {
  overflow: hidden;
  height: 9px;
  margin: 10px 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--portal-muted) 14%, transparent);
}

.portal-progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-700));
}

.portal-list,
.portal-timeline,
.portal-checklist {
  margin: 0;
  padding: 0;
  list-style: none;
}

.portal-list-row {
  padding: 14px 0;
  border-top: 1px solid var(--portal-line);
}

.portal-list-row:first-child { border-top: 0; }
.portal-list-row > div { min-width: 0; }
.portal-list-row strong { display: block; font-size: 0.9rem; }
.portal-list-row small { color: var(--portal-muted); }

.portal-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: var(--primary-900);
  background: var(--primary-200);
  font-weight: 800;
}

.portal-patient-row {
  display: grid;
  grid-template-columns: auto minmax(150px, 1.2fr) minmax(120px, 1fr) minmax(130px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--portal-line);
}

.portal-patient-row:first-child { border-top: 0; }

.portal-input,
.portal-select,
.portal-textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--portal-line);
  border-radius: 12px;
  color: var(--portal-ink);
  background: var(--portal-surface);
  font: inherit;
  font-size: 0.86rem;
}

.portal-textarea { min-height: 110px; resize: vertical; }

.portal-search { flex: 1 1 260px; }

.portal-filter {
  padding: 7px 12px;
  border: 1px solid var(--portal-line);
  border-radius: 999px;
  color: var(--portal-muted);
  background: var(--portal-surface);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.portal-filter.is-active {
  border-color: var(--primary-500);
  color: var(--primary-900);
  background: var(--primary-100);
}

.portal-timeline li {
  position: relative;
  margin-left: 8px;
  padding: 0 0 22px 28px;
  border-left: 2px solid var(--portal-line);
}

.portal-timeline li::before {
  position: absolute;
  top: 2px;
  left: -7px;
  width: 12px;
  height: 12px;
  border: 3px solid var(--portal-surface);
  border-radius: 50%;
  background: var(--primary-600);
  content: "";
}

.portal-timeline li:last-child { padding-bottom: 0; }
.portal-timeline time { color: var(--portal-muted); font-size: 0.72rem; }

.portal-privacy {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0 0;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--primary-500) 25%, transparent);
  border-radius: 12px;
  color: var(--portal-muted);
  background: color-mix(in srgb, var(--primary-050) 62%, transparent);
  font-size: 0.78rem;
  line-height: 1.45;
}

.portal-document-row {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) 130px 120px auto;
  align-items: center;
  gap: 15px;
  padding: 15px 0;
  border-top: 1px solid var(--portal-line);
}

.portal-document-row:first-child { border-top: 0; }
.portal-file-icon { color: var(--primary-700); font-size: 1.35rem; }

.portal-form-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.portal-form-step {
  padding: 10px;
  border-radius: 10px;
  color: var(--portal-muted);
  background: color-mix(in srgb, var(--portal-muted) 8%, transparent);
  font-size: 0.74rem;
  font-weight: 700;
  text-align: center;
}

.portal-form-step.is-active { color: var(--primary-900); background: var(--primary-100); }

.portal-message-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.75fr) minmax(0, 2fr);
  min-height: 580px;
  padding: 0;
  overflow: hidden;
}

.portal-conversations { border-right: 1px solid var(--portal-line); }
.portal-conversations,
.portal-chat { padding: 20px; }

.portal-message {
  max-width: 76%;
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 15px 15px 15px 4px;
  color: var(--portal-ink);
  background: color-mix(in srgb, var(--portal-muted) 9%, var(--portal-surface));
  font-size: 0.86rem;
  line-height: 1.5;
}

.portal-message.is-own {
  margin-left: auto;
  border-radius: 15px 15px 4px;
  background: var(--primary-100);
}

.portal-workflow {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.portal-workflow > div {
  position: relative;
  padding: 14px 10px;
  border-radius: 12px;
  color: var(--portal-muted);
  background: color-mix(in srgb, var(--primary-100) 46%, var(--portal-surface));
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
}

.portal-workflow > div:not(:last-child)::after {
  position: absolute;
  top: 50%;
  right: -8px;
  z-index: 1;
  color: var(--primary-700);
  content: "›";
  transform: translateY(-50%);
}

.portal-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 150px;
  margin-top: 20px;
  padding-top: 12px;
  border-bottom: 1px solid var(--portal-line);
}

.portal-chart-bars span {
  flex: 1;
  min-width: 24px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(var(--primary-400), var(--primary-700));
}

[hidden] { display: none !important; }

@media (max-width: 950px) {
  .portal-span-3 { grid-column: span 6; }
  .portal-span-4,
  .portal-span-5,
  .portal-span-6,
  .portal-span-7,
  .portal-span-8 { grid-column: span 12; }
  .portal-patient-row { grid-template-columns: auto 1fr auto; align-items: start; }
  .portal-patient-row > :nth-child(3),
  .portal-patient-row > :nth-child(4) { grid-column: 2; }
  .portal-patient-row > :last-child { grid-column: 3; grid-row: 1 / span 3; }
}

@media (max-width: 700px) {
  .portal-page { padding-top: 18px; }
  .portal-shell { width: min(100% - 28px, 1240px); }
  .portal-hero { align-items: flex-start; flex-direction: column; padding: 26px 22px; border-radius: 18px; }
  .portal-span-3 { grid-column: span 12; }
  .portal-card { padding: 18px; }
  .portal-document-row { grid-template-columns: auto 1fr auto; align-items: start; }
  .portal-document-row > :nth-child(3),
  .portal-document-row > :nth-child(4) { grid-column: 2; }
  .portal-document-row > :last-child { grid-column: 3; grid-row: 1 / span 3; }
  .portal-message-layout { grid-template-columns: 1fr; }
  .portal-conversations { border-right: 0; border-bottom: 1px solid var(--portal-line); }
  .portal-workflow { grid-template-columns: 1fr; }
  .portal-workflow > div:not(:last-child)::after { top: auto; right: 50%; bottom: -12px; transform: rotate(90deg); }
  .portal-form-steps { grid-template-columns: repeat(2, 1fr); }
}

/* Original home component visual system */
.portal-page {
  color: #252a31;
  background: #f3f5f7;
}

.portal-shell {
  width: min(1295px, calc(100% - 48px));
}

.portal-hero,
.portal-card {
  border: 1px solid rgb(138 150 163 / 0.25);
  border-radius: 0.8rem;
  background: #fff;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.portal-hero {
  overflow: visible;
  padding: 36px 40px;
}

.portal-hero::after {
  display: none;
}

.portal-card.is-accent,
.portal-card.is-mint,
.portal-card.is-peach,
.portal-card.is-lilac {
  background: #fff;
}

.portal-eyebrow {
  color: #68717b;
}

.portal-hero h1,
.portal-card h2,
.portal-card h3,
.portal-section-header h2 {
  color: #20252b;
}

.portal-hero p:not(.portal-eyebrow),
.portal-card p,
.portal-caption,
.portal-meta,
.portal-stat-label {
  color: #606872;
}

.portal-button {
  min-height: 42px;
  padding: 10px 17px;
  border: 1px solid var(--primary-600);
  border-radius: 10px;
  color: var(--primary-950) !important;
  background: var(--primary-500);
  font-size: 0.86rem;
  font-weight: 600;
}

.portal-button:hover,
.portal-button.is-complete {
  color: var(--fw-white-000) !important;
  background: var(--primary-600);
}

.portal-button.is-secondary {
  border-color: #cbd1d7;
  color: #343a42 !important;
  background: #fff;
}

.portal-button.is-secondary:hover {
  border-color: #9da9b4;
  color: #20252b !important;
  background: #f3f5f7;
}

.portal-button.is-quiet {
  border-color: transparent;
  color: #245b8a !important;
  background: transparent;
}

.portal-button.is-quiet:hover {
  color: #163f63 !important;
  background: #f3f5f7;
}

.portal-badge,
.portal-badge.is-warning,
.portal-badge.is-info,
.portal-badge.is-neutral {
  color: #5d6670;
  background: #eef1f3;
}

.portal-progress {
  background: #e1e3e6;
}

.portal-progress > span,
.portal-chart-bars span {
  background: var(--primary-500);
}

.portal-avatar {
  color: #343a42;
  background: #e7eaed;
}

.portal-list-row,
.portal-patient-row,
.portal-document-row {
  border-color: #e1e3e6;
}

.portal-input,
.portal-select,
.portal-textarea {
  border: 1px solid;
  border-color: #a8adb1;
  border-radius: 10px;
  color: #252a31;
  background: #fff;
}

.portal-input:focus,
.portal-select:focus,
.portal-textarea:focus {
  border-color: var(--primary-500);
  outline: 2px solid color-mix(in srgb, var(--primary-500) 18%, transparent);
}

.portal-filter {
  border-color: #d7dce0;
  color: #606872;
  background: #fff;
}

.portal-filter.is-active {
  border-color: #9da9b4;
  color: #252a31;
  background: #eef1f3;
}

.portal-privacy {
  border-color: #d8dde1;
  color: #606872;
  background: #f7f8f9;
}

.portal-form-step,
.portal-form-step.is-active,
.portal-workflow > div {
  color: #5d6670;
  background: #eef1f3;
}

.portal-form-step.is-active {
  color: #20252b;
  box-shadow: inset 0 0 0 1px #b8c0c7;
}

.portal-message {
  color: #343a42;
  background: #eef1f3;
}

.portal-message.is-own {
  color: #20252b;
  background: color-mix(in srgb, var(--primary-800) 65%, #fff);
}

.portal-timeline li,
.portal-chart-bars {
  border-color: #dfe3e6;
}

.portal-timeline li::before {
  border-color: #fff;
  background: var(--primary-500);
}

@media (max-width: 700px) {
  .portal-shell {
    width: min(100% - 32px, 1295px);
  }

  .portal-hero {
    padding: 26px 24px;
  }
}
