/* ===============================
   CareThread 365 — App Styles (refactored)
   Single palette for App + Public pages
   Priority is bottom-up: later sections intentionally override earlier ones.
   =============================== */


/* ===============================
   1) Theme + Resets (Unified palette + light/dark)
   =============================== */

:root{
  /* ===== CareThread Brand Palette (single source of truth) ===== */
  --ct-navy: #07111a;         /* darkest */
  --ct-ink:  #0b1220;         /* app background base */
  --ct-slate:#0f1a2f;         /* cards/panels */
  --ct-line: rgba(232,238,252,.12);

  --ct-text: #e8eefc;
  --ct-muted: rgba(232,238,252,.72);

  /* Brand gradient stops */
  --ct-teal: #2dd4bf;         /* teal */
  --ct-cyan: #19a7ff;         /* cyan/blue */
  --ct-blue: #4f8cff;         /* primary blue */

  /* ===== Semantic tokens used everywhere (app + public) ===== */
  --bg: var(--ct-ink);
  --card: var(--ct-slate);
  --text: var(--ct-text);
  --muted: var(--ct-muted);
  --border: var(--ct-line);

  /* Primary/Accent unify */
  --primary: var(--ct-blue);
  --accent: var(--ct-teal);

  /* Brand gradient */
  --brand-grad: linear-gradient(135deg, var(--ct-blue), var(--ct-teal));
  --brand-grad-soft:
    radial-gradient(900px 600px at 15% 10%, rgba(45,212,191,.18), transparent 55%),
    radial-gradient(900px 600px at 85% 20%, rgba(25,167,255,.14), transparent 55%);

  --radius:14px;
  --radius-lg:18px;

  --shadow:0 18px 55px rgba(0,0,0,.14);
  --shadow-soft:0 10px 30px rgba(0,0,0,.10);
}

/* Manual theme override (JS applies these classes) */
body.theme-dark{
  color-scheme: dark;
}
body.theme-light{
  color-scheme: light;
}

/* When user forces LIGHT, override tokens (same as prefers-color-scheme: light) */
body.theme-light{
  --ct-navy: #f6f7fb;
  --ct-ink:  #f6f7fb;
  --ct-slate:#ffffff;
  --ct-line: rgba(15,23,42,.12);

  --ct-text: #0f172a;
  --ct-muted: rgba(15,23,42,.65);

  --bg: var(--ct-ink);
  --card: var(--ct-slate);
  --text: var(--ct-text);
  --muted: var(--ct-muted);
  --border: var(--ct-line);

  --shadow:0 18px 55px rgba(15,23,42,.10);
  --shadow-soft:0 10px 30px rgba(15,23,42,.08);
}

/* When user forces DARK, ensure tokens are the dark set */
body.theme-dark{
  --ct-navy: #07111a;
  --ct-ink:  #0b1220;
  --ct-slate:#0f1a2f;
  --ct-line: rgba(232,238,252,.12);

  --ct-text: #e8eefc;
  --ct-muted: rgba(232,238,252,.72);

  --bg: var(--ct-ink);
  --card: var(--ct-slate);
  --text: var(--ct-text);
  --muted: var(--ct-muted);
  --border: var(--ct-line);

  --shadow:0 18px 55px rgba(0,0,0,.14);
  --shadow-soft:0 10px 30px rgba(0,0,0,.10);
}


/* Light mode (uses same brand accents, lighter surfaces) */
@media (prefers-color-scheme: light){
  :root{
    --ct-navy: #f6f7fb;
    --ct-ink:  #f6f7fb;
    --ct-slate:#ffffff;
    --ct-line: rgba(15,23,42,.12);

    --ct-text: #0f172a;
    --ct-muted: rgba(15,23,42,.65);

    --bg: var(--ct-ink);
    --card: var(--ct-slate);
    --text: var(--ct-text);
    --muted: var(--ct-muted);
    --border: var(--ct-line);

    --shadow:0 18px 55px rgba(15,23,42,.10);
    --shadow-soft:0 10px 30px rgba(15,23,42,.08);
  }
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  background:var(--bg);
  color:var(--text);
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

a{ color:inherit; text-decoration:none; }

/* Better default wrapping so content stays inside cards */
p, td, th, .kpi-value, .kpi-meta{
  overflow-wrap:anywhere;
  word-break:normal;
}


/* ===============================
   2) Containers + Page Layout
   =============================== */

.container{
  width:100%;
  margin:0 auto;
  padding:0 18px;
  max-width:1200px;
}

@media (min-width:1100px){
  .container{ padding:0 26px; }
}

.container--app{ max-width:1440px; }
@media (min-width:1600px){
  .container--app{ max-width:1680px; }

}

main{
  flex:1 0 auto;
  padding:28px 0 64px;
}

/* Public pages can opt into a slightly different main padding */
.page{
  padding: 26px 0 60px;
}

footer{
  margin-top:auto;
  border-top:1px solid var(--border);
  padding:18px 0;
}

.footer-inner{
  display:flex;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:12px;
  color:var(--muted);
}

.footer-links a{ color:inherit; margin-left:10px; }
.footer-links a:hover{ color:var(--text); text-decoration:underline; }


/* ===============================
   3) Header / Nav
   =============================== */

.topbar{
  position:sticky;
  top:0;
  background:color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);
  z-index:30;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.topbar-inner{
  display:flex;
  justify-content:space-between;
  align-items:center;
  height:66px;
  gap:14px;
}

.brand{
  display:flex;
  align-items:center;
  gap:14px;
}

.brand-logo-wrap{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  text-align:center;
}

.site-logo{
  max-width:110px;
  height:auto;
  display:block;
  filter:drop-shadow(0 6px 14px rgba(0,0,0,.20));
}

.brand-title{
  font-size:14px;
  font-weight:900;
  letter-spacing:-0.02em;
  line-height:1.1;
}

.brand-subtitle{
  font-size:12px;
  color:var(--muted);
}

.nav{
  display:flex;
  align-items:center;
  gap:10px;
}

/* In your base template, you can either:
   - keep nav-links + menu-btn pattern (existing), OR
   - use nav-desktop + menu button (my earlier suggestion).
   This file supports both. */

.nav-links{ display:none; }
.nav-desktop{ display:none; }

@media (min-width:860px){
  .nav-links{ display:flex; align-items:center; gap:10px; }
  .nav-desktop{ display:flex; align-items:center; gap:12px; }
  .menu-btn{ display:none; }
}

.nav-link{
  padding:9px 12px;
  border-radius:var(--radius);
  color:var(--muted);
  font-weight:650;
}

.nav-link:hover{
  background:color-mix(in srgb, var(--card) 85%, transparent);
  color:var(--text);
}

.menu-btn{
  background:none;
  border:1px solid var(--border);
  padding:8px 12px;
  border-radius:var(--radius);
  color:var(--text);
  cursor:pointer;
}

.mobile-panel{
  display:none;
  padding:12px 0 14px;
  border-top:1px solid var(--border);
}

.mobile-panel.open{
  display:grid;
  gap:10px;
}

.divider{
  height:1px;
  background:var(--border);
  margin:10px 0;
}


/* ===============================
   3b) Public surface (marketing) — uses same palette
   =============================== */

body.public{
  background:
    var(--brand-grad-soft),
    linear-gradient(180deg, var(--ct-navy), var(--bg) 70%, #03070a);
  color: var(--text);
}

/* Optional: make public buttons more "pill" */
body.public .btn{
  border-radius: 999px;
}


/* ===============================
   4) Buttons + Inputs
   =============================== */

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:10px 14px;
  border-radius:14px;
  font:inherit;
  font-weight:850;
  font-size:13px;
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--card) 78%, transparent);
  color:var(--text);
  cursor:pointer;
}

