/*
 * Parhoon user interface — mobile-first implementation of docs/design-system.html.
 * This layer intentionally loads after the historical shell so every user-facing
 * page shares one predictable responsive and accessible visual language.
 */

:root {
  /* Reassert canonical aliases after the historical shell layer. */
  --brand-primary: #12664e;
  --brand-dark: #153c32;
  --brand-soft: #edf5ef;
  --brand-accent: #d9f5ab;
  --color-primary: var(--brand-primary);
  --color-primary-hover: #0f5843;
  --color-primary-content: #fff;
  --color-base-100: #fff;
  --color-base-200: #f4f7f6;
  --color-base-300: #e0e7e3;
  --color-base-content: #192f29;
  --color-muted: #62736b;
  --color-line: #e1e8e4;
  --color-soft: var(--brand-soft);
  --color-lime: var(--brand-accent);
  --color-success: #176346;
  --color-success-soft: #e8f6ee;
  --color-danger: #b42318;
  --color-danger-soft: #fdecea;
  --color-warning: #875611;
  --color-warning-soft: #fff8e8;
  --color-info: #155e75;
  --color-info-soft: #e8f4f8;
  --color-focus: #759b34;
  --radius-field: .65rem;
  --radius-box: 1rem;
  --radius-selector: .55rem;
  --shadow: 0 10px 30px rgba(18,63,51,.07);
  --touch-min: 44px;
  --card-radius: 14px;
  --card-pad: 16px;
  --card-pad-compact: 12px;
  --card-border: 1px solid var(--color-line);
  --card-bg: #fff;
  --card-shadow: 0 2px 10px rgba(18,63,51,.035);
  --card-hover-border: #b7cdbf;
  --card-hover-shadow: 0 8px 22px rgba(18,63,51,.07);
  --bg: var(--color-base-200);
  --ink: var(--color-base-content);
  --muted: var(--color-muted);
  --line: var(--color-line);
  --green: var(--brand-primary);
  --dark: var(--brand-dark);
  --soft: var(--brand-soft);
  --lime: var(--brand-accent);
  --shell-sidebar: 268px;
  --shell-topbar: 64px;
  --shell-mobile-nav: 70px;
  --content-max: 1200px;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--color-base-200);
  scroll-behavior: smooth;
  scroll-padding-block: calc(var(--shell-topbar) + 16px) calc(var(--shell-mobile-nav) + 24px);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--color-base-content);
  background: var(--color-base-200);
  font-family: Vazirmatn, Tahoma, Arial, sans-serif;
  line-height: 1.85;
}

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

button,
a,
select,
input[type="checkbox"],
input[type="radio"] { touch-action: manipulation; }

a { color: var(--color-primary); }

a:hover { color: var(--color-primary-hover); }

img,
svg { max-width: 100%; }

[hidden] { display: none !important; }

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

::selection {
  color: var(--brand-dark);
  background: var(--brand-accent);
}

h1,
h2,
h3,
p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(1.4rem, 6vw, 1.85rem);
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: -.035em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.7;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.75;
}

.muted,
.help,
.field__help { color: var(--color-muted); }

.skip-link,
.skip {
  position: fixed;
  z-index: 100;
  inset: 8px 8px auto auto;
  min-height: var(--touch-min);
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--color-base-content);
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateY(-160%);
}

.skip-link:focus,
.skip:focus { transform: none; }

/* Product shell */

body.app-shell { padding: 0; }

.app-shell .workspace {
  min-width: 0;
  min-height: 100dvh;
  margin: 0;
}

.app-shell .side { display: none; }

.app-shell .topbar {
  position: sticky;
  z-index: 28;
  top: 0;
  display: flex;
  min-height: var(--shell-topbar);
  height: var(--shell-topbar);
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--color-line);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
}

.topbar__row {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topbar__start,
.account-menu { flex: 0 0 auto; }

.topbar__title {
  position: absolute;
  left: 50%;
  max-width: calc(100% - 210px);
  overflow: hidden;
  font-size: .92rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.topbar-back {
  display: inline-flex;
  min-height: var(--touch-min);
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  color: var(--color-primary);
  font-size: .84rem;
  font-weight: 700;
  text-decoration: none;
}

.topbar-back svg {
  width: 20px;
  height: 20px;
  transform: scaleX(-1);
}

.app-shell .mobile-brand {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 10px;
  color: var(--brand-dark);
  background: var(--brand-accent);
  font-size: 1.05rem;
  font-weight: 800;
}

.account-menu { position: relative; }

.account-menu__btn {
  display: grid;
  width: var(--touch-min);
  height: var(--touch-min);
  place-items: center;
  border-radius: 10px;
  color: var(--color-primary);
  list-style: none;
  cursor: pointer;
}

.account-menu__btn::-webkit-details-marker { display: none; }

.account-menu__btn svg { width: 22px; height: 22px; }

.account-menu[open] > .account-menu__btn,
.account-menu__btn:hover { background: var(--color-soft); }

.account-menu__panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  display: grid;
  min-width: 168px;
  padding: 6px;
  border: 1px solid var(--color-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--card-hover-shadow);
}

.account-menu__panel a,
.account-menu__panel button {
  display: flex;
  width: 100%;
  min-height: var(--touch-min);
  align-items: center;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-base-content);
  font: inherit;
  font-size: .84rem;
  font-weight: 650;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.account-menu__panel a:hover { background: var(--color-soft); }

.account-menu__panel form { margin: 0; }

.account-menu__panel button { color: var(--color-danger); }

.account-menu__panel button:hover { background: var(--color-danger-soft); }

.app-shell .container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 20px 16px calc(96px + env(safe-area-inset-bottom, 0px));
}

