:root {
  --red: #c0392b; --red-dark: #96281b;
  --blue: #2980b9; --blue-light: #3498db;
  --green: #27ae60; --orange: #e67e22; --purple: #8e44ad;
  --gray-50: #f8f9fa; --gray-100: #f1f3f5; --gray-200: #e9ecef;
  --gray-300: #dee2e6; --gray-400: #ced4da; --gray-500: #adb5bd;
  --gray-600: #6c757d; --gray-700: #495057; --gray-800: #343a40;
  --text: #212529; --border: #dee2e6;
  --white: #ffffff; --primary: #2980b9;
  --shadow: 0 1px 3px rgba(0,0,0,.12);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.15);
  /* Semantic tokens (overridden per theme) */
  --selected-bg: #e8f4fd;
  --badge-warn-bg: #ffeeba;    --badge-warn-text: #856404;
  --badge-danger-bg: #f8d7da;  --badge-danger-text: #721c24;
  --badge-info-bg: #cce5ff;    --badge-info-text: #004085;
  --pill-active-bg: #d4edda;   --pill-active-text: #155724;
  --pill-inactive-bg: #f8d7da; --pill-inactive-text: #721c24;
  --pill-locked-bg: #fff3cd;   --pill-locked-text: #856404;
  --pill-admin-bg: #cce5ff;    --pill-admin-text: #004085;
  --field-invalid-bg: #fff5f5;
  --danger-light-bg: #fdecea;
  --today-bg: #f0f5ff;
  --overlay-bg: rgba(0,0,0,.45);
  --overlay-bg-loading: rgba(0,0,0,0.35);
  --visit-npeg: #0057b8; --visit-npeg-online: #4a90d9;
  --visit-ptc: #2e7d32;  --visit-ptc-online:  #43a860;
  --green-light: #d1fae5; --red-light: #fee2e2;
  --cf-badge-active-bg: #e6f7ee;   --cf-badge-active-text: #1a7f4b;
  --cf-badge-inactive-bg: #fde8e8; --cf-badge-inactive-text: #c0392b;
  --role-presidente-bg: #ffd700; --role-presidente-text: #333;
  --role-vereador-bg: #90ee90;   --role-vereador-text: #1a5c1a;
  --role-vice-bg: #ffa07a;       --role-vice-text: #7a1000;
  --role-chefe-bg: #87ceeb;      --role-chefe-text: #00366b;
}
[data-theme="dark"] {
  --text:       #e9ecef;
  --white:      #1e1e2e;
  --border:     #495057;
  --gray-50:    #2a2a3c;
  --gray-100:   #2e2e42;
  --gray-200:   #383850;
  --gray-300:   #424260;
  --gray-400:   #6c7086;
  --gray-500:   #8a8aa8;
  --gray-600:   #a0a0c0;
  --gray-700:   #cdd6f4;
  --gray-800:   #e0e0fa;
  --shadow:     0 1px 3px rgba(0,0,0,.4);
  --shadow-lg:  0 4px 20px rgba(0,0,0,.5);
  --primary:    #74b0e8;
  --blue:       #74b0e8;
  --blue-light: #89bfed;
  --green:      #4ec38a;
  --red:        #e06c75;
  --red-dark:   #c04f58;
  --selected-bg: #1c3a58;
  --badge-warn-bg: #3d3010;    --badge-warn-text: #ffd166;
  --badge-danger-bg: #3d1015;  --badge-danger-text: #f8818a;
  --badge-info-bg: #0d2b4a;    --badge-info-text: #74b0e8;
  --pill-active-bg: #0d2e1a;   --pill-active-text: #4ec38a;
  --pill-inactive-bg: #3d1015; --pill-inactive-text: #f8818a;
  --pill-locked-bg: #3d3010;   --pill-locked-text: #ffd166;
  --pill-admin-bg: #0d2b4a;    --pill-admin-text: #74b0e8;
  --field-invalid-bg: #2d1215;
  --danger-light-bg: #2d1215;
  --today-bg: #1a2a4a;
  --overlay-bg: rgba(0,0,0,.7);
  --overlay-bg-loading: rgba(0,0,0,0.6);
  --visit-npeg: #74b0e8; --visit-npeg-online: #9cc6f0;
  --visit-ptc: #4ec38a;  --visit-ptc-online:  #7dd4a8;
  --green-light: #0d2e1a; --red-light: #3d1015;
  --cf-badge-active-bg: #0d2e1a;   --cf-badge-active-text: #4ec38a;
  --cf-badge-inactive-bg: #3d1015; --cf-badge-inactive-text: #f8818a;
  --role-presidente-bg: #4a3e00; --role-presidente-text: #ffd700;
  --role-vereador-bg: #0a2a0a;   --role-vereador-text: #90ee90;
  --role-vice-bg: #3a1500;       --role-vice-text: #ffa07a;
  --role-chefe-bg: #001a3a;      --role-chefe-text: #87ceeb;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       font-size: 13px; color: var(--text); background: var(--gray-100); height: 100vh;
       display: flex; flex-direction: column; overflow: hidden; }

/* ── HEADER ── */
#header { background: var(--white); border-bottom: 1px solid var(--border);
          display: flex; flex-direction: row; align-items: stretch; flex-shrink: 0; }
#header .logo-col { display: flex; align-items: center; justify-content: center;
                    padding: 8px 16px 8px 16px; border-right: 1px solid var(--gray-100); }
/* Dark mode logo swap */
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }
#header .header-right { display: flex; flex-direction: column; flex: 1; min-width: 0; }
#header .header-top { display: flex; align-items: center; padding: 6px 16px;
                      gap: 14px; border-bottom: 1px solid var(--gray-100); }
#header .header-nav { display: flex; align-items: center; padding: 4px 10px; gap: 2px; }
#header .header-nav #main-nav { flex: 1; display: flex; align-items: center; gap: 2px; }
.nav-apps-link {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 10px; margin-left: 8px;
  font-size: 12px; font-weight: 600;
  color: var(--gray-600);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.nav-apps-link:hover { background: var(--gray-100); color: var(--gray-800); border-color: var(--gray-400); }
#header .app-title { font-size: 12px; font-weight: 700; color: var(--gray-800);
                     text-transform: uppercase; letter-spacing: .5px; }
#header nav { display: flex; gap: 2px; }
#header nav button { padding: 6px 14px; border: none; background: none; cursor: pointer;
  border-radius: 4px; font-size: 13px; color: var(--gray-600); display: flex;
  align-items: center; gap: 6px; transition: all .15s; }
#header nav button:hover { background: var(--gray-100); color: var(--text); }
#header nav button.active { background: var(--gray-100); color: var(--blue); font-weight: 600; }
#header nav button.hidden { display: none; }
#header .spacer { flex: 1; }
#header .user { font-size: 12px; color: var(--gray-600); text-align: right; }
#header .user strong { display: block; color: var(--text); }

