:root {
  --ink: #111111;
  --body: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f8f9fa;
  --card: #ffffff;
  --brand: #128c89;
  --brand-soft: #e8f7f6;
  --error: #ef4444;
  --success: #10b981;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--body);
  background: #ffffff;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}

.admin-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--soft);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.sidebar .brand {
  height: 44px;
  padding: 0 8px;
  margin-bottom: 18px;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 10px;
  color: var(--body);
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.nav-link:hover,
.nav-link.active {
  color: var(--ink);
  background: var(--brand-soft);
}

.nav-link small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

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

.admin-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.admin-content > main {
  flex: 1;
}

.admin-content .topbar {
  height: 78px;
  padding: 0 28px;
}

.topbar.public {
  height: 68px;
}

.topbar h1 {
  font-size: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-name {
  color: var(--muted);
  font-size: 14px;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 48px;
  width: min(1080px, calc(100% - 48px));
  min-height: calc(100vh - 120px);
  margin: 0 auto;
  align-items: center;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 14px 20px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: #ffffff;
  font-size: 13px;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--brand);
  text-decoration: underline;
}

.admin-content .site-footer {
  background: var(--soft);
}

.login-intro {
  max-width: 620px;
}

.login-panel {
  box-shadow: 0 20px 60px rgb(17 17 17 / 8%);
}

.public-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 180px));
  gap: 14px;
  margin-top: 26px;
}

.public-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 22px;
}