.btn:hover{
  background:color-mix(in srgb, var(--card) 86%, transparent);
}

.btn:active{ transform:translateY(1px); }

.btn-primary{
  border:0;
  color:#fff;
  background:var(--brand-grad);
  box-shadow:0 16px 40px rgba(0,0,0,.16);
}
.btn-primary:hover{ filter:brightness(1.03); }

.w-full{ width:100%; }

.logout-form{ margin:0; }

.btn-link{
  background:none;
  border:none;
  padding:9px 12px;
  border-radius:var(--radius);
  color:var(--muted);
  cursor:pointer;
  font:inherit;
  font-weight:650;
}
.btn-link:hover{
  background:color-mix(in srgb, var(--card) 85%, transparent);
  color:var(--text);
}

select, input, textarea{ font:inherit; }

.site-switch-nav{
  display:flex;
  gap:10px;
  align-items:center;
}

.site-switch-nav select{
  max-width:260px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--card) 90%, transparent);
  color:var(--text);
}

.site-switch-mobile{
  display:grid;
  gap:10px;
  margin-top:8px;
}

.mobile-label{
  font-size:12px;
  font-weight:900;
  letter-spacing:.10em;
  text-transform:uppercase;
  color:var(--muted);
}

.input{
  appearance:none;
  -webkit-appearance:none;
  width:100% !important;
  max-width:100%;
  display:block;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--card) 90%, transparent);
  color:var(--text);
  font-size:14px;
  line-height:1.4;
  transition:border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.input::placeholder{
  color:color-mix(in srgb, var(--muted) 85%, transparent);
}

.input:focus{
  outline:none;
  border-color:color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow:0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
}


/* ===============================
   5) Cards + Tables + Messages
   =============================== */

.card{
  border-radius:var(--radius-lg);
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--card) 94%, transparent);
  box-shadow:var(--shadow-soft);
}

.card-pad{ padding:18px; }
@media (min-width:1100px){
  .card-pad{ padding:22px; }
}

.messages{ margin:16px 0; }

.msg{
  padding:12px;
  border-radius:var(--radius);
  background:color-mix(in srgb, var(--card) 90%, transparent);
  border:1px solid var(--border);
  margin-bottom:10px;
}
.msg.success{ border-left:4px solid #22c55e; }
.msg.error{ border-left:4px solid #ef4444; }

.table{
  width:100%;
  border-collapse:collapse;
}

.table th,
.table td{
  padding:12px 10px;
  border-bottom:1px solid var(--border);
  text-align:left;
  font-size:14px;
  vertical-align:top;
}

.table th{
  color:var(--muted);
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.10em;
  white-space:nowrap;
}


/* ===============================
   6) Auth Forms
   =============================== */

.auth-wrap{
  min-height:calc(100vh - 66px - 80px);
  display:grid;
  place-items:center;
  padding:32px 0;
}

.auth-card{
  width:100%;
  max-width:460px;
  padding:22px;
  border-radius:18px;
  background:color-mix(in srgb, var(--card) 94%, transparent);
  border:1px solid var(--border);
  box-shadow:var(--shadow);
}

@media (min-width:720px){
  .auth-card{ padding:28px; }
}

.form-row{ margin-bottom:16px; }

.form-row label,
.form-p p label{
  display:block;
  margin-bottom:8px;
  font-weight:700;
  font-size:13px;
  color:color-mix(in srgb, var(--text) 92%, var(--muted));
}

.field-error{
  margin-top:7px;
  font-size:13px;
  color:#ef4444;
}

.form-actions{ margin-top:16px; }

.form-p p{ margin:0 0 14px; }

.form-p p input,
.form-p p select,
.form-p p textarea{
  width:100% !important;
  box-sizing:border-box;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--card) 90%, transparent);
  color:var(--text);
}

.form-p p input:focus,
.form-p p select:focus,
.form-p p textarea:focus{
  outline:none;
  border-color:color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow:0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
}


/* ===============================
   6b) Page headings + public forms
   (used by tenant signup and similar)
   =============================== */

.page-head{ margin: 10px 0 14px; }

.page-title{
  margin:0;
  font-size: clamp(24px, 3.6vw, 34px);
  letter-spacing:-0.03em;
}

.page-subtitle{
  margin: 6px 0 0;
  color: var(--muted);
}

/* General form grid for normal pages (2-col -> 1-col) */
.form-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 980px){
  .form-grid{ grid-template-columns: 1fr; }
}

.span-2{ grid-column: 1 / -1; }


/* ===============================
   7) App Pages (dash + modern grid system)
   =============================== */

.dash{
  padding:10px 0 34px;
}

.dash-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
  margin:10px 0 22px;
}

.dash-title{
  margin:0;
  font-size:34px;
  letter-spacing:-0.03em;
}

.dash-subtitle{
  margin:8px 0 0;
  color:var(--muted);
  font-size:14px;
}

.dash-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

.kpi-label{
  color:var(--muted);
  font-weight:900;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.10em;
}

.kpi-value{
  margin-top:10px;
  font-size:18px;
  font-weight:900;
  letter-spacing:-0.01em;
}

