/* ============================================================
   Trestly — stylesheet (mobile-first)
   ============================================================ */
:root {
  --teal:        #1B4F5A;
  --teal-mid:    #2A6B79;
  --teal-pale:   #E8F2F4;
  --sage:        #7BAF9A;
  --sage-light:  #EAF4EF;
  --amber:       #E8A040;
  --amber-light: #FDF3E3;
  --paper:       #F7F5F1;
  --white:       #FFFFFF;
  --charcoal:    #2C2C2C;
  --mid:         #6B7280;
  --border:      #E4E0D8;
  --red-soft:    #F5E8E8;
  --red:         #C0392B;
  --purple-soft: #F0EBF8;
  --purple:      #6B4FA0;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; font-size: 15px; }

@media (min-width: 641px) {
  html { font-size: 20px; }
}

body { font-family: 'DM Sans', sans-serif; background: var(--paper); color: var(--charcoal); display: flex; min-height: 100vh; font-size: 1rem; line-height: 1.5; }

/* SIDEBAR */
.sidebar { width: 220px; min-height: 100vh; background: var(--teal); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; z-index: 100; }
.sidebar-logo { padding: 24px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.logo-mark { font-family: 'Lora', serif; font-size: 1.25rem; font-weight: 600; color: #fff; letter-spacing: -.3px; }
.logo-sub  { font-size: 0.625rem; color: rgba(255,255,255,.45); letter-spacing: .8px; text-transform: uppercase; margin-top: 2px; }
.sidebar-child { padding: 12px 14px; margin: 12px 10px; background: rgba(255,255,255,.08); border-radius: 12px; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: background .15s; }
.sidebar-child:hover { background: rgba(255,255,255,.13); }
.child-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--sage), #5a9a84); display: flex; align-items: center; justify-content: center; font-family: 'Lora', serif; font-size: 0.875rem; font-weight: 600; color: #fff; flex-shrink: 0; }
.child-name { font-size: 0.844rem; font-weight: 600; color: #fff; }
.child-meta { font-size: 0.656rem; color: rgba(255,255,255,.5); margin-top: 1px; }
.sidebar-nav { padding: 6px 10px; flex: 1; }
.nav-label { font-size: 0.594rem; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,.3); padding: 12px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; color: rgba(255,255,255,.65); font-size: 0.812rem; cursor: pointer; transition: all .15s; text-decoration: none; margin-bottom: 1px; }
.nav-item:hover  { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 500; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.nav-disabled { opacity: .35; cursor: default !important; pointer-events: none; }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.1); }
.reminder-shortcut { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: rgba(255,255,255,.65); font-size: 0.812rem; cursor: pointer; transition: all .15s; margin: 0 0 2px; border: 1px dashed rgba(255,255,255,.2); }
.reminder-shortcut:hover { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.35); }

/* MAIN */
.main { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* TOPBAR */
.topbar { background: var(--white); border-bottom: 1px solid var(--border); padding: 0 24px; height: 58px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; gap: 12px; }
.topbar h1 { font-family: 'Lora', serif; font-size: 1.125rem; font-weight: 500; color: var(--teal); white-space: nowrap; }
.topbar .sub { font-size: 0.688rem; color: var(--mid); margin-top: 1px; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px; border-radius: 8px; font-family: 'DM Sans', sans-serif; font-size: 0.812rem; font-weight: 500; cursor: pointer; border: none; transition: all .15s; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-mid); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--charcoal); }
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }

/* CONTENT */
.content { padding: 20px 24px; }