/* ── FILTERS BAR ── */
#filters-bar { background: var(--white); border-bottom: 1px solid var(--border);
  padding: 8px 16px; display: flex; align-items: center; gap: 16px;
  flex-shrink: 0; flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--gray-700); white-space: nowrap; }
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 12px;
  background: var(--chip-bg, var(--blue-light)); color: var(--chip-text, white); font-size: 11px; cursor: pointer;
  transition: all .15s; user-select: none; }
.chip:hover { opacity: .85; }
.chip.inactive { background: var(--gray-300); color: var(--gray-700); opacity: .7; }
.chip-legend { display: flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 12px;
  font-size: 11px; user-select: none; opacity: .9; }
.filter-dropdown { padding: 5px 10px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 12px; background: var(--white); cursor: pointer; }
/* Participação pill filter (Escolas + Municípios) — single-line scroll carousel; reuses .chip / .chip.inactive */
.sy-carousel { display: inline-flex; align-items: center; gap: 2px; max-width: 400px; }
.sy-pill-row { flex: 1 1 auto; flex-wrap: nowrap; overflow-x: auto; scroll-behavior: smooth;
  scrollbar-width: none; -ms-overflow-style: none; }
.sy-pill-row::-webkit-scrollbar { width: 0; height: 0; }
.sy-pill-row .chip, .sy-pill-row .sy-sep { flex: 0 0 auto; }
.sy-pill-row .chip { white-space: nowrap; }
.sy-sep { width: 1px; align-self: stretch; min-height: 16px; background: var(--border); margin: 0 3px; }
.chip.sy-year { --chip-bg: #2e7d32; }
.sy-arrow { flex: 0 0 auto; width: 20px; height: 22px; padding: 0; border: 1px solid var(--border);
  border-radius: 6px; background: var(--white); color: var(--gray-700); font-size: 14px; line-height: 1;
  cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: center; }
.sy-arrow:hover { background: var(--gray-100); }
.sy-arrow.disabled { opacity: .3; pointer-events: none; }
.sy-no-overflow .sy-arrow { display: none; }

/* ── MUNICÍPIOS FILTERS ── */
#municipios-filters { background: var(--white); border-bottom: 1px solid var(--border);
  padding: 8px 16px; display: flex; align-items: center; gap: 16px;
  flex-shrink: 0; }
.toggle-label { display: flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 12px; color: var(--gray-700); }
.toggle-label input { width: 34px; height: 18px; cursor: pointer; }

/* ── MAIN CONTENT ── */
#content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.tab-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.tab-panel.hidden { display: none; }

/* ── COLUMN GRIDS ── */
.four-col { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr);
            gap: 0; overflow: hidden; }
.five-col  { flex: 1; display: grid;
             grid-template-columns: 130px 150px 180px 220px 1fr;
             gap: 0; overflow: hidden; }
.col { display: flex; flex-direction: column; border-right: 1px solid var(--border);
       background: var(--white); overflow: hidden; }
.col:last-child { border-right: none; }
.col-header { padding: 8px 12px; font-weight: 700; font-size: 14px; color: var(--gray-800);
  background: var(--gray-50); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.col-body { flex: 1; overflow-y: auto; }
.col-footer { padding: 5px 10px; border-top: 1px solid var(--border); background: var(--gray-50);
  font-size: 11px; color: var(--gray-500); display: flex; align-items: center;
  justify-content: space-between; flex-shrink: 0; min-height: 35px; box-sizing: border-box; }
.col-footer .actions { display: flex; gap: 8px; align-items: center; }
.col-footer .actions span { cursor: pointer; color: var(--gray-400); font-size: 14px; }
.col-footer .actions span:hover { color: var(--blue); }
.btn-deselect { background: none; border: none; cursor: pointer; color: var(--gray-400); font-size: 12px; padding: 0 2px; line-height: 1; }
.btn-deselect:hover { color: var(--red, #c0392b); }
.col-context-badge { font-size: 10px; font-weight: 400; color: var(--gray-500); margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }

/* ── LIST ITEMS ── */
.list-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--gray-100);
  display: flex; justify-content: space-between; align-items: center;
  transition: background .1s; }
.list-item:hover { background: var(--gray-50); }
.list-item.selected { background: var(--selected-bg); border-left: 3px solid var(--blue); }
.list-item .item-name { font-size: 12px; color: var(--text); line-height: 1.4; flex: 1; min-width: 0; }
.list-item .item-badge, .escola-item .item-badge { font-size: 11px; color: var(--gray-500);
  display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.list-item .item-badge .icon, .escola-item .item-badge .icon { font-size: 12px; }
.item-badge-green { color: #15803d !important; background: #f0fdf4; border: 1px solid #bbf7d0;
  border-radius: 10px; padding: 1px 6px; font-size: 10px !important; }
.item-badge-gray { color: var(--gray-600) !important; background: var(--gray-100); border: 1px solid var(--gray-200);
  border-radius: 10px; padding: 1px 6px; font-size: 10px !important; }
.admin-id-tag { font-size: 10px; color: var(--gray-400); font-weight: normal; }

/* ── ESCOLA TABLE (4th column) ── */
.escola-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--gray-100); }
.escola-item:hover { background: var(--gray-50); }
.escola-item.selected { background: var(--selected-bg); border-left: 3px solid var(--blue); }
.escola-item .escola-name { font-size: 12px; font-weight: 500; color: var(--text); }
.escola-item .escola-meta { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.escola-item .escola-row2 { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }
.escola-open-btn { flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 14px; padding: 2px 4px; border-radius: 3px;
  line-height: 1; opacity: 0; transition: opacity .15s, color .15s; }
.escola-item:hover .escola-open-btn,
.list-item:hover .escola-open-btn,
tr:hover .escola-open-btn { opacity: 1; }
.escola-open-btn:hover { color: var(--blue); }
.badge { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 10px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.badge-publico { background: var(--badge-warn-bg); color: var(--badge-warn-text); }
.badge-privado { background: var(--badge-danger-bg); color: var(--badge-danger-text); }
.badge-blue { background: var(--badge-info-bg); color: var(--badge-info-text); }

/* ── CONTACTS TABLE (municípios 4th col) ── */
.contacts-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.contacts-table th { padding: 6px 8px; background: var(--gray-50);
  border-bottom: 2px solid var(--border); font-weight: 600; text-align: left;
  position: sticky; top: 0; white-space: nowrap; }
.contacts-table td { padding: 6px 8px; border-bottom: 1px solid var(--gray-100);
  vertical-align: middle; }
.contacts-table tr:hover td { background: var(--gray-50); cursor: pointer; }
.contacts-table tr.selected td { background: var(--selected-bg); }
/* tr.list-item must override the flex display from .list-item */
.contacts-table tr.list-item { display: table-row; padding: 0; border-bottom: none; }
.contacts-table tr.list-item.selected { background: transparent; border-left: none; }
.contacts-table tr.list-item.selected td { background: var(--selected-bg); }
.contacts-table tr.list-item.selected td:first-child { border-left: 3px solid var(--blue); }
.role-badge { display: inline-block; padding: 2px 7px; border-radius: 10px;
  font-size: 10px; font-weight: 600; white-space: nowrap; }
.role-presidente { background: var(--role-presidente-bg); color: var(--role-presidente-text); }
.role-vereador { background: var(--role-vereador-bg); color: var(--role-vereador-text); }
.role-vice { background: var(--role-vice-bg); color: var(--role-vice-text); }
.role-chefe { background: var(--role-chefe-bg); color: var(--role-chefe-text); }
.role-default { background: var(--gray-200); color: var(--gray-700); }
.status-ok { color: var(--green); font-size: 15px; }

/* ── BOTTOM BAR ── */
#bottom-bar { background: var(--white); border-top: 1px solid var(--border);
  padding: 10px 16px; display: flex; justify-content: flex-end; gap: 10px;
  flex-shrink: 0; }
.btn { padding: 7px 18px; border: none; border-radius: 4px; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all .15s; }
.btn-primary { background: var(--blue-light); color: white; }
.btn-primary:hover { background: var(--blue); }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: var(--red-dark); }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay-bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px; }
.modal-overlay.hidden { display: none; }
/* Reset-pw back link defaults to hidden until shown.
   (There is no global `.hidden` utility — each `.hidden` is scoped per element.) */
