/* TG Admin — Warm Pastoral Design System */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --teal:         #066164;
  --teal-mid:     #00797a;
  --teal-dark:    #044c4e;
  --teal-light:   #e8f4f4;
  --teal-pale:    #f2f9f9;
  --cream:        #f7f8f6;
  --cream-dark:   #eef1ee;
  --bg:           #f7f8f6;
  --surface:      #ffffff;
  --border:       rgba(6,29,45,0.08);
  --text-1:       #061d2d;
  --text-2:       #4c6f77;
  --text-3:       #61747a;
  --coral:        #b8665a;
  --coral-ink:    #9e584d;
  --coral-light:  #f9eeed;
  --amber:        #c4894a;
  --amber-ink:    #9a6030;
  --amber-light:  #faf0e4;
  --sage:         #6a9e82;
  --sage-light:   #eaf4ef;
  --red:          #b8665a;
  --red-light:    #f9eeed;
  --orange:       #c4894a;
  --orange-light: #faf0e4;
  --green:        #6a9e82;
  --green-light:  #eaf4ef;
  --purple:       #7c5aaf;
  --purple-light: #f0ecff;
  --accent:       #066164;
  --accent-light: #e8f4f4;
  --accent-dark:  #00797a;
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 22px;
  --shadow-sm: 0 1px 3px rgba(6,29,45,0.08), 0 1px 2px rgba(6,29,45,0.04);
  --shadow-md: 0 4px 16px rgba(6,29,45,0.1), 0 1px 4px rgba(6,29,45,0.05);
  --shadow-lg: 0 12px 40px rgba(6,29,45,0.18), 0 2px 8px rgba(6,29,45,0.07);
}

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
               'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(180deg, rgba(6,97,100,.05), transparent 320px), var(--cream);
  color: var(--text-1); min-height: 100vh;
}

/* ── App shell ── */
.app-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  background: var(--teal); color: white;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
.sidebar-logo {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
  text-align: center;
}
.sidebar-logo img { height: 64px; width: 64px; display: block; margin: 0 auto 12px; object-fit: contain; background: #fff; border-radius: 14px; padding: 10px; box-sizing: border-box; }
.sidebar-logo strong { font-size: 13px; font-weight: 700; display: block; line-height: 1.3; color: white; }
.sidebar-logo span   { font-size: 11px; opacity: 0.6; }
.sidebar-nav { padding: 10px 10px; flex: 1; }
.sidebar-section {
  font-size: 9px; font-weight: 700; letter-spacing: 0.9px; text-transform: uppercase;
  opacity: 0.4; padding: 14px 10px 5px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px; font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,0.72); text-decoration: none; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  transition: background 0.12s, color 0.12s; font-family: inherit;
}
.sidebar-link:hover  { background: rgba(255,255,255,0.12); color: white; }
.sidebar-link.active { background: rgba(255,255,255,0.2);  color: white; font-weight: 600; }
.sidebar-footer {
  padding: 14px 20px 20px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 11px; opacity: 0.42; line-height: 1.7; font-style: italic;
}

/* ── Mobile chrome (hidden on desktop) ── */
.mobile-topbar {
  display: none; background: var(--teal); color: white;
  padding: 10px 16px; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 50;
}
.mobile-topbar img { height: 30px; width: auto; max-width: 120px; object-fit: contain; background: #fff; border-radius: 6px; padding: 4px 6px; box-sizing: border-box; }
.mobile-topbar strong { font-size: 14px; font-weight: 700; flex: 1; }
.mobile-nav {
  display: none; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border); padding: 8px 16px; gap: 6px;
  position: sticky; top: 46px; z-index: 49;
}
.mobile-nav::-webkit-scrollbar { display: none; }
.mobile-nav .nav-btn {
  flex-shrink: 0; font-size: 12px; padding: 6px 12px;
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); background: var(--cream);
  border-radius: 20px; color: var(--text-2);
  text-decoration: none; cursor: pointer; white-space: nowrap;
  font-family: inherit;
}
.mobile-nav .nav-btn.active { background: var(--teal); color: white; border-color: var(--teal); font-weight: 600; }
.mobile-nav .nav-btn.danger { color: var(--coral-ink); }

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
  .mobile-nav { display: flex; }
  .page-hdr { position: static !important; }
}

