:root {
  --bg: #f8f6f1;
  --surface: #ffffff;
  --ink: #2a2826;
  --muted: #797470;
  --accent: #4a8c5b;
  --accent-soft: #e3efe6;
  --warn: #b54a3a;
  --warn-soft: #fbe7e3;
  --border: #e6e1d8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); font-size: .9rem; }
.warn { color: var(--warn); }

/* Header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: .8rem 1.2rem;
  gap: 1.5rem;
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.topbar nav { display: flex; gap: 1.2rem; }
.topbar nav a { color: var(--ink); font-weight: 500; }
.topbar nav a:hover { color: var(--accent); text-decoration: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* Page head */
.page-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 1rem;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  margin-bottom: 1rem;
}
.card.empty { text-align: center; padding: 2.5rem 1rem; }

.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) { .grid.two { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
  display: inline-block;
  padding: .55rem 1rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.primary:hover { background: #3a7448; border-color: #3a7448; }
.btn.small { padding: .35rem .7rem; font-size: .9rem; }
.btn-link {
  background: none; border: none; color: var(--muted);
  font-size: .85rem; cursor: pointer; padding: 0 .3rem;
}
.btn-link:hover { color: var(--warn); text-decoration: underline; }

/* Forms */
.form { display: flex; flex-direction: column; gap: .8rem; }
.form.compact { gap: .4rem; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
.form input, .form textarea, .form select {
  font: inherit;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.form textarea { resize: vertical; }
.form-actions { display: flex; gap: .6rem; }
.form.inline, form.inline { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
fieldset.eyfs-pickers { border: 1px solid var(--border); border-radius: 6px; padding: .6rem .9rem; }
fieldset.eyfs-pickers legend { padding: 0 .4rem; font-size: .85rem; color: var(--muted); }
.check { flex-direction: row !important; gap: .4rem !important; align-items: center; font-size: .9rem !important; color: var(--ink) !important; margin-right: 1rem; }

.diary-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.diary-form select, .diary-form input { padding: .5rem .6rem; }
.diary-form input[name=text] { flex: 1; min-width: 200px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .6rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }

/* Diary list */
.diary { list-style: none; padding: 0; margin: 0; }
.diary li {
  padding: .55rem 0;
  border-bottom: 1px dashed var(--border);
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
}
.diary li:last-child { border-bottom: 0; }
.time { color: var(--muted); font-size: .85rem; min-width: 9em; }
.badge {
  background: var(--accent-soft); color: var(--accent);
  padding: .15rem .55rem; border-radius: 999px;
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  font-weight: 600;
}
.badge-feed { background: #fff3d6; color: #8a6d12; }
.badge-nap { background: #e0e7f7; color: #3553a0; }
.badge-nappy { background: #f4e6f2; color: #8c3a82; }
.badge-mood { background: #ffe6dc; color: #a8492a; }
.badge-activity { background: var(--accent-soft); color: var(--accent); }
.badge-note { background: #e6e6e6; color: #555; }

/* Children */
.children-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.child-tile {
  display: flex; gap: .8rem; align-items: center;
  background: var(--surface); padding: .8rem; border: 1px solid var(--border); border-radius: 10px;
  color: var(--ink);
}
.child-tile:hover { border-color: var(--accent); text-decoration: none; }
.child-tile img, .child-tile-placeholder {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 600;
}

/* Child detail */
.child-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.child-head .spacer { flex: 1; }
.avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder {
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 600;
}
.thumb { max-width: 200px; border-radius: 8px; }
.big-photo { max-width: 100%; border-radius: 8px; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a {
  padding: .55rem .9rem; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Observations */
.obs { list-style: none; padding: 0; margin: 0; }
.obs li { border-bottom: 1px dashed var(--border); padding: .8rem 0; }
.obs li:last-child { border-bottom: 0; }
.obs-time { color: var(--muted); font-size: .85rem; }
.obs-photo { max-width: 280px; border-radius: 8px; margin: .4rem 0; display: block; }
.obs-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.obs-card {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface);
  display: flex; flex-direction: column;
}
.obs-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.obs-card-body { padding: .8rem 1rem; }
.tags { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .4rem; }
.tag {
  background: var(--accent-soft); color: var(--accent);
  padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
}

/* Menus */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.menu-card h3 { color: var(--accent); }
.menu-list { list-style: none; padding: 0; margin: 0; }
.menu-list li { padding: .35rem 0; border-bottom: 1px dashed var(--border); font-size: .95rem; }
.menu-list li:last-child { border-bottom: 0; }

/* Attendance */
.attendance-table input[type="text"], .attendance-table input:not([type]) { width: 9em; }

/* Tokens */
.token-list { list-style: none; padding: 0; margin: .8rem 0 0; }
.token-list li { padding: .6rem 0; border-bottom: 1px dashed var(--border); display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.token-list code { background: var(--bg); padding: .25rem .5rem; border-radius: 4px; font-size: .85rem; }

/* KV / contact lists */
.kv, .contacts { display: grid; grid-template-columns: 8em 1fr; gap: .35rem .8rem; margin: 0; }
.kv dt, .contacts dt { color: var(--muted); font-weight: 500; }
.kv dd, .contacts dd { margin: 0; }

/* Accident / medical lists */
.accident-list, .medical-list { list-style: none; padding: 0; margin: 0; }
.accident-list li, .medical-list li {
  padding: .55rem 0; border-bottom: 1px dashed var(--border);
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
}

/* Parent header */
.parent-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; padding-top: 1rem; }

/* Auth pages */
.auth-body {
  display: flex; min-height: 100vh; align-items: center; justify-content: center;
  background: var(--bg);
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 2rem 2.4rem; width: 100%; max-width: 380px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.auth-card h1 { margin-top: 0; }
.auth-card .form { margin-top: 1rem; }

.error { background: var(--warn-soft); color: var(--warn); padding: .5rem .8rem; border-radius: 6px; }
.info  { background: var(--accent-soft); color: var(--accent); padding: .5rem .8rem; border-radius: 6px; }

/* Topbar user block */
.topbar { justify-content: flex-start; }
.topbar nav { flex: 1; }
.user-block { display: flex; align-items: center; gap: .8rem; }
.role {
  background: var(--accent-soft); color: var(--accent);
  padding: .1rem .45rem; border-radius: 999px; font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}

/* Milestones */
.milestone-area h4.band { color: var(--muted); margin: .8rem 0 .3rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
table.milestones { table-layout: fixed; }
table.milestones td { vertical-align: top; padding: .45rem .5rem; }
.ms-text { width: 56%; }
.ms-status { width: 22%; }
.ms-status select { width: 100%; padding: .35rem .4rem; }
.ms-meta { width: 22%; font-size: .8rem; }

/* Contract / invoice badges */
.badge-draft     { background: #e6e6e6; color: #555; }
.badge-active    { background: var(--accent-soft); color: var(--accent); }
.badge-ended     { background: #f0e6dc; color: #8a6d4f; }
.badge-sent      { background: #e0e7f7; color: #3553a0; }
.badge-paid      { background: var(--accent-soft); color: var(--accent); }
.badge-cancelled { background: #efeaea; color: #777; }
.badge-overdue   { background: var(--warn-soft); color: var(--warn); }

/* Invoice line-item table (form) */
table.invoice-lines { width: 100%; }
table.invoice-lines th { font-weight: 500; color: var(--muted); font-size: .85rem; }
table.invoice-lines td { padding: .25rem .3rem; border: none; }
table.invoice-lines input { width: 100%; }
table.invoice-lines td:nth-child(2) input,
table.invoice-lines td:nth-child(3) input,
table.invoice-lines td:nth-child(4) input { width: auto; }

/* Invoice line-item table (read view) */
table.invoice-table .total-row td { border-top: 2px solid var(--ink); padding-top: .6rem; }
table.invoice-table td:nth-child(n+2),
table.invoice-table th:nth-child(n+2) { text-align: right; }
table.invoice-table td:nth-child(3),
table.invoice-table th:nth-child(3) { text-align: left; }
