:root {
  color-scheme: light;
  --color-primary: #1a3a5c;
  --color-primary-deep: #102b46;
  --color-accent: #1d9e75;
  --color-accent-dark: #168362;
  --color-accent-soft: #e7f7f1;
  --color-bg: #f4f6fa;
  --color-surface: #ffffff;
  --color-surface-muted: #f8fafc;
  --color-surface-alt: #eef2ff;
  --color-text: #1a202c;
  --color-text-secondary: #5a7499;
  --color-text-faint: #8ca0ba;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-success: #1d9e75;
  --color-success-soft: #e7f7f1;
  --color-warning: #ba7413;
  --color-warning-soft: #fff5df;
  --color-danger: #c34e61;
  --color-danger-soft: #fff0f2;
  --color-info: #3973bf;
  --color-info-soft: #edf4ff;
  --sidebar-width: 232px;
  --content-max: 1440px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 2px 9px rgba(23, 42, 67, 0.045);
  --shadow-hover: 0 8px 22px rgba(23, 42, 67, 0.09);
  --shadow-modal: 0 24px 72px rgba(12, 30, 51, 0.24);
  --focus-ring: 0 0 0 3px rgba(29, 158, 117, 0.2);
  --ease: 160ms ease;
}

body[data-theme="dark"],
body.theme-dark,
body.dark-mode {
  color-scheme: dark;
  --color-primary: #163a5a;
  --color-primary-deep: #0c2238;
  --color-accent: #34b888;
  --color-accent-dark: #4ac69b;
  --color-accent-soft: #153c35;
  --color-bg: #0f1822;
  --color-surface: #172431;
  --color-surface-muted: #1b2c3b;
  --color-surface-alt: #1d3150;
  --color-text: #eff5f8;
  --color-text-secondary: #a9bfd3;
  --color-text-faint: #7e9ab4;
  --color-border: #2a3d4e;
  --color-border-strong: #3c5366;
  --color-success: #42c191;
  --color-success-soft: #153c35;
  --color-warning: #e3a140;
  --color-warning-soft: #44351d;
  --color-danger: #e47c8d;
  --color-danger-soft: #432631;
  --color-info: #73a8eb;
  --color-info-soft: #203653;
  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.17);
  --shadow-hover: 0 10px 26px rgba(0, 0, 0, 0.24);
  --shadow-modal: 0 24px 72px rgba(0, 0, 0, 0.48);
  --focus-ring: 0 0 0 3px rgba(66, 193, 145, 0.23);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--color-bg);
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--color-text);
  background: var(--color-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  transition: color var(--ease), background-color var(--ease);
}

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

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button,
input,
select,
textarea {
  border-radius: var(--radius-md);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

a {
  color: var(--color-accent-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--color-text);
  line-height: 1.25;
}

svg {
  display: block;
  flex: 0 0 auto;
}

::selection {
  color: #fff;
  background: var(--color-accent);
}

/* Overall application shell */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--color-bg);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  padding: 20px 14px 16px;
  overflow-y: auto;
  color: #f5fbff;
  background: var(--color-primary);
  box-shadow: 4px 0 18px rgba(20, 45, 70, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 3px 9px 4px;
}

.brand-mark {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #2eb189, #167a61);
  box-shadow: 0 5px 14px rgba(8, 42, 49, 0.26);
  font-size: 19px;
  font-weight: 800;
}

.brand-copy {
  min-width: 0;
}

.brand-word {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-tag {
  display: block;
  margin-top: 3px;
  color: rgba(237, 247, 251, 0.67);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  line-height: 1.2;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 31px;
}

.nav-label {
  margin: 0 10px 7px;
  color: rgba(239, 248, 252, 0.49);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 44px;
  gap: 11px;
  padding: 9px 11px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 10px;
  color: rgba(241, 248, 252, 0.74);
  background: transparent;
  font-size: 13px;
  font-weight: 610;
  text-align: left;
  transition: color var(--ease), background-color var(--ease), border-color var(--ease), transform var(--ease);
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.095);
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-item:active {
  transform: translateY(1px);
}

.nav-item.active,
.nav-item.is-active,
.nav-item[aria-current="page"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: inset 3px 0 0 var(--color-accent);
}

.nav-icon {
  display: grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  place-items: center;
  color: currentColor;
  font-size: 16px;
  line-height: 1;
}

.nav-item > span:first-child {
  display: grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  place-items: center;
  color: currentColor;
  font-size: 17px;
  line-height: 1;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.nav-item > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.sidebar-bottom .muted,
.sidebar-bottom small {
  display: block;
  color: rgba(238, 248, 251, 0.58);
  font-size: 11px;
}

.sidebar-bottom .notice .muted,
.sidebar-bottom .notice small {
  color: var(--color-text-secondary);
}

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

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 88px;
  gap: 20px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-surface) 95%, transparent);
}

.topbar-heading {
  min-width: 0;
}

.topbar-heading h1,
#page-title {
  overflow: hidden;
  color: var(--color-text);
  font-size: clamp(20px, 2vw, 25px);
  font-weight: 740;
  letter-spacing: -0.035em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-heading p,