.app-shell.no-mobile-nav .container,
.app-shell.form-view .container { padding-bottom: 32px; }

.app-shell .mobile-nav {
  position: fixed;
  z-index: 30;
  inset: auto 0 0;
  display: flex;
  min-height: var(--shell-mobile-nav);
  justify-content: stretch;
  gap: 2px;
  padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--color-line);
  background: rgba(255,255,255,.98);
  box-shadow: 0 -6px 24px rgba(18,63,51,.06);
}

.app-shell.no-mobile-nav .mobile-nav,
.app-shell.form-view .mobile-nav { display: none !important; }

.app-shell .mobile-nav a {
  display: flex;
  min-width: 0;
  min-height: 56px;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  border-radius: 10px;
  color: var(--color-muted);
  font-size: clamp(.59rem, 2.6vw, .72rem);
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}

.app-shell .mobile-nav a:hover,
.app-shell .mobile-nav a.active {
  color: var(--color-primary);
  background: var(--color-soft);
}

.app-shell .mobile-nav a.active { font-weight: 700; }

.app-shell .mobile-nav svg { width: 20px; height: 20px; }

#connectivity-banner {
  position: sticky;
  z-index: 27;
  top: var(--shell-topbar);
  margin: 0;
  border-width: 0 0 1px;
  border-radius: 0;
  text-align: center;
}

/* Page structure */

.pagehead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.pagehead--stack,
.pagehead__copy { display: grid; gap: 4px; }

.pagehead--stack { justify-content: stretch; }

.pagehead__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pagehead__title-row h1,
.pagehead__title-row .profile-kicker {
  flex: 1 1 auto;
  min-width: 0;
}

.pagehead p {
  margin: 0;
  color: var(--color-muted);
  font-size: .875rem;
}

.pagehead__actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
}

.page-section { margin-top: 28px; }

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

.section-head p { margin: 4px 0 0; font-size: .84rem; }

.crumb {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  overflow-x: auto;
  color: var(--color-muted);
  font-size: .76rem;
  scrollbar-width: none;
  white-space: nowrap;
}

.crumb::-webkit-scrollbar { display: none; }

.crumb a { min-height: var(--touch-min); display: inline-flex; align-items: center; }

.card,
.form-section-card,
.record-card,
.mobile-record {
  min-width: 0;
  border: var(--card-border);
  border-radius: var(--card-radius);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}

.card { overflow: hidden; }

.record-card { transition: border-color .15s ease, box-shadow .15s ease; }

@media (hover: hover) {
  .record-card:hover {
    border-color: var(--card-hover-border);
    box-shadow: var(--card-hover-shadow);
  }
}

.pad { padding: var(--card-pad); }

.stack { display: grid; gap: 14px; }

ul.stack,
ol.stack { margin: 0; padding: 0; list-style: none; }

.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

.surface-section {
  padding: 18px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-box);
  background: #fff;
}

.surface-section > :last-child { margin-bottom: 0; }

/* Buttons, links and badges */

.button,
.btn {
  display: inline-flex;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--color-line);
  border-radius: 10px;
  color: var(--color-base-content);
  background: #fff;
  box-shadow: none;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
}

.button:hover,
.btn:hover {
  border-color: #b7cdbf;
  color: var(--color-base-content);
  background: #f8faf9;
}

.button--primary,
.btn-primary,
.btn.primary {
  border-color: var(--color-primary);
  color: #fff;
  background: var(--color-primary);
}

.button--primary:hover,
.btn-primary:hover,
.btn.primary:hover {
  border-color: var(--color-primary-hover);
  color: #fff;
  background: var(--color-primary-hover);
}

.button--secondary {
  border-color: #cbded1;
  color: var(--brand-dark);
  background: var(--color-soft);
}

.btn-ghost { border-color: transparent; background: transparent; }

.btn-danger {
  border-color: #e8b9b4;
  color: var(--color-danger);
  background: var(--color-danger-soft);
}

.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .82rem; }

.icon-btn { width: var(--touch-min); padding: 0; }

.button:disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: .52;
}

.link-secondary,
.textlink {
  display: inline-flex;
  min-height: var(--touch-min);
  align-items: center;
  color: var(--color-primary);
  font-weight: 600;
  text-underline-offset: 3px;
}

.badge {
  display: inline-flex;
  width: max-content;
  height: auto;
  align-items: center;
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  color: #52685b;
  background: #eef2ef;
  font-size: .76rem;
  font-weight: 600;
  line-height: 1.7;
  white-space: nowrap;
}