.kpi-meta{
  margin-top:8px;
  color:var(--muted);
  font-size:13px;
}

.app-grid{
  display:grid;
  gap:20px;
  grid-template-columns:1fr;
  align-items:start;
}

@media (min-width:1100px){
  .app-grid{
    grid-template-columns:1.6fr .8fr;
  }
}

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

@media (min-width:760px){
  .kpi-grid{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }
}

@media (min-width:1200px){
  .kpi-grid{
    grid-template-columns:repeat(4, minmax(0, 1fr));
  }
}

.kpi-grid > .card{ height:100%; }

.grid{
  display:grid;
  gap:16px;
  grid-template-columns:1fr;
  align-items:stretch;
}

@media (min-width:760px){
  .grid{ grid-template-columns:repeat(3, minmax(0, 1fr)); }
}

@media (min-width:1300px){
  .grid.grid-4{ grid-template-columns:repeat(4, minmax(0, 1fr)); }
}


/* ===============================
   Dashboard right-rail (Quick actions / Your sites)
   =============================== */

.rail-title{
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: color-mix(in srgb, var(--text) 90%, var(--muted));
  font-weight: 900;
}

.mini-list{
  display: grid;
  gap: 10px;
}

.mini-item{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;

  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 92%, transparent);
}

.mini-item strong{
  font-weight: 850;
}

.mini-item span{
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.mini-item .nav-link{
  padding: 0;
  border-radius: 0;
  color: var(--primary);
  font-weight: 800;
}

.mini-item .nav-link:hover{
  background: transparent;
  color: color-mix(in srgb, var(--primary) 85%, var(--text));
  text-decoration: underline;
}

.checkbox{
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  vertical-align: middle;
}

/* ===== Accordion (Service Users list) ===== */
.accordion{
  border: 0;
  margin-bottom: 14px;
}

.accordion-summary{
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  box-shadow: var(--shadow-soft);
}

.accordion-summary::-webkit-details-marker{ display:none; }

.accordion-left{
  min-width: 0;
}

.accordion-body{
  margin-top: 10px;
}

.accordion-chevron{
  color: var(--muted);
  font-weight: 900;
  transition: transform .15s ease;
}

.accordion[open] .accordion-chevron{
  transform: rotate(180deg);
}

input[type="datetime-local"].input { width: 100%; }


/* =========================
   Care Plan Version Detail
   ========================= */

.cp-need-list{ display:flex; flex-direction:column; }
.cp-need-btn{
  appearance:none;
  width:100%;
  text-align:left;
  border:0;
  background:transparent;
  padding:12px 14px;
  cursor:pointer;
  display:flex;
  flex-direction:column;
  gap:6px;
  border-bottom:1px solid var(--border);
}
.cp-need-btn:last-child{ border-bottom:0; }
.cp-need-btn:hover{ background:color-mix(in srgb, var(--card) 88%, transparent); }

.cp-need-name{
  font-weight:950;
  font-size:14px;
  letter-spacing:-0.01em;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.cp-need-meta{
  color:var(--muted);
  font-weight:800;
  font-size:12px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.badge{
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--card) 84%, transparent);
  font-weight:900;
  font-size:12px;
  color:var(--text);
  white-space:nowrap;
}
.muted{ color:var(--muted); font-weight:800; font-size:12px; }

.cp-box{
  border:1px solid var(--border);
  border-radius:16px;
  background:color-mix(in srgb, var(--card) 90%, transparent);
  padding:12px 12px;
}
.cp-label{ font-weight:950; font-size:12px; text-transform:uppercase; letter-spacing:.02em; color:var(--muted); }
.cp-text{ margin-top:8px; color:var(--text); white-space:pre-wrap; }

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

.goals-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin:14px 0 10px;
}
.goals-title{ font-weight:950; text-transform:uppercase; letter-spacing:.02em; color:var(--muted); font-size:12px; }
.goals-help{ color:var(--muted); font-weight:800; font-size:12px; }

.gtable{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  border:1px solid var(--border);
  border-radius:16px;
  background:color-mix(in srgb, var(--card) 96%, transparent);
}
.gtable th, .gtable td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  vertical-align:top;
}
.gtable th{
  background:color-mix(in srgb, var(--card) 88%, transparent);
  color:var(--muted);
  font-weight:950;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.02em;
  white-space:nowrap;
}
.gtable tr:last-child td{ border-bottom:0; }
.gtitle{ font-weight:950; margin:0; }
.gmeta{ margin-top:4px; color:var(--muted); font-weight:800; font-size:12px; }

.toggle{
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--card) 84%, transparent);
  border-radius:12px;
  padding:8px 10px;
  font-weight:900;
  font-size:12px;
  cursor:pointer;
  color:var(--text);
  white-space:nowrap;
}
.toggle:hover{ background:color-mix(in srgb, var(--card) 92%, transparent); }

.int-list{ display:flex; flex-direction:column; gap:10px; }
.int-item{
  border:1px solid var(--border);
  border-radius:14px;
  background:color-mix(in srgb, var(--card) 94%, transparent);
  padding:10px 10px;
}
.int-top{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.int-instruction{ font-weight:900; white-space:pre-wrap; }
.int-meta{
  color:var(--muted);
  font-weight:800;
  font-size:12px;
  margin-top:6px;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.card-square{ border-radius:12px; }

.cp-actions-row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }

.linkish{
  background:none;
  border:0;
  padding:0;
  color:var(--primary);
  font-weight:900;
  cursor:pointer;
}
.linkish:hover{ text-decoration:underline; }


/* ===============================
   MODALS (single source of truth)
   - Scrollable body
   - Sticky header + actions
   - Professional spacing
   =============================== */

body.modal-open{
  overflow:hidden;
}

/* Overlay */
.modal-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.62);
  display:none;
  align-items:center;
  justify-content:center;
  padding:18px;
  z-index:10000;
}
.modal-overlay.open{ display:flex; }

/* Keep create-modals above drilldown modal */
#needModal.modal-overlay,
#goalModal.modal-overlay,
#interventionModal.modal-overlay{ z-index:10050; }
#cpModal.modal-overlay{ z-index:10000; }

/* Shell */
.modal{
  width:100%;
  max-width:980px;
  max-height:90vh;

  border-radius:18px;
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--card) 96%, transparent);
  box-shadow:var(--shadow);

  display:flex;
  flex-direction:column;
  overflow:hidden; /* IMPORTANT: body scrolls */
}