/* ── Main content column ── */
.main { overflow-y: auto; display: flex; flex-direction: column; min-height: 100vh; }

/* ── Page header (sticky within .main on desktop) ── */
.page-hdr {
  padding: 20px 28px 16px; background: var(--cream);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.page-hdr h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; color: var(--text-1); margin-bottom: 4px; }
.page-hdr .subtitle { font-size: 14px; color: var(--text-2); margin-bottom: 14px; line-height: 1.5; }
.role-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--teal-light); color: var(--teal-dark);
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 10px;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  cursor: pointer; appearance: none; -webkit-appearance: none; font-family: inherit;
  transition: border-color 0.12s, color 0.12s;
}
.filter-chip:focus { outline: none; border-color: var(--teal); color: var(--teal); }
select.filter-chip {
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ab0b3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.btn-refresh {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--teal); color: var(--teal); background: transparent;
  cursor: pointer; font-family: inherit; transition: background 0.12s;
}
.btn-refresh:hover { background: var(--teal-light); }
.scope-note { display: flex; align-items: center; gap: 5px; margin-top: 10px; font-size: 11px; color: var(--text-3); }

/* ── Content wrapper ── */
.content { padding: 20px 28px 80px; overflow-x: hidden; }
@media (max-width: 768px) { .content { padding: 16px 16px 80px; } }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 500px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
.stat-card {
  background: var(--surface); border-radius: var(--r-lg); padding: 18px 20px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; position: relative;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.s-accent  .stat-icon { background: var(--teal);   color: white; }
.s-red     .stat-icon { background: var(--coral);  color: white; }
.s-green   .stat-icon { background: var(--sage);   color: white; }
.s-orange  .stat-icon { background: var(--amber);  color: white; }
.s-indigo  .stat-icon { background: var(--purple); color: white; }
.s-gray    .stat-icon { background: var(--cream-dark); color: var(--text-2); }
.stat-body  { flex: 1; min-width: 0; }
.stat-num   { font-size: 34px; font-weight: 800; letter-spacing: -1px; line-height: 1; margin-bottom: 4px; color: var(--text-1); }
.stat-label { font-size: 13px; font-weight: 600; color: var(--text-1); margin-bottom: 2px; }
.stat-sub   { font-size: 11px; color: var(--text-3); }
.stat-link  {
  position: absolute; top: 14px; right: 14px;
  width: 26px; height: 26px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--cream);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); text-decoration: none; transition: border-color 0.12s, color 0.12s;
}
.stat-link:hover { border-color: var(--teal); color: var(--teal); }

/* ── Chart cards ── */
/* auto-fill mirrors the stat-grid pattern: columns wrap naturally as width shrinks */
.chart-grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.chart-grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 16px; }
.chart-grid-1 { margin-bottom: 16px; }
.chart-card {
  background: var(--surface); border-radius: var(--r-lg); padding: 18px 20px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.chart-card-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.chart-card-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--teal-light); color: var(--teal);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chart-card h3   { font-size: 13px; font-weight: 600; color: var(--text-1); line-height: 1.3; margin-bottom: 2px; }
.chart-card .desc { font-size: 11px; color: var(--text-3); }
.chart-wrap    { position: relative; height: 190px; }
.chart-wrap-lg { position: relative; height: 230px; }
canvas { cursor: pointer; }
.empty-chart {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 160px; gap: 6px; color: var(--text-3); font-size: 12px;
}

