/* Compliance Assessment Tool — App Styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&display=swap');

:root {
  --ink: #0f1923;
  --ink-mid: #3a4a5a;
  --ink-light: #8a9baa;
  --bg: #f4f2ee;
  --bg-card: #ffffff;
  --bg-muted: #eceae5;
  --rule: #ddd9d1;
  --gold: #c8922a;
  --gold-light: #f5e9c8;
  --green: #2a7a4b;
  --green-bg: #e6f4ed;
  --red: #b83232;
  --red-bg: #fbeaea;
  --amber: #b86a1a;
  --amber-bg: #fdf0e0;
  --blue: #1a5c8a;
  --blue-bg: #e3eef8;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(15,25,35,0.07);
  --shadow-lg: 0 8px 32px rgba(15,25,35,0.13);
  --header-h: 58px;
  --filter-h: 46px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--ink); min-height: 100vh; font-size: 14px; line-height: 1.5; }

/* ── HEADER ─────────────────────────────────────────────────────── */
.app-header {
  background: #fff; padding: 0 28px; display: flex; align-items: center;
  justify-content: space-between; height: var(--header-h);
  position: sticky; top: 0; z-index: 100;
  border-bottom: 3px solid var(--gold); gap: 16px;
}
.logo { font-family: 'DM Serif Display', serif; font-size: 17px; color: var(--ink); white-space: nowrap; }
.logo span { color: var(--gold); }

.header-center { flex: 1; display: flex; justify-content: center; }
.header-progress {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-muted); border: 1px solid var(--rule);
  border-radius: 20px; padding: 5px 14px; font-size: 12px; color: var(--ink-mid);
}
.mini-bar { width: 100px; height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.mini-bar-fill { height: 100%; background: var(--gold); border-radius: 2px; transition: width 0.4s; }

.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.btn-icon {
  background: none; border: 1px solid var(--rule); color: var(--ink-mid);
  border-radius: 6px; padding: 6px 8px; cursor: pointer; display: flex;
  align-items: center; transition: all 0.2s;
}
.btn-icon:hover { background: var(--bg-muted); border-color: var(--gold); color: var(--gold); }

/* User menu */
.user-menu { position: relative; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--gold);
  color: var(--ink); border: none; font-family: 'DM Serif Display', serif;
  font-size: 14px; cursor: pointer; font-weight: 700; transition: opacity 0.2s;
}
.user-avatar:hover { opacity: 0.85; }
.user-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  background: #fff; border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: var(--shadow-lg); min-width: 200px; padding: 8px 0; z-index: 200;
}
.user-dropdown.open { display: block; }
.ud-name { padding: 8px 16px 2px; font-weight: 600; font-size: 14px; color: var(--ink); }
.ud-email { padding: 0 16px 8px; font-size: 11px; color: var(--ink-light); }
.ud-sep { height: 1px; background: var(--rule); margin: 4px 0; }
.ud-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 8px 16px; font-family: 'DM Sans', sans-serif; font-size: 13px;
  color: var(--ink-mid); cursor: pointer; transition: background 0.12s;
}
.ud-item:hover { background: var(--bg-muted); }
.ud-logout { color: var(--red); }

/* ── LEGISLATION FILTER BAR ─────────────────────────────────────── */
.leg-filter-bar {
  background: var(--bg); border-bottom: 1px solid var(--rule);
  padding: 0 28px; display: flex; align-items: center; gap: 12px;
  min-height: var(--filter-h); flex-wrap: wrap;
  position: sticky; top: var(--header-h); z-index: 99;
}
.lfb-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-light); white-space: nowrap; flex-shrink: 0;
}