#page-subtitle {
  max-width: 64ch;
  margin-top: 5px;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
}

#role-select {
  min-width: 146px;
}

#theme-toggle {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 11px;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  transition: color var(--ease), background-color var(--ease), border-color var(--ease), transform var(--ease);
}

#theme-toggle:hover {
  color: var(--color-primary);
  border-color: var(--color-border-strong);
  background: var(--color-surface-muted);
}

#theme-toggle:active {
  transform: scale(0.96);
}

.demo-banner {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  gap: 12px;
  margin: 22px auto 0;
  padding: 13px 17px;
  border: 1px solid #ccd9fa;
  border-radius: var(--radius-md);
  color: #35558d;
  background: var(--color-surface-alt);
  line-height: 1.45;
  width: min(calc(100% - 64px), var(--content-max));
}

.demo-banner strong {
  color: var(--color-primary);
  font-weight: 720;
}

.demo-banner .banner-icon {
  display: grid;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 8px;
  color: #4268b0;
  background: rgba(255, 255, 255, 0.58);
  font-size: 13px;
  font-weight: 800;
}

body[data-theme="dark"] .demo-banner,
body.theme-dark .demo-banner,
body.dark-mode .demo-banner {
  border-color: #304d75;
  color: #b9cbed;
}

body[data-theme="dark"] .demo-banner strong,
body.theme-dark .demo-banner strong,
body.dark-mode .demo-banner strong {
  color: #e1eaff;
}

main#app {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: 24px 32px 38px;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100%, var(--content-max));
  margin: auto auto 0;
  padding: 0 32px 24px;
  color: var(--color-text-faint);
  font-size: 11px;
}

/* Shared headings, actions, controls, and form fields */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-width: 0;
  gap: 18px;
  margin-bottom: 22px;
}

.page-header > :first-child {
  min-width: 0;
}

.page-header h2 {
  color: var(--color-text);
  font-size: 20px;
  font-weight: 740;
  letter-spacing: -0.025em;
}

.page-header p,
.page-description,
.card-description {
  margin-top: 5px;
  color: var(--color-text-secondary);
  font-size: 13px;
}

.section-label {
  margin-bottom: 11px;
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.075em;
  line-height: 1.3;
  text-transform: uppercase;
}

.actions-row,
.quick-actions,
.filter-row,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  gap: 8px;
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  transition: color var(--ease), background-color var(--ease), border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button-primary {
  border-color: var(--color-primary);
  color: #fff;
  background: var(--color-primary);
  box-shadow: 0 3px 7px rgba(26, 58, 92, 0.14);
}

.button-primary:hover {
  border-color: var(--color-primary-deep);
  background: var(--color-primary-deep);
  box-shadow: 0 6px 13px rgba(26, 58, 92, 0.2);
}

.button-secondary {
  border-color: var(--color-border-strong);
  color: var(--color-primary);
  background: var(--color-surface);
}

.button-secondary:hover {
  border-color: var(--color-primary);
  background: var(--color-surface-muted);
}

.button-danger {
  border-color: color-mix(in srgb, var(--color-danger) 48%, var(--color-border));
  color: var(--color-danger);
  background: var(--color-danger-soft);
}

.button-danger:hover {
  border-color: var(--color-danger);
  background: color-mix(in srgb, var(--color-danger-soft) 72%, var(--color-danger) 28%);
}

.button-small {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 12px;
}

.button .icon,
.button svg {
  width: 16px;
  height: 16px;
}

.select,
select,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="password"],
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--color-border-strong);
  border-radius: 10px;
  color: var(--color-text);
  outline: none;
  background: var(--color-surface);
  font-size: 14px;
  transition: border-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}

.select:hover,
select:hover,
input:hover,
textarea:hover {
  border-color: #9db0c6;
}

.select:focus,
select:focus,
input:focus,
textarea:focus {
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
}

select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text-secondary) 50%), linear-gradient(135deg, var(--color-text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 16px) 20px, calc(100% - 11px) 20px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

textarea {
  min-height: 108px;
  resize: vertical;
}

::placeholder {
  color: var(--color-text-faint);
  opacity: 1;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.field label,
.field > .field-label {
  color: var(--color-text);
  font-size: 12px;
  font-weight: 700;
}

.field small,
.help-text {
  color: var(--color-text-secondary);
  font-size: 11px;
}

.checkbox-list {
  display: grid;
  gap: 9px;
}

.checkbox-list label,
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  color: var(--color-text);
  font-size: 13px;
}

input[type="checkbox"],
input[type="radio"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--color-accent);
}