.badge.green { color: var(--color-success); background: #e7f4ed; }
.badge.amber { color: #855508; background: #fff3d8; }
.badge.red { color: #a33224; background: #fcedea; }

/* Forms */

.field { display: grid; gap: 6px; margin: 0 0 16px; }

.field__label,
.field label,
.field legend {
  margin: 0;
  font-size: .9rem;
  font-weight: 600;
}

.field__input,
.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid #cdd9d1;
  border-radius: var(--radius-field);
  color: var(--color-base-content);
  background: #fff;
  box-shadow: none;
  font-size: 1rem;
}

textarea.field__input,
.textarea { min-height: 120px; resize: vertical; }

.field__input:focus,
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--color-primary);
  outline: 3px solid rgba(117,155,52,.22);
}

.field__input[aria-invalid="true"],
.field__input--error,
.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--color-danger);
  background: #fff;
}

.field:has(.field__error) { gap: 4px; }

.field__input:disabled,
.input:disabled,
.select:disabled,
.textarea:disabled {
  cursor: not-allowed;
  color: var(--color-muted);
  background: var(--color-base-200);
}

.field__input[readonly],
.input[readonly],
.textarea[readonly] { background: #f7f9f7; }

.field__help,
.field__error,
.help,
.error {
  margin: 0;
  font-size: .82rem;
  line-height: 1.75;
}

.field__error,
.field-error,
.error,
.required { color: var(--color-danger); }

.field__error,
.field-error,
p.error[role="alert"] {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  color: #b42318;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.6;
}

.field__error-icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 1rem;
  margin-top: .15em;
}

.field__error:not(:has(.field__error-icon))::before,
.field-error:not(:has(.field__error-icon))::before,
p.error[role="alert"]:not(:has(.field__error-icon))::before {
  content: "";
  width: 1rem;
  height: 1rem;
  flex: 0 0 1rem;
  margin-top: .15em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='black' d='M10 1.75a8.25 8.25 0 1 0 0 16.5 8.25 8.25 0 0 0 0-16.5Zm0 4.1a.9.9 0 0 1 .9.9v4.1a.9.9 0 1 1-1.8 0V6.75a.9.9 0 0 1 .9-.9Zm0 8.3a1.05 1.05 0 1 1 0-2.1 1.05 1.05 0 0 1 0 2.1Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='black' d='M10 1.75a8.25 8.25 0 1 0 0 16.5 8.25 8.25 0 0 0 0-16.5Zm0 4.1a.9.9 0 0 1 .9.9v4.1a.9.9 0 1 1-1.8 0V6.75a.9.9 0 0 1 .9-.9Zm0 8.3a1.05 1.05 0 1 1 0-2.1 1.05 1.05 0 0 1 0 2.1Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.form-card { width: 100%; max-width: 720px; padding: var(--card-pad); }

.form-layout { display: grid; gap: 14px; }

.form-section-card { padding: var(--card-pad); }

.form-section-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-line);
}

.form-section-card__head p { margin: 2px 0 0; color: var(--color-muted); font-size: .8rem; }

.form-actions {
  position: sticky;
  z-index: 20;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-inline: -16px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--color-line);
  background: rgba(255,255,255,.98);
  box-shadow: 0 -6px 22px rgba(18,63,51,.06);
}

.form-actions .btn-primary { width: 100%; }

.choice {
  display: flex !important;
  min-height: 48px;
  align-items: flex-start;
  gap: 10px;
  margin: 0 !important;
  padding: 11px 12px;
  border: 1px solid var(--color-line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 400 !important;
}

.choice:has(input:checked) {
  border-color: var(--color-primary);
  background: #f0f7f2;
}

.choice input {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  margin-top: 3px;
  accent-color: var(--color-primary);
}

.field > div[id^="id_q_"]:has(input[type="radio"]) {
  display: grid;
  gap: 9px;
}

.field > div[id^="id_q_"]:has(input[type="radio"]) > div > label {
  display: flex;
  min-height: 48px;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--color-line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 400;
}

.field > div[id^="id_q_"]:has(input[type="radio"]) > div > label:has(input:checked) {
  border-color: var(--color-primary);
  background: #f0f7f2;
}

.field > div[id^="id_q_"] input[type="radio"] {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  margin-top: 3px;
  accent-color: var(--color-primary);
}

.date-field { display: flex; align-items: center; gap: 8px; }
.date-field .input { min-width: 0; flex: 1 1 auto; }
.calendar-trigger { flex: 0 0 44px; }

.search-form {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: end;
  gap: 8px;
  margin-bottom: 18px;
}

.search-form .field,
.search-form .search-field { min-width: 0; margin: 0; }

.search-form .btn { white-space: nowrap; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 18px;
}

.toolbar .search-field,
.toolbar .field { min-width: min(100%,260px); flex: 1 1 260px; margin: 0; }

.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 18px;
}

.filter-form .field { min-width: 190px; flex: 1 1 240px; margin: 0; }

.error-summary,
.form-errors { margin-bottom: 0; }

/* Feedback and system states */

.status {
  margin: 0 0 16px;
  padding: 11px 14px;
  border: 1px solid var(--color-line);
  border-radius: 10px;
  color: var(--color-base-content);
  background: #f7f9f7;
}