.leg-picker-wrap { position: relative; flex-shrink: 0; }
.leg-picker-btn {
  display: flex; align-items: center; gap: 8px; background: #fff;
  border: 1px solid var(--rule); color: var(--ink); padding: 6px 12px;
  border-radius: 6px; font-family: 'DM Sans', sans-serif; font-size: 12px;
  cursor: pointer; transition: border-color 0.2s; white-space: nowrap;
  min-width: 180px; justify-content: space-between;
}
.leg-picker-btn:hover, .leg-picker-btn.open { border-color: var(--gold); background: var(--gold-light); }
.lpb-count {
  background: var(--gold); color: var(--ink); font-size: 10px; font-weight: 700;
  border-radius: 10px; padding: 1px 6px; margin-left: 4px;
}
.leg-picker-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  background: #fff; border: 1px solid var(--rule); border-radius: 8px;
  box-shadow: var(--shadow-lg); z-index: 200; width: 380px; max-height: 420px;
  overflow: hidden; flex-direction: column;
}
.leg-picker-dropdown.open { display: flex; }
.lpd-search-wrap { padding: 10px 12px; border-bottom: 1px solid var(--rule); flex-shrink: 0; }
.lpd-search {
  width: 100%; background: var(--bg); border: 1px solid var(--rule);
  color: var(--ink); padding: 6px 10px; border-radius: 5px;
  font-family: 'DM Sans', sans-serif; font-size: 12px; outline: none;
}
.lpd-search:focus { border-color: var(--gold); }
.lpd-search::placeholder { color: var(--ink-light); }
.lpd-actions { display: flex; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--rule); flex-shrink: 0; }
.lpd-action-btn {
  font-size: 11px; padding: 4px 10px; border-radius: 4px; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-weight: 600; border: none;
  text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--bg-muted); color: var(--ink-mid);
}
.lpd-action-btn:hover { opacity: 0.75; }
.lpd-list { overflow-y: auto; flex: 1; padding: 6px 0; }
.lpd-list::-webkit-scrollbar { width: 3px; }
.lpd-list::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }
.lpd-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 14px;
  cursor: pointer; transition: background 0.12s; user-select: none;
}
.lpd-item:hover { background: var(--bg-muted); }
.lpd-item.checked { background: rgba(200,146,42,0.1); }
.lpd-cb {
  width: 15px; height: 15px; border-radius: 3px; border: 1.5px solid var(--rule);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: transparent; transition: all 0.15s;
}
.lpd-item.checked .lpd-cb { background: var(--gold); border-color: var(--gold); }
.lpd-cb::after {
  content: ''; display: none; width: 4px; height: 7px;
  border: 2px solid var(--ink); border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px);
}
.lpd-item.checked .lpd-cb::after { display: block; }
.lpd-name { font-size: 12px; color: var(--ink-mid); line-height: 1.35; flex: 1; }
.lpd-item.checked .lpd-name { color: var(--ink); }
.lpd-item-count { font-size: 10px; color: var(--ink-light); flex-shrink: 0; }