.muted {
  color: var(--color-text-secondary);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Cards and dashboard widgets */
.card,
.connection-card,
.parent-summary {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.card,
.connection-card,
.parent-summary {
  padding: 21px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-width: 0;
  gap: 14px;
  margin-bottom: 17px;
}

.card-header > :first-child {
  min-width: 0;
}

.card-title {
  overflow: hidden;
  color: var(--color-text);
  font-size: 15px;
  font-weight: 730;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
}

.card-header .button,
.card-header .button-small {
  flex: 0 0 auto;
}

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

.stat-card {
  position: relative;
  min-width: 0;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.stat-card::after {
  position: absolute;
  right: -22px;
  bottom: -27px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-accent-soft) 65%, transparent);
  content: "";
  pointer-events: none;
}

.stat-icon {
  display: grid;
  width: 35px;
  height: 35px;
  margin-bottom: 13px;
  place-items: center;
  border-radius: 10px;
  color: var(--color-primary);
  background: var(--color-surface-alt);
  font-size: 16px;
  font-weight: 750;
}

.stat-card:nth-child(2) .stat-icon {
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
}

.stat-card:nth-child(3) .stat-icon {
  color: var(--color-warning);
  background: var(--color-warning-soft);
}

.stat-card:nth-child(4) .stat-icon {
  color: var(--color-info);
  background: var(--color-info-soft);
}

.stat-label {
  display: block;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 680;
  letter-spacing: 0.045em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat-value {
  display: block;
  margin-top: 4px;
  color: var(--color-text);
  font-size: 26px;
  font-weight: 770;
  letter-spacing: -0.045em;
  line-height: 1.08;
}

.stat-note {
  display: block;
  margin-top: 6px;
  color: var(--color-text-secondary);
  font-size: 11px;
}

.grid,
.dashboard-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1.38fr) minmax(280px, 0.9fr);
  align-items: start;
  gap: 16px;
}

.grid > *,
.dashboard-grid > * {
  min-width: 0;
}