/* Header */
.modal-head{
  padding:16px 18px;
  border-bottom:1px solid var(--border);

  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;

  position:sticky;
  top:0;
  z-index:2;

  background:color-mix(in srgb, var(--card) 98%, transparent);
  backdrop-filter: blur(10px);
}

.modal-title{
  font-weight:950;
  letter-spacing:-0.01em;
}

/* Scroll area */
.modal-body{
  padding:18px;
  overflow-y: scroll !important;    /* IMPORTANT */
  flex:1 1 auto;     /* IMPORTANT */
  min-height:0;      /* IMPORTANT */
}

/* Footer actions */
.modal-actions{
  padding:16px 18px;
  border-top:1px solid var(--border);

  display:flex;
  gap:10px;
  justify-content:flex-end;
  flex-wrap:wrap;

  position:sticky;
  bottom:0;
  z-index:2;

  background:color-mix(in srgb, var(--card) 98%, transparent);
  backdrop-filter: blur(10px);
}

/* ✅ FIX: modal form grids must NOT leak to page forms */
.modal .form-grid{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap:12px 14px;
  align-items:start;
}

@media (max-width: 1100px){
  .modal{ max-width:860px; }
  .modal .form-grid{ grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px){
  .modal{ max-width:calc(100vw - 22px); }
  .modal .form-grid{ grid-template-columns: 1fr; }
}

.form-row{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width:0;
}

.form-row label{
  font-weight:900;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.02em;
  color:var(--muted);
}

.form-hint{
  color:var(--muted);
  font-weight:800;
  font-size:12px;
  line-height:1.35;
  margin-top:2px;
}

/* Inputs inside modals look tighter + consistent */
.modal input,
.modal select,
.modal textarea{
  width:100% !important;
  box-sizing:border-box;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--border);
  background:color-mix(in srgb, var(--card) 90%, transparent);
  color:var(--text);
}

.modal input:focus,
.modal select:focus,
.modal textarea:focus{
  outline:none;
  border-color:color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow:0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
}

.modal textarea{ min-height:110px; resize:vertical; }


/* ===============================
   Care Plan / Page-only tile grid utilities
   =============================== */

.tile-grid{
  display:grid;
  gap:16px;
  grid-template-columns:repeat(12, minmax(0, 1fr));
  align-items:stretch;
}

@media (max-width: 980px){
  .tile-grid{ grid-template-columns:1fr; }
}

.col-12{ grid-column: span 12; }
.col-8{ grid-column: span 8; }
.col-6{ grid-column: span 6; }
.col-4{ grid-column: span 4; }

.card-square{ border-radius:12px; }


/* ===============================
   Global Tile / Card Flip-In Animation
   =============================== */

.su-anim{
  opacity: 0;
  transform:
    perspective(1000px)
    rotateX(18deg)
    translateY(18px)
    scale(0.985);
  transform-origin: top center;

  transition:
    transform 0.7s cubic-bezier(.2,.85,.25,1),
    opacity 0.5s ease;

  will-change: transform, opacity;
}

.su-anim.in{
  opacity: 1;
  transform:
    perspective(1000px)
    rotateX(0deg)
    translateY(0)
    scale(1);
}

/* ✅ FIX: only apply the "strong" tilt BEFORE the card animates in */
.su-anim.su-anim-strong:not(.in){
  transform:
    perspective(1200px)
    rotateX(26deg)
    translateY(22px)
    scale(0.97);
}

.su-hidden{
  display: none !important;
}

@media (prefers-reduced-motion: reduce){
  .su-anim,
  .su-anim.in{
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

.no-anywhere{
  overflow-wrap: normal !important;
  word-break: normal !important;
}

.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  letter-spacing: -0.01em;
}

/* If a modal contains a form, the form must be the flex column */
.modal > form{
  display:flex;
  flex-direction:column;
  flex:1 1 auto;
  min-height:0;      /* critical for scroll to work */
}

/* Make body the scrollable region */
.modal > form > .modal-body{
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
}

/* Keep actions at the bottom (sticky still works) */
.modal > form > .modal-actions{
  flex:0 0 auto;
}

/* Global loading overlay */
.gl-overlay{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20000;

  background: rgba(0,0,0,.45);
  backdrop-filter: blur(6px);
}

.gl-overlay.open{ display: flex; }

.gl-card{
  width: min(420px, calc(100vw - 36px));
  border-radius: 18px;
  border: 1px solid var(--border, rgba(255,255,255,.15));
  background: color-mix(in srgb, var(--card, #111827) 92%, transparent);
  box-shadow: 0 18px 55px rgba(0,0,0,.25);
  padding: 18px 18px;
  text-align: center;
}

.gl-title{
  margin-top: 10px;
  font-weight: 950;
  letter-spacing: -0.01em;
}

.gl-sub{
  margin-top: 6px;
  color: var(--muted, rgba(255,255,255,.7));
  font-size: 13px;
  font-weight: 800;
}

.gl-spinner{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: rgba(255,255,255,.95);
  margin: 0 auto;
  animation: glspin .8s linear infinite;
}

@keyframes glspin{
  to { transform: rotate(360deg); }
}

/* Optional: prevent clicks while loading */
body.is-loading{
  cursor: progress;
}

/* ===== Navbar service user dropdown ===== */

.nav-dropdown{
  position: relative;
}

.nav-dropdown > summary{
  list-style: none;
  cursor: pointer;
}
.nav-dropdown > summary::-webkit-details-marker{
  display: none;
}

.nav-dropdown-panel{
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(320px, 90vw);
  z-index: 1000;
}

.nav-user-list{
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.nav-user-link{
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 800;
  color: var(--text);
}

.nav-user-link:hover{
  background: color-mix(in srgb, var(--card) 88%, transparent);
  color: var(--primary);
}


/* ===== Nice checkbox “cards” for the Sites field ===== */

#id_sites {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

#id_sites li {
  margin: 0;
}

/* Make each option a clickable row */
#id_sites label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  font-weight: 700;
}

/* Hover */
#id_sites label:hover {
  background: rgba(0,0,0,0.03);
}

/* Hide ugly native checkbox + draw a nice one */
#id_sites input[type="checkbox"] {
  appearance: none !important;
  -webkit-appearance: none !important;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: inline-grid;
  place-content: center;
  margin: 0;
  flex-shrink: 0;
  background: #fff;
}