/* ── Table cards ── */
.table-card {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  overflow: hidden; margin-bottom: 14px;
}
.table-card.urgent-card  { border-left: 3px solid var(--coral); }
.table-card.overdue-card { border-left: 3px solid var(--amber); }
.table-card.active-card  { border-left: 3px solid var(--teal);  }
.table-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--cream);
}
.table-card-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--teal-light); color: var(--teal);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.urgent-card  .table-card-icon { background: var(--coral-light); color: var(--coral); }
.overdue-card .table-card-icon { background: var(--amber-light); color: var(--amber-ink); }
.table-card-header h3 { font-size: 13px; font-weight: 600; flex: 1; }
.tbl-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: var(--cream); color: var(--text-2); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  text-align: left; padding: 8px 16px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-3);
  background: var(--cream); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--cream-dark); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--teal-pale); cursor: pointer; }
.cell-name    { font-weight: 600; font-size: 13px; }
.cell-date    { color: var(--text-3); white-space: nowrap; font-size: 11px; }
.empty-table  { text-align: center; padding: 32px; color: var(--text-3); font-size: 13px; }
.overdue-flag { font-size: 10px; color: var(--coral-ink); font-weight: 700; }

/* ── Pills ── */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pill-open              { background: var(--teal-light);  color: var(--teal-dark); }
.pill-open .pill-dot    { background: var(--teal); }
.pill-closed            { background: var(--cream-dark);  color: var(--text-2); }
.pill-progress, .pill-in-progress            { background: var(--amber-light); color: #9a6030; }
.pill-progress .pill-dot, .pill-in-progress .pill-dot { background: var(--amber); }
.pill-hold, .pill-on-hold                    { background: #f4ede0; color: #795c38; }
.pill-urgent            { background: var(--coral-light); color: #8a3e34; }
.pill-urgent .pill-dot  { background: var(--coral); }
.pill-high              { background: var(--coral-light); color: #8a3e34; }
.pill-high .pill-dot    { background: var(--coral); }
.pill-medium            { background: var(--amber-light); color: #9a6030; }
.pill-medium .pill-dot  { background: var(--amber); }
.pill-low               { background: var(--sage-light);  color: #3e6e52; }
.pill-low .pill-dot     { background: var(--sage); }
.pill-conf, .pill-confidential              { background: var(--purple-light); color: var(--purple); }
.pill-sens-high, .pill-highly-sensitive     { background: var(--coral-light); color: #8a3e34; }
.pill-sens-med          { background: var(--amber-light); color: #9a6030; }
.pill-sens-low          { background: var(--sage-light);  color: #3e6e52; }
.pill-salvation         { background: var(--sage-light);  color: #3e6e52; }
.pill-rededication      { background: var(--teal-light);  color: var(--teal-dark); }
.pill-prayer            { background: var(--purple-light); color: var(--purple); }
.pill-baptism           { background: var(--teal-light);  color: var(--teal-dark); }
.pill-membership        { background: var(--amber-light); color: #9a6030; }
.pill-1st               { background: var(--sage-light);  color: #3e6e52; }
.pill-intake            { background: var(--cream-dark);  color: var(--text-2); }

/* ── Modal sheet ── */
.case-hero-photo { margin: 10px 0 14px; }
.case-photo-frame { border: 1px solid var(--border,#e2e8ea); border-radius: 10px; background: var(--cream,#f7f8f6); padding: 8px; }
.case-photo-frame img { width: 100%; max-height: 260px; border-radius: 8px; object-fit: cover; display: block; box-shadow: 0 1px 6px rgba(6,29,45,0.08); }
.case-photo-remove { margin-top: 8px; padding: 7px 10px; border: 1px solid rgba(184,102,90,.35); border-radius: 8px; background: #fff; color: var(--coral-ink,#9e584d); font-size: 12px; font-weight: 600; cursor: pointer; }
.case-photo-drop { border: 2px dashed var(--border,#ddd); border-radius: 10px; padding: 18px 12px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; background: transparent; }
.case-photo-drop:hover { border-color: var(--teal,#2d6a6a); background: var(--teal-light,#f0f7f7); }
.case-photo-status { font-size: 11px; margin-top: 6px; }
.case-title-photo { display: none; flex-basis: 100%; margin-top: 4px; }
.case-title-photo.has-photo { display: block; }
.case-title-photo img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border,#e2e8ea); box-shadow: 0 1px 8px rgba(6,29,45,0.1); display: block; }

.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.28); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: var(--surface); width: 100%; max-width: 700px; max-height: 88vh;
  border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: sheetUp 0.28s cubic-bezier(0.32,0.72,0,1);
}
@keyframes sheetUp { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet-pill { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 10px auto 4px; flex-shrink: 0; }
.sheet-header { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 6px 20px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sheet-header h3 { flex: 1; font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.sheet-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: var(--cream); color: var(--text-2); }
.sheet-close {
  width: 30px; height: 30px; border-radius: 50%; background: var(--cream);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: background 0.12s;
}
.sheet-close:hover { background: var(--cream-dark); }
.sheet-body { overflow-y: auto; flex: 1; padding: 16px 20px 36px; }
.sheet-body::-webkit-scrollbar { width: 4px; }
.sheet-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.detail-box { background: var(--cream); border-radius: var(--r-sm); padding: 10px 12px; }
.detail-box label { display: block; font-size: 10px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.detail-box p { font-size: 13px; font-weight: 500; color: var(--text-1); }
.detail-full { background: var(--cream); border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 12px; }
.detail-full label { display: block; font-size: 10px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.detail-full p { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.sheet-divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.sheet-back {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--teal); padding: 0; margin-bottom: 14px; font-family: inherit;
}
.sheet-back:hover { text-decoration: underline; }
.log-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; border-radius: var(--r-md);
  background: var(--teal); color: white; border: none; cursor: pointer;
  font-size: 15px; font-weight: 600; text-decoration: none; font-family: inherit;
  transition: background 0.12s, transform 0.1s;
}
.log-btn:hover  { background: var(--teal-mid); }
.log-btn:active { transform: scale(0.98); }
.drill-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--cream); border-radius: var(--r-md); padding: 13px 14px;
  margin-bottom: 8px; cursor: pointer;
  border: 1px solid transparent; transition: border-color 0.12s, background 0.12s;
}
.drill-card:hover { background: var(--teal-light); border-color: rgba(92,164,175,0.2); }
.drill-card-body   { flex: 1; min-width: 0; }
.drill-card-title  { font-size: 13px; font-weight: 600; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drill-card-pills  { display: flex; flex-wrap: wrap; gap: 4px; }
.drill-card-chevron { color: var(--text-3); flex-shrink: 0; }
.drill-empty { text-align: center; padding: 40px; color: var(--text-3); font-size: 13px; }

/* ── Edit sheet ── */
.edit-sheet {
  background: var(--surface); width: 100%; max-width: 600px; max-height: 90vh;
  border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: sheetUp 0.28s cubic-bezier(0.32,0.72,0,1);
}
.edit-field { margin-bottom: 14px; }
.edit-field label { display: block; font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.edit-field select, .edit-field textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: 14px; background: var(--cream);
  color: var(--text-1); transition: border-color 0.12s; font-family: inherit;
}
.edit-field select:focus, .edit-field textarea:focus { outline: none; border-color: var(--teal); background: var(--surface); }
.edit-field textarea { resize: vertical; min-height: 90px; }
.save-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 13px; background: var(--teal); color: white;
  border: none; border-radius: var(--r-sm); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background 0.12s; margin-top: 4px; font-family: inherit;
}
.save-btn:hover    { background: var(--teal-mid); }
.save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Care case grid ── */
.care-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
@media (max-width: 500px) { .care-grid { grid-template-columns: 1fr; } }
.case-card {
  background: var(--surface); border-radius: var(--r-lg); padding: 18px 20px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border); position: relative;
}
.case-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--teal);
}
.case-card.p-urgent::before { background: var(--coral); }
.case-card.p-high::before   { background: var(--coral); }
.case-card.p-medium::before { background: var(--amber); }
.case-card.p-low::before    { background: var(--sage);  }
.case-card-title   { font-size: 14px; font-weight: 700; color: var(--text-1); margin-bottom: 8px; line-height: 1.3; padding-right: 50px; }
.case-card-meta    { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.case-card-badges  { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.case-card-detail  { font-size: 12px; color: var(--text-2); margin-bottom: 6px; line-height: 1.5; }
.case-card-detail strong { color: var(--text-1); font-weight: 600; }
.case-card-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.case-card-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 10px; border-radius: var(--r-sm); font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background 0.12s;
  border: none; font-family: inherit;
}
.case-card-btn.primary           { background: var(--teal);  color: white; }
.case-card-btn.primary:hover     { background: var(--teal-mid); }
.case-card-btn.secondary         { background: var(--cream); color: var(--text-1); border: 1px solid var(--border); }
.case-card-btn.secondary:hover   { background: var(--cream-dark); }

/* ── Directory ── */
.dir-section-header { display: flex; align-items: center; gap: 10px; padding: 20px 0 12px; }
.dir-section-header h2 { font-size: 15px; font-weight: 700; color: var(--text-1); }
.dir-list {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--border); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.dir-card {
  background: var(--surface); padding: 12px 18px;
  display: flex; align-items: center; gap: 14px; transition: background 0.1s;
}
.dir-card:hover { background: var(--teal-pale); }
.dir-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--teal-light); color: var(--teal-dark);
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.dir-avatar-photo { object-fit: cover; }
.dir-info   { flex: 1; min-width: 0; }
.dir-name   { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 1px; }
.dir-detail { font-size: 12px; color: var(--text-2); }
.dir-pills  { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* ── Search bar ── */
.search-bar { padding: 12px 28px; border-bottom: 1px solid var(--border); background: var(--surface); }
.search-bar-inner { max-width: 1120px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.search-input-wrap { position: relative; max-width: 420px; }
.search-input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-input {
  width: 100%; padding: 9px 12px 9px 36px; border: 1.5px solid var(--border);
  border-radius: 20px; font-size: 14px; background: var(--cream); color: var(--text-1);
  transition: border-color 0.12s, background 0.12s; font-family: inherit;
}
.search-input:focus { outline: none; border-color: var(--teal); background: var(--surface); }

/* ── Loading ── */
.page-loading { text-align: center; padding: 80px 20px; color: var(--text-3); }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--teal);
  animation: spin 0.7s linear infinite; margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.last-refresh { font-size: 11px; color: var(--text-3); text-align: right; margin-top: 8px; }

/* ── Login pages ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--cream); }
.login-card {
  background: var(--surface); border-radius: var(--r-xl); padding: 40px 36px;
  width: 100%; max-width: 380px; box-shadow: var(--shadow-md);
  border: 1px solid var(--border); text-align: center;
}
.login-logo-box {
  width: 64px; height: 64px; border-radius: var(--r-xl); background: var(--teal);
  margin: 0 auto 18px; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.login-logo-box img { width: 96px; height: 54px; object-fit: contain; padding: 0; border-radius: 0; }
.login-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; color: var(--text-1); margin-bottom: 4px; }
.login-card p.sub { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field { margin-bottom: 14px; text-align: left; }
.field label { display: block; font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: 16px; background: var(--cream);
  transition: border-color 0.12s, background 0.12s; color: var(--text-1); font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--teal); background: var(--surface); }
.login-btn {
  width: 100%; padding: 13px; background: var(--teal); color: white;
  border: none; border-radius: var(--r-sm); font-size: 16px; font-weight: 600;
  cursor: pointer; transition: background 0.12s, transform 0.1s; margin-top: 4px; font-family: inherit;
}
.login-btn:hover  { background: var(--teal-mid); }
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.login-error {
  display: none; background: var(--coral-light); color: var(--coral-ink);
  border: 1px solid rgba(184,102,90,0.2); border-radius: var(--r-sm);
  padding: 10px 14px; font-size: 13px; margin-bottom: 14px; text-align: left;
}
.login-back { margin-top: 20px; font-size: 13px; color: var(--text-3); }
.login-back a { color: var(--teal); text-decoration: none; font-weight: 600; }
.login-back a:hover { text-decoration: underline; }

/* ── Sidebar collapse toggle ── */
.sidebar-collapse-btn {
  width: 26px; height: 26px; flex-shrink: 0;
  background: rgba(255,255,255,0.13); color: white;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 7px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.24); }
.sidebar-logo { position: relative; display: flex; flex-direction: column; align-items: center; }
.sidebar-logo-row { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 8px; }

/* Collapsed state */
.app-shell.sidebar-collapsed { grid-template-columns: 58px minmax(0, 1fr); }
.app-shell.sidebar-collapsed .sidebar { overflow: hidden; }
.app-shell.sidebar-collapsed .sidebar-logo-text,
.app-shell.sidebar-collapsed .sidebar-section,
.app-shell.sidebar-collapsed .sidebar-link-text,
.app-shell.sidebar-collapsed .sidebar-footer { display: none !important; }
.app-shell.sidebar-collapsed .sidebar-logo {
  padding: 12px 8px; gap: 8px; border-bottom: 1px solid rgba(255,255,255,0.14);
}
.app-shell.sidebar-collapsed .sidebar-logo img { width: 34px; height: 34px; object-fit: contain; margin: 0; background: #fff; border-radius: 8px; padding: 5px; box-sizing: border-box; }
.app-shell.sidebar-collapsed .sidebar-logo-row { justify-content: center; }
.app-shell.sidebar-collapsed .sidebar-link { justify-content: center; padding: 10px 8px; gap: 0; }
.app-shell.sidebar-collapsed .sidebar-nav { padding: 8px 4px; }

/* Modal full-screen on very small screens */
@media (max-width: 500px) {
  .modal-sheet, .edit-sheet { max-height: 96vh; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* ── Responsive table column hiding ── */
/* Drop secondary columns progressively so tables reflow without horizontal scroll */
@media (max-width: 900px) {
  .data-table .col-caregiver,
  .data-table .col-visibility { display: none; }
}
@media (max-width: 700px) {
  .data-table .col-lastcontact { display: none; }
}
@media (max-width: 480px) {
  .data-table .col-status { display: none; }
}


/* Assigned follow-up editor */
.edit-followup-list{display:grid;gap:8px;margin-top:8px}
.edit-followup-row{border:1px solid var(--border,#ddd);border-radius:8px;background:#fff;padding:10px;display:grid;gap:8px}
.edit-followup-head{display:flex;align-items:center;gap:8px;font-size:11px;font-weight:700;color:var(--text-3,#888);text-transform:uppercase;letter-spacing:.4px}
.edit-followup-assignee-summary{flex:1;text-align:right;text-transform:none;letter-spacing:normal;font-weight:600;font-size:12px;color:var(--teal,#066164)}
.edit-followup-remove{border:none;background:transparent;color:var(--coral-ink,#9e584d);cursor:pointer;padding:4px;border-radius:6px}
.edit-followup-remove:hover{background:var(--coral-light,#f9eeed)}
.edit-followup-grid{display:grid;grid-template-columns:minmax(130px,.65fr) 1fr;gap:8px;align-items:start}
.edit-followup-grid input{width:100%;padding:8px 10px;border:1px solid var(--border,#ddd);border-radius:8px;background:#fff;color:var(--text-1,#111);font-size:13px;box-sizing:border-box}
.edit-assignee-options{display:flex;flex-wrap:wrap;gap:6px;max-height:104px;overflow:auto;padding:1px}
.edit-assignee-chip{display:inline-flex;align-items:center;gap:5px;min-height:30px;border:1px solid var(--border,#ddd);border-radius:999px;background:var(--cream,#f7f8f6);color:var(--text-2,#4c6f77);font:inherit;font-size:12px;font-weight:600;padding:5px 9px;cursor:pointer;max-width:100%}
.edit-assignee-chip:hover{border-color:rgba(6,97,100,.28);background:var(--teal-pale,#f2f9f9)}
.edit-assignee-chip.is-selected{border-color:rgba(6,97,100,.35);background:var(--teal-light,#e8f4f4);color:var(--teal,#066164)}
.edit-assignee-chip span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.edit-followup-empty{font-size:12px;color:var(--text-3,#888);line-height:1.4}
.edit-followup-add{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--border,#ddd);background:#fff;color:var(--teal,#066164);border-radius:8px;padding:8px 10px;font-size:12px;font-weight:700;cursor:pointer;width:max-content}
.edit-followup-add:hover{background:var(--teal-pale,#f2f9f9);border-color:rgba(6,97,100,.28)}
@media (max-width:560px){.edit-followup-grid{grid-template-columns:1fr}}


/* Mobile modal escape routes */
@media (max-width: 768px) {
  .modal-overlay { align-items: stretch; background: rgba(6,29,45,0.52); }
  .modal-sheet, .edit-sheet {
    width: 100% !important; max-width: none !important; height: 100dvh !important; max-height: 100dvh !important;
    border-radius: 0 !important; box-shadow: none !important;
  }
  .sheet-pill { display: none; }
  .sheet-header {
    position: sticky; top: 0; z-index: 5;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 12px;
    background: var(--surface); box-shadow: 0 1px 0 var(--border);
  }
  .sheet-header h3 { min-width: 0; font-size: 17px; }
  .sheet-close {
    width: auto !important; min-width: 88px; height: 44px; padding: 0 14px;
    border-radius: 999px; border: 1px solid rgba(6,97,100,.16);
    background: var(--teal); color: #fff; gap: 7px;
    font-size: 13px; font-weight: 800;
  }
  .sheet-close::after { content: 'Close'; }
  .sheet-close:hover { background: var(--teal-mid); }
  .sheet-body { padding: 16px 16px calc(36px + env(safe-area-inset-bottom, 0px)); }
  .sheet-back {
    min-height: 44px; padding: 0 13px; margin-bottom: 12px;
    border-radius: 999px; border: 1px solid rgba(6,97,100,.18);
    background: var(--teal-light); text-decoration: none;
    font-weight: 800; justify-content: center;
  }
  .log-btn, .save-btn, .case-card-btn, .edit-followup-add { min-height: 44px; }
}


/* Coordinator/pastoral inline multi-assignee editor */
.edit-caregiver-list{display:flex;flex-wrap:wrap;gap:6px;max-height:132px;overflow:auto;padding:1px}
.edit-caregiver-chip{display:inline-flex;align-items:center;gap:6px;min-height:34px;border:1px solid var(--border,#ddd);border-radius:999px;background:#fff;color:var(--text-2,#4c6f77);font:inherit;font-size:12px;font-weight:700;padding:6px 10px;cursor:pointer;max-width:100%}
.edit-caregiver-chip:hover{border-color:rgba(6,97,100,.28);background:var(--teal-pale,#f2f9f9)}
.edit-caregiver-chip.is-selected{border-color:rgba(6,97,100,.35);background:var(--teal-light,#e8f4f4);color:var(--teal,#066164)}
.edit-caregiver-chip span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.edit-caregiver-empty{font-size:12px;color:var(--text-3,#888);line-height:1.4}
@media (max-width:768px){.edit-caregiver-chip{min-height:44px;padding:8px 12px}.edit-caregiver-list{max-height:180px}}


/* Shared assignee picker, matching Care Needs edit modal */
.assignee-picker{border:1.5px solid var(--border);border-radius:10px;background:var(--cream);padding:8px}
.assignee-picker:focus-within{border-color:var(--teal);background:var(--surface);box-shadow:0 0 0 3px rgba(6,97,100,.08)}
.assignee-selected{display:flex;flex-wrap:wrap;gap:6px;min-height:30px;align-items:center;margin-bottom:7px}
.assignee-empty{color:var(--text-3);font-size:12px;padding:5px 2px;line-height:1.35}
.assignee-chip{display:inline-flex;align-items:center;gap:6px;min-height:28px;max-width:100%;border:1px solid rgba(6,97,100,.18);background:var(--teal-light);color:var(--teal-dark);border-radius:999px;padding:4px 7px 4px 9px;font-size:12px;font-weight:700}
.assignee-chip span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.assignee-chip button{width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:50%;background:rgba(6,97,100,.12);color:var(--teal-dark);cursor:pointer;padding:0}
.assignee-search{position:relative;margin-bottom:7px}
.assignee-search i{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--text-3);pointer-events:none}
.assignee-search input{width:100%;min-height:42px;padding:9px 11px 9px 32px;border:1px solid var(--border);border-radius:8px;background:var(--surface);color:var(--text-1);font:inherit;font-size:14px}
.assignee-search input:focus{outline:none;border-color:var(--teal)}
.assignee-options{display:grid;gap:5px;max-height:180px;overflow:auto;padding-right:2px}
.assignee-option{width:100%;min-height:42px;display:flex;align-items:center;gap:9px;border:1px solid transparent;border-radius:8px;background:transparent;color:var(--text-1);text-align:left;cursor:pointer;padding:8px 9px;font:inherit;font-size:13px}
.assignee-option:hover,.assignee-option:focus{outline:none;background:var(--teal-pale);border-color:rgba(6,97,100,.14)}
.assignee-option.is-selected{background:var(--teal-light);border-color:rgba(6,97,100,.25);color:var(--teal-dark);font-weight:700}
.assignee-check{width:20px;height:20px;border-radius:50%;border:1.5px solid rgba(6,29,45,.18);display:flex;align-items:center;justify-content:center;color:transparent;flex-shrink:0}
.assignee-option.is-selected .assignee-check{border-color:var(--teal);background:var(--teal);color:white}
.assignee-option-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.assignee-actions{display:flex;justify-content:flex-end;margin-top:7px}
.assignee-clear{border:none;background:transparent;color:var(--text-3);cursor:pointer;font-size:12px;font-weight:700;padding:4px 2px}
.assignee-clear:hover{color:var(--coral-ink)}

/* Coordinator mobile header/filter compaction */
@media (max-width:768px){
  .mobile-topbar{min-height:44px;padding:8px 16px;gap:12px}
  .mobile-topbar img{height:26px;max-width:78px}
  .mobile-topbar strong{font-size:15px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .mobile-nav{top:44px;padding:7px 16px;gap:8px}
  .mobile-nav .nav-btn{min-height:40px;padding:7px 12px;font-size:12px;max-width:76vw;overflow:hidden;text-overflow:ellipsis}
  .page-hdr{padding:16px 18px 12px}
  .page-hdr h1{font-size:26px;line-height:1.1;margin-bottom:5px;letter-spacing:-.2px}
  .page-hdr .subtitle{font-size:15px;line-height:1.45;margin-bottom:12px;max-width:32rem}
  .role-badge{margin-bottom:8px;font-size:10px;padding:3px 9px}
  .btn-new-case{min-height:44px;padding:10px 14px;border-radius:10px;font-size:14px}
  .filter-row{gap:8px}
  .filter-chip,.btn-refresh{min-height:42px;font-size:13px;padding-top:8px;padding-bottom:8px}
  .btn-refresh{margin-left:0;justify-content:center}
  .scope-note{margin-top:8px;line-height:1.35}
  .assignee-chip,.assignee-option,.assignee-search input{min-height:44px}
  .assignee-options{max-height:210px}
}
@media (max-width:520px){
  .page-hdr{padding:14px 16px 10px}
  .page-hdr>div[style*="justify-content:space-between"]{gap:10px!important}
  .page-hdr .subtitle{margin-bottom:10px}
  .page-hdr .btn-new-case{width:100%;justify-content:center}
  #active-filters{display:grid;grid-template-columns:1fr 1fr;align-items:stretch}
  #active-filters .filter-chip,#active-filters .btn-refresh{width:100%;min-width:0!important}
  #active-filters #af-search{grid-column:1 / -1;order:-1}
  #active-filters #af-category{grid-column:1 / -1}
  #closed-filters{display:grid;grid-template-columns:1fr 1fr;align-items:stretch}
  #closed-filters .filter-chip,#closed-filters .btn-refresh{width:100%;min-width:0!important}
}