.status--success {
  border-color: #b7dbc7;
  color: var(--color-success);
  background: var(--color-success-soft);
}

.status--error,
.form-errors {
  border-color: #efc1bc;
  color: var(--color-danger);
  background: var(--color-danger-soft);
}

.status--notice {
  border-color: #efd8a8;
  color: var(--color-warning);
  background: var(--color-warning-soft);
}

.status--info {
  border-color: #b9dce5;
  color: var(--color-info);
  background: var(--color-info-soft);
}

.empty-state {
  padding: 28px 18px;
  border: 1px dashed #b7cdbf;
  border-radius: 12px;
  background: #fbfcfb;
  text-align: center;
}

.empty-state h3 { margin-bottom: 6px; }
.empty-state p { margin: 0 0 14px; }

.spinner {
  display: inline-block;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255,255,255,.48);
  border-top-color: #fff;
  border-radius: 50%;
  animation: parhoon-spin .8s linear infinite;
  vertical-align: middle;
}

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

/* Home dashboard and reusable task cards */

.identity-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 20px;
  overflow: hidden;
  border: 0;
  border-radius: var(--card-radius);
  color: #fff;
  background: linear-gradient(135deg,var(--brand-dark),var(--color-primary));
  box-shadow: var(--shadow);
}

.identity-card::after {
  position: absolute;
  width: 150px;
  height: 150px;
  inset: -66px auto auto -44px;
  border-radius: 50%;
  background: rgba(217,245,171,.13);
  content: "";
}