/* Tick */
#id_sites input[type="checkbox"]::before {
  content: "";
  width: 10px;
  height: 10px;
  transform: scale(0);
  transition: transform 0.12s ease-in-out;
  background: #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

/* Checked */
#id_sites input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
#id_sites input[type="checkbox"]:checked::before {
  transform: scale(1);
}

/* Keyboard focus */
#id_sites input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

/* Optional: highlight selected row (modern browsers) */
#id_sites label:has(input[type="checkbox"]:checked) {
  background: rgba(79, 70, 229, 0.07);
  border-color: var(--primary);
}

/* ---------- Assign sites form polish ---------- */

/* Space the whole field block */
.form-grid {
  margin-top: 18px;
}

/* "Sites:" label */
.form-grid > label,
.form-grid > p > label {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
  font-size: 0.9rem;
}

/* Checkbox list container */
#id_sites {
  margin-top: 12px;
  margin-bottom: 10px;
}

/* Individual checkbox cards */
#id_sites label {
  padding: 14px 16px;
  min-height: 52px;
}

/* Space between cards */
#id_sites {
  display: grid;
  gap: 12px;
}

/* Checkbox itself */
#id_sites input[type="checkbox"] {
  margin-left: 2px;
}

/* Help text under list */
.form-grid .helptext {
  margin-top: 10px;
  padding-left: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Save button spacing */
.form-actions {
  margin-top: 26px;
}

/* Back link spacing */
.auth-links {
  margin-top: 16px;
}

/* Mobile tightening */
@media (max-width: 480px) {
  #id_sites label {
    padding: 12px 14px;
  }
}

/* ===============================
   Buttons (Corporate SaaS polish)
   Paste at bottom so it overrides older .btn rules
   =============================== */

:root{
  /* Optional button-specific tokens */
  --btn-radius: 12px;
  --btn-border: color-mix(in srgb, var(--border) 85%, transparent);
  --btn-bg: color-mix(in srgb, var(--card) 92%, transparent);
  --btn-bg-hover: color-mix(in srgb, var(--card) 86%, transparent);
  --btn-text: var(--text);
  --btn-shadow: 0 8px 22px rgba(0,0,0,.12);
}

/* Ensure light mode buttons have actual surface contrast */
body.theme-light{
  --btn-border: rgba(15,23,42,.14);
  --btn-bg: rgba(15,23,42,.04);
  --btn-bg-hover: rgba(15,23,42,.07);
  --btn-shadow: 0 10px 28px rgba(15,23,42,.10);
}

@media (prefers-color-scheme: light){
  body:not(.theme-dark){
    --btn-border: rgba(15,23,42,.14);
    --btn-bg: rgba(15,23,42,.04);
    --btn-bg-hover: rgba(15,23,42,.07);
    --btn-shadow: 0 10px 28px rgba(15,23,42,.10);
  }
}

.btn{
  appearance: none;
  -webkit-appearance: none;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  height: 40px;
  padding: 0 14px;

  border-radius: var(--btn-radius);
  border: 1px solid var(--btn-border);

  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--btn-bg) 85%, transparent),
      color-mix(in srgb, var(--btn-bg) 100%, transparent)
    );

  color: var(--btn-text);
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.01em;

  cursor: pointer;
  user-select: none;

  transition:
    transform .12s ease,
    background-color .12s ease,
    border-color .12s ease,
    box-shadow .12s ease,
    filter .12s ease;
}

.btn:hover{
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--btn-bg-hover) 85%, transparent),
      color-mix(in srgb, var(--btn-bg-hover) 100%, transparent)
    );
  border-color: color-mix(in srgb, var(--primary) 18%, var(--btn-border));
  box-shadow: var(--btn-shadow);
  transform: translateY(-1px);
}

.btn:active{
  transform: translateY(0px);
  box-shadow: none;
}

.btn:focus-visible{
  outline: none;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent),
    var(--btn-shadow);
  border-color: color-mix(in srgb, var(--primary) 30%, var(--btn-border));
}

/* Primary button: modern gradient + readable in light mode */
.btn-primary{
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  color: #041016;
  box-shadow: 0 14px 40px rgba(0,0,0,.18);
}

.btn-primary:hover{
  filter: brightness(1.03);
  box-shadow: 0 18px 52px rgba(0,0,0,.22);
}

.btn-primary:focus-visible{
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--ct-teal) 22%, transparent),
    0 18px 52px rgba(0,0,0,.22);
}

/* Full width utility stays */
.w-full{ width: 100%; }

