:root {
  color-scheme: light;
  --ink: #1d2433;
  --muted: #657084;
  --line: #d9dee8;
  --panel: #ffffff;
  --paper: #f6f7f2;
  --accent: #2166f3;
  --accent-dark: #164ebc;
  --green: #157a50;
  --amber: #a35d00;
  --red: #b42318;
  --teal: #0f766e;
  --shadow: 0 18px 50px rgba(30, 42, 70, 0.12);
  --header: #17324d;
  --soft: #f8fafc;
  --button-soft: #eef2f7;
  --button-text: #27344a;
  --row-hover: rgba(33, 102, 243, 0.1);
  --card-note: #e7f0ff;
}

body.dark-mode {
  color-scheme: dark;
  --ink: #edf2ff;
  --muted: #a8b3c7;
  --line: #344157;
  --panel: #182234;
  --paper: #0e1522;
  --accent: #6ea2ff;
  --accent-dark: #9cc0ff;
  --green: #66d29b;
  --amber: #f2b35d;
  --red: #ff8f82;
  --teal: #72d4ca;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --header: #111b2c;
  --soft: #202c42;
  --button-soft: #26344c;
  --button-text: #e8efff;
  --row-hover: rgba(110, 162, 255, 0.18);
  --card-note: #1d3558;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-width: 320px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  align-items: center;
  background: var(--header);
  color: white;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 44px);
}

.app-header h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: #7a8496;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-header .eyebrow {
  color: #b8d4ff;
}

.app-header h1 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  margin-top: 5px;
}

.header-actions,
menu,
.filters,
.quick-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.date-control {
  color: #dce9ff;
  display: grid;
  font-size: 0.78rem;
  gap: 4px;
}

.date-control input {
  margin: 0;
  min-height: 42px;
  width: 160px;
}

.sync-status {
  align-self: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  color: #dce9ff;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 9px 12px;
  white-space: nowrap;
}

main {
  margin: 0 auto;
  max-width: 1320px;
  padding: 24px clamp(16px, 4vw, 40px) 42px;
}

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