.leg-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1; min-width: 0; }
.leg-tag {
  display: flex; align-items: center; gap: 5px;
  background: var(--gold-light); border: 1px solid rgba(200,146,42,0.4);
  color: var(--amber); font-size: 11px; padding: 3px 8px; border-radius: 4px;
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.leg-tag-remove {
  background: none; border: none; color: rgba(200,146,42,0.7); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 0; flex-shrink: 0;
}
.leg-tag-remove:hover { color: var(--red); }
.leg-tag-all { font-size: 11px; color: var(--ink-light); font-style: italic; }

/* ── LAYOUT ─────────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - var(--header-h) - var(--filter-h));
}
.app-layout.no-sidebar {
  grid-template-columns: 1fr;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-card); height: calc(100vh - var(--header-h) - var(--filter-h));
  position: sticky; top: calc(var(--header-h) + var(--filter-h));
  overflow-y: auto; border-right: 1px solid var(--rule);
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }

.sidebar-stats {
  padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  border-bottom: 1px solid var(--rule);
}
.sstat { background: var(--bg); border: 1px solid var(--rule); border-radius: 6px; padding: 10px; text-align: center; }
.sstat .n { font-family: 'DM Serif Display', serif; font-size: 22px; color: var(--ink); line-height: 1; }
.sstat .l { font-size: 10px; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 2px; }
.sstat.c .n { color: #4db87a; }
.sstat.nc .n { color: #e06060; }
.sstat.p .n { color: #e0a040; }
.sstat.na .n { color: #70a8d8; }

.filter-section { padding: 14px 16px; border-bottom: 1px solid var(--rule); }
.filter-section-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-light); margin-bottom: 10px; }
.f-row { margin-bottom: 8px; }
.f-label { display: block; font-size: 10px; color: var(--ink-light); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.f-select, .f-search {
  width: 100%; background: var(--bg); border: 1px solid var(--rule);
  color: var(--ink); padding: 7px 9px; border-radius: 5px;
  font-family: 'DM Sans', sans-serif; font-size: 12px; outline: none; appearance: none;
}
.f-search::placeholder { color: var(--ink-light); }
.f-search:focus, .f-select:focus { border-color: var(--gold); }

.btn-clear-filters {
  width: 100%; background: rgba(200,146,42,0.12); border: 1px solid rgba(200,146,42,0.25);
  color: var(--gold); padding: 6px; border-radius: 5px; font-family: 'DM Sans', sans-serif;
  font-size: 11px; font-weight: 600; cursor: pointer; margin-top: 4px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.btn-clear-filters:hover { background: rgba(200,146,42,0.22); }

.results-count { padding: 10px 16px; font-size: 11px; color: var(--ink-light); border-bottom: 1px solid var(--rule); }
.results-count strong { color: var(--ink); }

/* ── MAIN CONTENT ───────────────────────────────────────────────── */
.main-content { padding: 28px 32px; overflow-y: auto; }

/* Loading / empty states */
.loading-state { text-align: center; padding: 80px 20px; color: var(--ink-light); }
.loading-state .ls-spinner {
  width: 36px; height: 36px; border: 3px solid var(--rule);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.no-results { text-align: center; padding: 80px 20px; color: var(--ink-light); }
.no-results .nri { font-size: 44px; margin-bottom: 14px; }
.no-results h3 { font-size: 20px; margin-bottom: 6px; color: var(--ink-mid); }

/* ── LEG GROUPS ─────────────────────────────────────────────────── */
.leg-group { margin-bottom: 32px; }
.leg-group-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
  padding-bottom: 12px; border-bottom: 2px solid var(--rule);
  cursor: pointer; -webkit-user-select: none; user-select: none;
}
.leg-group-header:hover .leg-title { color: var(--gold); }
.leg-title { font-family: 'DM Serif Display', serif; font-size: 18px; color: var(--ink); flex: 1; line-height: 1.3; transition: color 0.2s; }
.leg-badge { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.leg-progress-pill {
  font-size: 11px; background: var(--gold-light); color: var(--amber);
  padding: 3px 10px; border-radius: 10px; font-weight: 600; white-space: nowrap;
}
.leg-collapse-icon { color: var(--ink-light); font-size: 14px; transition: transform 0.2s; }
.leg-group.collapsed .leg-collapse-icon { transform: rotate(-90deg); }
.leg-group.collapsed .leg-items { display: none; }

/* ── ITEM CARDS ─────────────────────────────────────────────────── */
.leg-items { display: flex; flex-direction: column; gap: 10px; }

.item-card {
  background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--rule); border-left: 4px solid var(--rule);
  box-shadow: var(--shadow); overflow: hidden; transition: box-shadow 0.2s, border-left-color 0.2s;
}
.item-card:hover { box-shadow: var(--shadow-lg); }
.item-card.s-compliant { border-left-color: var(--green); }
.item-card.s-non_compliant { border-left-color: var(--red); }
.item-card.s-partial { border-left-color: var(--amber); }
.item-card.s-na { border-left-color: var(--blue); }

.item-header {
  padding: 12px 16px; cursor: pointer; -webkit-user-select: none; user-select: none;
  display: flex; align-items: flex-start; gap: 12px;
}
.item-num { font-size: 11px; color: var(--ink-light); min-width: 24px; padding-top: 3px; flex-shrink: 0; }
.item-hcontent { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 13.5px; color: var(--ink); margin-bottom: 5px; line-height: 1.35; }
.item-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }

.chip {
  font-size: 10px; padding: 2px 7px; border-radius: 4px; font-weight: 500;
  background: var(--bg-muted); color: var(--ink-mid);
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.chip.section { background: var(--bg-muted); color: var(--ink-mid); }
.chip.primary { background: #fdf4e7; color: var(--amber); }
.chip.secondary { background: #f0f4ff; color: #4060cc; }
.chip.monthly { background: #e8f4fd; color: #1a6fab; }
.chip.quarterly { background: #f0e8fd; color: #6a1ab8; }
.chip.annually { background: #e8fdf0; color: #157a38; }
.chip.halfyearly { background: #fde8e8; color: #b81a1a; }
.chip.fine { background: var(--red-bg); color: var(--red); }

.item-hright { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.status-badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 5px;
  min-width: 88px; text-align: center; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.status-badge.compliant { background: var(--green-bg); color: var(--green); }
.status-badge.non_compliant { background: var(--red-bg); color: var(--red); }
.status-badge.partial { background: var(--amber-bg); color: var(--amber); }
.status-badge.na { background: var(--blue-bg); color: var(--blue); }
.status-badge.not_started { background: var(--bg-muted); color: var(--ink-light); }
.btn-open-item {
  background: var(--gold); color: var(--ink); border: none; border-radius: 5px;
  padding: 4px 12px; font-family: 'DM Sans', sans-serif; font-size: 11px;
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: opacity 0.2s;
}
.btn-open-item:hover { opacity: 0.8; }

/* ── TOAST ───────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 9px;
  transform: translateY(70px); opacity: 0; transition: all 0.28s; z-index: 999;
  border-left: 4px solid var(--gold); max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-left-color: var(--red); }

/* ── MODALS ──────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(15,25,35,0.55); z-index: 200;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-card); border-radius: 12px; padding: 32px;
  max-width: 520px; width: 100%; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-family: 'DM Serif Display', serif; font-size: 22px; margin-bottom: 8px; }
.modal p { color: var(--ink-mid); font-size: 13px; margin-bottom: 20px; }

.modal-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px; }
.mstat { background: var(--bg); border-radius: 6px; padding: 14px; text-align: center; }
.mstat .n { font-family: 'DM Serif Display', serif; font-size: 26px; }
.mstat .l { font-size: 10px; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }
.mstat.c .n { color: var(--green); }
.mstat.nc .n { color: var(--red); }
.mstat.p .n { color: var(--amber); }
.mstat.na .n { color: var(--blue); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-sec {
  background: var(--bg); border: 1px solid var(--rule); color: var(--ink-mid);
  padding: 9px 16px; border-radius: 6px; font-family: 'DM Sans', sans-serif; font-size: 13px; cursor: pointer;
}
.btn-sec:hover { background: var(--bg-muted); }
.btn-prim {
  background: var(--ink); color: #fff; border: none; padding: 9px 18px; border-radius: 6px;
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center;
}
.btn-prim:hover { opacity: 0.85; }
.btn-pdf { background: #b83232; }

/* Large item modal */
.modal-lg {
  max-width: 960px; width: 100%; padding: 0;
  display: flex; flex-direction: column; max-height: 90vh;
}
.modal-header {
  padding: 24px 28px 16px; border-bottom: 1px solid var(--rule);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  flex-shrink: 0;
}
.modal-leg-name { font-size: 11px; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 4px; }
.modal-header h3 { font-family: 'DM Serif Display', serif; font-size: 20px; line-height: 1.3; }
.modal-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.modal-close {
  background: none; border: none; color: var(--ink-light); font-size: 18px;
  cursor: pointer; padding: 4px 6px; border-radius: 4px; flex-shrink: 0;
  line-height: 1; transition: color 0.15s;
}
.modal-close:hover { color: var(--ink); }

.modal-body-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0; flex: 1; overflow: hidden;
}
.modal-details {
  padding: 24px 24px 24px 28px; overflow-y: auto; border-right: 1px solid var(--rule);
}
.modal-details::-webkit-scrollbar { width: 3px; }
.modal-details::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }
.modal-assessment { padding: 24px 28px 24px 24px; overflow-y: auto; }
.modal-assessment::-webkit-scrollbar { width: 3px; }
.modal-assessment::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }

/* Assessment panel inside modal */
.assessment-panel { display: flex; flex-direction: column; }
.apanel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.fgroup label {
  display: block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-light); margin-bottom: 5px;
}
.fselect, .finput, .ftextarea {
  width: 100%; background: var(--bg-card); border: 1px solid var(--rule);
  color: var(--ink); padding: 8px 10px; border-radius: 5px;
  font-family: 'DM Sans', sans-serif; font-size: 13px; outline: none; transition: border-color 0.2s;
}
.fselect:focus, .finput:focus, .ftextarea:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,146,42,0.1);
}
.ftextarea { resize: vertical; min-height: 80px; }

.sub-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-light); margin-bottom: 8px; display: flex; align-items: center; gap: 8px;
}
.sub-label::after { content: ''; flex: 1; height: 1px; background: var(--rule); }

.desc-text { font-size: 12.5px; color: var(--ink-mid); line-height: 1.7; white-space: pre-wrap; max-height: 130px; overflow-y: auto; }
.desc-text::-webkit-scrollbar { width: 3px; }
.desc-text::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 2px; }

