/* === Email history logs (legacy portal style) === */
.logs-sticky-bar {
  position: sticky;
  top: calc(var(--topbar-h) + 4px);
  z-index: 20;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: 0 4px 16px rgba(15,23,42,.06);
}
.logs-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0;
}
.logs-toolbar .btn {
  padding: 7px 13px; border-radius: 9px; font-size: 12.5px; font-weight: 700;
  border: 1.5px solid var(--primary-soft); background: #fff; color: var(--primary);
  display: inline-flex; align-items: center; gap: 6px;
}
.logs-toolbar .btn:hover { background: var(--primary-bg); }
.logs-toolbar .btn.blue { border-color: #bfdbfe; color: #1d4ed8; }
.logs-toolbar .btn.blue:hover { background: #eff6ff; }
.logs-quota {
  font-size: 12px; color: var(--primary); font-weight: 700;
}
.logs-note { font-size: 12px; color: #6b7280; margin-left: auto; }

.log-item {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 56px 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.log-item:hover { box-shadow: var(--shadow); border-color: #ddd6fe; }
.log-item .log-type { font-size: 14px; font-weight: 800; color: var(--text); }
.log-item .log-source {
  font-size: 11px; color: var(--text-muted);
  background: #f1f5f9; color: #64748b;
  padding: 1px 7px; border-radius: 999px; font-weight: 600;
  margin-left: 6px; display: inline-block;
}
.log-item .log-subject { margin-top: 4px; color: #374151; font-size: 13px; }
.log-item .log-meta { margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.log-item .log-time {
  margin-top: 6px; font-size: 13px; font-weight: 800; color: #4c1d95;
  display: inline-flex; align-items: center; gap: 6px;
}
.log-item .log-recipients {
  display: inline-block; margin-top: 2px;
}
.log-item .log-expand-btn {
  position: absolute; right: 12px; top: 12px;
  width: 34px; height: 34px; border-radius: 10px;
  border: 1.5px solid #e0e7ff; background: #f5f3ff; color: #5b21b6;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; line-height: 1;
  transition: transform .25s ease, background .2s, border-color .2s, box-shadow .2s;
}
.log-item .log-expand-btn:hover {
  background: #ede9fe; border-color: #ddd6fe;
  box-shadow: 0 3px 10px rgba(91,33,182,.14);
}
.log-item .log-expand-btn.open {
  background: #ede9fe; border-color: #ddd6fe;
  transform: rotate(180deg);
}
.log-item .log-detail {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .35s ease, opacity .25s ease, margin .25s ease, padding .25s ease;
  margin: 0; padding: 0;
}
.log-item .log-detail.open {
  max-height: 420px; opacity: 1; margin-top: 10px; padding: 12px 14px;
  background: #f8fafc; border-radius: 10px; border: 1px solid #e2e8f0;
  overflow: auto;
}
.log-item .log-detail .lbl {
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  margin-top: 10px;
}
.log-item .log-detail .lbl:first-child { margin-top: 0; }
.log-item .log-detail .val { font-size: 13px; color: var(--text); word-break: break-word; }
.log-item .log-detail .val.mail-link { color: var(--primary); font-weight: 700; }
.log-item .log-body-frame {
  margin-top: 6px; border: 1px solid #e2e8f0; border-radius: 12px;
  background: #fff; max-height: 300px; overflow: auto; padding: 14px;
  font-size: 13px; line-height: 1.55; color: #1e293b;
}
.log-item .log-body-frame img { max-width: 100%; height: auto; }
.log-item .log-empty { color: #94a3b8; font-size: 12.5px; padding: 20px; text-align: center; }

/* === Mail portal workspace (3-column) === */
.mail-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #f1f0f7;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
}
.mail-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.mail-tab:hover { color: var(--text); }
.mail-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(15,23,42,.10), 0 1px 2px rgba(15,23,42,.06);
}
.mail-tab .mt-ico { width: 16px; height: 16px; display: inline-flex; }
.mail-tab .mt-ico svg { width: 16px; height: 16px; }

.mail-workspace {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.mail-workspace.with-drawer {
  grid-template-columns: 296px minmax(0, 1fr) 380px;
}

/* --- left rail --- */
.mail-side {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
.mail-side-head {
  padding: 16px 16px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.mail-side-title { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 0; }
.ms-ico {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ms-ico svg { width: 17px; height: 17px; }
.ms-name { font-size: 14.5px; font-weight: 800; color: var(--text); }
.ms-sub { font-size: 11.5px; color: var(--text-muted); }
.btn-dark {
  background: #111827; color: #fff; padding: 7px 13px; border-radius: 9px;
  font-size: 12.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s ease;
}
.btn-dark:hover { background: #1f2937; }
.btn-dark svg { width: 13px; height: 13px; }

.mail-side-nav { padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.msn {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; color: #334155;
  transition: background .15s ease, color .15s ease;
}
.msn:hover { background: var(--bg-2); }
.msn.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.msn-ico { width: 16px; height: 16px; display: inline-flex; }
.msn-ico svg { width: 16px; height: 16px; }
.msn-label { flex: 1; text-align: left; }
.msn-badge {
  background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 800;
  padding: 1px 7px; border-radius: 999px; min-width: 20px; text-align: center;
}

/* backend status card */
.asb-status-card {
  margin: 0 12px 14px; padding: 11px 12px;
  background: #faf8ff; border: 1px solid #e8e0fb; border-radius: 12px;
}
.asb-status-row {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 11.5px; font-weight: 700; color: var(--text-muted); line-height: 1.5;
}
.asb-status-row .dot {
  width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0;
}
.asb-status-row .dot.on {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16,185,129,.18);
}
.asb-status-row .dot.off {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245,158,11,.18);
}
.asb-connect-btn {
  margin-top: 10px; width: 100%;
  padding: 7px 10px; border-radius: 8px;
  font-family: inherit; font-size: 11.5px; font-weight: 800;
  color: var(--primary); background: #fff;
  border: 1.5px solid #e8e0fb;
  transition: background .15s ease, border-color .15s ease;
}
.asb-connect-btn:hover { background: var(--primary-soft); border-color: var(--primary-2); }

/* --- middle list --- */
.mail-list-panel {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-xl); overflow: hidden;
}
.mlp-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.mlp-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 800; color: var(--text);
}
.mlp-title .mlp-ico { width: 17px; height: 17px; color: var(--text-muted); }
.mlp-title .mlp-ico svg { width: 17px; height: 17px; }
.mlp-count { color: var(--primary); font-weight: 800; }
.mlp-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px; min-width: 220px;
}
.mlp-search svg { width: 14px; height: 14px; color: var(--text-dim); flex-shrink: 0; }
.mlp-search input {
  border: none; background: none; outline: none; width: 100%;
  font-family: inherit; font-size: 13px; color: var(--text);
}
.mlp-search input::placeholder { color: var(--text-dim); }

.ml-item {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s ease;
}
.ml-item:last-child { border-bottom: none; }
.ml-item:hover { background: #fbfaff; }
.ml-item.unread { background: #fcfbff; }
.ml-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ml-avatar.dim { background: #e9e7f3; color: #6b7280; }
.ml-body { flex: 1; min-width: 0; }
.ml-row1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ml-from { font-size: 13.5px; font-weight: 800; color: var(--text); }
.ml-tag {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; letter-spacing: .01em;
}
.ml-tag.payment { background: #dcfce7; color: #15803d; }
.ml-tag.agreement { background: #ede9fe; color: #5b21b6; }
.ml-tag.support { background: #dbeafe; color: #1d4ed8; }
.ml-tag.otp { background: #fef3c7; color: #b45309; }
.ml-subject { font-size: 13px; font-weight: 700; color: #334155; margin-top: 3px; }
.ml-preview {
  font-size: 12.5px; color: var(--text-muted); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden;
}
.ml-meta {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  font-size: 11.5px; color: var(--text-dim);
}
.ml-time { white-space: nowrap; }
.ml-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }

/* --- compose drawer --- */
.compose-drawer {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-xl); overflow: hidden;
  display: flex; flex-direction: column;
  position: sticky; top: calc(var(--topbar-h) + 16px);
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.cd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.cd-title { font-size: 14px; font-weight: 800; color: var(--text); }
.cd-close {
  width: 28px; height: 28px; border-radius: 8px; font-size: 17px;
  color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center;
}
.cd-close:hover { background: var(--bg-2); }
.cd-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.cd-field {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; font-family: inherit; font-size: 13px; background: #fff;
}
.cd-field:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
.cd-field::placeholder { color: var(--text-dim); }
.cd-textarea {
  width: 100%; min-height: 190px; padding: 12px 13px; resize: vertical;
  border: 1px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 13px; line-height: 1.6; color: var(--text);
}
.cd-textarea:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
.cd-foot {
  padding: 13px 18px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fdfdff;
}
.cd-note { font-size: 11px; color: var(--text-dim); }
.btn-purple {
  background: var(--primary); color: #fff; padding: 10px 16px;
  border-radius: 10px; font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s ease;
}
.btn-purple:hover { background: #4c1d95; }
.btn-purple svg { width: 14px; height: 14px; }

/* === Program Mail (from legacy portal) === */
.pm-hero {
  background: linear-gradient(135deg, #5b21b6 0%, #2563eb 55%, #f97316 100%);
  color: #fff; border-radius: 16px; padding: 16px 20px; margin-bottom: 14px;
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
}
.pm-hero-title { font-size: 19px; font-weight: 800; }
.pm-hero-sub { font-size: 12px; opacity: .92; }
.pm-hero-label { font-size: 11.5px; font-weight: 700; opacity: .9; display: block; margin-bottom: 4px; }
.pm-select {
  padding: 9px 14px; border-radius: 10px; border: none; font-weight: 700;
  font-size: 13.5px; color: #5b21b6; background: #fff; min-width: 190px;
  font-family: inherit;
}
.pm-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 14px;
}
.pm-stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 12px; text-align: center; border-top: 3px solid var(--primary);
  transition: transform .2s ease, box-shadow .2s ease;
}
.pm-stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.pm-stat-card:nth-child(1) { border-top-color: #7c3aed; }
.pm-stat-card:nth-child(2) { border-top-color: #2563eb; }
.pm-stat-card:nth-child(3) { border-top-color: #f97316; }
.pm-stat-card:nth-child(4) { border-top-color: #0d9488; }
.pm-stat-card .num {
  font-size: 1.5rem; font-weight: 800; color: var(--primary-2);
  letter-spacing: -.5px;
}
.pm-stat-card .lbl {
  font-size: 10.5px; font-weight: 800; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em; margin-top: 4px;
}
.pm-actions-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px;
}
.pm-actions-row .btn {
  padding: 8px 13px; border-radius: 9px; font-size: 12.5px; font-weight: 700;
  border: 1.5px solid var(--border); background: #fff; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.pm-actions-row .btn:hover { background: var(--bg-2); }
.pm-actions-row .btn.primary { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.pm-actions-row .btn.blue { border-color: #3b82f6; color: #1d4ed8; background: #eff6ff; }
.pm-quota-text { font-size: 12px; color: var(--primary); font-weight: 700; }
.pm-sync-note { font-size: 11px; color: var(--text-dim); margin-left: auto; }

.pm-filter-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px;
}
.pm-filter-row label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.pm-filter-row select,
.pm-filter-row input {
  padding: 7px 10px; border-radius: 8px; border: 1.5px solid #e0e7ff;
  font-family: inherit; font-size: 12.5px; background: #fff; color: var(--text);
}
.pm-filter-row input[type="search"] { min-width: 210px; }

/* compose */
.pm-compose {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 20px; margin-bottom: 16px;
}
.pm-compose h3 { margin: 0 0 14px; font-size: 17px; font-weight: 800; color: var(--primary); }
.pm-row { margin-bottom: 12px; }
.pm-row > label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; color: var(--text-muted); }
.pm-input-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pm-input-row input[type="text"] {
  flex: 1; min-width: 220px; padding: 10px 13px; border-radius: 10px;
  border: 1.5px solid #e0e7ff; font-family: inherit; font-size: 13.5px;
}
.pm-input-row input:focus { outline: none; border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
.pm-chip-btn {
  padding: 9px 14px; border-radius: 9px; font-size: 12.5px; font-weight: 700;
  border: 1.5px solid #ddd6fe; background: #f5f3ff; color: #5b21b6;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.pm-chip-btn:hover { background: #ede9fe; }
.pm-chip-btn.solid { background: var(--primary); color: #fff; border-color: var(--primary); }
.pm-chip-btn.green { background: #059669; color: #fff; border-color: #059669; }
.pm-chip-btn.ghost { background: #fff; color: var(--text-muted); border-color: var(--border); }

.pm-dual { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pm-editor-label {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 6px;
}
.pm-editor-label .hint { font-weight: 500; color: var(--text-muted); font-size: 11.5px; }
.pm-editor {
  min-height: 150px; max-height: 280px; overflow: auto; padding: 12px 14px;
  border: 1.5px solid #e0e7ff; border-radius: 12px; background: #fff;
  font-size: 14px; line-height: 1.6; outline: none; color: var(--text);
}
.pm-editor:focus { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
.pm-editor:empty:before { content: attr(data-placeholder); color: #94a3b8; }
.pm-fmt-bar {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px;
}
.pm-fmt {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 8px;
  border: 1.5px solid var(--border); background: #fff; color: var(--text);
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.pm-fmt:hover { background: var(--bg-2); }
.pm-fmt.color { padding: 0 10px; }
.pm-fmt select {
  height: 30px; border-radius: 8px; border: 1.5px solid var(--border);
  font-family: inherit; font-size: 12px; padding: 0 6px; background: #fff; color: var(--text);
}
.pm-fmt input[type="color"] {
  width: 30px; height: 30px; padding: 0; border: 1.5px solid var(--border);
  border-radius: 8px; background: #fff; cursor: pointer;
}
.pm-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
.pm-check {
  display: flex; align-items: center; gap: 9px; font-size: 13px;
  color: var(--text); cursor: pointer; margin-top: 6px;
}
.pm-check input { width: 16px; height: 16px; accent-color: var(--primary); }
.pm-radio-row { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; }
.pm-radio-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.pm-radio-row input { accent-color: var(--primary); }
.pm-send-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
}
.pm-status-line { font-size: 12px; color: var(--text-muted); }
.pm-progress { margin-top: 12px; }
.pm-progress-bar {
  height: 9px; background: #e2e8f0; border-radius: 99px; overflow: hidden;
}
.pm-progress-fill {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, #14b8a6, #7c3aed); transition: width .25s ease;
}
.pm-progress-text { font-size: 12px; font-weight: 700; margin-top: 6px; color: var(--primary); }
.pm-last-sent { margin-top: 16px; }
.pm-last-sent h4 { font-size: 12.5px; font-weight: 800; color: var(--text-muted); margin: 0 0 8px; }
.pm-sent-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fafaff; font-size: 12.5px;
}
.pm-sent-item .tick { color: #059669; font-weight: 800; }
.pm-sent-item .sub { color: var(--text-muted); font-size: 11.5px; }

/* decision table */
.pm-table-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 0 0 10px; padding: 11px 13px;
  background: linear-gradient(135deg, #ede9fe, #dbeafe);
  border-radius: 12px; border: 1px solid #e0e7ff;
}
.pm-tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.pm-tbl thead th {
  background: linear-gradient(90deg, #5b21b6, #2563eb); color: #fff;
  font-size: 11.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  padding: 11px 14px; text-align: left; position: sticky; top: 0; z-index: 1;
}
.pm-tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.pm-tbl tr:last-child td { border-bottom: none; }
.pm-tbl tr:hover td { background: #fbfaff; }
.pm-tbl .id-cell { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; color: var(--primary); font-weight: 700; }
.pm-tbl .name-cell { font-weight: 700; }
.pm-tbl .email-cell { color: var(--text-muted); font-size: 12.5px; }
.pm-tbl tr.to-send { background: linear-gradient(90deg, #ecfdf5 0%, #f0fdf4 100%) !important; }
.pm-tbl tr.to-send td { border-color: #bbf7d0 !important; }
.pm-tbl tr.to-send select { border-color: #86efac !important; background: #fff; font-weight: 700; color: #166534; }
.pm-decision {
  padding: 5px 9px; border-radius: 8px; border: 1.5px solid var(--border);
  font-family: inherit; font-size: 12.5px; background: #fff; color: var(--text);
}

@media (max-width: 1100px) {
  .mail-workspace, .mail-workspace.with-drawer { grid-template-columns: 1fr; }
  .compose-drawer { position: static; }
}
@media (max-width: 760px) {
  .pm-dual, .pm-row2 { grid-template-columns: 1fr; }
}

/* === NCM tracker grid (Class & attendance) === */
.tracker-wrap {
  overflow: auto;
  max-height: 66vh;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.tracker-tbl {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  width: max-content;
  min-width: 100%;
}
.tracker-tbl .tg-row th {
  position: sticky; top: 0; z-index: 3;
  background: linear-gradient(90deg, #1e1b4b, #4c1d95);
  color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; text-align: center;
  padding: 9px 12px;
  border-right: 1px solid rgba(255,255,255,.12);
  white-space: nowrap;
}
.tracker-tbl .tr-head th {
  position: sticky; top: 32px; z-index: 2;
  background: #faf9ff;
  font-size: 10.5px; font-weight: 800; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 8px 10px; text-align: center;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.tracker-tbl tbody tr:nth-child(even) td { background: #fcfbff; }
.tracker-tbl tbody tr:hover td { background: #f7f4ff; }
.tracker-tbl td.tc {
  padding: 0;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid #f1f0f6;
  text-align: center;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
}
.tracker-tbl td.tc-ro { padding: 7px 10px; text-align: left; }
.tracker-tbl td.tc-ro.id-cell { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 11.5px; color: var(--primary); font-weight: 700; }
.tracker-tbl td.tc-ro.name-cell { font-weight: 700; text-align: left; }
.tracker-tbl td.tc-auto { background: #f8f7fc; color: var(--text-muted); padding: 7px 10px; }
.tracker-tbl td.tc-att select {
  width: 100%; border: none; background: transparent;
  font-family: inherit; font-size: 12px; font-weight: 700;
  padding: 7px 8px; cursor: pointer; text-align: center;
}
.tracker-tbl td.tc-att select:disabled { cursor: default; opacity: .8; }
.tracker-tbl td.tc-num input {
  width: 100%; border: none; background: transparent; text-align: center;
  font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 7px 6px; color: var(--text);
}
.tracker-tbl td.tc-num input:disabled { cursor: default; }
.tracker-tbl td.tc-num input:focus, .tracker-tbl td.tc-att select:focus {
  outline: 2px solid var(--primary-2); outline-offset: -2px; background: #fff;
}
/* status colours */
.tracker-tbl td.tc-att.is-punctual { background: #ecfdf5 !important; }
.tracker-tbl td.tc-att.is-punctual select { color: #047857; }
.tracker-tbl td.tc-att.is-late { background: #fffbeb !important; }
.tracker-tbl td.tc-att.is-late select { color: #b45309; }
.tracker-tbl td.tc-att.is-absent { background: #fef2f2 !important; }
.tracker-tbl td.tc-att.is-absent select { color: #b91c1c; }
/* save feedback */
.tracker-tbl td.saving { position: relative; }
.tracker-tbl td.saving::after {
  content: ""; position: absolute; inset: 0; background: rgba(124,58,237,.10);
}
.tracker-tbl td.saved { animation: flashOk .9s ease; }
@keyframes flashOk { 0% { background: #d1fae5; } 100% { background: transparent; } }
.tracker-tbl td.save-err { animation: flashErr .9s ease; }
@keyframes flashErr { 0% { background: #fee2e2; } 100% { background: transparent; } }

.tracker-legend {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px;
  font-size: 11.5px; color: var(--text-muted);
}
.tracker-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.tracker-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.tracker-legend .sw.punctual { background: #d1fae5; border: 1px solid #6ee7b7; }
.tracker-legend .sw.late { background: #fef3c7; border: 1px solid #fcd34d; }
.tracker-legend .sw.absent { background: #fee2e2; border: 1px solid #fca5a5; }
.tracker-legend .sw.auto { background: #f1f0f6; border: 1px solid #d9d6e6; }
.tracker-legend .sw.num { background: #fff; border: 1px solid #cbd5e1; }

/* === Member detail drawer === */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.42);
  display: flex; justify-content: flex-end; z-index: 90;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  width: min(430px, 94vw); background: #fff; height: 100%;
  display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.16);
  animation: slideDrawer .22s ease;
}
@keyframes slideDrawer { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.drawer-body { flex: 1; overflow-y: auto; padding: 0 20px 24px; }
.drawer-tabs {
  display: flex; gap: 4px; padding: 12px 0;
  border-bottom: 1px solid var(--border); margin-bottom: 8px;
  position: sticky; top: 0; background: #fff; z-index: 2;
}
.dtab {
  padding: 7px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 700;
  color: var(--text-muted); background: var(--bg-2);
}
.dtab.active { background: var(--primary-soft); color: var(--primary); }

/* Facebook badge next to profile links */
.fb-badge {
  width: 16px; height: 16px; border-radius: 3px;
  vertical-align: -3px; margin-right: 2px;
  box-shadow: 0 0 0 1px rgba(15,23,42,.08);
}

/* === Sidebar sheet links === */
.sheet-links { margin-bottom: 10px; }
.sheet-link {
  display: flex; align-items: flex-start; gap: 9px; width: 100%;
  padding: 8px 9px; border-radius: 9px; text-align: left;
  transition: background .15s ease;
}
.sheet-link:hover { background: var(--bg-2); }
.sheet-link .sl-ico {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e6f4ea; color: #188038;
}
.sheet-link .sl-ico svg { width: 14px; height: 14px; }
.sheet-link .sl-txt { min-width: 0; }
.sheet-link .sl-name {
  font-size: 12px; font-weight: 800; color: var(--text);
  display: flex; align-items: center; gap: 5px;
}
.sheet-link .sl-name svg { width: 11px; height: 11px; color: var(--text-dim); }
.sheet-link .sl-sub {
  font-size: 10.5px; color: var(--text-muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sheet-links-label {
  font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-dim); padding: 0 9px 6px;
}

/* === Files bar (collapsible, sidebar) === */
.files-bar {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 10px;
  overflow: hidden;
}
.files-bar-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 11px;
  transition: background .15s ease;
}
.files-bar-head:hover { background: var(--bg-2); }
.fb-ico {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
}
.fb-ico svg { width: 14px; height: 14px; }
.fb-title { font-size: 12.5px; font-weight: 800; color: var(--text); flex: 1; text-align: left; }
.fb-count {
  font-size: 10.5px; font-weight: 800; color: var(--primary);
  background: var(--primary-soft); padding: 1px 7px; border-radius: 999px;
}
.fb-chev { width: 14px; height: 14px; color: var(--text-dim); display: inline-flex; transition: transform .22s ease; }
.fb-chev svg { width: 14px; height: 14px; }
.files-bar.open .fb-chev { transform: rotate(180deg); }
.files-bar-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .28s cubic-bezier(.4,0,.2,1);
}
.files-bar.open .files-bar-body { max-height: 320px; overflow-y: auto; }
.files-bar.open { border-color: #ddd6fe; box-shadow: 0 4px 14px rgba(91,33,182,.07); }
.sheet-links { padding: 0 8px; }
.sheet-links-label { display: none; }
.files-open {
  display: block; width: 100%; text-align: left;
  padding: 9px 11px; margin-top: 2px;
  border-top: 1px solid var(--border);
  font-size: 12px; font-weight: 700; color: var(--primary);
}
.files-open:hover { background: var(--primary-bg); }

/* === Files page === */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}
.file-card {
  display: flex;
  align-items: center;
  gap: 11px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 13px;
  text-decoration: none;
  color: inherit;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.file-card:hover {
  border-color: #ddd6fe;
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.fc-ico {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.fc-ico svg { width: 17px; height: 17px; }
.fc-ico.sheet { background: #e6f4ea; color: #188038; }
.fc-ico.doc { background: var(--info-soft); color: var(--info); }
.fc-ico.link { background: var(--primary-soft); color: var(--primary); }
.fc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fc-name {
  font-size: 13px; font-weight: 800; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fc-sub {
  font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fc-ext { width: 15px; height: 15px; color: var(--text-dim); display: inline-flex; flex-shrink: 0; }
.fc-ext svg { width: 15px; height: 15px; }
.fc-actions { display: flex; gap: 4px; flex-shrink: 0; }
.fc-btn {
  width: 28px; height: 28px; min-width: 28px; border-radius: 7px;
  border: 1px solid var(--border); background: #fff;
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; padding: 0;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
/* the icon must never be squeezed away — it is the only sign of the button */
.fc-btn svg { width: 14px; height: 14px; flex: 0 0 auto; display: block; }
.fc-btn:hover { background: var(--primary-bg); color: var(--primary); border-color: #ddd6fe; }
.fc-btn.danger:hover { background: #fef2f2; color: var(--danger); border-color: #fecaca; }

/* the named Remove action — no guessing what the icon means */
.fc-remove {
  display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto;
  height: 28px; padding: 0 10px; border-radius: 7px;
  border: 1px solid #fecaca; background: #fff5f5; color: var(--danger);
  font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background .14s ease, border-color .14s ease;
}
.fc-remove svg { width: 13px; height: 13px; flex: 0 0 auto; display: block; }
.fc-remove:hover { background: #fee2e2; border-color: #fca5a5; }
.file-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 34px 20px;
  color: var(--text-muted);
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  background: #fcfbff;
}
.file-empty .fe-ico { font-size: 30px; display: block; margin-bottom: 8px; }
/* a mock row so the buttons are obvious even when the list is empty */
.fe-demo {
  display: flex; align-items: center; gap: 10px;
  margin: 16px auto 0; max-width: 460px;
  padding: 10px 12px; text-align: left;
  border: 1px dashed #ddd6fe; border-radius: 12px; background: #faf9ff;
  opacity: .95;
}
.fe-demo .fc-body { min-width: 0; }
.fe-demo .fc-name { color: var(--text-muted); }
.fe-demo .fc-actions { pointer-events: none; }
.file-empty b { color: var(--text); display: block; margin-bottom: 4px; font-size: 14px; }
/* inline words inside the sentence must stay on the line */
.file-empty p b { display: inline; margin: 0; font-size: 12.5px; color: var(--primary); font-weight: 800; }
.file-empty p { margin: 0; font-size: 12.5px; }

/* === Batch card labelled meta === */
.batch-meta { flex-wrap: wrap; gap: 8px 16px; }
.batch-meta-item { white-space: nowrap; }
.batch-meta-item .bmi-label {
  font-weight: 600; color: var(--text-dim); font-size: 11.5px;
}
.batch-meta-item .bmi-val { font-weight: 700; color: var(--text); }
.batch-foot {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
}

/* === Agreements register === */
.ag-status {
  padding: 5px 9px; border-radius: 8px; border: 1.5px solid var(--border);
  font-family: inherit; font-size: 12.5px; font-weight: 700; background: #fff; color: var(--text);
  min-width: 128px; cursor: pointer;
}
.ag-status:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
.ag-status:disabled { opacity: .6; cursor: default; }
.ag-link { color: var(--primary); font-weight: 700; font-size: 12.5px; text-decoration: none; }
.ag-link:hover { text-decoration: underline; }

/* ===== Program Mail header — stays put while the list scrolls =====
   It is deliberately light: the list shows through it like a watermark,
   so you always know which program you are marking while you scroll. */
.pm-sticky-head {
  position: sticky;
  /* sit just below the sticky top bar */
  top: calc(var(--topbar-h, 60px) + 6px);
  z-index: 14;
  margin: 0 -4px 14px;
  padding: 4px 4px 0;
}
.pm-sticky-head .pm-hero {
  background: linear-gradient(135deg, rgba(91,33,182,.82) 0%, rgba(37,99,235,.78) 55%, rgba(249,115,22,.74) 100%);
  backdrop-filter: blur(7px) saturate(115%);
  -webkit-backdrop-filter: blur(7px) saturate(115%);
  box-shadow: 0 6px 18px rgba(91,33,182,.14);
  padding: 12px 18px;
}
.pm-sticky-head .pm-stats {
  margin-bottom: 0;
}
.pm-sticky-head .pm-stat-card {
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  padding: 10px 12px;
}
.pm-sticky-head .pm-stat-card:hover { transform: none; }
@media (max-width: 900px) {
  .pm-sticky-head { position: static; margin-left: 0; margin-right: 0; }
}