.identity-card__name { position: relative; z-index: 1; }
.identity-card__name h1 { color: #fff; }
.identity-card__name p { margin: 3px 0 0; color: #d9e8e1; }

.identity-meta {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.identity-meta span {
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  color: #fff;
  font-size: .78rem;
}

/*
 * Item cards — form-tile, response-card, plan-card and task-card share one
 * anatomy: header (mark, title, badges), body (text, facts), footer
 * (time, actions, or chevron). Roots keep their own class names.
 *
 * --item-card-pad: 10px below 768px, 12px from 768px
 * --item-card-radius: 12px
 * --item-card-gap: 6px between regions; 8px between adjacent controls
 * --item-card-mark: 28px tile, --item-card-icon: 16px glyph
 * Type: title .92rem/750 (1rem from 620px), meta .75rem,
 *       fact label .72rem, fact value .78rem/650
 */

.task-grid,
.form-catalog,
.response-feed,
.plan-grid {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-grid > *,
.form-catalog > *,
.response-feed > *,
.plan-grid > * { min-width: 0; }

.form-tile,
.response-card,
.plan-card,
.task-card {
  --item-card-pad: 10px;
  --item-card-radius: 12px;
  --item-card-gap: 6px;
  --item-card-mark: 28px;
  --item-card-icon: 16px;
  position: relative;
  display: flex;
  min-width: 0;
  height: 100%;
  flex-direction: column;
  gap: var(--item-card-gap);
  padding: var(--item-card-pad);
  border: var(--card-border);
  border-radius: var(--item-card-radius);
  color: var(--color-base-content);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}

a.plan-card:hover,
a.task-card:hover { color: var(--color-base-content); }

a.plan-card:active,
a.task-card:active {
  border-color: var(--card-hover-border);
  background: #f6f9f7;
}

/* The response title link stretches over the card so the whole card opens it;
   the actions footer sits above that overlay. */
.response-card .item-card__title a::after {
  position: absolute;
  inset: 0;
  border-radius: var(--item-card-radius);
  content: "";
}

.response-card .item-card__title a:focus-visible { outline: none; }

.response-card .item-card__title a:focus-visible::after {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.response-card .item-card__title a:active::after { background: rgba(18,63,51,.035); }

@media (hover: hover) {
  .form-tile:hover,
  .response-card:hover,
  .plan-card:hover,
  .task-card:hover {
    border-color: var(--card-hover-border);
    box-shadow: var(--card-hover-shadow);
  }
}

.item-card__header {
  display: flex;
  align-items: center;
  gap: var(--item-card-gap);
  min-width: 0;
}

.item-card__mark {
  display: grid;
  width: var(--item-card-mark);
  height: var(--item-card-mark);
  flex: 0 0 var(--item-card-mark);
  place-items: center;
  border-radius: 8px;
  color: var(--color-primary);
  background: var(--color-soft);
}

.item-card__mark svg {
  width: var(--item-card-icon);
  height: var(--item-card-icon);
}

.form-tile--linked .item-card__mark {
  color: #855508;
  background: #fff6e4;
}

.item-card__header .item-card__title {
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1.35;
}

.item-card__badges {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 58%;
}

.item-card__badges .badge {
  max-width: 100%;
  padding: 1px 8px;
  font-size: .7rem;
  line-height: 1.6;
  white-space: normal;
  text-align: center;
}

.item-card__main {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
}

.item-card__title {
  display: block;
  margin: 0;
  font-size: .92rem;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.item-card__title a {
  color: inherit;
  text-decoration: none;
}

.item-card__title a:hover { color: var(--color-primary); }

.item-card__meta {
  display: block;
  min-width: 0;
  flex: 1 1 auto;
  margin: 0;
  color: var(--color-muted);
  font-size: .75rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.item-card__meta time { font-variant-numeric: tabular-nums; }

.item-card__chevron {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  margin-inline-start: auto;
  color: var(--color-primary);
}

.item-card__chevron svg { width: 20px; height: 20px; }

.item-card__text {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--color-muted);
  font-size: .78rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.item-card__facts {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: 0;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--color-base-200);
}

.item-card__facts > div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 4px;
}

.item-card__facts dt {
  flex: 0 0 auto;
  margin: 0;
  color: var(--color-muted);
  font-size: .72rem;
  font-weight: 650;
  line-height: 1.45;
}

.item-card__facts dd {
  min-width: 0;
  margin: 0;
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.item-card__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--item-card-gap);
  margin: auto calc(var(--item-card-pad) * -1) calc(var(--item-card-pad) * -1);
  padding: 0 var(--item-card-pad);
  border-top: 1px solid var(--color-line);
}

.item-card__footer:has(.item-card__actions) { padding-block: 6px; }

.item-card__actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1 1 100%;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.item-card__actions .btn {
  min-width: 0;
  min-height: var(--touch-min);
  flex: 1 1 0;
  padding: 6px 10px;
  font-size: .84rem;
  white-space: nowrap;
}

@media (min-width: 620px) {
  .task-grid,
  .form-catalog,
  .response-feed,
  .plan-grid { gap: 12px; }
  .item-card__title { font-size: 1rem; }
}

@media (min-width: 768px) {
  .form-tile,
  .response-card,
  .plan-card,
  .task-card { --item-card-pad: 12px; }
}

@media (min-width: 700px) {
  .task-grid,
  .form-catalog,
  .response-feed,
  .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  .task-grid,
  .form-catalog,
  .response-feed,
  .plan-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Lists and records */

.record-grid {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.record-card,
.mobile-record { padding: var(--card-pad); }

.record-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.record-card__title {
  display: inline-flex;
  min-height: var(--touch-min);
  align-items: center;
  font-weight: 700;
  line-height: 1.65;
  text-decoration: none;
}

.record-card__description { margin: 4px 0 0; color: var(--color-muted); font-size: .85rem; }

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 10px;
  color: var(--color-muted);
  font-size: .8rem;
}

.record-meta--center { justify-content: center; }

.responses-view .pagehead { margin-bottom: 12px; }

.responses-toolbar {
  position: sticky;
  z-index: 12;
  top: var(--shell-topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 8px 0;
  background: color-mix(in srgb, var(--color-base-200) 92%, transparent);
  backdrop-filter: blur(8px);
}

.responses-filter-btn { width: auto; }
.responses-filter-btn svg { width: 18px; height: 18px; }
.responses-filter-btn.is-active {
  border-color: #b7d7c4;
  background: var(--color-soft);
}

.responses-count {
  margin: 0;
  color: var(--color-muted);
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.responses-view .filter-chips {
  flex-wrap: nowrap;
  gap: 6px;
  margin: 0 0 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.responses-view .filter-chip { flex: 0 0 auto; }

#response-filter-dialog {
  width: 100%;
  max-width: none;
  max-height: min(92dvh, 760px);
  margin: auto 0 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 20px 20px 0 0;
  color: var(--color-base-content);
  background: #fff;
}

#response-filter-dialog:not([open]) { display: none; }

#response-filter-dialog[open] {
  display: flex;
  flex-direction: column;
}

#response-filter-dialog form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(92dvh, 760px);
}

#response-filter-dialog .sheet-head {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
  padding: 10px 16px 12px;
}

#response-filter-dialog .sheet-handle {
  width: 36px;
  height: 4px;
  margin: 0 auto;
  border-radius: 999px;
  background: #d5e0da;
}

#response-filter-dialog .sheet-head__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#response-filter-dialog .sheet-head h2 { font-size: 1.05rem; }

#response-filter-dialog .sheet-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(92dvh - 168px);
  overflow: auto;
  padding: 4px 16px 12px;
  -webkit-overflow-scrolling: touch;
}

#response-filter-dialog .sheet-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#response-filter-dialog .field { margin: 0; }
#response-filter-dialog .help { margin: 0; font-size: .75rem; }
#response-filter-dialog .school-search { margin-bottom: 0; }

#response-filter-dialog .school-search .ss-panel {
  position: static;
  inset: auto;
  margin-top: 6px;
  box-shadow: none;
}

#response-filter-dialog .sheet-footer {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-line);
  background: #fff;
}

#response-filter-dialog .sheet-footer .btn { flex: 1 1 0; min-height: 48px; }

#response-filter-dialog:has(.calendar-popover),
#response-filter-dialog:has(.calendar-popover) form,
#response-filter-dialog:has(.calendar-popover) .sheet-fields { overflow: visible; }

@media (min-width: 768px) {
  #response-filter-dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: 86dvh;
    margin: auto;
    border-radius: 18px;
  }
  #response-filter-dialog form { max-height: 86dvh; }
  #response-filter-dialog .sheet-fields { max-height: calc(86dvh - 150px); }
  #response-filter-dialog .sheet-handle { display: none; }
  #response-filter-dialog .sheet-head { padding-top: 16px; }
}