#rp-back-btn.hidden { display: none; }
/* Mail-merge "escolas selecionadas" note — hidden when no schools are inherited
   from the Escolas tab selection (there is no global `.hidden`, so it needs its
   own scoped rule or the empty yellow bar shows permanently). */
#mm-escolas-note.hidden { display: none; }
.modal { background: var(--white); border-radius: 8px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden; }
.modal-sm { width: 500px; max-height: 90vh; }
.modal-md { width: 780px; max-height: 92vh; }
.modal-lg { width: 1200px; max-height: 94vh; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--gray-500); line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--gray-100); color: var(--text); }
.modal-body { flex: 1; overflow-y: auto; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-shrink: 0; min-height: 57px; box-sizing: border-box; }

/* ── DETAIL PANELS ── */
.detail-grid { display: grid; grid-template-columns: minmax(300px,1fr) minmax(300px,2fr) minmax(300px,1fr);
  gap: 0; height: 100%; overflow: hidden; }
.detail-grid-2col { display: grid; grid-template-columns: 1fr 280px;
  gap: 0; height: 100%; overflow: hidden; }
.panel { display: flex; flex-direction: column; border-right: 1px solid var(--border);
  overflow: hidden; }
.panel:last-child { border-right: none; }
.panel-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-section h3 { font-size: 13px; font-weight: 700; margin-bottom: 10px; color: var(--gray-800); }
.panel-scroll { flex: 1; overflow-y: auto; }

/* ── FIELD ROWS ── */
.field-row { display: flex; align-items: flex-start; padding: 5px 0;
  border-bottom: 1px solid var(--gray-100); gap: 8px; }
.field-row:last-child { border-bottom: none; }
.field-label { font-size: 11px; color: var(--gray-600); width: 100px; flex-shrink: 0;
  padding-top: 2px; font-weight: 500; }
.field-value { flex: 1; font-size: 12px; color: var(--text); }

/* ── MODAL LOADING OVERLAY ── */
#modal-loading { position:fixed; inset:0; background:var(--overlay-bg-loading);
  z-index:9999; display:flex; align-items:center; justify-content:center; }
#modal-loading.hidden { display:none; }

/* ── SAVE OVERLAY ── */
#save-overlay { position:fixed; inset:0; background:var(--overlay-bg);
  z-index:10001; display:flex; align-items:center; justify-content:center; }
#save-overlay.hidden { display:none; }

/* ── ERROR DRAWER ── */
#error-drawer { position:fixed; bottom:0; left:0; right:0; z-index:10100;
  background:var(--white); border-top:3px solid var(--red);
  box-shadow:0 -4px 24px rgba(0,0,0,0.18);
  padding:14px 20px; display:flex; align-items:flex-start; gap:12px;
  transform:translateY(0); transition:transform 0.25s ease; }
#error-drawer.hidden { transform:translateY(110%); pointer-events:none; }
#error-drawer .err-icon { font-size:20px; line-height:1; flex-shrink:0; margin-top:1px; }
#error-drawer .err-body { flex:1; min-width:0; }
#error-drawer .err-title { font-weight:600; color:var(--red); font-size:13px; margin-bottom:3px; }
#error-drawer .err-detail { font-size:12px; color:var(--gray-700); word-break:break-word;
  font-family:monospace; background:var(--gray-100); border-radius:4px;
  padding:6px 8px; max-height:120px; overflow-y:auto; white-space:pre-wrap; }
#error-drawer .err-close { flex-shrink:0; background:none; border:none; cursor:pointer;
  font-size:18px; color:var(--gray-500); line-height:1; padding:2px 4px; }
#error-drawer .err-close:hover { color:var(--gray-800); }
.modal-loading-card { background:var(--white); border-radius:10px; padding:28px 36px;
  display:flex; flex-direction:column; align-items:center; gap:10px;
  box-shadow:0 6px 24px rgba(0,0,0,0.18); }