/* Link-style button: keep it clean and non-bootstrappy */
.btn-link{
  height: auto;
  padding: 8px 10px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.btn-link:hover{
  background: color-mix(in srgb, var(--card) 88%, transparent);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.btn-link:focus-visible{
  outline: none;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* Optional: compact icon button (useful for theme toggle) */
.btn-icon{
  width: 40px;
  padding: 0;
  justify-content: center;
}

/* Optional: “quiet” button variant */
.btn-quiet{
  background: transparent;
  border-color: var(--btn-border);
}
.btn-quiet:hover{
  background: color-mix(in srgb, var(--card) 92%, transparent);
}

/* ===============================
   Public landing page (LP) — scoped, calm, matches app UI
   Paste at bottom of app.css
   =============================== */

.lp-hero{ padding: 22px 0 8px; }
.lp-hero-grid{
  display:grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
  align-items: start;
}

.lp-kicker{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 90%, transparent);
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}
.lp-dot{
  width:9px; height:9px; border-radius:999px;
  background: color-mix(in srgb, var(--primary) 70%, var(--accent));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent);
}

.lp-title{
  margin: 14px 0 8px;
  font-size: clamp(30px, 4.2vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.lp-lead{
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.65;
  max-width: 65ch;
}

.lp-actions{ display:flex; gap:10px; flex-wrap:wrap; margin-top: 10px; }
.lp-badges{ display:flex; gap:10px; flex-wrap:wrap; margin-top: 14px; }

.lp-hero-panel{ position: relative; overflow:hidden; }
.lp-preview{
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  padding: 14px;
}
.lp-preview-img{
  width:100%;
  height:auto;
  display:block;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.lp-preview-skel{ display:grid; gap: 12px; }
.lp-skel-top{ display:flex; justify-content:space-between; gap:10px; }
.lp-skel-pill{
  height: 28px;
  width: 140px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 88%, transparent);
}
.lp-skel-pill--short{ width: 92px; }

.lp-skel-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.lp-skel-card{
  height: 86px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 86%, transparent);
}

.lp-mini{ margin-top: 14px; }
.lp-mini-title{
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .10em;
  color: var(--muted);
}
.lp-mini-list{
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.65;
}

.lp-section{ padding: 26px 0; }
.lp-section-head h2{ margin:0 0 6px; letter-spacing:-0.02em; }
.lp-section-head p{ margin:0 0 14px; color: var(--muted); line-height:1.6; max-width: 80ch; }

.lp-cards{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.lp-card-title{ font-weight: 950; letter-spacing: -0.01em; }
.lp-card-sub{ margin-top: 6px; color: var(--muted); line-height: 1.55; font-size: 14px; }

.lp-pricing{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}
.lp-price-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap: 12px;
}
.lp-price-name{ font-weight: 950; }
.lp-price-value{ margin-top: 6px; font-size: 34px; font-weight: 950; letter-spacing:-0.02em; }
.lp-price-value span{ font-size: 14px; font-weight: 800; color: var(--muted); }
.lp-list{ margin: 12px 0 14px; padding-left: 18px; color: var(--muted); line-height: 1.65; }

.lp-cta{ padding: 10px 0 46px; }
.lp-cta-inner{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 14px;
  flex-wrap: wrap;
}
.lp-cta-title{ margin:0; }
.lp-cta-sub{ margin:6px 0 0; color: var(--muted); line-height: 1.6; max-width: 70ch; }
.lp-cta-actions{ display:flex; gap: 10px; flex-wrap: wrap; }

/* Responsive */
@media (max-width: 980px){
  .lp-hero-grid{ grid-template-columns: 1fr; }
  .lp-cards{ grid-template-columns: 1fr; }
  .lp-pricing{ grid-template-columns: 1fr; }
  .lp-skel-grid{ grid-template-columns: 1fr; }
}

/* ===============================
   Public landing spacing fixes
   =============================== */

/* Make anchor jumps land below the sticky header */
:root{ --topbar-h: 66px; }
html{ scroll-padding-top: calc(var(--topbar-h) + 18px); }

/* Better vertical rhythm on public pages */
body.public .page{ padding-top: 18px; }               /* was 26px; feels cramped under header */
body.public .lp-hero{ padding-top: 18px; }            /* ensure hero doesn't kiss the topbar */

/* Sections: consistent top spacing and nicer separation */
body.public .lp-section{
  padding: 46px 0;                                    /* more breathing room */
}
body.public .lp-section:first-of-type{
  padding-top: 34px;                                  /* features section starts nicely */
}

/* Head spacing inside sections */
body.public .lp-section-head{ margin-bottom: 16px; }
body.public .lp-section-head h2{ margin-top: 0; }

/* Optional: add subtle separators between sections (keeps it “SaaS”) */
body.public .lp-section{
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}
body.public .lp-section:first-of-type{
  border-top: 0;
}

/* CTA spacing */
body.public .lp-cta{ padding: 18px 0 54px; }


/* ===============================
   Public website overrides (SHARP + embossed) — app unchanged
   Paste at very bottom of app.css
   =============================== */

:root{ --topbar-h: 66px; }
html{ scroll-padding-top: calc(var(--topbar-h) + 18px); }

/* Public background: calmer, less “washed” */
body.public{
  background:
    radial-gradient(1100px 680px at 12% 6%, rgba(25,167,255,.18), transparent 55%),
    radial-gradient(900px 560px at 78% 10%, rgba(45,212,191,.14), transparent 58%),
    linear-gradient(180deg, var(--ct-navy), var(--bg) 70%, var(--bg));
}

/* Website-only sharp geometry + embossed surfaces */
body.public{
  --lp-radius: 10px;          /* sharp, but not brutal */
  --lp-radius-sm: 8px;
  --lp-shadow: 0 16px 34px rgba(0,0,0,.10);
  --lp-emboss: inset 0 1px 0 rgba(255,255,255,.06);
}

/* Light mode: emboss highlight needs to switch */
body.public.theme-light
@media (prefers-color-scheme: light){
  body.public:not(.theme-dark){
    --lp-shadow: 0 16px 34px rgba(15,23,42,.10);
    --lp-emboss: inset 0 1px 0 rgba(255,255,255,.85);
  }
}

/* Kill pill buttons on public site (you had this earlier) */
body.public .btn{ border-radius: var(--lp-radius-sm); }

/* Public cards: sharp + subtle embossed rim */
body.public .card{
  border-radius: var(--lp-radius);
  box-shadow: var(--lp-shadow);
  background: color-mix(in srgb, var(--card) 96%, transparent);
  position: relative;
}
body.public .card::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  pointer-events:none;
  box-shadow: var(--lp-emboss);
}

/* Public badges: sharp */
body.public .badge{
  border-radius: 999px; /* keep these as pills; reads better */
  background: color-mix(in srgb, var(--card) 92%, transparent);
}

/* Public spacing (the padding problem) */
body.public .page{ padding-top: 18px; }
body.public .lp-hero{ padding: 22px 0 18px; }
body.public .lp-section{ padding: 54px 0; }
body.public .lp-cta{ padding: 22px 0 64px; }
body.public .lp-section + .lp-section{
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}

/* Layout tweaks */
body.public .lp-hero-grid{
  gap: 22px;
  align-items: start;
}
body.public .lp-title{ margin-top: 14px; }
body.public .lp-lead{ margin-bottom: 16px; }

/* Testing notice */
.lp-notice{
  margin-top: 14px;
  padding: 12px 12px;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border-radius: var(--lp-radius-sm);
  color: var(--muted);
  line-height: 1.55;
}
.lp-notice strong{ color: var(--text); }

/* Screenshot system */
.lp-shots{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
.lp-shot-frame{
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--lp-radius-sm);
  overflow: hidden;
  background: color-mix(in srgb, var(--card) 92%, transparent);
}
.lp-shot-img{
  width:100%;
  height:auto;
  display:block;
}
.lp-shot-placeholder{
  min-height: 180px;
  display:grid;
  place-items:center;
  padding: 16px;
  text-align:center;
  color: var(--muted);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--card) 94%, transparent),
      color-mix(in srgb, var(--card) 90%, transparent)
    );
}
.lp-shot-title{ font-weight: 950; color: var(--text); }
.lp-shot-sub{ margin-top: 6px; font-size: 13px; }
.lp-shot-kicker{
  font-weight: 950;
  letter-spacing: -0.01em;
}
.lp-shot-fn{
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.lp-shot-desc{
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

/* Long-read block */
.lp-longread{ line-height: 1.7; }
.lp-h3{
  margin: 16px 0 8px;
  letter-spacing: -0.01em;
}
.lp-divider{
  height: 1px;
  background: color-mix(in srgb, var(--border) 80%, transparent);
  margin: 18px 0;
}
.lp-muted{ color: var(--muted); }

/* Responsive */
@media (max-width: 980px){
  body.public .lp-hero-grid{ grid-template-columns: 1fr; }
  .lp-shots{ grid-template-columns: 1fr; }
}


/* ===============================
   Public landing: 100vh snap sections (ONLY website)
   Paste at very bottom of app.css
   =============================== */

:root { --topbar-h: 66px; }

/* Make the PUBLIC page the scroll container */
body.public{
  height: 100vh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-padding-top: var(--topbar-h);
  scroll-behavior: smooth;

  /* Prevent “rubber band” overscroll glow / weirdness */
  overscroll-behavior-y: none;
}

/* Remove extra padding that was designed for normal document scrolling */
body.public main{
  padding: 0 !important;
}

/* Every landing section becomes a snap “panel” */
body.public .lp-hero,
body.public .lp-section,
body.public .lp-cta{
  min-height: calc(100vh - var(--topbar-h));
  scroll-snap-align: start;
  scroll-snap-stop: always;

  /* Consistent spacing so content never kisses edges */
  padding: 48px 0;

  /* Stop box-shadows from visually “overlapping” the next section */
  position: relative;
  isolation: isolate;
}

/* Snap targets for anchor links so headings aren’t hidden under the sticky header */
body.public .lp-hero,
body.public .lp-section,
body.public .lp-cta{
  scroll-margin-top: var(--topbar-h);
}

/* Optional: make each panel feel separated without heavy gradients */
body.public .lp-hero::after,
body.public .lp-section::after,
body.public .lp-cta::after{
  content:"";
  position:absolute;
  left:0; right:0; bottom:0;
  height: 1px;
  background: color-mix(in srgb, var(--border) 75%, transparent);
  pointer-events:none;
}

/* If a section’s content is taller than the viewport, allow it to scroll internally */
body.public .lp-hero > *,
body.public .lp-section > *,
body.public .lp-cta > *{
  max-width: 100%;
}

/* Mobile: slightly tighter vertical padding */
@media (max-width: 760px){
  body.public .lp-hero,
  body.public .lp-section,
  body.public .lp-cta{
    padding: 34px 0;
  }
}

/* Reduced motion: keep snap but avoid smooth scroll */
@media (prefers-reduced-motion: reduce){
  body.public{ scroll-behavior: auto; }
}
/* ===============================
   PUBLIC ONLY: snap panels + centred sections
   =============================== */

:root { --topbar-h: 66px; }
html, body { height: 100%; }

/* Only public website pages snap */
body.public{
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;

  scroll-snap-type: y mandatory;
  scroll-padding-top: var(--topbar-h);
  overscroll-behavior-y: contain;
  scroll-behavior: auto;
}

/* App should behave normally */
body.app{
  height: auto;
  overflow: visible;
}

/* Public main must not fight the panel layout */
body.public main{
  padding: 0 !important;
  margin: 0 !important;
}

/* Each public landing section becomes a panel */
body.public .lp-hero,
body.public .lp-section,
body.public .lp-cta{
  min-height: calc(100vh - var(--topbar-h));
  scroll-snap-align: start;
  scroll-snap-stop: always;

  display: grid;
  align-items: center;
  padding: 24px 0;
  position: relative;
  isolation: isolate;
}

/* Optional: if a section is long, add class="is-tall" to that section */
body.public .lp-section.is-tall{
  align-items: start;
  padding-top: 48px;
  padding-bottom: 48px;
}

/* =========================================================
   RESPONSIVE WIDE FORMS (paste at very bottom of app.css)
   - Wider auth-card-wide
   - Responsive 2-col form layout (desktop), 1-col (tablet/mobile)
   - Better spacing + readable inputs
   ========================================================= */

/* ---- Global container breathing room on small screens ---- */
@media (max-width: 520px){
  .container{ padding: 0 14px; }
  main{ padding: 18px 0 44px; }
}

/* ---- Auth layout: better vertical rhythm on mobile ---- */
.auth-wrap{
  padding: clamp(18px, 4vw, 40px) 0;
  min-height: calc(100vh - 66px - 80px);
}

/* ---- Make “wide” cards actually wide, but still responsive ---- */
.auth-card.auth-card-wide{
  max-width: 1400px;                 /* desktop width */
  width: min(1400px, calc(100% - 48px));
  margin: 0 auto;
}

/* Ultra-wide screens: give it more space */
@media (min-width: 1600px){
  .auth-card.auth-card-wide{
    max-width: 1600px;
    width: min(1600px, calc(100% - 72px));
  }
}

/* Tablet: reduce outer gutters so it doesn’t feel cramped */
@media (max-width: 980px){
  .auth-card.auth-card-wide{
    width: calc(100% - 32px);
    max-width: 980px;
  }
}

/* Mobile: full-width feel without touching edges */
@media (max-width: 520px){
  .auth-card,
  .auth-card.auth-card-wide{
    width: calc(100% - 22px);
    padding: 18px;
    border-radius: 16px;
  }
}

/* ---- Improve the auth header spacing ---- */
.auth-head{ margin-bottom: 14px; }
.auth-title{
  margin: 0;
  font-size: clamp(22px, 3.2vw, 34px);
  letter-spacing: -0.03em;
}
.auth-subtitle{
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

/* =========================================================
   DJANGO form.as_p -> responsive “two column” layout
   Works for both .auth-card pages and .page/.dash cards.
   ========================================================= */

/* Base: turn <p> blocks into “field cards” */
.form-p p{
  margin: 0 0 14px;
}

/* Force consistent label + help + errors spacing */
.form-p p label{
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
  font-size: 13px;
  color: color-mix(in srgb, var(--text) 92%, var(--muted));
}

/* Inputs always stretch */
.form-p p input,
.form-p p select,
.form-p p textarea{
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box;
}

/* Helptext if Django renders it */
.form-p .helptext,
.form-p p .helptext{
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  line-height: 1.35;
}

/* Error lists if Django renders <ul class="errorlist"> */
.form-p ul.errorlist{
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  color: #ef4444;
  font-weight: 800;
  font-size: 12px;
}
.form-p ul.errorlist li{ margin: 0; }

/* =========================================================
   TWO-COLUMN FORMS (desktop) / ONE COLUMN (tablet+mobile)
   Apply automatically to forms inside these “wide” contexts:
   - .auth-card-wide
   - .card.card-pad (common in your app)
   ========================================================= */

/* Default: 1 col (safe everywhere) */
.auth-card-wide .form-p,
.card.card-pad .form-p{
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px 22px;
}

/* Desktop: 2 col */
@media (min-width: 980px){
  .auth-card-wide .form-p,
  .card.card-pad .form-p{
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  /* Make actions span full width */
  .auth-card-wide .form-actions,
  .card.card-pad .form-actions{
    grid-column: 1 / -1;
    margin-top: 6px;
  }

  /* Dividers/titles span full width */
  .auth-card-wide .divider,
  .card.card-pad .divider,
  .auth-card-wide .section-title,
  .card.card-pad .section-title{
    grid-column: 1 / -1;
  }
}

/* Tablet: keep 1 col but increase readability */
@media (max-width: 980px){
  .auth-card-wide .form-p,
  .card.card-pad .form-p{
    gap: 12px;
  }
}

/* Mobile: tighten the vertical rhythm */
@media (max-width: 520px){
  .form-p p{ margin: 0 0 12px; }
  .form-actions{ margin-top: 12px; }
  .btn{ width: 100%; }              /* mobile UX: full width buttons */
}

/* =========================================================
   Optional: make “page” forms match auth look slightly
   (only affects pages using .page/.page-head)
   ========================================================= */
.page .card.card-pad{
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}
@media (max-width: 980px){
  .page .card.card-pad{
    max-width: 980px;
  }
}

/* ===============================
   BREAK OUT of .container for full-width auth pages
   (Works even if base.html wraps content in .container max-width:1200)
   =============================== */

.auth-wrap{
  /* take full viewport width, ignoring parent max-width */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);

  /* keep your nice centering */
  display: grid;
  place-items: center;
  padding: 32px 0;
}

/* Make wide auth cards actually wide */
.auth-card.auth-card-wide{
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
}

/* Tablet */
@media (max-width: 980px){
  .auth-card.auth-card-wide{
    width: calc(100vw - 32px);
  }
}

/* Mobile */
@media (max-width: 520px){
  .auth-card.auth-card-wide{
    width: calc(100vw - 22px);
    padding: 18px;
    border-radius: 16px;
  }
}

/* =========================================
   About Me — CLEAN staggered grid (NOT masonry)
   - Keeps a strict grid so it never looks “awful”
   - Adds subtle column-based offsets only
   ========================================= */

.am-masonry{
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  align-items: stretch;
}

/* 2 columns */
@media (min-width: 760px){
  .am-masonry{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* subtle stagger: right column down a touch */
  .am-masonry > .am-tile-btn:nth-child(2n){
    transform: translateY(10px);
  }
}

/* 3 columns */
@media (min-width: 1100px){
  .am-masonry{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* reset the 2-col rule */
  .am-masonry > .am-tile-btn{ transform: none; }

  /* subtle stagger by column */
  .am-masonry > .am-tile-btn:nth-child(3n+2){ transform: translateY(10px); }
  .am-masonry > .am-tile-btn:nth-child(3n){   transform: translateY(20px); }
}

/* 4 columns (wide) */
@media (min-width: 1400px){
  .am-masonry{
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .am-masonry > .am-tile-btn{ transform: none; }

  /* stepped columns: 0 / 8 / 16 / 24 */
  .am-masonry > .am-tile-btn:nth-child(4n+2){ transform: translateY(8px); }
  .am-masonry > .am-tile-btn:nth-child(4n+3){ transform: translateY(16px); }
  .am-masonry > .am-tile-btn:nth-child(4n){   transform: translateY(24px); }
}

/* Make tiles fill nicely */
.am-masonry > .am-tile-btn{
  width: 100%;
  display: block;
  will-change: transform;
}

/* Optional: nicer hover without changing layout */
.am-masonry .card{
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.am-masonry > .am-tile-btn:hover .card{
  transform: translateY(-2px);
  box-shadow: 0 18px 55px rgba(0,0,0,.20);
  border-color: color-mix(in srgb, var(--primary) 18%, var(--border));
}

/* =========================================
   About Me — clean aligned grid (no stagger)
   ========================================= */

.am-masonry{
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  align-items: stretch;
}

/* 2 cols */
@media (min-width: 760px){
  .am-masonry{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 3 cols */
@media (min-width: 1100px){
  .am-masonry{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 4 cols (match your KPI top grid feel) */
@media (min-width: 1400px){
  .am-masonry{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Make every tile fill its grid cell cleanly */
.am-masonry > .am-tile-btn{
  width: 100%;
  height: 100%;
  display: block;
}

/* Make the cards equal-height and structured */
.am-masonry > .am-tile-btn > .card{
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Keep the header row (title + View badge) pinned to the top */
.am-masonry > .am-tile-btn > .card > div:first-child{
  flex: 0 0 auto;
}

/* Let the content area breathe and keep spacing consistent */
.am-masonry .kpi-meta{
  margin-top: 8px;
}

/* Optional: tidy hover (no layout shift) */
.am-masonry > .am-tile-btn:hover .card{
  border-color: color-mix(in srgb, var(--primary) 18%, var(--border));
  box-shadow: 0 18px 55px rgba(0,0,0,.20);
}

/* ===============================
   FIX: Mobile topbar horizontal scroll (SCOPED)
   =============================== */

/* allow flex children to shrink instead of forcing overflow */
.topbar .topbar-inner{ min-width: 0; }
.topbar .brand{ min-width: 0; max-width: 100%; }
.topbar .brand-text{ min-width: 0; }

/* clamp just the host text */
.topbar .brand-subtitle{
  max-width: 44vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* keep the logo from forcing width on small screens */
@media (max-width: 520px){
  .topbar .site-logo{ max-width: 78px; }
  .topbar .brand-title{ font-size: 13px; white-space: nowrap; }
  .topbar .topbar-inner{ gap: 10px; }
}

/* dropdown panel must not exceed viewport width */
.topbar .nav-dropdown-panel{
  max-width: calc(100vw - 24px);
}

/* site switch select can also force overflow */
@media (max-width: 520px){
  .topbar .site-switch-nav select{ max-width: 140px; }
}