#response-filter-dialog .date-field { position: relative; }
#response-filter-dialog .date-field:has(.calendar-popover) { z-index: 6; }

dialog.calendar-popover { display: block !important; }

#response-filter-dialog .calendar-popover {
  border-radius: 16px;
  overflow: auto;
  box-shadow: 0 12px 32px #18382b33;
}

.forms-list-view .pagehead { align-items: center; }
.forms-list-view .pagehead__copy { flex: 1 1 auto; min-width: 0; }

.forms-count {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  color: var(--color-muted);
  background: #fff;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.quick-dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: min(640px, calc(100dvh - 32px));
  padding: 0;
  overflow: auto;
}

.quick-dialog__head {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--color-line);
  background: #fff;
}

.quick-dialog__head > div { flex: 1 1 auto; min-width: 0; }

.quick-dialog__head .btn { flex: 0 0 auto; }

.quick-dialog__kicker {
  margin: 0;
  color: var(--color-primary);
  font-size: .75rem;
  font-weight: 700;
}

.quick-dialog__head h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.quick-dialog__body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.quick-dialog .status,
.quick-dialog .field { margin: 0; }

.quick-dialog__pin {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--color-soft);
  font-size: .95rem;
}

.quick-dialog__pin span {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: .14em;
  font-variant-numeric: tabular-nums;
}

.quick-dialog__url {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.quick-dialog__url .input {
  min-height: 44px;
  font-size: .82rem;
}

.quick-dialog__meta {
  margin: 0;
  color: var(--color-muted);
  font-size: .82rem;
}

.quick-dialog__meta time { font-variant-numeric: tabular-nums; }

.quick-dialog__actions,
.quick-dialog__create { margin: 0; }

.quick-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-dialog__actions .btn { flex: 1 1 8rem; }

.quick-dialog__actions .btn-danger { flex-basis: 100%; }

.quick-dialog__create .btn { width: 100%; }

.mobile-cards { display: grid; gap: 10px; }
.mobile-record b { display: block; }
.mobile-record small { display: block; margin-top: 4px; }
.mobile-record a { display: flex; min-height: var(--touch-min); align-items: center; text-decoration: none; }

.readonly-card { padding: 0; }

.readonly-dl {
  display: grid;
  grid-template-columns: minmax(92px,.45fr) minmax(0,1fr);
  margin: 0;
}

.readonly-dl dt,
.readonly-dl dd {
  min-width: 0;
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-line);
  overflow-wrap: anywhere;
}

.readonly-dl dt { color: var(--color-muted); background: #f7f9f7; font-size: .82rem; }
.readonly-dl dd { font-weight: 600; }
.readonly-dl > :nth-last-child(-n+2) { border-bottom: 0; }

.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.profile-actions form { margin: 0; }

.answer-summary { display: grid; gap: 0; padding: 0; }
.answer-summary p { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--color-line); }
.answer-summary p:last-child { border-bottom: 0; }

.answer-list { margin: 0; padding: 0; list-style: none; counter-reset: answer; }

.answer-card { display: grid; gap: 8px; padding: var(--card-pad); }

.answer-card__prompt {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-weight: 700;
}

.answer-card__prompt::before {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: 8px;
  color: var(--color-primary);
  background: var(--color-soft);
  content: counter(answer);
  counter-increment: answer;
  font-size: .75rem;
  font-weight: 700;
}

.answer-card__value { margin: 0; white-space: pre-wrap; }
.answer-card .input,
.answer-card .select { width: 100%; }
.response-detail .status { margin-top: 12px; }
.response-detail__actions { display: flex; margin-top: 16px; }

.success-card {
  max-width: 640px;
  margin: 12px auto;
  padding: 30px 20px;
  text-align: center;
}

.success-card__icon {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 50%;
  color: var(--color-success);
  background: var(--color-success-soft);
}

.success-card__icon svg { width: 30px; height: 30px; }
.success-card p { color: var(--color-muted); }
.success-card__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* Pagination */

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.page-numbers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pagination .btn,
.page-ellipsis { min-width: var(--touch-min); min-height: var(--touch-min); }
.page-ellipsis { display: inline-flex; align-items: center; justify-content: center; color: var(--color-muted); }
.pagination .is-current { border-color: var(--color-primary); color: #fff; background: var(--color-primary); }

/* Auth and standalone states */

.auth-shell,
.standalone-shell {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: max(20px,env(safe-area-inset-top,0px)) 16px max(28px,env(safe-area-inset-bottom,0px));
}

.auth-shell .container,
.standalone-shell .container {
  width: min(100%,440px);
  margin: auto;
  padding: 0;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
  color: var(--brand-dark);
}

.auth-brand .brandmark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 13px;
  color: var(--brand-dark);
  background: var(--brand-accent);
  font-size: 1.25rem;
  font-weight: 800;
}

