
:root {
  --bg:#f4f5f7;
  --panel:#ffffff;
  --ink:#171717;
  --muted:#666;
  --border:#d7d9dd;
  --red:#8f161c;
  --red-dark:#611015;
  --black:#111;
  --good:#eaf6ed;
  --warn:#fff4d6;
  --bad:#fde8e8;
}
*{box-sizing:border-box}
body{margin:0;font-family:Arial,Helvetica,sans-serif;background:var(--bg);color:var(--ink)}
.topbar{background:linear-gradient(135deg,var(--black),#2b2b2b);color:white;padding:20px 28px;display:flex;justify-content:space-between;gap:20px;align-items:center;border-bottom:5px solid var(--red)}
.topbar h1{margin:0 0 4px;font-size:25px}.topbar p{margin:0;color:#ddd}
.session{display:flex;gap:10px;align-items:end;flex-wrap:wrap}.session label{font-size:12px;display:flex;flex-direction:column;gap:5px}
main{max-width:1500px;margin:22px auto;padding:0 18px 60px}
.card{background:var(--panel);border:1px solid var(--border);border-radius:10px;padding:18px;box-shadow:0 2px 8px rgba(0,0,0,.04)}
.scopebar{display:flex;justify-content:space-between;align-items:center;gap:15px;margin-bottom:14px}
.filters{display:flex;gap:10px;flex-wrap:wrap}.filters label{font-size:12px;color:var(--muted);display:flex;flex-direction:column;gap:4px}
.tabs{display:flex;gap:7px;flex-wrap:wrap;margin-bottom:14px}
.tabs button{background:#eceef1;color:#222;border:1px solid #d4d6da}.tabs button.active{background:var(--red);color:#fff;border-color:var(--red)}
button,.file-button{border:0;background:var(--red);color:white;border-radius:6px;padding:9px 13px;font-weight:700;cursor:pointer}
button:hover,.file-button:hover{background:var(--red-dark)}
button.secondary{background:#eee;color:#222;border:1px solid #ccc}
button:disabled{opacity:.45;cursor:not-allowed}
select,input,textarea{border:1px solid #bfc3c9;border-radius:6px;padding:8px 9px;background:white;min-height:36px}
.tab-panel{display:none}.tab-panel.active{display:block}
.metric-grid{display:grid;grid-template-columns:repeat(5,minmax(160px,1fr));gap:12px;margin-bottom:14px}
.metric{background:white;border:1px solid var(--border);border-radius:10px;padding:17px;border-top:4px solid var(--red)}
.metric .value{font-size:28px;font-weight:800;margin-top:5px}.metric .label{color:var(--muted);font-size:13px}
.grid-2{display:grid;grid-template-columns:1.3fr 1fr;gap:14px}
.section-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:12px}
.section-head h2,.card h2{margin:0 0 5px}.section-head p,.card>p{margin:0;color:var(--muted)}
.toolbar{display:flex;gap:10px;margin:12px 0}.toolbar input{min-width:300px}
.table-wrap{overflow:auto}
table{width:100%;border-collapse:collapse;font-size:14px}
th,td{text-align:left;border-bottom:1px solid #e2e4e7;padding:10px 8px;vertical-align:top}
th{background:#f7f7f8;position:sticky;top:0}
.badge{display:inline-block;padding:4px 7px;border-radius:999px;font-size:12px;font-weight:700;background:#eee}
.badge.good{background:var(--good)}.badge.warn{background:var(--warn)}.badge.bad{background:var(--bad)}
.summary-row{display:grid;grid-template-columns:1fr 90px 110px;gap:8px;padding:8px 0;border-bottom:1px solid #eee}
.attention{padding:10px;border-left:4px solid var(--red);background:#fafafa;margin:8px 0;border-radius:5px}
.documents-list{display:grid;grid-template-columns:repeat(3,minmax(220px,1fr));gap:10px}
.doc{border:1px solid var(--border);padding:13px;border-radius:8px}.doc small{color:var(--muted)}
dialog{width:min(800px,95vw);border:0;border-radius:10px;padding:0;box-shadow:0 20px 70px rgba(0,0,0,.3)}
dialog::backdrop{background:rgba(0,0,0,.45)}
#modalForm{padding:18px}.modal-head{display:flex;justify-content:space-between;align-items:center}.modal-head h2{margin:0}
.icon{font-size:22px;padding:4px 10px}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:17px 0}
.form-grid label{display:flex;flex-direction:column;gap:5px;font-size:13px}.form-grid label.full{grid-column:1/-1}
.modal-actions{display:flex;justify-content:flex-end;gap:8px}
.muted{color:var(--muted)} .right{text-align:right}
@media(max-width:900px){.metric-grid{grid-template-columns:repeat(2,1fr)}.grid-2{grid-template-columns:1fr}.documents-list{grid-template-columns:1fr}.topbar{align-items:flex-start;flex-direction:column}.scopebar{align-items:flex-start;flex-direction:column}}
@media(max-width:600px){.metric-grid{grid-template-columns:1fr}.form-grid{grid-template-columns:1fr}.toolbar{flex-direction:column}.toolbar input{min-width:0;width:100%}}

.export-actions{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0 14px}.export-actions button{background:#222}.export-actions button:hover{background:#000}.small-note{font-size:12px;color:var(--muted)}


.hidden{display:none!important}
.auth-shell{min-height:100vh;display:grid;place-items:center;padding:25px;background:linear-gradient(135deg,#111,#2b2b2b)}
.auth-card{width:min(520px,95vw);background:#fff;border-radius:12px;padding:26px;border-top:6px solid var(--red);box-shadow:0 20px 70px rgba(0,0,0,.35)}
.auth-card h1{margin:0 0 5px}.auth-card p{color:var(--muted)}
.auth-card form{display:grid;gap:12px;margin-top:18px}
.auth-card label{display:grid;gap:6px;font-size:13px;font-weight:700}
.auth-status{margin-top:12px;padding:10px;border-radius:6px;background:#f4f5f7;font-size:13px}
.user-chip{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.user-chip strong{display:block}.user-chip small{color:#ddd}
.status-strip{margin:0 0 14px;padding:10px 14px;border-radius:7px;background:#eef3f7;border:1px solid #d3dce5}
.status-strip.error{background:#fde8e8;border-color:#e9bcbc}
.status-strip.success{background:#eaf6ed;border-color:#b9dec0}
.import-box{border:1px dashed #aaa;border-radius:8px;padding:15px;margin-top:12px}
.progress{height:12px;background:#e4e5e7;border-radius:999px;overflow:hidden;margin:10px 0}.progress>div{height:100%;background:var(--red);width:0%}
.doc-actions{display:flex;gap:7px;margin-top:10px;flex-wrap:wrap}
.small{font-size:12px}.nowrap{white-space:nowrap}
.role-pill{padding:5px 8px;border-radius:999px;background:#3b3b3b;color:#fff;font-size:12px}


/* SOP / PDF routing and verification */
.sop-training-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:12px 0}
.sop-training-card{border:1px solid #d1d5db;border-radius:10px;padding:12px;background:#fff}
.sop-training-card strong{color:#102f5e}
.sop-training-card p{margin:6px 0 0}
.sop-doc-card{display:flex;justify-content:space-between;gap:14px;align-items:flex-start;border:1px solid #d1d5db;border-radius:10px;padding:12px;margin:10px 0;background:#fff}
.sop-doc-main{min-width:0;flex:1}.sop-badges{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}.sop-verify-meta{margin-top:7px}.sop-doc-card .doc-actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
@media(max-width:850px){.sop-training-grid{grid-template-columns:1fr}.sop-doc-card{flex-direction:column}.sop-doc-card .doc-actions{justify-content:flex-start}}


/* Dashboard chapter-count list */
.dashboard-summary-grid{
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:14px;
  align-items:start;
}
.chapter-count-row{
  grid-template-columns:1fr 70px 90px;
}
.chapter-total-row{
  margin-top:6px;
  padding-top:10px;
  border-top:2px solid #8f161c;
  grid-template-columns:1fr 70px 90px;
}
@media(max-width:1200px){
  .dashboard-summary-grid{grid-template-columns:1fr 1fr}
}
@media(max-width:800px){
  .dashboard-summary-grid{grid-template-columns:1fr}
}


/* Members roster: compact screen-fit layout.
   ICE contact stays in the member Edit form, not in the roster table. */
.members-table-wrap{
  width:100%;
  overflow-x:auto;
  overflow-y:visible;
}
.members-table{
  width:100%;
  min-width:0;
  table-layout:fixed;
  font-size:12px;
}
.members-table th,
.members-table td{
  padding:7px 4px;
  line-height:1.15;
  overflow-wrap:anywhere;
  word-break:normal;
}
.members-table th{
  font-size:12px;
}
.members-table th:nth-child(1),
.members-table td:nth-child(1){width:7.5%}   /* Name */
.members-table th:nth-child(2),
.members-table td:nth-child(2){width:5.5%}   /* Member # */
.members-table th:nth-child(3),
.members-table td:nth-child(3){width:5.5%}   /* Renewal */
.members-table th:nth-child(4),
.members-table td:nth-child(4){width:6.5%}   /* Rider/Supporter */
.members-table th:nth-child(5),
.members-table td:nth-child(5){width:6%}     /* Parent Org */
.members-table th:nth-child(6),
.members-table td:nth-child(6){width:7%}     /* Department */
.members-table th:nth-child(7),
.members-table td:nth-child(7){width:5%}     /* Chapter */
.members-table th:nth-child(8),
.members-table td:nth-child(8){width:6.5%}   /* Chapter Office */
.members-table th:nth-child(9),
.members-table td:nth-child(9){width:6.5%}   /* Department Office */
.members-table th:nth-child(10),
.members-table td:nth-child(10){width:6.5%}  /* National Office */
.members-table th:nth-child(11),
.members-table td:nth-child(11){width:5.5%}  /* Chapter Dues */
.members-table th:nth-child(12),
.members-table td:nth-child(12){width:6%}    /* Department Dues */
.members-table th:nth-child(13),
.members-table td:nth-child(13){width:5.5%}  /* National Dues */
.members-table th:nth-child(14),
.members-table td:nth-child(14){width:5.5%}  /* Status */
.members-table th:nth-child(15),
.members-table td:nth-child(15){width:9%}    /* Contact */
.members-table th:nth-child(16),
.members-table td:nth-child(16){width:5%}    /* Actions */

.members-table th.member-actions-col,
.members-table td.member-actions-col{
  position:static;
  min-width:0;
  width:auto;
  text-align:center;
  background:inherit;
  border-left:0;
  box-shadow:none;
}
.members-table thead th.member-actions-col{
  background:#f7f7f8;
}
.member-edit-btn{
  min-width:48px;
  padding:6px 8px;
  white-space:nowrap;
  font-weight:800;
}

@media(max-width:1350px){
  .members-table{
    font-size:11px;
  }
  .members-table th{
    font-size:11px;
  }
  .members-table th,
  .members-table td{
    padding:6px 3px;
  }
}