.summary-grid article,
.left-panel,
.detail-panel,
.class-board,
.history-board {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-grid article {
  padding: 18px;
}

.summary-grid span {
  display: block;
  font-size: 2rem;
  font-weight: 800;
}

.summary-grid p {
  color: var(--muted);
  margin-top: 4px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
  margin-top: 18px;
}

.left-panel,
.detail-panel,
.class-board,
.history-board {
  padding: 18px;
}

.panel-heading,
.child-profile,
.pickup-strip {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading h2 {
  margin-top: 4px;
}

.search-box {
  display: grid;
  gap: 7px;
  margin: 18px 0 12px;
}

.import-box {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 13px;
}

.helper-text {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  margin-top: 7px;
  padding: 12px 13px;
  width: 100%;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(33, 102, 243, 0.16);
}

.primary-button,
.ghost-button,
.icon-button,
.danger-button {
  border: 0;
  border-radius: 6px;
  font-weight: 800;
  min-height: 42px;
  padding: 0 15px;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.ghost-button,
.icon-button {
  background: var(--button-soft);
  color: var(--button-text);
}

.danger-button {
  background: #fff0ee;
  color: var(--red);
}

.filter-chip {
  background: var(--button-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--button-text);
  min-height: 34px;
  padding: 0 12px;
}

.filter-chip.active {
  background: #e7f0ff;
  border-color: #9fc2ff;
  color: var(--accent-dark);
  font-weight: 800;
}

.child-list {
  display: grid;
  gap: 9px;
  margin-top: 16px;
  max-height: 58vh;
  overflow: auto;
  padding-right: 4px;
}

.child-row {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: 42px 1fr auto;
  padding: 10px;
  text-align: left;
}

.child-row:hover,
.child-row.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--row-hover);
}

.avatar,
.large-avatar {
  align-items: center;
  background: #daefe9;
  border-radius: 50%;
  color: var(--teal);
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
}

.avatar {
  height: 42px;
  width: 42px;
}

.large-avatar {
  font-size: 1.7rem;
  height: 68px;
  width: 68px;
}

.row-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.row-main strong,
.row-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-main small {
  color: var(--muted);
}

.status-pill {
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 6px 9px;
  white-space: nowrap;
}

.status-away {
  background: var(--button-soft);
  color: var(--muted);
}

.status-in {
  background: #e5f6ee;
  color: var(--green);
}

.status-out {
  background: #fff3df;
  color: var(--amber);
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: grid;
  min-height: 360px;
  place-content: center;
  text-align: center;
}

.empty-state h2 {
  color: var(--ink);
  margin-bottom: 8px;
}

.child-profile {
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.profile-left {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.profile-left h2 {
  overflow-wrap: anywhere;
}

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

.meta-card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
}

.meta-card strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.pickup-strip {
  background: #fff8e9;
  border: 1px solid #f4d08a;
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 14px;
}

.pickup-code {
  color: #6c3f00;
  font-size: clamp(1.7rem, 5vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.pickup-dialog {
  max-width: 540px;
  padding: 18px;
  width: min(calc(100vw - 32px), 540px);
}

.photo-card {
  background: var(--panel);
  border: 2px solid #17324d;
  border-radius: 8px;
  color: #17324d;
  display: grid;
  gap: 16px;
  padding: clamp(20px, 5vw, 34px);
  text-align: center;
  width: 100%;
}

.photo-card h2 {
  font-size: clamp(1.4rem, 5vw, 2rem);
}

.photo-card .photo-code {
  align-items: center;
  background: #fff8e9;
  border: 1px solid #f4d08a;
  border-radius: 8px;
  color: #6c3f00;
  display: flex;
  font-size: clamp(3.2rem, 14vw, 5.4rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  justify-content: center;
  letter-spacing: 0.04em;
  line-height: 1;
  min-height: 128px;
  overflow: hidden;
  padding: 20px 10px;
  text-align: center;
  white-space: nowrap;
  width: 100%;
}

.photo-card .photo-meta {
  color: #46566f;
  display: grid;
  font-size: 1.1rem;
  gap: 6px;
}

.photo-card .photo-note {
  background: var(--card-note);
  border-radius: 8px;
  color: #164ebc;
  font-weight: 800;
  padding: 12px;
}

.timeline {
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  gap: 7px;
  margin-top: 18px;
  padding-top: 16px;
}

.class-board,
.history-board {
  margin-top: 18px;
}

.class-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 16px;
}

.class-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.class-card h3 {
  margin: 0 0 10px;
}

.class-card ul {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.class-card li {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
}

.analysis-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  margin-top: 16px;
}

.analysis-card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.analysis-card span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 7px;
}

.analysis-card strong {
  display: block;
  font-size: 1.45rem;
  overflow-wrap: anywhere;
}

.history-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
  overflow: auto;
}

.history-table table {
  border-collapse: collapse;
  min-width: 720px;
  width: 100%;
}

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

.history-table th {
  background: var(--soft);
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.history-table tr:last-child td {
  border-bottom: 0;
}

.history-link {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  font-weight: 800;
  padding: 0;
}

.mini-history {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 9px;
  margin-top: 16px;
  padding-top: 16px;
}

.mini-history h3 {
  margin: 0;
}

.mini-history ul {
  display: grid;
  gap: 7px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.mini-history li {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 30px 70px rgba(10, 20, 35, 0.28);
  max-width: 720px;
  width: min(calc(100vw - 28px), 720px);
}

dialog::backdrop {
  background: rgba(15, 24, 38, 0.45);
}

.dialog-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

.round-button {
  background: var(--button-soft);
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  font-size: 1.5rem;
  height: 38px;
  line-height: 1;
  width: 38px;
}

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

.full {
  grid-column: 1 / -1;
}

menu {
  justify-content: flex-end;
  margin: 20px 0 0;
  padding: 0;
}

@media (max-width: 860px) {
  .app-header,
  .panel-heading,
  .child-profile,
  .pickup-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .workbench,
  .meta-grid,
  .form-grid,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    padding: 18px 16px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .header-actions .date-control {
    grid-column: 1 / -1;
  }

  .sync-status {
    grid-column: 1 / -1;
    justify-self: start;
    white-space: normal;
  }

  .date-control input {
    width: 100%;
  }

  .header-actions button,
  .header-actions .primary-button,
  .header-actions .icon-button {
    min-width: 0;
    padding-inline: 10px;
    width: 100%;
  }

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

  .child-list {
    max-height: none;
  }

  .detail-panel {
    min-width: 0;
  }

  .quick-actions {
    align-items: stretch;
    width: 100%;
  }

  .quick-actions button {
    flex: 1 1 140px;
  }

  .history-table {
    margin-inline: -4px;
  }
}

@media (max-width: 420px) {
  main {
    padding: 16px 10px 30px;
  }

  .left-panel,
  .detail-panel,
  .class-board,
  .history-board {
    padding: 14px;
  }

  .app-header h1 {
    font-size: 1.35rem;
  }

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

  .summary-grid {
    gap: 10px;
  }

  .summary-grid article {
    padding: 13px;
  }

  .summary-grid span {
    font-size: 1.55rem;
  }

  .summary-grid p {
    font-size: 0.82rem;
  }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

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

  .child-row {
    align-items: start;
    grid-template-columns: 38px 1fr;
  }

  .child-row .status-pill {
    grid-column: 2;
    justify-self: start;
  }

  .avatar {
    height: 38px;
    width: 38px;
  }

  .large-avatar {
    height: 56px;
    width: 56px;
  }

  .profile-left {
    align-items: flex-start;
  }

  .pickup-code {
    font-size: 2.5rem;
  }

  dialog {
    max-height: calc(100vh - 24px);
    overflow: auto;
    padding: 14px;
    width: min(calc(100vw - 20px), 720px);
  }

  menu {
    display: grid;
    grid-template-columns: 1fr;
  }

  menu button {
    width: 100%;
  }

  .pickup-dialog {
    padding: 12px;
  }

  .photo-card {
    padding: 18px;
  }

  .photo-card .photo-code {
    font-size: clamp(2.7rem, 13vw, 3.4rem);
    min-height: 104px;
    padding-inline: 6px;
  }
}

@media (max-width: 360px) {
  .header-actions,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .quick-actions button {
    flex-basis: 100%;
  }

  .pickup-code {
    font-size: 2.1rem;
  }
}