.brand__copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}
.brand__copy strong { line-height: 1.35; }
.brand__copy small {
  display: block;
  font-weight: 450;
  line-height: 1.55;
}
.auth-brand .brand__copy {
  flex: 1 1 auto;
  max-width: 18rem;
  min-width: 0;
}
.auth-brand strong { font-size: 1.15rem; }
.auth-brand small { display: block; color: var(--color-muted); font-size: .74rem; }
.auth-shell .pagehead { margin-bottom: 14px; }
.auth-shell .card { padding: 20px; }
.auth-shell form > .button { width: 100%; margin-top: 4px; }
.auth-shell .password-control { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.auth-shell .password-control .field__input { min-width: 0; }

#captcha-widget {
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  align-items: center;
  gap: 8px;
}

#captcha-widget img {
  width: auto;
  max-width: 128px;
  height: 48px;
  border: 1px solid var(--color-line);
  border-radius: 8px;
}

#captcha-widget .field__input { min-width: 0; }

.standalone-state { padding: 24px; text-align: center; }
.standalone-state .auth-brand { margin-bottom: 18px; }
.standalone-state h1 { margin-bottom: 8px; }
.standalone-state p { margin-bottom: 16px; color: var(--color-muted); }

/* Hierarchy search and native dialogs */

.school-search { margin-bottom: 16px; }
.school-search .ss-panel { max-width: 100%; }

dialog {
  max-width: calc(100vw - 32px);
  border: 0;
  border-radius: 18px;
  color: var(--color-base-content);
  background: #fff;
  box-shadow: 0 20px 70px rgba(18,63,51,.28);
}

dialog::backdrop { background: rgba(18,41,28,.45); backdrop-filter: blur(2px); }

.draft-choice {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  overflow: hidden;
  text-align: center;
}

.draft-choice[open] { animation: draft-choice-in .2s ease-out; }

@keyframes draft-choice-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.draft-choice__hero {
  padding: 28px 24px 20px;
  background:
    radial-gradient(140px 90px at 50% 0%, rgba(217, 245, 171, .7), transparent 72%),
    var(--color-soft);
}

.draft-choice__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  color: var(--color-primary);
  background: #fff;
  box-shadow: 0 8px 20px rgba(18, 102, 78, .12);
}

.draft-choice__icon svg { width: 26px; height: 26px; }

.draft-choice__hero h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -.02em;
}

.draft-choice__body {
  display: grid;
  gap: 16px;
  padding: 18px 22px 22px;
}

.draft-choice__body > p {
  margin: 0;
  color: var(--color-muted);
  font-size: .92rem;
  line-height: 1.85;
}

.draft-choice__actions { display: grid; gap: 8px; }

.draft-choice__actions .btn { width: 100%; min-height: 48px; }

.draft-choice__restart:hover {
  border-color: #e8b9b4;
  color: var(--color-danger);
  background: var(--color-danger-soft);
}

.draft-choice__note { font-size: .8rem; }

.draft-choice__error {
  color: var(--color-danger);
  font-size: .82rem;
}