.grid-3,
.three-column {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.children-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.child-card {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.child-card:hover {
  border-color: color-mix(in srgb, var(--color-accent) 48%, var(--color-border));
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.avatar {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: var(--color-primary);
  background: var(--color-surface-alt);
  font-size: 15px;
  font-weight: 760;
}

.avatar-green {
  color: #126f58;
  background: var(--color-accent-soft);
}

.avatar-amber {
  color: #93600e;
  background: var(--color-warning-soft);
}

.avatar-blue {
  color: #2e61a6;
  background: var(--color-info-soft);
}

.child-info {
  min-width: 0;
}

.child-name {
  overflow: hidden;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.child-meta {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 720;
  line-height: 1.1;
  white-space: nowrap;
}

.badge-green {
  border-color: color-mix(in srgb, var(--color-success) 22%, transparent);
  color: var(--color-accent-dark);
  background: var(--color-success-soft);
}

.badge-amber {
  border-color: color-mix(in srgb, var(--color-warning) 22%, transparent);
  color: var(--color-warning);
  background: var(--color-warning-soft);
}

.badge-blue {
  border-color: color-mix(in srgb, var(--color-info) 22%, transparent);
  color: var(--color-info);
  background: var(--color-info-soft);
}

.badge-gray {
  border-color: var(--color-border);
  color: var(--color-text-secondary);
  background: var(--color-surface-muted);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.quick-action {
  display: flex;
  min-width: 0;
  min-height: 78px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 12px 13px;
  border: 1px solid var(--color-border);
  border-radius: 11px;
  color: var(--color-text);
  background: var(--color-surface-muted);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  transition: color var(--ease), background-color var(--ease), border-color var(--ease), transform var(--ease);
}

.quick-action:hover {
  border-color: color-mix(in srgb, var(--color-accent) 48%, var(--color-border));
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
  transform: translateY(-1px);
}

.quick-action .action-icon {
  color: var(--color-accent-dark);
  font-size: 17px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  min-width: 0;
  gap: 10px;
  padding-bottom: 18px;
}

.timeline-item:not(:last-child)::before {
  position: absolute;
  top: 31px;
  bottom: 0;
  left: 15px;
  width: 1px;
  background: var(--color-border);
  content: "";
}

.timeline-icon {
  position: relative;
  z-index: 1;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 3px solid var(--color-surface);
  border-radius: 50%;
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
  font-size: 12px;
  font-weight: 760;
  box-shadow: 0 0 0 1px var(--color-border);
}

.timeline-body {
  min-width: 0;
  padding-top: 3px;
}

.timeline-title {
  overflow: hidden;
  color: var(--color-text);
  font-size: 12px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-meta,
.timeline-note,
.timeline-time {
  color: var(--color-text-secondary);
  font-size: 11px;
}

.timeline-meta {
  margin-top: 2px;
}

.timeline-note {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.timeline-time {
  padding-top: 4px;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  min-height: 152px;
  padding: 24px;
  place-items: center;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  background: var(--color-surface-muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 3px;
  color: var(--color-text);
  font-size: 13px;
}

/* SereniKid's compact dashboard components */
.page-view {
  min-width: 0;
}

.section-block {
  min-width: 0;
  margin-top: 24px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-width: 0;
  gap: 12px;
  margin-bottom: 13px;
}

.section-heading > :first-child {
  min-width: 0;
}

.section-heading h2 {
  color: var(--color-text);
  font-size: 16px;
  font-weight: 740;
  letter-spacing: -0.02em;
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--color-accent-dark);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.1em;
  line-height: 1.25;
  text-transform: uppercase;
}

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

.summary-card {
  min-width: 0;
  padding: 17px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.card-label {
  display: block;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.card-value {
  display: block;
  margin-top: 7px;
  color: var(--color-primary);
  font-size: 27px;
  font-weight: 780;
  letter-spacing: -0.05em;
  line-height: 1.05;
}

.card-value small {
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}

.card-meta {
  display: block;
  margin-top: 7px;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-count {
  flex: 0 0 auto;
  color: var(--color-text-secondary);
  font-size: 11px;
}

.child-grid,
.quick-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
}

.child-grid .child-card {
  width: 100%;
  cursor: pointer;
  text-align: left;
}

.child-card.is-selected {
  border-color: color-mix(in srgb, var(--color-accent) 68%, var(--color-border));
  background: var(--color-accent-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 14%, transparent);
}

.child-card .child-meta {
  flex: 1 1 auto;
}

.child-card .child-meta strong,
.child-card .child-meta small {
  display: block;
}

.child-card .child-meta strong {
  overflow: hidden;
  color: var(--color-text);
  font-size: 12px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.child-card .child-meta small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checkmark {
  display: grid;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  font-size: 13px;
  font-weight: 800;
}

.child-card.is-selected .checkmark {
  border-color: var(--color-accent);
  color: #fff;
  background: var(--color-accent);
}

.quick-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.quick-grid .quick-action {
  min-height: 96px;
  align-items: center;
  text-align: center;
}

.quick-action > span:first-child {
  display: grid;
  width: 30px;
  height: 30px;
  margin-bottom: 4px;
  place-items: center;
  border-radius: 9px;
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
  font-size: 16px;
}

.quick-action strong {
  overflow: hidden;
  max-width: 100%;
  color: var(--color-text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-action small {
  color: var(--color-text-secondary);
  font-size: 10px;
}

.text-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 30px;
  padding: 5px 8px;
  border: 0;
  color: var(--color-accent-dark);
  background: transparent;
  font-size: 11px;
  font-weight: 720;
  text-decoration: none;
}

.text-button:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.parent-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 20px;
  padding: 23px 24px;
  border: 1px solid #d5e4e1;
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, var(--color-accent-soft), var(--color-surface));
  box-shadow: var(--shadow-card);
}

.parent-hero > :first-child {
  min-width: 0;
}

.parent-hero h2 {
  color: var(--color-primary);
  font-size: clamp(19px, 2.5vw, 25px);
  font-weight: 760;
  letter-spacing: -0.04em;
}

.parent-hero p {
  max-width: 54ch;
  margin-top: 6px;
  color: var(--color-text-secondary);
  font-size: 13px;
}

.parent-hero > .avatar {
  flex-basis: 58px;
  width: 58px;
  height: 58px;
  border-radius: 17px;
  font-size: 19px;
}

.ack-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 18px;
  margin-top: 14px;
  padding: 17px 19px;
  border: 1px solid color-mix(in srgb, var(--color-accent) 34%, var(--color-border));
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.ack-card > :first-child {
  min-width: 0;
}

.ack-card h3 {
  overflow: hidden;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 730;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ack-card p {
  margin-top: 4px;
  color: var(--color-text-secondary);
  font-size: 12px;
}

.role-note {
  margin-bottom: 17px;
}

.entry-list {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.entry-item {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr) auto auto;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
}

.entry-item + .entry-item {
  border-top: 1px solid var(--color-border);
}

.entry-icon {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 10px;
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
  font-size: 17px;
}

.entry-body {
  min-width: 0;
}

.entry-body strong,
.entry-body span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-body strong {
  color: var(--color-text);
  font-size: 13px;
  font-weight: 720;
}

.entry-body span {
  margin-top: 3px;
  color: var(--color-text-secondary);
  font-size: 13px;
}

.entry-time {
  align-self: center;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.entry-time small {
  display: block;
  margin-top: 2px;
  color: var(--color-text-secondary);
  font-size: 10px;
  font-weight: 500;
}

.icon-button {
  display: grid;
  width: 29px;
  height: 29px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 9px;
  color: var(--color-text-secondary);
  background: var(--color-surface-muted);
  font-size: 18px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--color-danger);
  color: var(--color-danger);
  background: var(--color-danger-soft);
}

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

.profile-card {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  text-align: left;
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.profile-card:hover {
  border-color: color-mix(in srgb, var(--color-accent) 50%, var(--color-border));
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.profile-card > span:nth-child(2) {
  display: block;
  min-width: 0;
  flex: 1 1 auto;
}

.profile-card strong,
.profile-card small,
.profile-card em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-card strong {
  color: var(--color-text);
  font-size: 13px;
  font-weight: 720;
}

.profile-card small,
.profile-card em {
  margin-top: 3px;
  color: var(--color-text-secondary);
  font-size: 11px;
  font-style: normal;
}

.profile-card em {
  color: var(--color-accent-dark);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 14px;
}

.toolbar label {
  flex: 0 0 auto;
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 680;
}

.filter-select {
  width: min(100%, 230px);
}

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

.connection-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease), background-color var(--ease);
}

.connection-card:hover {
  border-color: color-mix(in srgb, var(--color-accent) 48%, var(--color-border));
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.connection-card.is-selected {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 15%, transparent);
}

.connection-card strong {
  color: var(--color-text);
  font-size: 15px;
  font-weight: 740;
}

.connection-card span,
.connection-card small {
  color: var(--color-text-secondary);
  font-size: 12px;
}

.connection-card small {
  margin-top: 4px;
  color: var(--color-accent-dark);
  font-size: 11px;
  font-weight: 650;
}

.connection-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.connection-panel > p {
  max-width: 65ch;
  color: var(--color-text-secondary);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  min-height: 26px;
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-secondary);
  background: var(--color-surface-muted);
  font-size: 11px;
  font-weight: 700;
}

.status-pill.is-connected {
  border-color: color-mix(in srgb, var(--color-accent) 30%, var(--color-border));
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--color-text);
  font-size: 12px;
}

.consent-row input {
  flex: 0 0 auto;
  margin-top: 1px;
}

/* Parent, messages, connections, and list views */
.filter-row {
  margin-bottom: 18px;
}

.filter-row > * {
  flex: 0 1 190px;
}

.filter-row > .button {
  flex: 0 0 auto;
}

.connection-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.connection-card > :first-child {
  min-width: 0;
}

.connection-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 17px;
}

.connection-option {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text);
  background: var(--color-surface-muted);
}

.connection-option > :first-child {
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  color: var(--color-primary);
  background: var(--color-surface-alt);
}

.connection-option strong {
  display: block;
  font-size: 12px;
  font-weight: 720;
}

.connection-option small {
  display: block;
  margin-top: 2px;
  color: var(--color-text-secondary);
  font-size: 11px;
}

.message-list {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
}

.message-bubble {
  align-self: flex-start;
  max-width: min(78%, 570px);
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: 4px 14px 14px 14px;
  color: var(--color-text);
  background: var(--color-surface-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.message-bubble.sent {
  align-self: flex-end;
  border-color: color-mix(in srgb, var(--color-accent) 25%, var(--color-border));
  border-radius: 14px 4px 14px 14px;
  background: var(--color-accent-soft);
}

.message-bubble .message-meta {
  display: block;
  margin-top: 5px;
  color: var(--color-text-secondary);
  font-size: 10px;
}

.message-item {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
}

.message-item.from-parent {
  align-items: flex-start;
}

.message-item.from-creche {
  align-items: flex-end;
}

.message-item.from-creche .message-bubble {
  align-self: auto;
  border-color: color-mix(in srgb, var(--color-accent) 25%, var(--color-border));
  border-radius: 14px 4px 14px 14px;
  background: var(--color-accent-soft);
}

.message-meta {
  display: block;
  margin-top: 4px;
  color: var(--color-text-secondary);
  font-size: 10px;
}

.message-meta b {
  color: var(--color-accent-dark);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.message-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.message-form textarea {
  min-height: 50px;
  max-height: 150px;
  resize: vertical;
}

.message-form .button {
  flex: 0 0 auto;
}

.message-compose {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 19px;
}

.message-compose > label {
  color: var(--color-text);
  font-size: 12px;
  font-weight: 700;
}

.message-compose > div {
  display: flex;
  align-items: stretch;
  gap: 9px;
}

.message-compose input {
  min-width: 0;
  flex: 1 1 auto;
}

.message-compose .button {
  flex: 0 0 auto;
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.quick-replies button {
  min-height: 31px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  font-size: 11px;
}

.quick-replies button:hover {
  color: var(--color-accent-dark);
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.chip {
  min-height: 31px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  font-size: 11px;
  transition: color var(--ease), border-color var(--ease), background-color var(--ease), transform var(--ease);
}

.chip:hover {
  color: var(--color-accent-dark);
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  transform: translateY(-1px);
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text-secondary);
  background: var(--color-surface-muted);
  font-size: 12px;
}

.notice-success {
  border-color: color-mix(in srgb, var(--color-success) 30%, var(--color-border));
  color: var(--color-accent-dark);
  background: var(--color-success-soft);
}

.notice-warning {
  border-color: color-mix(in srgb, var(--color-warning) 30%, var(--color-border));
  color: var(--color-warning);
  background: var(--color-warning-soft);
}

.parent-summary {
  padding: 0;
  overflow: hidden;
}

.parent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border);
}

.parent-header > :first-child {
  min-width: 0;
}

.parent-header .avatar {
  flex-basis: 44px;
  width: 44px;
  height: 44px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 22px;
  padding: 19px 20px 21px;
}

.profile-grid .profile-item {
  min-width: 0;
}

.profile-grid .profile-label {
  display: block;
  margin-bottom: 3px;
  color: var(--color-text-secondary);
  font-size: 11px;
}

.profile-grid .profile-value {
  display: block;
  overflow: hidden;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list {
  display: flex;
  flex-direction: column;
}

.list .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--color-border);
}

.list .row:first-child {
  padding-top: 0;
}

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

.list .row > :first-child {
  min-width: 0;
}

.list .row strong {
  display: block;
  color: var(--color-text);
  font-size: 12px;
}

.list .row small {
  display: block;
  margin-top: 3px;
  color: var(--color-text-secondary);
  font-size: 11px;
}

.selected {
  border-color: color-mix(in srgb, var(--color-accent) 54%, var(--color-border));
  background: var(--color-accent-soft);
}

.check-dot {
  display: inline-grid;
  flex: 0 0 19px;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  color: #fff;
  background: transparent;
  font-size: 11px;
}

.selected .check-dot,
.check-dot.selected {
  border-color: var(--color-accent);
  background: var(--color-accent);
}

.child-select {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color var(--ease), background-color var(--ease);
}

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

.child-select.selected {
  border-color: var(--color-accent);
}

.child-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.child-check {
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text);
  background: var(--color-surface-muted);
  cursor: pointer;
  transition: border-color var(--ease), background-color var(--ease);
}

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

.child-check input {
  grid-row: span 2;
}

.child-check > span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.child-check small {
  min-width: 0;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

fieldset.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.field legend {
  margin-bottom: 7px;
  color: var(--color-text);
  font-size: 12px;
  font-weight: 700;
}

/* Modal and transient feedback */
dialog#entry-dialog {
  width: min(100% - 32px, 580px);
  max-height: min(88vh, 760px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: var(--shadow-modal);
}

dialog#entry-dialog::backdrop {
  background: rgba(10, 28, 47, 0.46);
  backdrop-filter: blur(3px);
}

dialog#entry-dialog form {
  display: flex;
  min-height: 0;
  max-height: min(88vh, 760px);
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 21px 23px 17px;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h2,
.modal-header h3 {
  color: var(--color-text);
  font-size: 18px;
  font-weight: 740;
}

.modal-body {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
  padding: 21px 23px;
  overflow-y: auto;
}

.modal-actions {
  justify-content: flex-end;
  padding: 15px 23px 21px;
  border-top: 1px solid var(--color-border);
}

.modal-actions .button {
  min-width: 100px;
}

#toast.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  max-width: min(360px, calc(100vw - 32px));
  padding: 13px 16px;
  border: 1px solid color-mix(in srgb, var(--color-accent) 34%, var(--color-border));
  border-radius: 12px;
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: var(--shadow-hover);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

#toast.toast.show {
  opacity: 1;
  transform: translateY(0);
}

#toast.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

#close-entry {
  min-width: 42px;
  width: 42px;
  min-height: 42px;
  padding: 8px;
  font-size: 20px;
  line-height: 1;
}

.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;
}

/* Responsive navigation and compact layouts */
@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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

@media (max-width: 940px) {
  :root {
    --sidebar-width: 208px;
  }

  .sidebar {
    padding-right: 11px;
    padding-left: 11px;
  }

  .topbar,
  main#app {
    padding-right: 24px;
    padding-left: 24px;
  }

  .demo-banner {
    width: calc(100% - 48px);
  }

  .grid,
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    width: 100%;
    height: auto;
    padding: 7px 8px max(7px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.13);
    box-shadow: 0 -6px 22px rgba(12, 37, 57, 0.14);
    overflow: visible;
  }

  .brand,
  .sidebar-bottom,
  .nav-label,
  .sidebar > .section-label {
    display: none;
  }

  .nav {
    display: flex;
    width: 100%;
    flex-direction: row;
    gap: 3px;
    margin: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

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

  .nav-item {
    display: flex;
    flex: 1 1 0;
    width: 20%;
    min-width: 0;
    min-height: 52px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 5px 8px;
    border-radius: 9px;
    font-size: 10px;
    text-align: center;
    white-space: normal;
    line-height: 1.15;
  }

  .nav-item.active,
  .nav-item.is-active,
  .nav-item[aria-current="page"] {
    box-shadow: inset 0 2px 0 var(--color-accent);
  }

  .nav-icon {
    flex-basis: 19px;
    width: 19px;
    height: 19px;
    font-size: 15px;
  }

  .nav-item > span:first-child {
    flex-basis: 19px;
    width: 19px;
    height: 19px;
    font-size: 15px;
  }

  .nav-item > span:last-child {
    max-width: 76px;
  }

  .workspace {
    min-height: calc(100vh - 66px);
    padding-bottom: 67px;
  }

  .topbar {
    min-height: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding-top: 15px;
    padding-bottom: 15px;
  }

  .topbar-heading p,
  #page-subtitle {
    font-size: 12px;
    white-space: normal;
  }

  .topbar-heading h1,
  #page-title {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .topbar-controls {
    width: 100%;
  }

  #role-select {
    min-width: 0;
    max-width: none;
    flex: 1 1 auto;
  }

  main#app {
    padding-top: 20px;
    padding-bottom: 30px;
  }

  .app-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding-right: 24px;
    padding-bottom: 86px;
    padding-left: 24px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
    margin-bottom: 18px;
  }

  .page-header .actions-row {
    width: 100%;
  }

  .page-header .actions-row .button {
    flex: 1 1 auto;
  }

  .connection-card {
    flex-direction: column;
  }

  .connection-card > .button,
  .connection-card > .actions-row {
    width: 100%;
  }

  .connection-card > .button {
    flex: 1;
  }

  .message-bubble {
    max-width: 89%;
  }

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

  .connection-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