.qlist { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.qlist li { font-size: 12.5px; color: var(--ink-mid); display: flex; gap: 8px; line-height: 1.5; }
.qlist.q li::before { content: '▶'; color: var(--gold); font-size: 8px; padding-top: 4px; flex-shrink: 0; }
.qlist.e li::before { content: '📎'; font-size: 10px; padding-top: 2px; flex-shrink: 0; }

/* Evidence upload */
.attach-zone {
  border: 2px dashed var(--rule); border-radius: 6px; padding: 14px 16px;
  text-align: center; cursor: pointer; transition: all 0.2s; background: var(--bg-card);
  position: relative; margin-bottom: 10px;
}
.attach-zone:hover, .attach-zone.drag-over { border-color: var(--gold); background: var(--gold-light); }
.attach-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.attach-icon { font-size: 22px; margin-bottom: 4px; }
.attach-hint { font-size: 11px; color: var(--ink-light); line-height: 1.4; }
.attach-hint strong { color: var(--ink-mid); }

.attach-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.attach-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  background: var(--bg-card); border: 1px solid var(--rule); border-radius: 5px; font-size: 12px;
}
.attach-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-mid); }
.attach-size { font-size: 10px; color: var(--ink-light); white-space: nowrap; flex-shrink: 0; }
.attach-remove {
  background: none; border: none; color: var(--ink-light); cursor: pointer;
  font-size: 14px; padding: 0 2px; line-height: 1; flex-shrink: 0;
}
.attach-remove:hover { color: var(--red); }
.attach-view {
  background: none; border: none; color: var(--blue); cursor: pointer; font-size: 11px;
  padding: 0 4px; font-family: 'DM Sans', sans-serif; font-weight: 600; text-decoration: underline;
}

.apanel-actions {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding-top: 8px;
  border-top: 1px solid var(--rule); margin-top: 4px;
}
.unsaved-indicator { font-size: 11px; color: var(--amber); flex: 1; }

/* ── ADMIN / SETTINGS VIEWS ─────────────────────────────────────── */
.view-header { margin-bottom: 24px; }
.view-header h2 { font-family: 'DM Serif Display', serif; font-size: 26px; }
.view-header p { color: var(--ink-mid); margin-top: 4px; }

.table-wrap { background: var(--bg-card); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--bg-muted); padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-light); border-bottom: 1px solid var(--rule); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--bg-muted); color: var(--ink-mid); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

.btn-sm {
  padding: 4px 10px; border-radius: 4px; font-family: 'DM Sans', sans-serif; font-size: 11px;
  font-weight: 600; cursor: pointer; border: 1px solid var(--rule); background: var(--bg); color: var(--ink-mid);
}
.btn-sm:hover { background: var(--bg-muted); }
.btn-sm.danger { color: var(--red); border-color: rgba(184,50,50,0.3); }
.btn-sm.danger:hover { background: var(--red-bg); }

.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-light); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--rule); color: var(--ink);
  padding: 9px 12px; border-radius: 6px; font-family: 'DM Sans', sans-serif; font-size: 13px; outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,146,42,0.1); }
.form-textarea { resize: vertical; min-height: 80px; }

/* ── ADMIN TABS ──────────────────────────────────────────────────── */
.admin-tabs {
  display: flex; gap: 4px; border-bottom: 2px solid var(--rule);
  margin-bottom: 20px;
}
.admin-tab {
  padding: 8px 18px; background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; font-family: 'DM Sans', sans-serif; font-size: 13px;
  font-weight: 500; color: var(--ink-light); cursor: pointer; transition: all 0.15s;
}
.admin-tab:hover { color: var(--ink); }
.admin-tab.active { color: var(--gold); border-bottom-color: var(--gold); font-weight: 600; }

.tab-toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.btn-sm-action {
  padding: 6px 14px; border-radius: 5px; font-family: 'DM Sans', sans-serif;
  font-size: 12px; font-weight: 600; cursor: pointer;
}

.tbl-actions { display: flex; gap: 6px; }

/* Row action menu (⋯ dropdown) */
.row-menu { position: relative; display: inline-block; }
.row-menu-btn {
  background: none; border: 1px solid var(--rule); border-radius: 4px;
  cursor: pointer; font-size: 14px; line-height: 1; padding: 2px 8px;
  color: var(--ink-mid);
}
.row-menu-btn:hover { background: var(--bg-muted); }
.row-menu-drop {
  display: none; position: fixed;
  background: var(--bg-card); border: 1px solid var(--rule); border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.1); min-width: 140px; z-index: 1000;
  overflow: hidden;
}
.row-menu-drop.open { display: block; }
.row-menu-drop button {
  display: block; width: 100%; text-align: left;
  background: none; border: none; padding: 9px 14px;
  font-size: 13px; font-family: 'DM Sans', sans-serif; cursor: pointer;
  color: var(--ink);
}
.row-menu-drop button:hover { background: var(--bg-muted); }
.row-menu-drop button.danger { color: var(--red); }

/* Status pills */
.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.status-pill.active { background: var(--green-bg); color: var(--green); }
.status-pill.inactive, .status-pill.archived { background: var(--bg-muted); color: var(--ink-light); }
.status-pill.suspended { background: var(--amber-bg); color: var(--amber); }