/* COLOUR HELPERS */
.i-teal   { background: var(--teal-pale);  color: var(--teal); }
.i-sage   { background: var(--sage-light); color: #2D7A5C; }
.i-amber  { background: var(--amber-light);color: #A0600A; }
.i-purple { background: var(--purple-soft);color: var(--purple); }

/* PILLS */
.pill { display: inline-flex; align-items: center; gap: 3px; padding: 2px 9px; border-radius: 20px; font-size: 0.688rem; font-weight: 500; white-space: nowrap; }
.p-green  { background: var(--sage-light);  color: #2D7A5C; }
.p-amber  { background: var(--amber-light); color: #A0600A; }
.p-purple { background: var(--purple-soft); color: var(--purple); }
.p-red    { background: var(--red-soft);    color: var(--red); }
.p-gray   { background: #F3F3F3;            color: var(--mid); }
.p-teal   { background: var(--teal-pale);   color: var(--teal); }
.p-sage   { background: var(--sage-light);  color: #2D7A5C; }

/* STAT CARDS */
.summary-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 18px; }
.scard { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.scard .s-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.125rem; flex-shrink: 0; }
.scard .s-text .lbl { font-size: 0.625rem; font-weight: 500; text-transform: uppercase; letter-spacing: .7px; color: var(--mid); }
.scard .s-text .val { font-family: 'Lora', serif; font-size: 1.625rem; font-weight: 500; color: var(--teal); line-height: 1.1; }

/* DASHBOARD GRID — masonry-style, fills space */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto;
  gap: 16px;
  align-items: start;
}

.dash-col-left  { display: flex; flex-direction: column; gap: 16px; }
.dash-col-right { display: flex; flex-direction: column; gap: 16px; }

/* CARD */
.card { background: var(--white); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h2 { font-family: 'Lora', serif; font-size: 0.938rem; font-weight: 500; color: var(--teal); }
.card-header .cm { font-size: 0.688rem; color: var(--mid); margin-top: 1px; }
.card-body { padding: 16px 18px; }

/* PROGRESS BAR */
.pbar { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.pfill { height: 100%; border-radius: 3px; }
.f-teal   { background: var(--teal); }
.f-sage   { background: var(--sage); }
.f-amber  { background: var(--amber); }
.f-purple { background: var(--purple); }
.gpw  { display: flex; align-items: center; gap: 9px; }
.ppct { font-size: 0.75rem; font-weight: 600; color: var(--mid); }

/* GOAL ITEMS */
.goal-list { display: flex; flex-direction: column; gap: 10px; }
.gi { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; align-items: flex-start; gap: 12px; transition: border-color .15s; }
.gi:hover { border-color: var(--sage); }
.gd { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.gb { flex: 1; min-width: 0; }
.gt { font-size: 0.844rem; font-weight: 500; color: var(--charcoal); margin-bottom: 2px; }
.gdesc { font-size: 0.719rem; color: var(--mid); margin-bottom: 8px; line-height: 1.4; }
.gfoot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.gthx  { font-size: 0.688rem; color: var(--mid); }

/* WHAT'S NEXT */
.nlist { display: flex; flex-direction: column; gap: 8px; }
.ni { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--paper); border-radius: 10px; border: 1px solid var(--border); }
.ni-empty { background: var(--sage-light); border-color: #b5d9c8; }
.ni-empty .nit { color: #2D7A5C; }
.ni-empty .nim { color: #3a7a60; }
.niicon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.938rem; flex-shrink: 0; }
.nib { flex: 1; min-width: 0; }
.nit { font-weight: 500; font-size: 0.812rem; color: var(--charcoal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nim { font-size: 0.688rem; color: var(--mid); margin-top: 1px; }
.dismiss-btn { background: none; border: none; color: var(--mid); font-size: 0.812rem; cursor: pointer; padding: 2px 5px; border-radius: 4px; line-height: 1; opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.ni:hover .dismiss-btn { opacity: 1; }

/* PRACTICE */
.pw { display: flex; gap: 4px; margin-bottom: 12px; }
.pd { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dl { font-size: 0.594rem; color: var(--mid); font-weight: 500; }
.dd { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.688rem; cursor: pointer; transition: transform .1s; }
.dd:active { transform: scale(.9); }
.d-done  { background: var(--sage-light); color: #2D7A5C; }
.d-miss  { background: var(--red-soft);   color: var(--red); }
.d-today { background: var(--teal-pale);  color: var(--teal); border: 2px solid var(--teal); }
.d-fut   { background: #F3F3F3;           color: #ccc; }
.pstreak { display: flex; align-items: center; justify-content: space-between; background: var(--sage-light); border-radius: 10px; padding: 10px 14px; }
.snum { font-family: 'Lora', serif; font-size: 1.375rem; font-weight: 500; color: #2D7A5C; }
.slbl { font-size: 0.688rem; color: #2D7A5C; }

/* HOME PRACTICE ITEMS */
.practice-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.practice-item:last-child { border-bottom: none; }
.practice-check { width: 20px; height: 20px; border-radius: 5px; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; margin-top: 1px; transition: all .15s; color: #fff; }
.practice-item.practice-done .practice-check { background: var(--sage); border-color: var(--sage); }
.practice-check:hover { border-color: var(--sage); }
.practice-text { flex: 1; min-width: 0; }
.practice-title { font-size: 0.812rem; color: var(--charcoal); line-height: 1.4; }
.practice-strike { text-decoration: line-through; color: var(--mid); }
.practice-notes { font-size: 0.719rem; color: var(--mid); margin-top: 2px; line-height: 1.4; }
.practice-edit-btn { background: none; border: none; color: var(--mid); font-size: 0.875rem; cursor: pointer; padding: 2px 4px; border-radius: 4px; flex-shrink: 0; opacity: 0; transition: opacity .15s; }
.practice-item:hover .practice-edit-btn { opacity: 1; }

/* TIMELINE */
.tl { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 10px; padding-bottom: 14px; position: relative; }
.tl-item:not(:last-child)::before { content: ''; position: absolute; left: 12px; top: 27px; bottom: 0; width: 1px; background: var(--border); }
.tl-dot { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; flex-shrink: 0; position: relative; z-index: 1; }
.tl-body  { flex: 1; padding-top: 2px; min-width: 0; }
.tl-title { font-size: 0.781rem; font-weight: 500; color: var(--charcoal); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-meta  { font-size: 0.688rem; color: var(--mid); }
.tl-date  { font-size: 0.688rem; color: var(--mid); white-space: nowrap; padding-top: 3px; }

/* GOAL CARD (goals page) */
.goal-card-full { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; transition: border-color .15s; }
.goal-card-full:hover { border-color: var(--sage); }
.goal-card-achieved { background: var(--sage-light); border-color: #b5d9c8; }

/* SESSION CARD */
.session-card-full { background: var(--white); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.session-card-full:hover { border-color: var(--sage); }
.session-card-full.open  { border-color: var(--teal); }
.sc-head { display: flex; align-items: center; gap: 12px; padding: 13px 15px; cursor: pointer; }
.sc-body { display: none; padding: 0 15px 14px; border-top: 1px solid var(--border); }
.session-card-full.open .sc-body { display: block; }
.sc-chevron { font-size: 1.125rem; color: var(--mid); margin-left: 4px; transition: transform .2s; flex-shrink: 0; }
.session-card-full.open .sc-chevron { transform: rotate(90deg); }

/* MODAL */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 300; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open, .modal-overlay[style*="flex"] { display: flex; }
.modal { background: var(--white); border-radius: 16px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); animation: fadeUp .2s ease; }
@keyframes fadeUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-family: 'Lora', serif; font-size: 1.062rem; font-weight: 500; color: var(--teal); }
.modal-close { background: var(--paper); border: none; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 0.938rem; color: var(--mid); }
.modal-close:hover { background: var(--border); }
.modal-body   { padding: 18px 20px; }
.modal-footer { padding: 0 20px 18px; display: flex; gap: 10px; }

/* FORMS */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.781rem; font-weight: 500; color: var(--charcoal); margin-bottom: 5px; }
.form-hint  { font-size: 0.719rem; color: var(--mid); margin-bottom: 5px; }
input[type=text], input[type=date], input[type=email], textarea, select {
  width: 100%; padding: 8px 11px; border: 1.5px solid var(--border); border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: 0.875rem; color: var(--charcoal);
  background: var(--white); transition: border-color .15s; outline: none; appearance: none; -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--teal); }
textarea { resize: vertical; min-height: 76px; }

/* OPTION PICKERS */
.dopt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dopt { display: flex; align-items: center; gap: 7px; padding: 8px 11px; border: 1.5px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 0.781rem; transition: all .15s; }
.dopt:hover { border-color: var(--teal); }
.dopt.sel   { border-color: var(--teal); background: var(--teal-pale); font-weight: 500; }

.prog-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; }
.popt { padding: 7px 4px; border: 1.5px solid var(--border); border-radius: 8px; cursor: pointer; text-align: center; font-size: 0.719rem; transition: all .15s; }
.popt:hover { border-color: var(--teal); }
.popt.sel   { border-color: var(--teal); background: var(--teal-pale); font-weight: 500; color: var(--teal); }
.popt-icon  { font-size: 1.062rem; margin-bottom: 3px; }

.ropt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ropt { display: flex; align-items: center; gap: 7px; padding: 8px 11px; border: 1.5px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 0.781rem; transition: all .15s; }
.ropt:hover { border-color: var(--teal); }
.ropt.sel   { border-color: var(--teal); background: var(--teal-pale); font-weight: 500; }

/* ONBOARDING */
#onboarding-overlay { position: fixed; inset: 0; background: var(--paper); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.ob-card { background: var(--white); border: 1px solid var(--border); border-radius: 16px; padding: 24px 22px; width: 100%; max-width: 420px; }
.ob-logo    { font-family: 'Lora', serif; font-size: 1.375rem; font-weight: 600; color: var(--teal); text-align: center; margin-bottom: 3px; }
.ob-tagline { font-size: 0.781rem; color: var(--mid); text-align: center; margin-bottom: 22px; }
.ob-card h2 { font-family: 'Lora', serif; font-size: 1.062rem; font-weight: 500; color: var(--teal); margin-bottom: 4px; }
.ob-card p  { font-size: 0.781rem; color: var(--mid); margin-bottom: 18px; line-height: 1.5; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.copt { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1.5px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 0.812rem; transition: all .15s; user-select: none; }
.copt:hover { border-color: var(--teal); }
.copt.sel   { border-color: var(--teal); background: var(--teal-pale); font-weight: 500; }
.cbox { width: 17px; height: 17px; border: 2px solid var(--border); border-radius: 4px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.625rem; transition: all .15s; }
.copt.sel .cbox { background: var(--teal); border-color: var(--teal); color: #fff; }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-title  { font-family: 'Lora', serif; font-size: 1.062rem; font-weight: 500; color: var(--teal); }

/* ── RESPONSIVE ─────────────────────────────────────────────── */

/* Large desktop: wider content, 2-col stays */
@media (min-width: 1200px) {
  .dash-grid { grid-template-columns: 1fr 360px; }
}

/* Tablet: collapse to single column */
@media (max-width: 900px) {
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .dash-grid   { grid-template-columns: 1fr; }
  .dash-col-right { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
}

/* Mobile: hide sidebar, full width */
@media (max-width: 640px) {
  html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
  .sidebar { display: flex; width: min(84vw, 300px); height: 100dvh; min-height: 100dvh; overflow-y: auto; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 12px 0 30px rgba(0,0,0,.18); }
  body.mobile-menu-open .sidebar { transform: translateX(0); }
  .mobile-nav-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(15,38,43,.46); opacity: 0; visibility: hidden; transition: opacity .22s ease, visibility .22s ease; }
  body.mobile-menu-open .mobile-nav-backdrop { opacity: 1; visibility: visible; }
  .main    { margin-left: 0; }
  .content { padding: 14px; padding-bottom: 28px; }
  .main, .topbar, .content, .summary-row, .dash-grid, .dash-col-left, .dash-col-right, .card { min-width: 0; max-width: 100%; }
  .topbar  { padding: 0 14px; height: 62px; }
  .mobile-menu-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 62px; height: 38px; padding: 0 9px; border: 1px solid var(--border); background: var(--white); border-radius: 9px; cursor: pointer; flex-shrink: 0; color: var(--teal); font-family: 'DM Sans', sans-serif; font-size: .75rem; font-weight: 600; }
  .mobile-menu-toggle span { font-size: 18px; line-height: 1; }
  .topbar h1 { font-size: 1rem; }
  .topbar .sub { display: none; }
  .topbar-right { margin-left: auto; gap: 6px; }
  .topbar-right .btn { padding: 7px 9px; font-size: .75rem; }
  .topbar-right .btn svg { display: none; }
  .mobile-profile { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--teal-pale); border-bottom: 1px solid #d3e6e9; }
  .mobile-profile .child-avatar { width: 34px; height: 34px; font-size: .8rem; }
  .mobile-profile-name { color: var(--teal); font-size: .82rem; font-weight: 700; line-height: 1.2; }
  .mobile-profile-meta, .mobile-profile-clinic { color: var(--mid); font-size: .68rem; line-height: 1.35; }
  .mobile-profile-clinic:empty { display: none; }
  .summary-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .scard { padding: 11px 12px; }
  .scard .s-icon { width: 32px; height: 32px; font-size: 0.938rem; }
  .scard .s-text .val { font-size: 1.375rem; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-col-right { display: flex; flex-direction: column; gap: 14px; }
  .dopt-grid { grid-template-columns: 1fr; }
  .prog-grid { grid-template-columns: repeat(2, 1fr); }
  .ropt-grid { grid-template-columns: 1fr; }
  .topbar-right .btn-outline:not(:last-child) { display: none; }
  .page-header { gap: 10px; align-items: flex-start; }
  .page-header .btn { flex-shrink: 0; }
  .card-header, .card-body { padding-left: 14px; padding-right: 14px; }
  .card-header { gap: 8px; }
  .card-header > * { min-width: 0; }
  .gt, .gdesc, .nit, .nim, .practice-title, .practice-notes { overflow-wrap: anywhere; }
  .goal-card-full { padding: 13px; }
  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal { max-height: calc(100dvh - 20px); border-radius: 16px 16px 10px 10px; }
  .modal-header, .modal-body { padding-left: 16px; padding-right: 16px; }
  .modal-footer { padding: 0 16px 16px; flex-direction: column; }
  .modal-footer .btn { width: 100%; justify-content: center; min-height: 42px; }
}
@media (min-width: 641px) {
  .mobile-menu-toggle, .mobile-nav-backdrop, .mobile-profile { display: none; }
}
.gap-top { margin-top: 16px; }

.child-clinic-sidebar { font-size: 0.625rem; color: rgba(255,255,255,.4); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