.modal-loading-spinner { width:32px; height:32px; border:3px solid var(--gray-200);
  border-top-color:var(--blue); border-radius:50%;
  animation:spin 0.7s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ── CONTACT FORM ── */
.cf-field { margin-bottom: 8px; }
.cf-field label { display: block; font-size: 11px; font-weight: 600;
  color: var(--gray-600); margin-bottom: 3px; }
.cf-field input, .cf-field select {
  width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 12px; font-family: inherit; background: var(--white); color: var(--text); }
.cf-field input:focus, .cf-field select:focus { outline: none; border-color: var(--blue-light); }
.cf-row { display: flex; gap: 10px; }
.cf-row .cf-field { flex: 1; min-width: 0; }
.cf-active-row { display: flex; align-items: center; gap: 6px; padding: 4px 0 8px; }
.cf-active-row label { font-size: 12px; color: var(--text); cursor: pointer; margin: 0; }
.cf-field input.cf-invalid, .cf-field select.cf-invalid { border-color: var(--red); background: var(--field-invalid-bg); }
.cf-hint { display: block; font-size: 10px; color: var(--red); margin-top: 2px; }
/* cf-group / cf-label / cf-input — entity & quick-add forms */
.cf-group { margin-bottom: 10px; }
.cf-label { display: block; font-size: 11px; font-weight: 600; color: var(--gray-600); margin-bottom: 3px; }
.cf-input { display: block; width: 100%; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 4px; font-size: 12px; font-family: inherit; background: var(--white);
  color: var(--text); box-sizing: border-box; }
.cf-input:focus { outline: none; border-color: var(--blue-light); }
textarea.cf-input { resize: vertical; }
.cf-input.cf-invalid { border-color: var(--red); background: var(--field-invalid-bg); }
/* contact view mode */
.cf-view-field { margin-bottom: 10px; }
.cf-view-field label { display: block; font-size: 10px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.cf-view-value { font-size: 13px; color: var(--text); min-height: 18px; word-break: break-word; }
.cf-view-value.empty { color: var(--gray-400); font-style: italic; }
.cf-view-row { display: flex; gap: 16px; margin-bottom: 10px; }
.cf-view-row .cf-view-field { flex: 1; min-width: 0; margin-bottom: 0; }
.cf-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.cf-badge.active { background: var(--cf-badge-active-bg); color: var(--cf-badge-active-text); }
.cf-badge.inactive { background: var(--cf-badge-inactive-bg); color: var(--cf-badge-inactive-text); }
.field-value a { color: var(--blue); text-decoration: none; }
.field-value a:hover { text-decoration: underline; }
.field-edit { display: flex; align-items: center; gap: 4px; flex: 1; }
.field-edit input { flex: 1; padding: 2px 6px; border: 1px solid var(--border);
  border-radius: 3px; font-size: 12px; }
.field-edit .edit-btn { background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 14px; padding: 2px; }
.field-edit .edit-btn:hover { color: var(--blue); }
.chips-row { display: flex; flex-wrap: wrap; gap: 3px; }

/* ── OBSERVATIONS ── */
.obs-item { padding: 8px 12px; border-bottom: 1px solid var(--gray-100); }
.obs-item .obs-header { display: flex; justify-content: space-between;
  font-size: 11px; color: var(--gray-500); margin-bottom: 4px; }
.obs-item .obs-subject { font-weight: 600; font-size: 12px; color: var(--text); }
.obs-item .obs-body { font-size: 12px; color: var(--gray-700); margin-top: 2px; }
.obs-body ul, .obs-body ol { margin: 3px 0 3px 18px; padding: 0; }
.obs-body li { margin: 1px 0; }
.obs-body p { margin: 2px 0; }
.obs-body a { color: var(--primary, #0057b8); }
.obs-body code { font-family: monospace; font-size: 11px; background: var(--gray-50); padding: 1px 3px; border-radius: 3px; }
.obs-body pre { font-family: monospace; font-size: 11px; background: var(--gray-50); padding: 4px 6px; border-radius: 3px; overflow-x: auto; }
.obs-body blockquote { border-left: 3px solid var(--border); margin: 3px 0 3px 4px; padding-left: 8px; color: var(--gray-600); }
.obs-item .obs-reminder { display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; background: var(--pill-locked-bg); border-radius: 10px;
  font-size: 10px; color: var(--pill-locked-text); margin-top: 4px; }
.obs-delete-btn { background: none; border: none; cursor: pointer; padding: 0 2px;
  font-size: 12px; opacity: 0; transition: opacity .15s; line-height: 1; }
.obs-item:hover .obs-delete-btn { opacity: 0.5; }
.obs-delete-btn:hover { opacity: 1 !important; }

/* ── ADD OBS FORM ── */
.obs-form { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--gray-50); }
.obs-form input, .obs-form textarea { width: 100%; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 4px; font-size: 12px;
  font-family: inherit; margin-bottom: 6px; resize: vertical; }
.obs-form textarea { min-height: 60px; }
.obs-form .form-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.obs-form label { font-size: 11px; color: var(--gray-600); white-space: nowrap; }
.obs-form .form-actions { display: flex; justify-content: flex-end; }
.obs-meta-row { display: flex; gap: 6px; margin-bottom: 6px; }
.obs-meta-sel { flex: 1; font-size: 11px; padding: 3px 5px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--white); color: var(--text); min-width: 0; }
.obs-meta-val { font-size: 10px; color: var(--gray-500); margin-right: 6px; }

/* ── TEACHER TABLE ── */
.teacher-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.teacher-table th { padding: 5px 8px; background: var(--gray-50);
  border-bottom: 2px solid var(--border); font-weight: 600; text-align: left; }
.teacher-table td { padding: 5px 8px; border-bottom: 1px solid var(--gray-100); }
.teacher-table tr:hover td { background: var(--gray-50); cursor: pointer; }

/* ── HISTORY ── */
.history-item { padding: 6px 12px; border-bottom: 1px solid var(--gray-100); }
.history-item .history-year { font-weight: 700; font-size: 12px; color: var(--gray-800); }
.history-item.clickable { cursor: pointer; }
.history-item.clickable:hover { background: var(--gray-50); }
.history-item.clickable.selected { background: var(--selected-bg); border-left: 3px solid var(--blue); padding-left: 9px; }
.history-item .history-school { font-size: 11px; color: var(--gray-600); }
.history-item .history-count { font-size: 11px; color: var(--gray-500); float: right; }

/* ── CHART MODAL ── */
#chart-modal .modal-body { padding: 20px; }
.chart-container { position: relative; height: 380px; }
.chart-subtitle { font-size: 11px; color: var(--gray-500); text-align: right; margin-top: 8px; }

/* ── LOADING / EMPTY ── */
.loading { padding: 20px; text-align: center; color: var(--gray-500); font-size: 12px; }
.empty { padding: 20px; text-align: center; color: var(--gray-400); font-size: 12px; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── STARTUP / LOGIN SCREENS ── */
#startup-screen { position: fixed; inset: 0; background: var(--gray-100);
  display: flex; align-items: center; justify-content: center; z-index: 10000; }
#startup-screen.hidden { display: none; }
.startup-box { display: flex; flex-direction: column; align-items: center; }
.startup-spinner { width: 28px; height: 28px; border: 3px solid var(--gray-200);
  border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 12px; font-weight: 600;
  color: var(--gray-700); margin-bottom: 4px; }
.form-field input { width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 5px; font-size: 13px; transition: border-color .15s; }
.form-field input:focus { outline: none; border-color: var(--blue-light); }
.login-error { color: var(--red); font-size: 12px; margin-bottom: 10px;
  padding: 6px 10px; background: var(--danger-light-bg); border-radius: 4px; }
.login-error.hidden { display: none; }

/* ── CHANGE PASSWORD MODAL ── */
#change-pw-modal .modal-body { padding: 20px; }

/* ── Panel container (Gestão de dados tab) ── */
.admin-content { flex: 1; overflow-y: auto; padding: 16px; }
.admin-content.hidden { display: none; }

/* ── ADMIN CARD (groups a heading + table together — Log + Gestão de dados tabs) ── */
.admin-card { background:var(--white); border:1px solid var(--border); border-radius:8px;
  margin-bottom:16px; overflow:hidden; }
.admin-card-head { display:flex; align-items:center; gap:10px; padding:11px 16px;
  border-bottom:1px solid var(--gray-200); flex-wrap:wrap; background:var(--gray-50); }
.admin-card-head strong { font-size:13px; color:var(--gray-700); }
.admin-card-body { padding:12px 16px; overflow-x:auto; }
/* Keep standard table headers pinned while a card body (or the panel) scrolls */
.admin-card-body .data-table thead th { position:sticky; top:0; z-index:1; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 7px 10px; background: var(--gray-50);
  border-bottom: 2px solid var(--border); font-weight: 600; text-align: left;
  white-space: nowrap; position: sticky; top: 0; }
.data-table td { padding: 7px 10px; border-bottom: 1px solid var(--gray-100);
  vertical-align: middle; }
.data-table tr:hover td { background: var(--gray-50); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px;
  font-weight: 600; }

/* ── COL SEARCH ── */
.col-search-wrap { position: relative; display: inline-flex; align-items: center; }
.col-search { border: 1px solid var(--border); border-radius: 4px; padding: 5px 22px 5px 10px;
  font-size: 12px; width: 160px; background: var(--white); color: var(--text); }
.col-search:focus { outline: none; border-color: var(--blue-light); }
.col-search::placeholder { color: var(--gray-400); }
.col-search-clear { position: absolute; right: 3px; border: none; background: none;
  cursor: pointer; color: var(--gray-500); font-size: 13px; line-height: 1;
  padding: 0 1px; display: none; }
.col-search-clear:hover { color: var(--text); }
.col-search:not(:placeholder-shown) ~ .col-search-clear { display: block; }

/* ── LOG FILTERS ── */
.log-filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.log-filters input, .log-filters select { padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 4px; font-size: 12px; }

/* ── QUICK FIND HEADER BUTTON ── */
#quick-find-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 4px;
  background: var(--green); color: white;
  border: none; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background .15s; white-space: nowrap; flex-shrink: 0;
}
#quick-find-btn:hover { background: #219a52; }

/* ── QUICK FIND OVERLAY ── */
#quick-find-overlay { align-items: flex-start; padding-top: 80px; }
#quick-find-overlay.modal-overlay { display: flex; }
#quick-find-overlay.modal-overlay.hidden { display: none; }
.qf-modal {
  background: var(--white); border-radius: 10px; width: 560px; max-width: 96vw;
  box-shadow: 0 8px 40px rgba(0,0,0,.22); display: flex; flex-direction: column;
  max-height: 70vh; overflow: hidden;
}
.qf-search-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.qf-search-icon { font-size: 20px; flex-shrink: 0; }
#qf-input {
  flex: 1; border: none; outline: none; font-size: 15px;
  color: var(--text); background: transparent;
}
#qf-input::placeholder { color: var(--gray-400); }
.qf-kbd { font-size: 11px; color: var(--gray-500); border: 1px solid var(--gray-300);
  border-radius: 4px; padding: 1px 5px; flex-shrink: 0; }
