  :root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1a202c;
    --muted: #718096;
    --accent: #4a6cf7;
    --accent-light: #eef0fe;
    --red: #e53e3e;
    --red-light: #fff5f5;
    --orange: #dd6b20;
    --orange-light: #fffaf0;
    --yellow: #d69e2e;
    --yellow-light: #fffff0;
    --green: #38a169;
    --green-light: #f0fff4;
    --gray-light: #f7fafc;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,.1);
    --radius: 10px;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
  }

  /* ── Header ── */
  header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
  }
  header h1 { font-size: 18px; font-weight: 700; color: var(--accent); }
  header span { font-size: 13px; color: var(--muted); }

  /* ── Layout ── */
  .container { max-width: 1300px; margin: 0 auto; padding: 28px 20px 24px; }

  /* ── Main panels ── */
  .panels { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
  @media (max-width: 960px) { .panels { grid-template-columns: 1fr; } }

  .panel {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  .panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .panel-header h2 { font-size: 15px; font-weight: 700; letter-spacing: .2px; }

  /* ── Controls bar ── */
  .controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--gray-light);
  }
  .controls input[type="text"] {
    flex: 1;
    min-width: 180px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: white;
  }
  .controls select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
  }

  /* ── Table ── */
  .table-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  thead th {
    background: var(--gray-light);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
  }
  thead th:hover { color: var(--accent); }
  thead th .sort-icon { margin-left: 4px; opacity: .4; }
  thead th.sorted .sort-icon { opacity: 1; color: var(--accent); }

  tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
  tbody tr:hover { background: var(--accent-light); }
  tbody td { padding: 10px 14px; vertical-align: middle; }

  .name-cell { font-weight: 600; }
  .note-cell { font-size: 11px; color: var(--muted); font-style: italic; }

  /* ── Status badges ── */
  .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
  }
  .badge.overdue-high { background: var(--red-light); color: var(--red); }
  .badge.overdue-low  { background: var(--yellow-light); color: var(--yellow); }
  .badge.recent       { background: var(--green-light); color: var(--green); }
  .badge.never        { background: #edf2f7; color: #4a5568; }
  .badge.note         { background: #e9d8fd; color: #6b46c1; }

  tr.row-high   td:first-child { border-left: 3px solid var(--red); }
  tr.row-low    td:first-child { border-left: 3px solid var(--yellow); }
  tr.row-recent td:first-child { border-left: 3px solid var(--green); }

  .date-cell { white-space: nowrap; }
  .days-cell { font-weight: 700; }
  .days-cell.high { color: var(--red); }
  .days-cell.low  { color: var(--yellow); }
  .days-cell.good { color: var(--green); }

  .action-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all .15s;
  }
  .action-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

  /* ── Empty / loading ── */
  .empty { padding: 40px; text-align: center; color: var(--muted); font-size: 14px; }

  /* ── Side panel ── */
  .side-section { margin-bottom: 0; }
  .side-section + .side-section { border-top: 1px solid var(--border); }

  .form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
  .form-group label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: border-color .15s;
  }
  .form-group input:focus,
  .form-group select:focus,
  .form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74,108,247,.1);
  }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: none;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
  }
  .btn-primary { background: var(--accent); color: white; width: 100%; }
  .btn-primary:hover { background: #3a5ce4; }
  .btn-secondary { background: var(--border); color: var(--text); }
  .btn-secondary:hover { background: #cbd5e0; }
  .btn-danger { background: var(--red); color: white; }
  .btn-danger:hover { background: #c53030; }

  .side-body { padding: 18px 20px; }

  /* ── Toast ── */
  #toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #2d3748;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(10px);
    transition: all .25s;
    z-index: 999;
    pointer-events: none;
  }
  #toast.show { opacity: 1; transform: translateY(0); }
  #toast .toast-undo {
    margin-left: 14px; color: #90cdf4; font-weight: 700;
    cursor: pointer; text-decoration: underline;
    pointer-events: auto;
  }

  /* ── Modal ── */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: white;
    border-radius: 12px;
    width: 480px;
    max-width: 95vw;
    box-shadow: var(--shadow-md);
    overflow: hidden;
  }
  .modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .modal-header h3 { font-size: 16px; font-weight: 700; }
  .modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
  .modal-body { padding: 22px; }
  .modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

  .history-list { list-style: none; max-height: 280px; overflow-y: auto; }
  .history-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
  }
  .history-list li:last-child { border-bottom: none; }
  .history-list .type-tag {
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
  }
  .type-tag.prayer { background: #bee3f8; color: #2b6cb0; }
  .type-tag.talk { background: #c6f6d5; color: #276749; }
  .history-list .del-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
  }
  .history-list .del-btn:hover { color: var(--red); }

  .row-count {
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
    text-align: right;
  }
  thead th.sorted { color: var(--accent); }
  thead th .sort-arrow { margin-left: 4px; font-size: 10px; }

  /* ── Add member section ── */
  .add-member-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    user-select: none;
  }
  .add-member-toggle:hover { background: var(--gray-light); }
  .collapse-body { padding: 18px 20px; }
  .collapse-body.hidden { display: none; }
