:root {
  --bg: #fbf8f2;
  --panel: #ffffff;
  --ink: #2c2a26;
  --muted: #74706a;
  --brand: #e8871e;
  --brand-dark: #c56e10;
  --accent: #6aa84f;
  --line: #ece5d8;
  --danger: #c0392b;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
/* Reserve the scrollbar's width at all times: opening a popup hides the page
   scrollbar (body overflow:hidden), which used to make everything behind it
   jump sideways by the scrollbar's width. */
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand .tag {
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
}
.auth-logo { display: block; height: 64px; width: auto; margin: 0 auto 18px; }
.hero-logo { height: 90px; width: auto; margin: 0 auto 18px; display: block; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav-link {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-link.active { background: var(--brand); color: white; }
.who { display: flex; align-items: center; gap: 10px; }
.who-name { font-size: 14px; color: var(--muted); }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
  padding: 8px 12px;
  color: var(--ink);
  cursor: pointer;
}
.nav-toggle:hover { background: var(--bg); }
.nav-link-mobile { display: none; }

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* Tables are left at their natural width and scroll horizontally inside
   their card on narrow screens, instead of squeezing columns unreadably
   or breaking the page layout. */
.card { overflow-x: auto; }

.hero {
  text-align: center;
  padding: 70px 20px;
}
.hero h1 { font-size: 36px; margin-bottom: 8px; }
.hero p { color: var(--muted); font-size: 17px; max-width: 520px; margin: 0 auto 24px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}
.card h2 { margin-top: 0; font-size: 19px; }
.card h3 { margin-top: 0; font-size: 16px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--brand);
  color: white;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: var(--danger); }

form { display: flex; flex-direction: column; gap: 12px; }
label { font-size: 13px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  background: white;
  color: var(--ink);
  font-family: inherit;
}
textarea { resize: vertical; min-height: 80px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
}
.badge-allergen { background: #fdeee0; color: var(--danger); }
.badge-ok { background: #eaf3e4; color: #4b7a34; }
.badge-pending { background: #fdf3da; color: #a1740a; }

.banner { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.banner-info { background: #eef4fb; color: #2c5c8c; }
.banner-error { background: #fdecec; color: var(--danger); }
.banner-success { background: #eaf3e4; color: #4b7a34; }

.field-invalid { border-color: var(--danger) !important; background: #fdecec; }
.field-error {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--danger);
  background: #fdecec;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  margin-top: 6px;
}
.field-error::before { content: '⚠'; font-size: 14px; line-height: 1; }

.muted { color: var(--muted); font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.auth-wrap { max-width: 420px; margin: 60px auto; }
.auth-wrap .card { padding: 30px; }
.center { text-align: center; }

.chat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.chat-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
}
.chat-tab-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.chat-tab-active .muted { color: rgba(255,255,255,.8); }

.chat-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 440px;
  overflow-y: auto;
  padding: 10px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 14px;
}
.msg { max-width: 70%; padding: 10px 14px; border-radius: 14px; font-size: 14px; }
.msg-staff { background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.msg-parent { background: var(--brand); color: white; align-self: flex-end; }
.msg-meta { font-size: 11px; opacity: .65; margin-top: 4px; }
.msg-sender { font-size: 11px; font-weight: 600; opacity: .75; margin-bottom: 3px; }

.menu-table td.day-head { font-weight: 700; background: var(--bg); }

.weekday-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.day-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.day-card h4 { margin: 0 0 8px; font-size: 14px; color: var(--brand-dark); }
.meal { margin-bottom: 8px; font-size: 13px; }
.meal .label { color: var(--muted); font-size: 11px; text-transform: uppercase; display: block; }

footer.site { text-align: center; padding: 30px; color: var(--muted); font-size: 13px; }

/* Group cards with an edit (✎) icon, at the top of /admin/grupe. */
.group-card { position: relative; padding-top: 30px; }
.group-edit-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  line-height: 1;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.group-edit-btn:hover { background: var(--brand); color: white; border-color: var(--brand); }

/* Drag-and-drop group assignment board (admin). */
.dnd-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.dnd-col { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.dnd-col h4 { margin: 0 0 10px; font-size: 14px; }
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
  padding: 8px;
  border: 2px dashed transparent;
  border-radius: 10px;
  transition: background .12s, border-color .12s;
}
.chip-list.drop-hover { background: #fdeee0; border-color: var(--brand); }
.dnd-empty { margin: 0; padding: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: grab;
  user-select: none;
}
.chip.dragging { opacity: .4; }
.chip.chip-selected { background: var(--brand); color: white; border-color: var(--brand-dark); }
.chip.chip-selected.chip-staff { background: var(--brand); border-color: var(--brand-dark); }
[data-dropzone].dropzone-active { border-color: var(--line); background: #fdf6ec; }
.chip-staff { background: #eef4fb; border-color: #cfe0f2; }
/* Pedagog — the one role that can cover more than one group — gets a
   distinct color so it's obvious at a glance on /admin/grupe. */
.chip-pedagog { background: #f3eafd; border-color: #ddc8f2; }
.chip.chip-selected.chip-pedagog { background: var(--brand); border-color: var(--brand-dark); }
.chip-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 0 0 2px;
}
.chip-remove:hover { color: var(--danger); }

/* The "⋯" mobile-popup trigger column on Osoblje/Roditelji (see the
   #osoblje-table/#roditelji-table rules below) only makes sense once those
   rows have collapsed to a name-only list — on a normal-width screen every
   field already shows in the table, so this column stays hidden there. */
.row-trigger-cell { display: none; }

/* Forced/optional password-change modal (parent app). */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 26, 20, 0.5);
  display: flex;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  /* A tall form (e.g. "Novo dijete i roditelj(i)") must scroll inside the
     backdrop instead of being centered and cut off above the viewport,
     which hid the × and made the popup impossible to close. */
  overflow-y: auto;
}
.modal-card {
  background: white;
  border-radius: var(--radius);
  padding: 28px;
  max-width: 400px;
  width: 100%;
  position: relative;
  margin: auto; /* centers when it fits, top-aligns + scrolls when it doesn't */
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--ink); }

/* ---------- Mobile (phones & small tablets) ---------- */
@media (max-width: 760px) {
  /* One slim row: logo | Odjava | menu button. "Šifra" lives inside the menu. */
  .topbar {
    padding: 6px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .brand-logo { height: 28px; }
  .brand .tag { font-size: 11px; padding: 1px 7px; }
  .brand { order: 0; }
  .who { order: 1; margin-left: auto; }
  .who .btn { padding: 6px 12px; font-size: 13px; }
  .who-pass { display: none; }
  .nav-link-mobile { display: block; }
  .nav-toggle { display: inline-flex; align-items: center; order: 2; margin-left: 0; padding: 6px 11px; font-size: 17px; }
  .nav {
    order: 3;
    display: none;
    flex-direction: column;
    gap: 2px;
    flex-basis: 100%;
    width: 100%;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }
  .topbar.nav-open .nav { display: flex; }
  .nav-link { padding: 11px 12px; }
  .who-name { display: none; }

  .container { padding: 18px 14px 48px; }
  .card { padding: 16px; }

  .hero { padding: 40px 14px; }
  .hero h1 { font-size: 27px; }
  .hero p { font-size: 15px; }

  .grid-2 { grid-template-columns: 1fr; }
  .row { flex-direction: column; }
  .row > * { min-width: 0; }

  .dnd-board, .weekday-grid { grid-template-columns: 1fr; }

  .auth-wrap { margin: 24px auto; max-width: 100%; }
  .auth-wrap .card { padding: 22px; }

  .msg { max-width: 85%; }

  .modal-card { padding: 22px; }

  /* Data tables (Osoblje, Roditelji, Izostanci, etc.) stop being wide grids
     that force horizontal scrolling, and become a stack of labeled cards
     instead — one per row, each cell showing its column name above its
     value. Needs each <td> to carry data-label="..."; a <td> without one
     (action buttons, links) just shows its content with no label line. */
  .card table { display: block; width: 100%; border: none; }
  .card table tr:has(th) { display: none; }
  .card table tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 4px 12px;
    margin-bottom: 10px;
    background: var(--panel);
  }
  .card table td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 8px 2px;
    border-bottom: 1px dashed var(--line);
  }
  .card table td:last-child { border-bottom: none; }
  .card table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .02em;
  }
  .card table td:not([data-label])::before { content: none; }
  .card table td form,
  .card table td .inline-edit { width: 100%; }
  .card table td .inline-edit input,
  .card table td .inline-edit select { width: auto; flex: 1; }

  /* Osoblje / Roditelji specifically: with many people the one-card-per-row
     stack above still means a lot of scrolling just to see who's who, so
     these two go further — each row shrinks to just a name (plus, for
     Roditelji, the child's name under it) and a "⋯" trigger. Everything
     else (telefon, email, uloga, dugmad...) is still there, just tucked
     into the shared popup (openRowPopup/closeRowPopup in admin-dnd.js)
     until that row's trigger is tapped. More specific than ".card table tr"
     above (id + class beats class-only), so it wins for these two tables
     only — every other table keeps the labeled-card look untouched. */
  #osoblje-table tr:has(th),
  #roditelji-table tr:has(th) { display: none; }
  #osoblje-table tr,
  #roditelji-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 8px;
    padding: 10px 14px;
  }
  #osoblje-table td.cell-primary,
  #roditelji-table td.cell-primary {
    grid-column: 1;
    display: block;
    padding: 2px 0;
    border: none;
    font-weight: 600;
  }
  #osoblje-table td.cell-primary::before,
  #roditelji-table td.cell-primary::before { content: none; }
  #roditelji-table td.cell-primary-sub {
    font-weight: 400;
    color: var(--muted);
    font-size: 13px;
  }
  #osoblje-table td.cell-more,
  #roditelji-table td.cell-more { display: none; }
  #osoblje-table td.row-trigger-cell,
  #roditelji-table td.row-trigger-cell {
    grid-column: 2;
    grid-row: 1 / -1;
    display: flex;
    border: none;
    padding: 0;
  }
  .row-trigger {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    padding: 6px 8px;
    cursor: pointer;
  }
  .row-trigger:hover, .row-trigger:active { color: var(--ink); }
}

/* Content of #row-popup-body (see openRowPopup in admin-dnd.js): the td's
   moved in from a collapsed Osoblje/Roditelji row, reusing the same
   labeled-card look as the mobile table rows above. Kept outside the media
   query since the trigger that opens it only exists under 760px anyway. */
#row-popup-body {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}
#row-popup-body td {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--line);
  width: 100%;
}
#row-popup-body td:last-child { border-bottom: none; }
#row-popup-body td::before {
  content: attr(data-label);
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .02em;
}
#row-popup-body td:not([data-label])::before { content: none; }
#row-popup-body td form,
#row-popup-body td .inline-edit { width: 100%; }
#row-popup-body td .inline-edit input,
#row-popup-body td .inline-edit select { width: auto; flex: 1; }