#qf-results {
  flex: 1; overflow-y: auto;
}
.qf-result-item {
  border-bottom: 1px solid var(--gray-100);
}
.qf-result-item:last-child { border-bottom: none; }
.qf-result-main {
  display: flex; align-items: center; padding: 10px 16px; gap: 10px;
  cursor: pointer; transition: background .1s;
}
.qf-result-main:hover { background: var(--gray-50); }
.qf-result-body { flex: 1; min-width: 0; }
.qf-result-name { font-weight: 600; font-size: 13px; color: var(--text); }
.qf-result-role { font-weight: 400; color: var(--gray-600); font-size: 12px; margin-left: 6px; }
.qf-result-detail { font-size: 12px; color: var(--gray-500); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qf-result-inactive { opacity: .55; }
.qf-result-btns { display: flex; gap: 6px; flex-shrink: 0; }
.qf-result-btns button {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--white); cursor: pointer; font-size: 12px; color: var(--gray-700);
  transition: all .1s; white-space: nowrap;
}
.qf-result-btns button:hover { background: var(--gray-100); border-color: var(--gray-400); }
.qf-result-btns button.btn-note-active { background: var(--blue-light); color: white; border-color: var(--blue-light); }
.qf-note-form {
  padding: 10px 16px 14px 42px; background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
}
.qf-note-form.hidden { display: none; }
.qf-note-form input[type="text"], .qf-note-form textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 4px;
  padding: 6px 8px; font-size: 12px; font-family: inherit;
  margin-bottom: 6px; resize: vertical;
}
.qf-note-form textarea { min-height: 56px; }
.qf-note-remind-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; color: var(--gray-700); }
.qf-note-remind-row input[type="date"] { padding: 4px 6px; border: 1px solid var(--border);
  border-radius: 4px; font-size: 12px; }