@media (prefers-reduced-motion: reduce) {
  .draft-choice[open] { animation: none; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 359px) {
  .app-shell .container { padding-inline: 12px; }
  .app-shell .topbar { padding-inline: 10px; }
  .app-shell .mobile-brand { display: none; }
  .search-form { grid-template-columns: 1fr; }
  .search-form .btn { width: 100%; }
  .readonly-dl { grid-template-columns: 82px minmax(0,1fr); }
  .readonly-dl dt,
  .readonly-dl dd { padding-inline: 12px; }
}

@media (max-width: 619px) {
  .pagehead__actions { width: 100%; }
  .pagehead__actions .btn { width: 100%; }
}

@media (min-width: 620px) {
  .record-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  :root { --card-pad: 20px; --card-pad-compact: 14px; }
  .identity-card { padding: 28px; }
  .surface-section { padding: var(--card-pad); }
  .form-actions { margin-inline: 0; border: 1px solid var(--color-line); border-radius: 12px; }
}

@media (min-width: 768px) {
  .app-shell .container { padding: 28px 28px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .app-shell.no-mobile-nav .container,
  .app-shell.form-view .container { padding-bottom: 42px; }
  .app-shell .topbar { padding-inline: 28px; }
  .form-actions { position: static; box-shadow: none; }
  .form-actions .btn-primary { width: auto; min-width: 160px; }
  .record-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .pagehead { margin-bottom: 24px; }
  .success-card { padding: 42px 28px; }
}

@media (min-width: 1024px) {
  :root { --shell-mobile-nav: 0px; }
  html { scroll-padding-top: calc(var(--shell-topbar) + 20px); }
  .app-shell .side {
    position: fixed;
    z-index: 30;
    inset: 0 0 0 auto;
    display: flex;
    width: var(--shell-sidebar);
    flex-direction: column;
    padding: 26px 16px 20px;
    overflow-y: auto;
    border: 0;
    color: #dceae4;
    background: var(--brand-dark);
  }
  .app-shell .side .brand {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 22px;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 800;
  }
  .app-shell .side .brand__copy small {
    color: #c5ddd4;
    font-size: .68rem;
    font-weight: 450;
  }
  .app-shell .side .brandmark {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    border-radius: 12px;
    color: var(--brand-dark);
    background: var(--brand-accent);
    font-size: 1.18rem;
  }
  .app-shell .side-nav { display: grid; gap: 6px; }
  .app-shell .side-nav a {
    display: flex;
    min-height: 46px;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    color: #dceae4;
    font-size: .88rem;
    text-decoration: none;
  }
  .app-shell .side-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
  .app-shell .side-nav a.active {
    color: var(--brand-dark);
    background: var(--brand-accent);
    font-weight: 700;
  }
  .app-shell .workspace { margin-right: var(--shell-sidebar); }
  .app-shell .mobile-nav { display: none; }
  .app-shell .topbar { padding-inline: 30px; }
  .app-shell .mobile-brand { display: none; }
  .app-shell .container { padding: 30px 30px 48px; }
  .record-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .button,
  .btn,
  .card,
  .mobile-record,
  .record-card,
  .form-tile,
  .response-card,
  .plan-card,
  .task-card { border: 1px solid CanvasText; }
}

@media print {
  .side,
  .topbar,
  .mobile-nav,
  .page-actions,
  .profile-actions,
  .form-actions,
  .toolbar,
  .search-form,
  .filter-form,
  .skip-link,
  .skip { display: none !important; }
  body,
  .app-shell .workspace { margin: 0; background: #fff; }
  .app-shell .container { max-width: none; padding: 0; }
  .card,
  .record-card,
  .form-tile,
  .response-card,
  .plan-card,
  .task-card,
  .mobile-record { break-inside: avoid; box-shadow: none; }
}

/* Contextual page help — mobile-first bottom sheet */

.page-help { flex: 0 0 auto; }

/* Keep the control on the title line, beside the heading, so it does not
   stretch the row or push the following text. */
.pagehead__title-row:has(> .page-help) {
  justify-content: flex-start;
  align-items: center;
}

.pagehead__title-row:has(> .page-help) > h1 {
  flex: 0 1 auto;
}

.profile-hero__person > .page-help { align-self: flex-start; }

.success-card .pagehead__title-row:has(> .page-help) {
  flex-direction: column;
  align-items: center;
}

.success-card .pagehead__title-row > .page-help {
  order: -1;
  margin-bottom: 8px;
}

.success-card .pagehead__title-row:has(> .page-help) > h1 {
  width: 100%;
  flex: none;
  text-align: center;
}

.page-help__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: var(--touch-min);
  padding: 4px 12px 4px 10px;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: #fff;
  color: var(--color-primary);
  font-size: .8rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.page-help__btn:hover { background: var(--color-soft); }

.page-help__icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
}

.page-help__icon svg {
  width: 18px;
  height: 18px;
}

.page-help--compact .page-help__btn {
  min-height: 36px;
  padding: 2px 10px 2px 8px;
  font-size: .75rem;
}

.page-help-sheet {
  width: 100%;
  max-width: none;
  max-height: min(88dvh, 720px);
  margin: auto 0 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 20px 20px 0 0;
  color: var(--color-base-content);
  background: #fff;
}

.page-help-sheet:not([open]) { display: none; }

.page-help-sheet[open] {
  display: flex;
  flex-direction: column;
}

.page-help-sheet::backdrop {
  background: rgba(21, 60, 50, .42);
}

.page-help-sheet__head {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--color-line);
}

.page-help-sheet__handle {
  width: 36px;
  height: 4px;
  margin: 0 auto;
  border-radius: 999px;
  background: #d5e0da;
}

.page-help-sheet__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-help-sheet__row h2 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.45;
}

.page-help-sheet__row .btn { flex: 0 0 auto; }

.page-help-sheet__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 16px 18px 8px;
  font-size: 1.02rem;
  line-height: 1.9;
  -webkit-overflow-scrolling: touch;
}

.page-help-sheet__body h3 {
  margin: 1.15em 0 .35em;
  color: var(--color-primary);
  font-size: 1.02rem;
}

.page-help-sheet__body h3:first-child { margin-top: 0; }

.page-help-sheet__body p,
.page-help-sheet__body ol,
.page-help-sheet__body ul { margin: 0 0 .85em; }

.page-help-sheet__body ol,
.page-help-sheet__body ul { padding-inline-start: 1.25em; }

.page-help-sheet__body li { margin-bottom: .45em; }

.page-help-sheet__body li:last-child { margin-bottom: 0; }

.page-help-sheet__foot {
  display: flex;
  flex: 0 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--color-line);
  background: #fff;
}

.page-help-sheet__foot .btn { width: 100%; min-height: 48px; }

.identity-card .page-help__btn {
  border-color: rgba(255,255,255,.4);
  background: #fff;
  color: var(--color-primary);
  box-shadow: 0 4px 12px rgba(8, 32, 24, .18);
}

.quick-dialog__head .page-help {
  position: static;
  margin: 0;
  transform: none;
  align-self: center;
}

@media (min-width: 768px) {
  .page-help-sheet {
    width: min(520px, calc(100vw - 32px));
    max-height: min(80dvh, 680px);
    margin: auto;
    border-radius: 18px;
  }

  .page-help-sheet__handle { display: none; }

  .page-help-sheet__head { padding-top: 16px; }

  .page-help-sheet__body { font-size: 1rem; }
}