@media (max-width: 520px) {
  .topbar,
  main#app {
    padding-right: 16px;
    padding-left: 16px;
  }

  .topbar {
    align-items: flex-start;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .topbar-heading h1,
  #page-title {
    font-size: 19px;
  }

  .topbar-heading p,
  #page-subtitle {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .topbar-controls {
    gap: 6px;
  }

  #role-select {
    min-width: 0;
    max-width: none;
    padding-right: 27px;
    font-size: 14px;
  }

  #theme-toggle {
    width: 40px;
    height: 40px;
  }

  .demo-banner {
    width: calc(100% - 32px);
    margin-top: 15px;
    padding: 11px 12px;
    font-size: 12px;
  }

  .stats-grid,
  .children-grid,
  .child-grid,
  .quick-grid,
  .connection-options,
  .grid-3,
  .three-column,
  .profile-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats-grid {
    gap: 10px;
    margin-bottom: 15px;
  }

  .stat-card {
    padding: 15px;
  }

  .stat-icon {
    margin-bottom: 9px;
  }

  .stat-value {
    font-size: 23px;
  }

  .card,
  .connection-card {
    padding: 16px;
  }

  .card-header {
    gap: 9px;
    margin-bottom: 13px;
  }

  .quick-actions {
    gap: 8px;
  }

  .quick-action {
    min-height: 68px;
    padding: 10px;
  }

  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-row > * {
    flex: 1 1 auto;
    width: 100%;
  }

  .summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .parent-hero,
  .ack-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .parent-hero > .avatar {
    order: -1;
  }

  .ack-card .button {
    width: 100%;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-select {
    width: 100%;
  }

  .child-picker {
    grid-template-columns: minmax(0, 1fr);
  }

  .message-form {
    align-items: stretch;
    flex-direction: column;
  }

  .message-form .button {
    width: 100%;
  }

  .message-compose > div {
    align-items: stretch;
    flex-direction: column;
  }

  .message-compose .button {
    width: 100%;
  }

  .parent-header {
    align-items: flex-start;
    padding: 16px;
  }

  .profile-grid {
    padding: 16px;
  }

  .timeline-item {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 9px;
  }

  .timeline-time {
    grid-column: 2;
    padding-top: 0;
  }

  .timeline-item:not(:last-child)::before {
    left: 14px;
  }

  .modal-header,
  .modal-body,
  .modal-actions {
    padding-right: 16px;
    padding-left: 16px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .button {
    width: 100%;
  }

  #toast.toast {
    right: 16px;
    bottom: 80px;
    left: 16px;
    max-width: none;
  }
}