.qf-note-form-actions { display: flex; gap: 8px; }
.qf-footer {
  padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.qf-empty { padding: 28px 16px; text-align: center; color: var(--gray-500); font-size: 13px; }
.qf-hint-text { font-size: 12px; color: var(--gray-400); }
/* ── Visitas calendar ─────────────────────────────────────────────── */
.vcal-header { text-align:center; padding:4px 2px; font-size:11px; font-weight:700;
  color:var(--gray-500); text-transform:uppercase; letter-spacing:.04em;
  border-bottom:2px solid var(--gray-200); }
.vcal-day { background:var(--white); border:1px solid var(--gray-200); border-radius:4px;
  min-height:90px; padding:4px; display:flex; flex-direction:column; gap:2px; overflow:hidden; }
.vcal-day.today { border-color:var(--primary); background:var(--today-bg); }
.vcal-day.other-month { background:var(--gray-50); opacity:.6; }
.vcal-day-num { font-size:11px; font-weight:600; color:var(--gray-500); margin-bottom:2px; }
.vcal-day.today .vcal-day-num { color:var(--primary); font-weight:700; }
.visit-chip { font-size:10.5px; padding:2px 5px; border-radius:3px; cursor:pointer;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:#fff;
  font-weight:500; line-height:1.4; }
.visit-chip:hover { opacity:.85; transform:scale(1.02); }
.visit-chip.npeg            { background:var(--visit-npeg); }
.visit-chip.npeg.online     { background:var(--visit-npeg-online); }
.visit-chip.ptc             { background:var(--visit-ptc); }
.visit-chip.ptc.online      { background:var(--visit-ptc-online); }
.visit-chip.pre  { opacity:.75; }
/* ── Week view ─────────────────────────────────────────────────────── */
.vweek-wrap   { display:grid; position:relative; }
.vweek-timecol{ display:flex;flex-direction:column;min-width:44px;flex-shrink:0; }
.vweek-time   { height:60px;border-top:1px solid var(--gray-200);font-size:10px;
  color:var(--gray-500);padding:2px 6px 0;box-sizing:border-box; }
.vweek-daycol { flex:1;position:relative;border-left:1px solid var(--gray-300);
  min-width:110px;background:var(--white); }
.vweek-dayhdr { text-align:center;padding:6px 4px;border-bottom:2px solid var(--gray-300);
  font-size:12px;font-weight:700;color:var(--gray-700);background:var(--gray-100);
  position:sticky;top:0;z-index:2; }
.vweek-dayhdr.today { color:var(--primary);background:var(--today-bg); }
.vweek-body   { position:relative; }
.vweek-hour   { height:60px;border-top:1px solid var(--gray-200);box-sizing:border-box; }
.vweek-chip   { position:absolute;left:2px;right:2px;border-radius:3px;
  padding:2px 5px;font-size:10.5px;color:#fff;cursor:pointer;overflow:hidden;
  box-sizing:border-box;font-weight:500;line-height:1.3; }
.vweek-chip:hover { opacity:.85;z-index:10; }
.vweek-chip.npeg            { background:var(--visit-npeg); }
.vweek-chip.npeg.online     { background:var(--visit-npeg-online); }
.vweek-chip.ptc             { background:var(--visit-ptc); }
.vweek-chip.ptc.online      { background:var(--visit-ptc-online); }
.vweek-chip.pre  { opacity:.75; }

/* ── Mobile guard ──────────────────────────────────────────────────────── */
#mobile-guard {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--bg);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.mobile-guard-box { max-width: 340px; }
.mobile-guard-box h2 { font-size: 18px; font-weight: 700; color: var(--text); margin: 0 0 12px; }
.mobile-guard-box p  { font-size: 14px; color: var(--muted); line-height: 1.6; margin: 0 0 8px; }

@media (max-width: 1023px) {
  #mobile-guard { display: flex; }
  body > *:not(#mobile-guard) { display: none !important; }
}

/* ── Mail Merge header button ─────────────────────────────────────── */
#mail-merge-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 4px;
  background: var(--blue-light); color: white;
  border: none; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background .15s; white-space: nowrap; flex-shrink: 0;
}
#mail-merge-btn:hover { background: var(--blue); }

/* ── User account dropdown ────────────────────────────────────────── */
.user-menu-wrap { position: relative; }
.user-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  min-width: 180px;
  z-index: 2000;
  padding: 4px 0;
}
#user-dropdown button,
#user-dropdown a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  font-weight: normal;
  text-decoration: none;
}
#user-dropdown button:hover,
#user-dropdown a:hover { background: var(--gray-100); }
.user-dropdown hr { margin: 4px 0; border: none; border-top: 1px solid var(--border); }
.user-dropdown.hidden { display: none; }
/* ── User dropdown — version footer ────────────────────────────────────── */
.dd-version-info {
  display: flex; align-items: center; justify-content: flex-end; gap: 5px; flex-wrap: wrap;
  padding: 6px 14px 8px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--gray-600);
  min-height: 0;
}
.dd-version-info:empty { display: none; }
.dd-ver-label { opacity: .75; }
.dd-ver-arrow { opacity: .5; }
.dd-ver-new { color: var(--primary); font-weight: 600; }
.dd-ver-btn {
  margin-left: 2px; padding: 2px 7px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 4px;
  font-size: 11px; cursor: pointer; line-height: 1.4;
}
.dd-ver-btn:hover { opacity: .85; }

/* ── Update banner (stale-client / new-version notice) ──────────────────────── */
#update-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 20px;
  background: #0057b8;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.25);
}
#update-banner button {
  background: #fff;
  color: #0057b8;
  border: none;
  border-radius: 4px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#update-banner button:hover { background: #eaf2fb; }

/* ── Help system (contextual ? icons + popup) ────────────────────────── */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 5px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--badge-info-bg);
  color: var(--badge-info-text);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: background .15s, color .15s;
}
.help-icon:hover { background: var(--blue); color: #fff; }
.help-modal { width: 480px; max-width: 92vw; max-height: 80vh; }
.help-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.help-modal-body p { margin: 0 0 10px; }
.help-modal-body p:last-child { margin-bottom: 0; }
.help-modal-body ul, .help-modal-body ol { margin: 0 0 10px; padding-left: 20px; }
.help-modal-body li { margin-bottom: 4px; }

/* ── Cross-app header link (📊 Dashboards) ────────────────────────── */
.header-app-link {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 4px;
  background: var(--blue-light); color: white;
  border: none; cursor: pointer; font-size: 13px; font-weight: 500;
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
  transition: background .15s;
}
.header-app-link:hover { background: var(--blue); color: #fff; }

/* Changelog viewer: wider than the compact ? help popups (match the Dashboards modal). */
#changelog-modal .help-modal { width: 640px; }

/* ── Changelog "unseen" indicators ────────────────────────────────── */
.menu-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); margin-left: 4px; vertical-align: middle;
}
.cl-badge {
  display: inline-block; min-width: 16px; height: 16px; line-height: 16px;
  padding: 0 5px; border-radius: 8px; margin-left: 6px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  text-align: center;
}
/* `.hidden` is not a global utility in this app (see note near .modal-overlay) —
   each element needs its own scoped rule. Cover the changelog indicators + the
   Dashboards header link (else a CRM-only user would see it). */
.menu-dot.hidden, .cl-badge.hidden, .header-app-link.hidden { display: none; }

