:root {
  --bg: #f4f9ff;
  --panel: #ffffff;
  --panel-soft: #edf5ff;
  --primary: #4d79b7;
  --primary-dark: #2d4c7a;
  --primary-light: #dfeeff;
  --text: #1f2d3d;
  --muted: #5f728c;
  --border: rgba(45, 76, 122, 0.12);
  --shadow: 0 16px 34px rgba(39, 61, 92, 0.08);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --container: 1180px;
  --font-display: "Balsamiq Sans", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-body: "Balsamiq Sans", "Segoe UI", "Verdana", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: linear-gradient(180deg, #d8e8fb 0%, #b7d0ef 42%, #dceafa 100%);
  color: var(--text);
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button,
input {
  font: inherit;
}

.container {
  width: min(var(--container), calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-logo {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-weight: 600;
}

.nav-links a {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-links a:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6a8fcb);
  color: #fff;
  box-shadow: 0 12px 22px rgba(77, 121, 183, 0.2);
}

.btn-block {
  width: 100%;
  margin-top: 10px;
}

.page-shell {
  padding: 24px 0 28px;
}

.auth-page {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
  padding: 48px 16px;
}

.auth-intro {
  margin: -10px 0 24px;
  color: var(--muted);
}

.form-message {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.form-message-error {
  background: #fff0f0;
  color: #a33a3a;
  border: 1px solid #f0c7c7;
}

.form-message-success {
  background: #eefaf2;
  color: #2e7545;
  border: 1px solid #c6e8d0;
}

.account-section {
  padding: 14px 0 28px;
}

.account-card {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 26px 28px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.account-card h2 {
  margin: 0 0 18px;
  font-family: var(--font-display);
}

.form-section {
  padding: 14px 0 28px;
}

.form-card-stack {
  display: grid;
  gap: 16px;
}

.form-card-stack > .form-card {
  margin: 0 auto;
}

.planner-section {
  padding: 14px 0;
}

.feedback-section {
  padding: 10px 0;
}

.feedback-section .form-message {
  margin: 0;
}

.feedback-section + .planner-section {
  padding-top: 0;
}

.planner-section .table-wrap,
.planner-section .form-card {
  margin: 0 auto;
}

.planner-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
}

.planner-actions form,
.table-header form {
  margin: 0;
}

.section-heading h2 {
  margin: 0 0 18px;
  font-family: var(--font-display);
}

.form-card {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 26px 28px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.filter-card {
  width: 100%;
}

.form-card h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
}

.form-help {
  margin: 0 0 24px;
  color: var(--muted);
}

.kls-form {
  display: grid;
  gap: 10px;
}

#child-details-form {
  gap: 0;
}

.kls-form label {
  color: var(--text);
  font-weight: 700;
}

.kls-form label span {
  color: var(--muted);
  font-weight: 400;
}

.kls-form input {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fbff;
  color: var(--text);
}

.kls-form input:focus-visible {
  outline: 3px solid rgba(77, 121, 183, 0.32);
  outline-offset: 2px;
}

.kls-form .parent-approval-checkbox,
.kls-form .parent-response-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fbff;
  cursor: pointer;
  line-height: 1.45;
}

.kls-form .parent-approval-checkbox {
  padding: 12px 14px;
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

.kls-form .parent-approval-checkbox input[type="checkbox"],
.kls-form .parent-response-option input[type="radio"] {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--primary);
}

.kls-form .parent-response-options {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.kls-form .parent-response-options legend {
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 700;
}

.child-picker {
  position: relative;
}

.child-options {
  position: absolute;
  z-index: 10;
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: 0 8px 18px rgba(24, 42, 67, 0.14);
}

.child-option {
  display: block;
  width: 100%;
  padding: 0.7rem 0.95rem;
  border: 0;
  background: #fff;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.child-option:hover,
.child-option.is-highlighted {
  background: #eaf2fb;
}

.kls-form select,
.kls-select {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fbff;
  color: var(--text);
}

.kls-form select:focus-visible,
.kls-select:focus-visible {
  outline: 3px solid rgba(77, 121, 183, 0.32);
  outline-offset: 2px;
}

.kls-form textarea {
  width: 100%;
  min-height: 110px;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fbff;
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.kls-form textarea:focus-visible {
  outline: 3px solid rgba(77, 121, 183, 0.32);
  outline-offset: 2px;
}

.form-label {
  color: var(--text);
  font-weight: 700;
}

.status-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 6px;
}

.status-options label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.kls-form .status-options input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.btn-danger {
  background: #a33a3a;
  color: #fff;
  box-shadow: 0 12px 22px rgba(163, 58, 58, 0.18);
}

.kls-form .btn {
  justify-self: start;
  margin-top: 12px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-form {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.filter-form label {
  color: var(--text);
  font-weight: 700;
}

.archive-filter-form {
  grid-template-columns: auto minmax(160px, 1fr) auto minmax(160px, 1fr) auto minmax(160px, 1fr) auto;
}

.filter-form select {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fbff;
  color: var(--text);
  font: inherit;
}

.activity-filter-form .activity-select {
  width: 100%;
}

.activity-filter-form {
  grid-template-columns: auto minmax(180px, 1fr) auto minmax(240px, 2fr) auto minmax(180px, 1fr) auto;
}

.filter-form input[type="search"] {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fbff;
  color: var(--text);
  font: inherit;
}

.filter-form input[type="search"]:focus-visible {
  outline: 3px solid rgba(77, 121, 183, 0.32);
  outline-offset: 2px;
}

.activity-filter-form .activity-search {
  width: 50%;
}

.filter-form input[type="date"] {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fbff;
  color: var(--text);
  font: inherit;
}

.term-selector-form {
  grid-template-columns: minmax(240px, 1fr) auto;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.term-field {
  width: 100%;
  min-width: 150px;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fbff;
  color: var(--text);
  font: inherit;
}

.term-field:focus-visible {
  outline: 3px solid rgba(77, 121, 183, 0.32);
  outline-offset: 2px;
}

.term-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.term-actions form {
  margin: 0;
}

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary-dark);
}

@media (max-width: 700px) {
  .filter-form {
    grid-template-columns: 1fr;
  }

  .activity-filter-form .activity-select {
    width: 100%;
  }

  .activity-filter-form .activity-search {
    width: 100%;
  }

  .filter-actions {
    margin-top: 8px;
  }
}

@media (min-width: 701px) and (max-width: 1000px) {
  .archive-filter-form {
    grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .archive-filter-form .filter-actions {
    grid-column: 3 / -1;
  }
}

.password-panel summary {
  display: inline-flex;
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  cursor: pointer;
}

.password-panel form {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.password-panel label {
  color: var(--text);
  font-weight: 600;
}

.password-panel input {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fbff;
  color: var(--text);
}

.password-panel input:focus-visible,
.password-panel summary:focus-visible {
  outline: 3px solid rgba(77, 121, 183, 0.32);
  outline-offset: 3px;
}

.hero-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
  align-items: center;
}

.hero-copy {
  padding: 0;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.hero-copy h1 {
  margin: 0 0 14px;
  font-size: clamp(3rem, 5vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
  font-family: var(--font-display);
}

.hero-copy p {
  margin: 0;
  font-size: 1.05rem;
  color: var(--muted);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.action-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 74px;
  padding: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 22px rgba(31, 44, 61, 0.04);
  color: var(--primary-dark);
  font-weight: 700;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.action-card:hover,
.action-card:focus-visible {
  background: var(--primary-light);
  box-shadow: 0 16px 28px rgba(39, 61, 92, 0.14);
  transform: translateY(-3px);
}

.action-card:focus-visible {
  outline: 3px solid rgba(77, 121, 183, 0.32);
  outline-offset: 3px;
}

.login-panel {
  display: flex;
  justify-content: center;
}

.login-card {
  width: min(100%, 430px);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 28px;
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 3vw, 2.4rem);
  letter-spacing: -0.05em;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

.login-card input {
  width: 100%;
  border: 1px solid var(--border);
  background: #f9fbff;
  border-radius: 12px;
  padding: 0.9rem 0.95rem;
  color: var(--text);
}

.login-card input:focus {
  outline: 2px solid rgba(77, 121, 183, 0.18);
  border-color: rgba(77, 121, 183, 0.35);
}

.login-card textarea {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 0.9rem 0.95rem;
  border: 1px solid #c6e8d0;
  border-radius: 12px;
  background: #f9fffb;
  color: var(--text);
  font: 0.9rem/1.45 Consolas, "Courier New", monospace;
  resize: vertical;
}

.login-card textarea:focus-visible {
  outline: 3px solid rgba(77, 121, 183, 0.32);
  outline-offset: 2px;
}

.table-section {
  padding: 18px 0 44px;
}

.table-section > .table-wrap + .table-wrap {
  margin-top: 20px;
}

.table-wrap {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
}

.table-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2vw, 2rem);
  letter-spacing: -0.04em;
}

.table-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.table-header > span {
  color: var(--muted);
  font-weight: 600;
}

.device-link-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: center;
  gap: 12px 18px;
}

.device-link-meta form {
  margin: 0;
}

.device-access-panel > form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.device-access-panel > form + form {
  grid-template-columns: minmax(240px, 360px) auto;
}

.device-access-panel > .password-management-form {
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
}

.device-access-panel label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-weight: 600;
}

.device-access-panel label span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.device-access-panel input,
.device-access-panel textarea {
  width: 100%;
  min-width: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f9fbff;
  color: var(--text);
}

.device-access-panel textarea {
  min-height: 88px;
  font: inherit;
  resize: vertical;
}

.device-access-panel input:focus-visible,
.device-access-panel textarea:focus-visible {
  outline: 3px solid rgba(77, 121, 183, 0.32);
  outline-offset: 2px;
}

.device-access-panel .btn {
  white-space: nowrap;
}

.device-link-output {
  display: grid;
  gap: 8px;
  margin: 0 24px 20px;
}

.device-link-output a {
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: underline;
}

@media (max-width: 850px) {
  .device-access-panel > form,
  .device-access-panel > form + form {
    grid-template-columns: 1fr 1fr;
  }

  .device-access-panel > form .btn {
    justify-self: start;
  }
}

@media (max-width: 560px) {
  .device-access-panel .table-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .device-link-meta {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 8px;
  }

  .device-access-panel > form,
  .device-access-panel > form + form {
    grid-template-columns: 1fr;
  }

  .device-access-panel > form .btn {
    width: 100%;
  }

  .device-link-output {
    margin-right: 16px;
    margin-left: 16px;
  }
}

.kls-table th a {
  color: inherit;
  text-decoration: none;
}

.kls-table th a:hover,
.kls-table th a:focus-visible {
  text-decoration: underline;
}

.kls-table form {
  margin: 0;
}

.small-btn {
  padding: 0.7rem 1.2rem;
  font-size: 0.9rem;
}

.parent-signature-image {
  display: block;
  width: min(100%, 600px);
  height: auto;
  border: 1px solid var(--border);
  background: #fff;
}

.accident-original-description {
  margin-top: 0;
}

.accident-log {
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.accident-original-entry {
  margin-left: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.accident-update-list {
  margin: 16px 0 0;
  padding: 0;
  margin-left: 24px;
}

.accident-update-entry {
  padding: 12px 0;
}

.accident-update-entry + .accident-update-entry {
  border-top: 1px solid var(--border);
}

.accident-update-meta {
  margin-bottom: 4px;
  font-weight: 700;
}

.accident-review-state {
  display: inline-block;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.accident-review-state.is-pending {
  color: #8a4b08;
  background: #fff2df;
  border-color: #f0d3aa;
}

.accident-review-state.is-discussion {
  color: #9c2c2c;
  background: #fdeaea;
  border-color: #f0b4b4;
}

.accident-review-state.is-reviewed {
  color: #2e7545;
  background: #eefaf2;
  border-color: #c6e8d0;
}

.nappy-approval-button.btn-approval-saving:disabled {
  cursor: wait;
  transform: none;
}

.btn-approval-success {
  background: #2e7545;
  color: #fff;
}

.btn-approval-error {
  background: #a33a3a;
  color: #fff;
}

.approval-feedback {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
}

.approval-feedback.is-error {
  color: #a33a3a;
}

.kls-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.kls-table th,
.kls-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.approval-check-column {
  width: 14%;
  text-align: center;
  white-space: nowrap;
}

.approval-check-column input[type="checkbox"] {
  margin: 0;
}

.kls-table thead th {
  background: #f5f9ff;
  color: var(--primary-dark);
  font-weight: 800;
}

.summary-slot-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.summary-table .summary-spacer td {
  height: 18px;
  padding: 0;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--border);
}

.summary-table .summary-summary td {
  padding: 8px 18px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.summary-note {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.kls-table tbody tr:hover {
  background: #f7fbff;
}

.kls-table tbody td:first-child {
  font-weight: 700;
  color: var(--primary-dark);
}

.site-footer {
  padding: 18px 0 32px;
  color: var(--muted);
}

.footer-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-weight: 600;
}

@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
    justify-content: center;
    padding: 16px 0;
  }

  .nav-links {
    display: flex;
    flex-basis: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 20px;
  }

  .hero-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .brand {
    width: 100%;
    justify-content: center;
  }

}