@media (max-width: 390px) {
  .nav-item {
    min-width: 0;
    padding-right: 6px;
    padding-left: 6px;
  }

  .topbar-heading p,
  #page-subtitle {
    display: none;
  }

  .topbar-controls {
    min-width: 0;
  }

  #role-select {
    min-width: 0;
    max-width: none;
  }

  .demo-banner {
    margin-top: 12px;
  }

  .page-header h2 {
    font-size: 19px;
  }

  .button {
    padding-right: 13px;
    padding-left: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Real account and workspace additions */
.auth-shell {
  display: grid;
  min-height: 100vh;
  padding: 28px 18px;
  place-items: center;
  background: radial-gradient(circle at 8% 8%, rgba(29, 158, 117, .13), transparent 32%), var(--color-bg);
}

.auth-panel {
  width: min(100%, 510px);
  padding: 34px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-surface);
  box-shadow: var(--shadow-hover);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--color-text);
}

.auth-brand:hover { text-decoration: none; }
.auth-brand > span:last-child { display: grid; gap: 2px; }
.auth-brand strong { font-size: 19px; letter-spacing: -.035em; }
.auth-brand strong span, .brand-word span { color: var(--color-accent); }
.auth-brand small { color: var(--color-text-secondary); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.auth-copy { margin: 42px 0 22px; }
.auth-copy h1 { font-size: clamp(25px, 5vw, 34px); letter-spacing: -.045em; }
.auth-copy p { max-width: 45ch; margin-top: 8px; color: var(--color-text-secondary); }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form > .button { width: 100%; margin-top: 4px; }
.auth-help, .auth-demo { margin-top: 18px; color: var(--color-text-secondary); font-size: 12px; }
.auth-demo { margin-top: 28px; padding-top: 19px; border-top: 1px solid var(--color-border); text-align: center; }
.invite-preview { display: grid; gap: 4px; margin-bottom: 18px; padding: 14px; border: 1px solid color-mix(in srgb, var(--color-accent) 26%, var(--color-border)); border-radius: 12px; background: var(--color-accent-soft); }
.invite-preview strong { color: var(--color-text); font-size: 15px; }
.invite-preview span, .invite-preview small { color: var(--color-text-secondary); font-size: 12px; }
.role-pill { display: inline-flex; min-height: 31px; align-items: center; padding: 5px 10px; border: 1px solid color-mix(in srgb, var(--color-accent) 26%, var(--color-border)); border-radius: 999px; color: var(--color-accent-dark); background: var(--color-accent-soft); font-size: 11px; font-weight: 750; }
.global-error { width: min(calc(100% - 64px), var(--content-max)); margin: 17px auto 0; }
.demo-link { display: block; margin-top: 16px; color: rgba(238, 248, 251, .7); font-size: 11px; text-decoration: underline; }
.demo-link:hover { color: #fff; }
.selection-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.selection-tools .filter-select { width: 190px; min-height: 38px; padding-top: 7px; padding-bottom: 7px; }
.signal-list, .management-list { display: grid; gap: 9px; }
.signal-item, .management-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface); box-shadow: var(--shadow-card); }
.signal-item > div, .management-row > div:first-child { min-width: 0; }
.signal-item strong, .management-row strong { display: block; color: var(--color-text); font-size: 13px; }
.signal-item span, .management-row span { display: block; margin-top: 3px; color: var(--color-text-secondary); font-size: 11px; }
.entry-actions { display: flex; align-items: center; gap: 6px; }
.entry-photos { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.entry-photos img { width: 74px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--color-surface-muted); }
.real-profile-grid { padding: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.real-profile-grid .profile-card { align-items: flex-start; }
.profile-actions, .row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.danger-text { color: var(--color-danger); }
.inline-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 10px; padding: 16px; border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface); box-shadow: var(--shadow-card); }
.inline-form .field-wide { grid-column: span 2; }
.inline-form > .button { min-height: 46px; }
.parent-toolbar { display: flex; align-items: center; gap: 10px; }
.parent-toolbar label { color: var(--color-text-secondary); font-size: 12px; font-weight: 700; }
.parent-toolbar select { width: min(100%, 280px); }
.card .message-list { margin-top: 22px; }
.form-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.photo-upload { padding-top: 2px; }
.management-grid { display: grid; gap: 16px; }
.management-row { align-items: flex-start; }
.management-row .row-actions { flex: 0 0 auto; }
.share-url { width: min(100%, 430px); min-height: 35px; margin-top: 8px; padding: 7px 9px; border: 1px solid var(--color-border); border-radius: 8px; color: var(--color-text-secondary); background: var(--color-surface-muted); font-size: 11px; }
.report-card { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.pairing-code { display: grid; gap: 5px; padding: 17px; border: 1px solid color-mix(in srgb, var(--color-accent) 30%, var(--color-border)); border-radius: 12px; color: var(--color-text-secondary); background: var(--color-accent-soft); }
.pairing-code strong { color: var(--color-primary); font-size: 28px; letter-spacing: .13em; }
.pairing-code small { font-size: 11px; }
dialog#app-modal { width: min(100% - 32px, 610px); max-height: min(90vh, 780px); padding: 0; overflow: hidden; border: 1px solid var(--color-border); border-radius: 16px; color: var(--color-text); background: var(--color-surface); box-shadow: var(--shadow-modal); }
dialog#app-modal::backdrop { background: rgba(10, 28, 47, .46); backdrop-filter: blur(3px); }
dialog#app-modal form { display: flex; max-height: min(90vh, 780px); flex-direction: column; }
dialog#app-modal .modal-body { overflow-y: auto; }
.modal-error { margin: 16px 23px 0; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--color-danger) 34%, var(--color-border)); border-radius: 10px; color: var(--color-danger); background: var(--color-danger-soft); font-size: 12px; }

