:root {
  --ink: #10243a;
  --muted: #5a6877;
  --navy: #123c69;
  --blue: #1b67a5;
  --sky: #e8f3fb;
  --paper: #ffffff;
  --ground: #f2f6f8;
  --green: #18794e;
  --green-bg: #e7f6ee;
  --amber: #9a5b00;
  --amber-bg: #fff5dc;
  --red: #b42318;
  --red-bg: #fef0ef;
  --line: #d7e0e7;
  --shadow: 0 18px 48px rgba(16, 36, 58, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(37, 130, 184, .12), transparent 35rem),
    var(--ground);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { touch-action: manipulation; }

.shell {
  width: min(780px * 2, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 50px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.8rem, 5vw, 2.55rem); letter-spacing: -.04em; }
h2 { margin-bottom: 8px; font-size: clamp(1.35rem, 4vw, 1.8rem); letter-spacing: -.025em; }
.eyebrow { margin-bottom: 5px; color: var(--blue); font-size: .76rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.clock { min-width: 190px; text-align: right; }
.clock strong { display: block; font-size: 2.2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.clock span, .clock small { display: block; margin-top: 5px; color: var(--muted); }
.clock small { font-size: .72rem; }

.slot-card, .search-card {
  background: var(--paper);
  border: 1px solid rgba(18, 60, 105, .08);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.slot-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.slot-card h2, .slot-card p:last-child { margin-bottom: 0; }
.slot-card p:last-child { color: var(--muted); }
.slot-dot { width: 17px; height: 17px; flex: 0 0 auto; border-radius: 50%; background: #8392a1; box-shadow: 0 0 0 7px #edf1f4; }
.slot-dot.open { background: var(--green); box-shadow: 0 0 0 7px var(--green-bg); }

.search-card { position: relative; padding: clamp(22px, 5vw, 36px); }
.section-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.demo-badge { padding: 7px 10px; border-radius: 99px; background: var(--sky); color: var(--navy); font-size: .75rem; font-weight: 800; white-space: nowrap; }
label { display: block; margin: 16px 0 8px; font-weight: 750; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 17px; top: 50%; width: 24px; transform: translateY(-50%); fill: none; stroke: var(--blue); stroke-width: 2; stroke-linecap: round; }
input[type="search"] {
  width: 100%;
  min-height: 62px;
  padding: 12px 18px 12px 54px;
  color: var(--ink);
  background: #f9fbfc;
  border: 2px solid var(--line);
  border-radius: 15px;
  outline: 0;
  font-size: 1.15rem;
}
input[type="search"]:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(27, 103, 165, .14); }
.help { margin: 10px 0 0; color: var(--muted); font-size: .88rem; }

.children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 18px;
  padding: 0;
}
.child-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-height: 64px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.child-card:hover { border-color: var(--blue); box-shadow: 0 8px 22px rgba(18, 60, 105, .12); }
.child-card:focus-visible { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(27, 103, 165, .22); }
.child-card:active { transform: translateY(1px); }
.child-card__avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  background: var(--sky);
  border-radius: 50%;
  font-weight: 850;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.child-card__body { display: flex; flex-direction: column; min-width: 0; }
.child-card__name {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.child-card__hint { color: var(--muted); font-size: .78rem; }
.empty-state {
  margin: 18px 0 0;
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, .55);
  border: 1px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  font-size: .95rem;
}

.rule-note { display: flex; gap: 12px; margin: 18px 5px 0; padding: 14px 18px; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.rule-note strong { color: var(--navy); white-space: nowrap; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; width: min(560px, calc(100% - 30px)); padding: 16px 20px; transform: translateX(-50%); color: white; background: var(--green); border-radius: 13px; box-shadow: var(--shadow); text-align: center; font-weight: 750; }

[hidden] { display: none !important; }

dialog { width: min(560px, calc(100% - 24px)); padding: 0; border: 0; border-radius: 24px; box-shadow: 0 24px 90px rgba(5, 20, 35, .35); }
dialog::backdrop { background: rgba(8, 24, 40, .68); backdrop-filter: blur(3px); }
.dialog-card { position: relative; padding: clamp(25px, 6vw, 40px); }
.close-button { position: absolute; top: 15px; right: 15px; width: 44px; height: 44px; color: var(--muted); background: #eef3f6; border: 0; border-radius: 50%; cursor: pointer; font-size: 1.8rem; line-height: 1; }
.close-button:focus-visible, .primary-button:focus-visible { outline: 4px solid rgba(27, 103, 165, .25); outline-offset: 2px; }
.dialog-slot { margin: 12px 0 16px; color: var(--muted); font-weight: 700; }
.status-box { padding: 16px 18px; background: var(--sky); border-radius: 13px; font-weight: 800; }
.status-box.present { color: var(--green); background: var(--green-bg); }
.status-box.completed { color: var(--amber); background: var(--amber-bg); }
.presence-detail { margin-top: 12px; color: var(--muted); font-size: .9rem; }
.auto-badge { display: inline-block; margin-top: 8px; padding: 5px 9px; color: var(--amber); background: var(--amber-bg); border-radius: 99px; font-size: .75rem; font-weight: 850; }
.error { margin: 14px 0 0; padding: 13px 15px; color: var(--red); background: var(--red-bg); border-radius: 11px; font-weight: 700; }
.primary-button { width: 100%; min-height: 58px; margin-top: 20px; color: white; background: var(--navy); border: 0; border-radius: 13px; cursor: pointer; font-size: 1.08rem; font-weight: 850; }
.primary-button:hover { background: var(--blue); }
.primary-button:disabled { cursor: wait; opacity: .72; }
.spinner { display: none; width: 20px; height: 20px; margin-left: 10px; vertical-align: middle; border: 3px solid rgba(255,255,255,.45); border-top-color: white; border-radius: 50%; animation: spin .75s linear infinite; }
.primary-button.loading .spinner { display: inline-block; }
.dialog-policy { margin: 16px 0 0; color: var(--muted); text-align: center; font-size: .78rem; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 780px); padding-top: 18px; }
  .topbar { align-items: flex-start; }
  .clock { min-width: 126px; }
  .clock strong { font-size: 1.7rem; }
  .clock span { font-size: .76rem; }
  .slot-card { align-items: flex-start; padding: 18px; border-radius: 18px; }
  .search-card { border-radius: 18px; }
  .section-heading { display: block; }
  .demo-badge { display: inline-block; margin-bottom: 6px; }
  .rule-note { display: block; }
  .rule-note strong { display: block; margin-bottom: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}