/* Role badges */
.role-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.role-badge.super_admin { background: #f0e8ff; color: #6b21a8; }
.role-badge.admin { background: var(--blue-bg); color: var(--blue); }
.role-badge.user { background: var(--bg-muted); color: var(--ink-mid); }

/* Form modal */
.modal-form { width: 560px; max-width: 96vw; max-height: 90vh; display: flex; flex-direction: column; }
.modal-body { overflow-y: auto; padding: 20px 24px; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 24px; border-top: 1px solid var(--rule);
}
.req { color: var(--red); }
.form-row label code { font-size: 11px; }

/* ── LEGISLATION CONFIG MODAL ────────────────────────────────────── */
.modal-form.modal-config { width: 860px; max-width: 96vw; }
.modal-form.modal-config .modal-body {
  padding: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
.leg-config-wrap {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  flex: 1; min-height: 0;
}
.leg-config-left {
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; overflow: hidden;
}
.leg-config-right { display: flex; flex-direction: column; overflow: hidden; }
.leg-config-heading {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-mid);
  padding: 12px 14px 8px; border-bottom: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: 3px;
}
.leg-config-hint { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px; color: var(--ink-muted); }
.leg-config-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.leg-config-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; cursor: pointer; -webkit-user-select: none; user-select: none;
  border-bottom: 1px solid transparent;
}
.leg-config-row:hover { background: var(--bg-muted); }
.leg-config-row.checked { background: var(--blue-bg); }
.leg-config-row.active { background: var(--bg-muted); font-weight: 600; outline: 2px solid var(--gold); outline-offset: -2px; }
.leg-config-row input[type=checkbox] { flex-shrink: 0; }
.leg-config-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg-config-count { font-size: 11px; color: var(--ink-mid); white-space: nowrap; }
.leg-config-items-btn { flex-shrink: 0; font-size: 11px; padding: 2px 7px; }
.leg-config-actions {
  padding: 8px 14px; border-top: 1px solid var(--rule);
  display: flex; gap: 6px;
}
.cust-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 1px 5px; border-radius: 8px;
  background: #fef3c7; color: #92400e; vertical-align: middle;
}
.form-hint-block {
  font-size: 12px; color: var(--ink-mid);
  background: var(--bg-muted); border-radius: 6px;
  padding: 8px 12px; margin-bottom: 14px;
}

/* ── ASSIGNMENTS TAB ─────────────────────────────────────────────── */
/* Reuses .leg-config-wrap / .leg-config-left / .leg-config-right    */
.assign-tab-body {
  height: calc(100vh - 300px);
  min-height: 420px;
  border: 1px solid var(--rule); border-radius: 6px;
  overflow: hidden; margin-top: 10px;
}
/* Item rows in the right panel — two-line cards */
.assign-item-row {
  border-bottom: 1px solid var(--rule);
  padding: 9px 14px 7px;
  transition: background .1s;
}
.assign-item-row:last-child { border-bottom: none; }
.assign-item-row:hover { background: var(--bg-muted); }
.assign-item-main {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; -webkit-user-select: none; user-select: none;
}
.assign-item-main input[type=checkbox] { flex-shrink: 0; }
.assign-item-title {
  flex: 1; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.assign-item-section { font-size: 11px; color: var(--ink-mid); white-space: nowrap; }
.assign-item-row.checked .assign-item-title { color: var(--ink); }
.assign-item-row:not(.checked) .assign-item-title { color: var(--ink-mid); }

/* User chips line */
.assign-item-users {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  padding: 5px 0 0 24px; min-height: 22px;
}
.user-chip {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--blue-bg); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 10px;
  padding: 1px 4px 1px 8px; font-size: 11px;
}
.user-chip-remove {
  background: none; border: none; padding: 0 2px; cursor: pointer;
  color: var(--ink-mid); font-size: 14px; line-height: 1;
  display: flex; align-items: center;
}
.user-chip-remove:hover { color: var(--danger); }
.assign-add-btn {
  font-size: 11px; padding: 1px 7px; border-radius: 10px;
  border: 1px dashed var(--rule); background: transparent;
  cursor: pointer; color: var(--ink-mid);
}
.assign-add-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-bg); }

/* User picker dropdown (position:fixed, anchored via JS) */
.assign-user-picker {
  position: fixed; background: #fff; border: 1px solid var(--rule);
  border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.12);
  z-index: 1002; min-width: 160px; max-height: 200px; overflow-y: auto;
  padding: 4px 0;
}
.assign-user-picker-opt {
  display: block; width: 100%; padding: 7px 14px;
  text-align: left; background: none; border: none;
  cursor: pointer; font-size: 13px; white-space: nowrap;
}
.assign-user-picker-opt:hover { background: var(--bg-muted); }
.assign-user-picker-empty {
  padding: 8px 14px; font-size: 12px; color: var(--ink-mid);
}