@media (max-width: 760px) {
  .auth-panel { padding: 25px 21px; }
  .global-error { width: calc(100% - 32px); }
  .selection-tools { width: 100%; align-items: stretch; }
  .selection-tools .filter-select, .selection-tools .button { flex: 1 1 160px; width: auto; }
  .real-profile-grid { grid-template-columns: minmax(0, 1fr); }
  .inline-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form .field-wide { grid-column: span 2; }
  .inline-form > .button { grid-column: span 2; }
}

@media (max-width: 520px) {
  .auth-shell { padding: 14px; }
  .auth-panel { padding: 21px 17px; border-radius: 15px; }
  .auth-copy { margin-top: 30px; }
  .signal-item, .management-row, .report-card { align-items: stretch; flex-direction: column; }
  .management-row .row-actions, .report-card .button { width: 100%; }
  .management-row .row-actions .button, .report-card .button { flex: 1; }
  .form-two, .inline-form { grid-template-columns: minmax(0, 1fr); }
  .inline-form .field-wide, .inline-form > .button { grid-column: auto; }
  .entry-item { grid-template-columns: 35px minmax(0, 1fr); }
  .entry-time, .entry-actions { grid-column: 2; justify-self: start; text-align: left; }
  .entry-actions { flex-wrap: wrap; }
  .modal-error { margin-right: 16px; margin-left: 16px; }
}
