:root{
  --bg:#f6f8fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e5e7eb;
  --primary:#2563eb;
  --primary2:#1d4ed8;
  --good:#16a34a;
  --warn:#f59e0b;
  --bad:#ef4444;
  --shadow:0 10px 30px rgba(2,6,23,.08);
  --radius:18px;
  --radius2:14px;
  --max:1180px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--font);
  color:var(--text);
  background:
    radial-gradient(1200px 700px at 50% -200px, rgba(37,99,235,.12), transparent 60%),
    radial-gradient(900px 500px at 85% 0%, rgba(239,68,68,.08), transparent 55%),
    var(--bg);
}
.sos-details.hidden { display:none; }
/* Layout */
.shell{ max-width:var(--max); margin:0 auto; padding:22px 18px 60px; }
.topbar{
  position:sticky; top:0; z-index:50;
  backdrop-filter:saturate(1.4) blur(10px);
  background:rgba(246,248,251,.78);
  border-bottom:1px solid rgba(229,231,235,.75);
}
.topbar-inner{
  max-width:var(--max); margin:0 auto;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 18px;
}
.brand{ display:flex; align-items:center; gap:12px; text-decoration:none; color:inherit; }
.brand img{ height:30px; width:auto; display:block; }
.brand .titles{ display:flex; flex-direction:column; line-height:1.1; }
.brand .titles .name{ font-weight:800; letter-spacing:.2px; }
.brand .titles .sub{ font-size:12px; color:var(--muted); font-weight:600; }

.pill{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.8);
  border-radius:999px;
  font-size:12px;
  color:var(--muted);
}

.row{ display:grid; gap:16px; }
.grid-2{ grid-template-columns: 1.15fr .85fr; }
.grid-3{ grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 980px){
  .grid-2,.grid-3{ grid-template-columns: 1fr; }
}

.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
}
.card h2{
  margin:0 0 8px 0;
  font-size:16px;
  letter-spacing:.2px;
}
.card p{ margin:6px 0; color:var(--muted); }

.kpis{ display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-top:12px; }
@media(max-width:980px){ .kpis{ grid-template-columns:repeat(2,1fr);} }
.kpi{
  border:1px solid var(--border);
  border-radius:var(--radius2);
  padding:10px 12px;
  background:linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.72));
}
.kpi .label{ font-size:12px; color:var(--muted); }
.kpi .value{ margin-top:4px; font-weight:800; }
.badge{
  display:inline-flex; align-items:center; gap:6px;
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
  font-weight:700;
  border:1px solid var(--border);
  background:#fff;
}
.badge.good{ color:var(--good); border-color:rgba(22,163,74,.25); background:rgba(22,163,74,.06); }
.badge.warn{ color:#b45309; border-color:rgba(245,158,11,.25); background:rgba(245,158,11,.10); }
.badge.bad{ color:var(--bad); border-color:rgba(239,68,68,.25); background:rgba(239,68,68,.08); }

.btn{
  appearance:none;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  border-radius:12px;
  padding:10px 12px;
  font-weight:700;
  cursor:pointer;
}
.btn.primary{
  background:linear-gradient(180deg, var(--primary), var(--primary2));
  color:#fff;
  border-color:rgba(37,99,235,.35);
}
.btn:disabled{ opacity:.55; cursor:not-allowed; }

.input, select, textarea{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:12px;
  font:inherit;
  background:#fff;
}
.care-journal {
  margin-top: 30px;
}

.journal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.journal-list {
  margin-top: 15px;
}

.journal-entry {
  background: #ffffff;
  border: 1px solid #e6e6e6;
  border-left: 4px solid #ccc;
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 6px;
}

.journal-entry.family { border-left-color: #3b82f6; }
.journal-entry.care { border-left-color: #16a34a; }
.journal-entry.private { border-left-color: #6b7280; }

.journal-meta {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
}

.journal-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
}

.tag-family { background: #dbeafe; color: #1e40af; }
.tag-care { background: #dcfce7; color: #065f46; }
.tag-private { background: #e5e7eb; color: #374151; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-content {
  background: #fff;
  width: 400px;
  padding: 20px;
  border-radius: 8px;
}

.modal-content textarea {
  width: 100%;
  min-height: 120px;
  margin: 10px 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

textarea{ min-height:90px; resize:vertical; }

.split{ display:flex; gap:10px; align-items:center; }
.split > *{ flex:1; }
.split .mini{ flex:.55; }

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

.table{ width:100%; border-collapse:separate; border-spacing:0 10px; }
.tr{
  border:1px solid var(--border);
  border-radius:14px;
  background:#fff;
  padding:12px;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.tr .left{ display:flex; flex-direction:column; gap:4px; }
.tr .meta{ font-size:12px; color:var(--muted); }
.tr .actions{ display:flex; gap:8px; align-items:center; }

.small{ font-size:12px; color:var(--muted); }
.footer{
  margin-top:28px;
  color:var(--muted);
  font-size:12px;
  text-align:center;
}

/* Map container */
#map{
  height:330px;
  border-radius:16px;
  border:1px solid var(--border);
  overflow:hidden;
}

/* Toast */
.toast{
  position:fixed;
  right:16px; bottom:16px;
  background:#fff;
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:var(--shadow);
  padding:12px 14px;
  max-width:360px;
  display:none;
}
.toast.show{ display:block; }
.toast b{ display:block; margin-bottom:3px; }
/* =========================
   LOGIN PAGE ONLY
   ========================= */
.page-login .shell{
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-login .main{
  flex: 1;
  display: grid;
  place-items: center;     /* dead-centre */
  padding: 34px 18px 60px; /* breathing space */
}

.page-login .card{
  width: min(520px, 100%);
  border-radius: 18px;
  box-shadow: 0 18px 60px rgba(2,6,23,.12);
  padding: 0;
}

.page-login .card-inner{
  padding: 26px;
}

.page-login .title{
  margin: 0 0 6px;
  font-size: 34px;
  line-height: 1.1;
}

.page-login .form input{
  height: 44px;
  reminder: none;
}
.sos-details.hidden { display:none; }
.sos-details { padding-left: 0; }
.sos-item { margin-bottom: 10px; }
.muted { opacity: .7; }

/* ==========================
   LOGIN PAGE POLISH
   ========================== */

.page-login .main{
  min-height: calc(100vh - 180px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 34px 0 10px;
  position: relative;
}
.page-login .btn.primary{
  padding: 12px 16px;
  font-size: 14px;
}
.page-login .card{
  transition: transform .25s ease, box-shadow .25s ease;
}
.page-login .card:hover{
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(2,6,23,.12);
}

/* watermark behind the card */
.page-login .main::before{
  content:"";
  position:absolute;
  inset: -40px 0 0 0;
  background-image: url("/assets/img/logo.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 420px auto;
  opacity: .06;
  pointer-events:none;
  filter: grayscale(100%);
}

.page-login .card{
  width: 440px;
  max-width: calc(100vw - 36px);
  padding: 18px;
}

.page-login .title{ margin:0; font-size:32px; letter-spacing:-.4px; }
.page-login .subtitle{ margin:6px 0 16px; color:var(--muted); }

.page-login .form{ display:grid; gap:12px; }
.page-login .form label{
  display:block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 6px;
}

.page-login .links{
  display:flex;
  gap: 12px;
  margin-top: 12px;
  font-weight: 700;
}
.page-login .links a{ color: var(--primary); text-decoration:none; }
.page-login .links a:hover{ text-decoration:underline; }
.hidden { display:none !important; }
.sos-details { margin-top: 10px; }