/* ── EXPORT MODAL ────────────────────────────────────────────────── */
.export-client-row { display: none; margin-bottom: 14px; }
.export-client-row.visible { display: flex; align-items: center; gap: 8px; }
.export-client-label { font-size: 13px; color: var(--ink-mid); white-space: nowrap; }
.export-client-sel { flex: 1; }

/* ── APPROVALS ───────────────────────────────────────────────────── */
.approvals-view { padding: 32px; max-width: 860px; }
.approvals-view h2 { font-family: 'DM Serif Display', serif; font-size: 22px; margin-bottom: 6px; }
.approvals-section { margin-bottom: 40px; }
.approvals-section-title {
  font-size: 13px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-mid); margin-bottom: 12px; padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}
.approval-group-block { margin-bottom: 20px; }
.approval-group-name {
  font-weight: 600; font-size: 14px; margin-bottom: 8px; color: var(--ink);
}
.approval-item-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--rule);
  border-radius: var(--radius); margin-bottom: 6px;
}
.approval-item-row:last-child { margin-bottom: 0; }
.approval-item-title { flex: 1; font-size: 13px; color: var(--ink); }
.approval-item-meta { font-size: 11px; color: var(--ink-mid); }
.approval-item-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.btn-approve {
  font-size: 12px; padding: 4px 10px; border-radius: 5px; border: none; cursor: pointer;
  background: var(--green-bg); color: var(--green); font-weight: 500;
}
.btn-approve:hover { background: var(--green); color: #fff; }
.btn-reject {
  font-size: 12px; padding: 4px 10px; border-radius: 5px; border: none; cursor: pointer;
  background: var(--red-bg); color: var(--red); font-weight: 500;
}
.btn-reject:hover { background: var(--red); color: #fff; }

/* Approval status badges */
.ap-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px;
  white-space: nowrap;
}
.ap-badge.ap-pending  { background: var(--amber-bg); color: var(--amber); }
.ap-badge.ap-approved { background: var(--green-bg);  color: var(--green); }
.ap-badge.ap-rejected { background: var(--red-bg);    color: var(--red); }

/* Sign-off group cards */
.signoff-card {
  background: var(--bg-card); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 12px;
}
.signoff-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.signoff-card-name { font-weight: 600; font-size: 14px; }
.signoff-card-meta { font-size: 12px; color: var(--ink-mid); margin-top: 4px; }
.signoff-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.signoff-bar { flex: 1; height: 5px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.signoff-bar-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width .4s; }
.signoff-pct { font-size: 11px; color: var(--ink-mid); white-space: nowrap; }
.ap-signed-off {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px;
  background: var(--green-bg); color: var(--green);
}
.btn-sign-off {
  font-size: 12px; padding: 5px 12px; border-radius: 6px; border: none; cursor: pointer;
  background: var(--gold); color: #fff; font-weight: 600; white-space: nowrap;
}
.btn-sign-off:hover { background: #a8761e; }
.btn-sign-off:disabled { opacity: .5; cursor: not-allowed; }
.btn-revoke {
  font-size: 11px; padding: 4px 9px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--rule); background: transparent; color: var(--red);
}
.btn-revoke:hover { background: var(--red-bg); }
.approvals-empty { color: var(--ink-mid); font-size: 13px; padding: 16px 0; }

/* User-dropdown badge count */
.ud-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  margin-left: 4px; vertical-align: middle;
}

/* Approval section inside item modal */
.approval-panel {
  border-top: 1px solid var(--rule); margin-top: 18px; padding-top: 16px;
}
.approval-panel .sub-label { margin-bottom: 10px; }
.approval-panel-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.approval-notes-input {
  width: 100%; border: 1px solid var(--rule); border-radius: 6px; padding: 6px 10px;
  font-size: 13px; font-family: inherit; resize: vertical; margin-top: 8px;
  background: var(--bg); color: var(--ink);
}
.approval-notes-input:focus { outline: none; border-color: var(--gold); }

/* ── SUPER ADMIN DASHBOARD ───────────────────────────────────────── */
.sa-dash { padding: 32px; max-width: 1100px; }
.sa-dash-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.sa-dash-header h2 { font-family: 'DM Serif Display', serif; font-size: 22px; }
.sa-dash-subtitle { font-size: 13px; color: var(--ink-mid); }