/* ── Changelog / scope chips ──────────────────────────────────────── */
.cl-scope {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .3px; vertical-align: middle;
}
.cl-scope-crm        { background: var(--badge-info-bg); color: var(--badge-info-text); }
.cl-scope-dashboards { background: #e2d9f3; color: #4a2f7a; }
.cl-scope-geral      { background: var(--gray-200, #e9ecef); color: var(--gray-700); }
body.dark .cl-scope-dashboards { background: #2c2350; color: #c9b8f0; }
body.dark .cl-scope-geral      { background: #3a3a4a; color: #c0c0d0; }
.cl-scope-admin      { background: #fde2e1; color: #9b1c1c; }
body.dark .cl-scope-admin { background: #4a2020; color: #f3b8b5; }

/* ── Changelog entries (viewer modal) ─────────────────────────────── */
.cl-entry { padding: 12px 0; border-bottom: 1px solid var(--border); }
.cl-entry:last-child { border-bottom: none; }
.cl-entry-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.cl-date { font-size: 12px; color: var(--gray-600); font-weight: 600; }
.cl-ver  { font-size: 11px; color: var(--gray-600); font-family: monospace; }
.cl-entry-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.cl-entry-body { font-size: 13px; line-height: 1.5; }
.cl-entry-body p { margin: 0 0 8px; }
.cl-entry-body p:last-child { margin-bottom: 0; }
.cl-entry-body ul, .cl-entry-body ol { margin: 0 0 8px; padding-left: 20px; }
.cl-entry-body li { margin-bottom: 3px; }

/* ── TIS informational badge (Phase 2, schema_v52) ───────────────────────── */
.tis-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  letter-spacing: .3px;
  background: #fff3e0;
  color: #b45309;
  border: 1px solid #f6c68a;
  vertical-align: middle;
  white-space: nowrap;
}
.tis-dot {
  font-size: 11px;
  vertical-align: middle;
  cursor: help;
}

/* TEIP informational badge — mirrors .tis-badge's amber family, distinct shade */
.teip-badge {
  display: inline-block;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  background: #fdecd1;
  color: #92400e;
  vertical-align: middle;
  white-space: nowrap;
}

/* Duplicate-contacts merge wizard (Admin -> Duplicados -> Fundir) */
#dup-merge-modal .modal { width: min(920px, 94vw); max-height: 92vh; }
#dup-merge-modal .modal-body { padding: 16px 20px; }
.dupm-steps { display:flex; gap:6px; margin:0 0 16px; flex-wrap:wrap; }
.dupm-step { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--gray-500); padding:3px 10px; border-radius:14px; border:1px solid var(--border); background:var(--gray-50); }
.dupm-step.active { color:#fff; background:var(--primary,#0057b8); border-color:var(--primary,#0057b8); font-weight:600; }
.dupm-step.done { color:var(--primary,#0057b8); border-color:var(--primary,#0057b8); }
.dupm-card { border:1px solid var(--border); border-radius:8px; padding:10px 12px; margin:0 0 8px; cursor:pointer; }
.dupm-card.sel { border-color:var(--primary,#0057b8); background:#f0f7ff; }
.dupm-fieldrow { display:grid; grid-template-columns:150px 1fr; gap:10px; padding:7px 0; border-top:1px solid #f0f0f0; align-items:start; }
.dupm-fieldrow:first-child { border-top:none; }
.dupm-flabel { font-size:12px; font-weight:600; color:var(--gray-600); padding-top:2px; }
.dupm-opt { display:flex; align-items:center; gap:7px; font-size:12px; padding:2px 0; cursor:pointer; }
.dupm-opt .who { color:var(--gray-400); font-size:11px; }
.dupm-ro { font-size:12px; color:var(--text); padding-top:2px; }
.dupm-discard { color:var(--gray-500); font-size:11px; }
.dupm-linkrow { display:flex; align-items:center; gap:8px; padding:6px 0; border-top:1px solid #f0f0f0; font-size:12px; }

/* Duplicados — per-member row buttons (🗑 apagar, ➖ excluir do grupo), hidden
   until row hover (mirrors the .obs-delete-btn / .escola-open-btn pattern). */
.dup-del-btn, .dup-excl-btn { opacity: 0; border: none; background: none; cursor: pointer;
  font-size: 13px; padding: 0 4px; transition: opacity .12s; }
tr:hover .dup-del-btn, tr:hover .dup-excl-btn { opacity: 1; }
@media (hover: none) { .dup-del-btn, .dup-excl-btn { opacity: 1; } }
.dup-del-btn:hover, .dup-excl-btn:hover { transform: scale(1.15); }

/* Duplicados — Contactos / Professores sub-tabs */
.dup-subtab { padding: 5px 14px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--white); color: var(--gray-700); font-size: 13px; cursor: pointer; }
.dup-subtab.active { background: var(--primary,#0057b8); border-color: var(--primary,#0057b8); color: #fff; font-weight: 600; }
/* No global `.hidden` — the professores sub-panel needs its own rule. */
.dup-subpanel.hidden { display: none; }
/* Inline detail expander (👁 Detalhes) inside a professores group card */
.tdup-detail { display: none; padding: 6px 10px 10px; font-size: 12px; color: var(--gray-600);
  background: #fafbfc; border-top: 1px solid #eee; }

/* Teacher-merge modal (Admin -> Duplicados -> Professores -> Fundir) */
#teacher-merge-modal .modal { width: min(760px, 94vw); max-height: 90vh; }
#teacher-merge-modal .modal-body { padding: 16px 20px; }
.tmw-card { border:1px solid var(--border); border-radius:8px; padding:9px 11px; margin:0 0 8px; cursor:pointer; }
.tmw-card.sel { border-color:var(--primary,#0057b8); background:#f0f7ff; }
.tmw-conflict { background:#fef2f2; border:1px solid #fecaca; color:#991b1b; border-radius:6px; padding:8px 10px; font-size:12px; margin:0 0 10px; }

/* ── ⚖ Comparar contactos (modules/compare-contacts.js) ────────────────────── */
/* The per-row checkbox markup is always rendered; only a container carrying
   .cmp-on reveals it, so toggling compare mode never needs a re-render. */
.cmp-box { display: none; }
.cmp-on .cmp-box { display: inline-flex; align-items: center; margin-right: 6px; }
.cmp-on .cmp-box input { cursor: pointer; }
/* Table surfaces keep a (collapsed) leading cell so the header stays aligned. */
.cmp-cell { width: 0; padding: 0 !important; }
.cmp-on .cmp-cell { width: 26px; padding: 0 0 0 8px !important; }

/* Floating «Comparar (N)» bar — z-index is set inline (above the open modal). */
#cmp-fab { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--white); border: 1px solid var(--border); border-radius: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18); font-size: 12px; color: var(--gray-700); }

/* Compare modal — no global .modal-body padding, and .hidden needs its own rule. */
#contact-compare-modal.hidden { display: none; }
#contact-compare-modal .modal { width: min(1100px, 96vw); max-height: 90vh; }
#contact-compare-modal .modal-body { padding: 16px 20px; overflow: auto; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cmp-table th, .cmp-table td { border: 1px solid var(--border); padding: 5px 8px;
  vertical-align: top; text-align: left; }
.cmp-table thead th { background: var(--gray-50); position: sticky; top: 0; z-index: 1; font-size: 12px; }
.cmp-table .cmp-sub { font-size: 10px; color: var(--gray-500); font-weight: 400; margin-top: 2px; }
.cmp-table .cmp-fld { width: 160px; background: var(--gray-50); color: var(--gray-600);
  font-size: 11px; white-space: nowrap; }
.cmp-diff { background: #fef9c3; }

/* ── Contact channel editor (Phase B — dynamic emails/phones list) ── */
.cf-chan-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
/* Two lines per row: the value gets the full width on line 1 (emails/numbers
   are long and were being truncated by the controls sharing their line), the
   metadata controls sit on line 2. */
.cf-chan-row { display: flex; flex-direction: column; align-items: stretch; gap: 4px;
  padding: 5px 6px; border: 1px solid var(--gray-200); border-radius: 4px; background: var(--gray-50); }
.cf-chan-line { display: flex; align-items: center; gap: 6px; }
.cf-chan-meta { flex-wrap: wrap; }
.cf-chan-row .cf-chan-value { flex: 1 1 auto; width: auto; min-width: 0; }
.cf-chan-row .cf-chan-kind { flex: 0 0 auto; width: auto; min-width: 110px; font-size: 11px; }
.cf-chan-row .cf-chan-label { flex: 1 1 80px; width: auto; min-width: 60px; font-size: 11px; }
.cf-chan-main { display: flex; align-items: center; gap: 3px; font-size: 10px;
  color: var(--gray-600); white-space: nowrap; cursor: pointer; margin: 0; }
.cf-chan-main input { width: auto; margin: 0; }
.cf-chan-vip { display: flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 600;
  color: #7c3aed; white-space: nowrap; cursor: pointer; margin: 0; }
.cf-chan-vip input { width: auto; margin: 0; }
.cf-chan-remove { flex: 0 0 auto; width: auto; background: none; border: 1px solid var(--gray-300);
  border-radius: 4px; color: var(--gray-500); font-size: 11px; line-height: 1; cursor: pointer;
  padding: 4px 7px; }
.cf-chan-remove:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }
.cf-chan-add { display: block; width: 100%; margin-top: 4px; background: none;
  border: 1px dashed var(--gray-300); border-radius: 4px; color: var(--gray-600);
  font-size: 11px; cursor: pointer; padding: 4px 10px; }
.cf-chan-add:hover { background: var(--gray-100); border-color: var(--blue-light); color: var(--blue); }
.cf-chan-empty { font-size: 11px; color: var(--gray-400); font-style: italic; padding: 4px 2px; }
.cf-chan-hint { padding-left: 2px; }
/* view-mode badges next to an email/phone value */
.cf-chan-badge { display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: .02em;
  padding: 1px 5px; border-radius: 8px; margin-left: 5px; vertical-align: middle; }
.cf-chan-badge.vip { background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; }
.cf-chan-badge.label { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-200);
  font-weight: 600; text-transform: none; letter-spacing: 0; }

/* ── User menu — same look as Dashboards / admin console (UserMenu.tsx) ───── */
/* The CRM header is light, so the colours are inverted: red avatar, dark name. */
.um-btn {
  display: flex; align-items: center; gap: 8px; position: relative;
  min-height: 40px; padding: 4px 12px 4px 4px;
  background: var(--gray-100); border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); font: inherit; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.um-btn:hover { background: var(--gray-200, #e9ecef); border-color: var(--gray-400, #ced4da); }
.um-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e30613; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .3px;
}
.um-name { font-size: 13px; font-weight: 600; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.um-dot { position: absolute; top: 2px; left: 28px; margin: 0; box-shadow: 0 0 0 1.5px var(--white); }
#user-dropdown { min-width: 230px; padding: 0 0 4px; overflow: hidden; border-radius: 8px; }
.um-who {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
  font-size: 13px; color: var(--text); overflow-wrap: anywhere;
}
.um-who span { font-size: 12px; color: var(--gray-600); }
#user-dropdown button, #user-dropdown a { display: flex; align-items: center; gap: 9px; padding: 10px 14px; }
.um-icon { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }
#user-dropdown .cl-badge { margin-left: auto; }
#user-dropdown .um-logout { color: var(--red); }

/* ── Professores sem participação / escolas conhecidas (schema_v89, teacher-known.js) ── */
.known-chip { display: inline-block; background: var(--badge-warn-bg); color: var(--badge-warn-text);
  border-radius: 8px; padding: 0 6px; font-size: 9px; font-weight: 600; line-height: 1.6;
  white-space: nowrap; vertical-align: 1px; }
.known-item { display: flex; align-items: flex-start; gap: 6px; padding: 5px 0; font-size: 12px;
  border-bottom: 1px solid var(--gray-100); }
.known-item .history-year { font-weight: 700; color: var(--gray-800); margin-right: 4px; }
.known-kind { font-size: 10px; color: var(--gray-500); margin-left: 4px; }
.known-note { color: var(--gray-700); margin-top: 1px; }
.known-meta { font-size: 10px; color: var(--gray-500); margin-top: 1px; }
.known-form { margin-top: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--gray-50); }
.sp-kinds { display: flex; gap: 6px; margin: 2px 0 6px; }
.sp-kind { padding: 3px 12px; border-radius: 20px; border: 1px solid var(--border); cursor: pointer;
  font-size: 12px; background: var(--white); color: var(--gray-700); }
.sp-kind.active { background: var(--blue-600, #2563eb); color: #fff; border-color: transparent; }
.sp-chosen { padding: 4px 10px; background: var(--badge-info-bg); color: var(--badge-info-text);
  border-radius: 4px; align-items: center; gap: 8px; font-size: 12px; }
.sp-chosen button { background: none; border: none; cursor: pointer; padding: 0; color: inherit; }
.sp-results { position: absolute; left: 0; right: 0; top: 100%; max-height: 180px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 0 0 6px 6px; background: var(--white);
  z-index: 100; box-shadow: 0 4px 6px rgba(0,0,0,.1); }
.sp-item { padding: 7px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--gray-100); }
.sp-item:hover { background: var(--gray-50); }
.sp-empty { padding: 8px 12px; color: var(--gray-400); font-size: 12px; }
#new-teacher-modal .nt-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  padding: 16px 20px; overflow-y: auto; }
#new-teacher-modal .nt-intro { font-size: 12px; color: var(--gray-600); margin: 0 0 10px; }
#new-teacher-modal .nt-matches { border-left: 1px solid var(--border); padding-left: 16px; min-width: 0; }
.nt-matches-head { font-size: 11px; font-weight: 700; color: var(--gray-600); text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 6px; }
.nt-match { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border: 1px solid var(--border);
  border-radius: 6px; margin-bottom: 6px; }
.nt-match.strong { border-color: var(--badge-warn-text); background: var(--badge-warn-bg); }
.nt-match-name { font-weight: 600; font-size: 13px; color: var(--text); }
.nt-match-meta { font-size: 11px; color: var(--gray-600); margin-top: 2px; word-break: break-word; }
.nt-match-actions { display: flex; flex-direction: column; gap: 4px; }
.nt-why { display: inline-block; font-size: 9px; font-weight: 600; padding: 0 6px; border-radius: 8px;
  background: var(--gray-100); color: var(--gray-600); margin-left: 4px; vertical-align: 1px; }
.nt-why.strong { background: var(--badge-warn-text); color: var(--white); }
.nt-error { margin-top: 8px; padding: 8px 10px; border-radius: 6px; font-size: 12px;
  background: var(--badge-warn-bg); color: var(--badge-warn-text); }
#teacher-role-warn-modal .trw-body { padding: 16px 20px; font-size: 13px; line-height: 1.5; }
#teacher-role-warn-modal .trw-body p { margin: 0 0 8px; }
@media (max-width: 720px) {
  #new-teacher-modal .nt-body { grid-template-columns: 1fr; }
  #new-teacher-modal .nt-matches { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 12px; }
}
.known-add-btn { margin-left: auto; font-size: 11px; padding: 2px 8px; white-space: nowrap; }