@media (max-width: 420px) {
  .brand .tag { display: none; }
  .hero h1 { font-size: 23px; }
}

/* Compact inline-edit form inside a table cell (e.g. parent email on
   /admin/roditelji, or the role <select> on /admin/osoblje) — input/select +
   small save button sitting side by side. */
.inline-edit { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-edit input { width: 160px; margin: 0; }
.inline-edit select { width: auto; margin: 0; }

/* ---------- Slike (photos) ---------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.photo-tile {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--line, #eee);
  cursor: pointer;
}
.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  z-index: 2;
  margin: 0;
  accent-color: var(--brand, #e8891d);
}
.photo-tile.selected { outline: 3px solid var(--brand, #e8891d); outline-offset: -3px; }
.photo-state {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 6px;
  font-size: 11px;
  line-height: 1.25;
  color: #fff;
  background: rgba(30, 26, 20, 0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.photo-tile.untagged .photo-state { background: rgba(176, 90, 0, 0.82); }
.badge-new {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--brand, #e8891d);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.tagbar { position: sticky; top: 8px; z-index: 5; }
.child-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line, #ddd);
  border-radius: 999px;
  background: #fff;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.chip-check input { width: auto; margin: 0; }
.tag-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-link {
  padding: 6px 14px;
  border: 1px solid var(--line, #ddd);
  border-radius: 999px;
  text-decoration: none;
  color: inherit;
  background: #fff;
}
.chip-link.on { background: var(--brand, #e8891d); border-color: var(--brand, #e8891d); color: #fff; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 12, 8, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox img { max-width: 100%; max-height: 82vh; object-fit: contain; }
.lb-close, .lb-nav {
  position: absolute;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
}
@media (max-width: 520px) {
  .photo-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
}

/* ---------- AI panel on /admin/slike ---------- */
.face-row { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0 14px; }
.face-item { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 132px; }
.face-circle { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid var(--brand, #e8871e); background: #eee; }
.face-select, .face-search { width: 100%; font-size: 13px; padding: 6px; }
.review-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line, #ece5d8); }
.review-thumb { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; background: #eee; cursor: zoom-in; }
.review-body { flex: 1; min-width: 0; }
.review-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Osoblje: reset / unlock / delete sit side by side in one "Radnje" cell */
#osoblje-table td.actions-cell form { display: inline-block; margin: 2px 6px 2px 0; }

/* Osoblje: "Bivše osoblje" is collapsed until asked for (no marker triangle) */
details.former-staff > summary::-webkit-details-marker { display: none; }

/* Osoblje: contact + all actions fit the card (no horizontal cut-off) */
#osoblje-table { table-layout: auto; width: 100%; }
#osoblje-table td.actions-cell { min-width: 210px; }
#osoblje-table td.actions-cell .inline-edit { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; }
#osoblje-table td.actions-cell .inline-edit select { max-width: 170px; }
#osoblje-table td.actions-cell > a.btn { margin: 2px 6px 2px 0; }
@media (min-width: 761px) {
  #osoblje-table td { vertical-align: top; }
}
#osoblje-table td.actions-cell { min-width: 300px; }
#osoblje-table td.actions-cell .inline-edit { flex-wrap: nowrap; }
#osoblje-table td.actions-cell .inline-edit select { max-width: 150px; }
#osoblje-table td.actions-cell form { vertical-align: middle; }

/* Osoblje: name / role / group always visible; contact and settings drop down */
#osoblje-table td { vertical-align: middle; padding-top: 12px; padding-bottom: 12px; }
#osoblje-table td.actions-cell { min-width: 0; }
.pop { position: relative; display: inline-block; }
.pop-body {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 250px;
  background: #fff;
  border: 1px solid var(--line, #ece5d8);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(40, 30, 10, 0.16);
  padding: 12px;
  text-align: left;
  white-space: normal;
}
.pop-body.pop-right { left: auto; right: 0; min-width: 270px; }
.pop-body[hidden] { display: none; }
.pop-row { margin: 0 0 8px; }
.pop-item { display: block; margin: 0 0 10px; }
.pop-item:last-child { margin-bottom: 0; }
.pop-label { display: block; font-size: 12px; color: var(--muted, #74706a); margin-bottom: 4px; }
.pop-body select { width: 100%; margin-bottom: 6px; }
/* in the phone popup (list of the row's details) everything is simply shown */
#row-popup-body .pop > .pop-toggle { display: none; }
#row-popup-body .pop-body,
#row-popup-body .pop-body[hidden] {
  display: block;
  position: static;
  min-width: 0;
  border: none;
  box-shadow: none;
  padding: 0;
}

/* --- WhatsApp-style messages (lib/chatui.js, public/chat.js) --------------- */
.wa { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 170px); min-height: 460px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.wa-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-width: 0; background: #fff; }
.wa-list-head { padding: 12px 14px 0; }
.wa-list-head h2 { margin: 0; font-size: 20px; }
.wa-search { padding: 10px 12px 6px; }
.wa-search input { width: 100%; box-sizing: border-box; border: 0; border-radius: 999px; background: #f3efe7; padding: 9px 14px; font: inherit; }
.wa-filters { display: flex; gap: 6px; padding: 4px 12px 8px; }
.wa-filters button { border: 0; border-radius: 999px; padding: 5px 12px; background: #f3efe7; cursor: pointer; font: inherit; font-size: 13px; color: var(--ink); }
.wa-filters button.on { background: #fde9cf; color: var(--brand-dark); font-weight: 600; }
.wa-items { overflow-y: auto; flex: 1; }
.wa-item { display: flex; gap: 12px; padding: 10px 12px; text-decoration: none; color: inherit; border-bottom: 1px solid #f4efe6; align-items: center; }
.wa-item:hover { background: #faf6ee; }
.wa-item.on { background: #f3efe7; }
.wa-avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 15px; }
.wa-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wa-top, .wa-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.wa-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-top time { font-size: 12px; color: var(--muted); flex: none; }
.wa-item.has-unread .wa-top time { color: var(--accent); font-weight: 600; }
.wa-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-last { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-item.has-unread .wa-last { color: var(--ink); font-weight: 600; }
.wa-badge { flex: none; min-width: 20px; height: 20px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.wa-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #efe7da; }
.wa-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: #f7f3ea; border-bottom: 1px solid var(--line); }
.wa-head .wa-meta b { font-size: 16px; }
.wa-back { display: none; text-decoration: none; font-size: 22px; color: var(--ink); padding: 0 4px; }
.wa-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 5%; display: flex; flex-direction: column; gap: 6px; }
.wa-msg { max-width: 72%; padding: 7px 10px 4px; border-radius: 10px; box-shadow: 0 1px 1px rgba(0,0,0,.08); font-size: 14px; }
.wa-in { background: #fff; align-self: flex-start; border-top-left-radius: 2px; }
.wa-out { background: #dcf8c6; align-self: flex-end; border-top-right-radius: 2px; }
.wa-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-time { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.wa-sender { font-size: 12px; font-weight: 600; color: var(--brand-dark); margin-bottom: 2px; }
.wa-compose { display: flex; gap: 8px; padding: 10px; background: #f7f3ea; border-top: 1px solid var(--line); align-items: flex-end; }
.wa-compose textarea { flex: 1; min-height: 42px; max-height: 140px; border-radius: 20px; resize: none; padding: 10px 14px; margin: 0; }
.wa-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.wa-empty-hint { text-align: center; margin: auto; }
@media (max-width: 760px) {
  .wa { grid-template-columns: 1fr; height: calc(100vh - 130px); }
  .wa.wa-open .wa-list { display: none; }
  .wa:not(.wa-open) .wa-chat { display: none; }
  .wa-back { display: inline-flex; }
  .wa-msg { max-width: 85%; }
}

/* --- Parent home (tiles) --------------------------------------------------- */
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.home-hello { margin: 0; font-size: 24px; }
.btn-quick { padding: 12px 20px; font-size: 15px; font-weight: 600; box-shadow: 0 2px 6px rgba(232,135,30,.35); }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; grid-template-areas: "kids abs" "news photos"; margin-bottom: 14px; align-items: start; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.tile h2 { margin: 0 0 10px; font-size: 18px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tile-kids { grid-area: kids; }
.tile-abs { grid-area: abs; }
.tile-news { grid-area: news; }
.tile-photos { grid-area: photos; }
.kid-row { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid #f4efe6; }
.kid-row:last-child { border-bottom: 0; }
.kid-avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; background: #fde9cf; color: var(--brand-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; }
.news-scroll { max-height: 360px; overflow-y: auto; }
.news-item { padding: 8px 0; border-bottom: 1px solid #f4efe6; }
.news-item:last-child { border-bottom: 0; }
.album { display: block; text-decoration: none; color: inherit; margin-bottom: 12px; }
.album-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.album-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.album-thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #f3efe7; }
.abs-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.abs-tools select { width: auto; margin: 0; }
.abs-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.abs-cal .dow { font-size: 12px; color: var(--muted); }
.abs-cal .day { aspect-ratio: 1.3; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 13px; background: #faf6ee; }
.abs-cal .day.we { background: transparent; color: #b9b3a8; }
.abs-cal .day.abs { background: #f6c9a0; color: #7a3d00; font-weight: 700; }
.abs-cal .day.today { outline: 2px solid var(--brand); outline-offset: -2px; }
@media (max-width: 760px) {
  .home-grid { grid-template-columns: 1fr; grid-template-areas: "kids" "news" "photos" "abs"; }
  .btn-quick { width: 100%; }
}