/* Aggregate stat row */
.sa-stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.sa-stat-tile {
  background: var(--bg-card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 4px;
}
.sa-stat-tile .val { font-size: 28px; font-weight: 700; color: var(--ink); line-height: 1; }
.sa-stat-tile .lbl { font-size: 12px; color: var(--ink-mid); }
.sa-stat-tile.highlight .val { color: var(--gold); }
.sa-stat-tile.good .val      { color: var(--green); }
.sa-stat-tile.warn .val      { color: var(--red); }

/* Section heading */
.sa-section-title {
  font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-mid); margin-bottom: 14px; padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

/* Client scorecards grid */
.sa-clients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.sa-client-card {
  background: var(--bg-card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow .15s, border-color .15s;
}
.sa-client-card:hover { box-shadow: var(--shadow); border-color: var(--gold); }
.sa-client-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sa-client-name { font-weight: 600; font-size: 15px; color: var(--ink); }
.sa-client-code { font-size: 11px; color: var(--ink-mid); margin-top: 2px; font-family: monospace; }
.sa-client-badge { font-size: 10px; padding: 2px 7px; border-radius: 8px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.sa-client-badge.active     { background: var(--green-bg);  color: var(--green); }
.sa-client-badge.suspended  { background: var(--amber-bg);  color: var(--amber); }

/* Completion bar */
.sa-completion { display: flex; flex-direction: column; gap: 5px; }
.sa-completion-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-mid); }
.sa-completion-label strong { color: var(--ink); }
.sa-comp-bar { height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.sa-comp-bar-fill { height: 100%; border-radius: 3px; transition: width .4s; }
.sa-comp-bar-fill.hi  { background: var(--green); }
.sa-comp-bar-fill.mid { background: var(--amber); }
.sa-comp-bar-fill.lo  { background: var(--red); }

/* Status breakdown mini-bar */
.sa-status-bar { display: flex; height: 5px; border-radius: 3px; overflow: hidden; gap: 1px; }
.sa-status-seg { height: 100%; }
.sa-status-seg.compliant     { background: var(--green); }
.sa-status-seg.non_compliant { background: var(--red); }
.sa-status-seg.partial       { background: var(--amber); }
.sa-status-seg.na            { background: var(--ink-light); }

/* Status count pills */
.sa-status-counts { display: flex; gap: 8px; flex-wrap: wrap; }
.sa-count { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--ink-mid); }
.sa-count-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sa-count-dot.compliant     { background: var(--green); }
.sa-count-dot.non_compliant { background: var(--red); }
.sa-count-dot.partial       { background: var(--amber); }
.sa-count-dot.na            { background: var(--ink-light); }
.sa-count-dot.not_started   { background: var(--rule); border: 1px solid var(--ink-light); }

.sa-client-footer { display: flex; justify-content: space-between; align-items: center; }
.sa-user-count { font-size: 11px; color: var(--ink-mid); }

/* Drill-down view */
.sa-drill { padding: 32px; max-width: 860px; }
.sa-drill-back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-mid); background: none; border: none; cursor: pointer; padding: 0; margin-bottom: 18px; }
.sa-drill-back:hover { color: var(--gold); }
.sa-drill h2 { font-family: 'DM Serif Display', serif; font-size: 22px; margin-bottom: 4px; }
.sa-drill-meta { font-size: 12px; color: var(--ink-mid); margin-bottom: 24px; }

.sa-drill-stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 24px; }
.sa-drill-stat { background: var(--bg-card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; text-align: center; }
.sa-drill-stat .val { font-size: 22px; font-weight: 700; }
.sa-drill-stat .lbl { font-size: 11px; color: var(--ink-mid); }
.sa-drill-stat.compliant .val     { color: var(--green); }
.sa-drill-stat.non_compliant .val { color: var(--red); }
.sa-drill-stat.partial .val       { color: var(--amber); }
.sa-drill-stat.na .val            { color: var(--ink-light); }

.sa-leg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sa-leg-table th { text-align: left; padding: 8px 12px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-mid); border-bottom: 2px solid var(--rule); white-space: nowrap; }
.sa-leg-table td { padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.sa-leg-table tr:last-child td { border-bottom: none; }
.sa-leg-table tr:hover td { background: var(--bg-muted); }
.sa-inline-bar { display: flex; height: 5px; border-radius: 3px; overflow: hidden; gap: 1px; min-width: 80px; }

/* ── RESPONSIVE ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .modal-body-grid { grid-template-columns: 1fr; }
  .modal-details { border-right: none; border-bottom: 1px solid var(--rule); }
  .apanel-grid { grid-template-columns: 1fr; }
}