.page {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

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

h1 {
  margin: 0;
  color: var(--ink);
  font-size: 44px;
  line-height: 1.1;
  letter-spacing: 0;
}

.page-description {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

h2 {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 18px;
}

.eyebrow,
.muted,
.lead {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 650;
}

.lead {
  max-width: 620px;
  font-size: 16px;
  line-height: 1.6;
}

.panel {
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel + .panel,
.grid + .panel,
.stats-grid + .grid,
.stats-grid + .panel {
  margin-top: 18px;
}

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

.panel-head h2 {
  margin: 0;
}

.narrow {
  max-width: 520px;
}

.placeholder-panel {
  min-height: 220px;
}

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

.feature-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--body);
  font-size: 14px;
  line-height: 1.5;
}

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

.portal-hero {
  max-width: 740px;
  margin-bottom: 28px;
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.text-link {
  color: var(--brand);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-value {
  color: var(--ink);
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.form-stack {
  display: grid;
  gap: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
}

.form-grid .wide {
  grid-column: span 2;
}

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  min-height: 40px;
  padding: 9px 11px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink);
}

textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  line-height: 1.55;
}

.textarea.mono {
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 13px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  min-height: auto;
}

.check-row,
.badge-group,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.template-admin-list {
  display: grid;
  gap: 16px;
}

.sub-panel {
  padding: 18px;
  background: #fbfbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.version-details {
  margin-top: 14px;
}

.version-details summary {
  color: var(--brand);
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

.primary,
.secondary {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

.primary {
  color: #ffffff;
  background: var(--ink);
  border: 1px solid var(--ink);
}

.secondary {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
}

.notice {
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 14px;
}

.notice.error {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.notice.success {
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.inline-form {
  display: grid;
  grid-template-columns: 170px minmax(160px, 1fr) minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.search-form,
.row-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-form input {
  min-width: 220px;
}

.row-form select {
  min-width: 118px;
}

.phone-reveal-form {
  display: inline;
  margin-left: 6px;
}

.segmented-control {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented-control a {
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
}

.segmented-control a.active {
  color: var(--ink);
  background: #f3f4f6;
  font-weight: 600;
}

.alert-panel {
  border-color: #e5484d;
  background: #fff5f5;
  color: #8f1d22;
}

.hidden-form {
  display: none;
}

.small {
  min-height: 34px;
  padding: 0 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 13px;
}

code {
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 13px;
}

.log-json {
  display: block;
  max-width: 360px;
  max-height: 110px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.h5-shell {
  width: min(100% - 28px, 520px);
  margin: 0 auto;
  padding: 24px 0 72px;
}

.h5-hero {
  padding: 12px 0 18px;
}

.h5-hero h1,
.h5-panel h1 {
  font-size: 30px;
}

.h5-public-profile {
  text-align: center;
}

.h5-profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
}

.h5-profile-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  color: #ffffff;
  background: linear-gradient(135deg, #ff9f43, #ff5a2d);
  font-size: 34px;
  font-weight: 800;
}

.h5-public-profile h1 {
  margin: 14px 0 4px;
}

.h5-profile-copy {
  padding-top: 18px;
  margin-top: 18px;
  text-align: left;
  border-top: 1px solid var(--line);
}

.h5-profile-copy p {
  color: var(--body);
  line-height: 1.75;
  white-space: pre-wrap;
}

.h5-public-profile .link-button {
  margin-top: 12px;
}

.h5-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.h5-stats-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.h5-stats-three .stat-card {
  min-width: 0;
  padding: 14px 8px;
}

.h5-stats-three .stat-value,
.h5-stats-three .stat-label {
  display: block;
  text-align: center;
}

.h5-filter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.h5-filter label,
.h5-filter label > span {
  display: block;
}

.h5-filter label > span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.h5-filter input,
.h5-filter select {
  width: 100%;
}

.h5-filter button {
  grid-column: 1 / -1;
}

.h5-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.record-detail {
  display: grid;
  gap: 0;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.detail-row span {
  flex: 0 0 auto;
  color: var(--muted);
}

.detail-row strong {
  text-align: right;
  overflow-wrap: anywhere;
}

.detail-row.stacked {
  display: block;
}

.detail-row.stacked strong {
  display: block;
  margin-top: 8px;
  text-align: left;
  white-space: pre-wrap;
}

.record-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 420px) {
  .h5-filter {
    grid-template-columns: 1fr;
  }

  .h5-filter button {
    grid-column: auto;
  }
}

.h5-section,
.h5-panel,
.h5-agreement {
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.h5-section + .h5-section {
  margin-top: 16px;
}

.stacked-form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.stacked-form label:not(.checkbox-row) {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.stacked-form input:not([type="checkbox"]),
.stacked-form select {
  width: 100%;
}

.stacked-form .checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--body);
  line-height: 1.55;
}

.stacked-form .checkbox-row input {
  flex: 0 0 auto;
  width: 20px;
  min-height: 20px;
}

.danger-zone {
  border-color: #efc4c0;
  background: #fff8f7;
}

.danger-zone button.danger {
  background: #b93f39;
}

.privacy-form {
  display: grid;
  gap: 16px;
}

.privacy-copy,
.legal-document p {
  color: var(--body);
  line-height: 1.75;
}

.h5-check,
.setting-switch {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--body);
  line-height: 1.65;
}

.h5-check input,
.setting-switch input {
  flex: 0 0 auto;
  width: 20px;
  min-height: 20px;
  margin-top: 2px;
}

.minor-consent {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #f0cf8d;
  border-radius: 8px;
  background: #fffaf0;
}

.minor-consent label:not(.h5-check) {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.setting-switch {
  justify-content: space-between;
}

.setting-switch strong,
.setting-switch small {
  display: block;
}

.setting-switch small {
  margin-top: 5px;
  color: var(--muted);
}

.upcoming-alert {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid #f0cf8d;
  border-radius: 8px;
  background: #fff7e8;
}

.upcoming-alert a {
  color: var(--body);
  text-decoration: none;
}

.reminder-inline-setting {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.h5-section + .h5-section,
.h5-list + .h5-bottom-nav,
.h5-agreement + .h5-section,
.notice + .h5-section {
  margin-top: 14px;
}

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

.h5-list-item,
.h5-radio-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 68px;
  padding: 14px;
  color: var(--body);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
}

.h5-list-item strong,
.h5-radio-item strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
}

.h5-list-item small,
.h5-radio-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.h5-radio-item {
  justify-content: start;
  cursor: pointer;
}

.h5-radio-item input {
  flex: 0 0 auto;
  min-height: auto;
}

.h5-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.h5-message-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.message-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  color: #ffffff;
  background: #e5484d;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.message-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.message-summary div {
  display: grid;
  gap: 3px;
  padding: 14px 8px;
  text-align: center;
  background: #ffffff;
}

.message-summary strong {
  color: var(--ink);
  font-size: 22px;
}

.message-summary span {
  color: var(--muted);
  font-size: 12px;
}

.message-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.message-tabs a {
  min-height: 40px;
  padding: 10px 4px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  text-decoration: none;
}

.message-tabs a.active {
  color: #ffffff;
  background: var(--primary);
  font-weight: 700;
}

.message-item {
  position: relative;
}

.message-item.unread {
  border-color: rgba(22, 119, 255, 0.34);
  background: #f7faff;
}

.message-item-body {
  min-width: 0;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.unread-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #e5484d;
}

.message-chevron {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 28px;
  line-height: 1;
}

.message-empty {
  text-align: center;
}

.message-detail {
  display: grid;
  gap: 16px;
}

.message-detail-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-detail-summary {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.6;
}

.message-detail-content {
  color: var(--body);
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  text-decoration: none;
}

.h5-full-button {
  width: 100%;
  margin-top: 14px;
}

.h5-bottom-nav {
  margin-top: 18px;
  text-align: center;
}

.h5-agreement {
  white-space: pre-wrap;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.75;
}

@media (max-width: 1060px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .form-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar .brand {
    margin-bottom: 12px;
  }

  .sidebar-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .admin-content .topbar {
    height: auto;
    min-height: 72px;
    padding: 16px 20px;
    align-items: start;
    gap: 16px;
  }

  .login-shell,
  .grid.two,
  .placeholder-grid,
  .portal-grid,
  .inline-form,
  .form-grid,
  .form-grid.compact,
  .search-form,
  .row-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .search-form,
  .row-form {
    display: grid;
  }

  .search-form input,
  .row-form select {
    min-width: 0;
  }

  .form-grid .wide {
    grid-column: auto;
  }

  .page-head {
    display: grid;
    align-items: start;
  }
}

@media (max-width: 620px) {
  .topbar,
  .topbar.public,
  .admin-content .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar-actions {
    display: grid;
    justify-items: end;
  }

  .login-shell,
  .page {
    width: min(100% - 28px, 1180px);
  }

  h1 {
    font-size: 34px;
  }

  .stats-grid,
  .public-stats {
    grid-template-columns: 1fr;
  }

  .h5-shell {
    width: min(100% - 24px, 520px);
  }

  .h5-list-item {
    align-items: flex-start;
  }
}
