:root {
  --primary: #162b44;
  --primary-700: #102238;
  --secondary: #21a179;
  --secondary-soft: #d6f3e5;
  --secondary-strong: #143225;
  --tertiary: #f59e0b;
  --danger: #cf3a3a;
  --rating-great: #16a34a;
  --rating-great-soft: #dcfce7;
  --rating-good: #fbbf24;
  --rating-good-soft: #fef3c7;
  --rating-regular: #f97316;
  --rating-regular-soft: #ffedd5;
  --rating-bad: #ef4444;
  --rating-bad-soft: #fee2e2;
  --neutral: #64748b;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #e9edf3;
  --line-strong: #dde3ec;
  --text: #1a2b3c;
  --muted: #64748b;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(17, 35, 58, .06);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- App shell ---------- */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  background: var(--bg);
}

.app-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  z-index: 150;
  transition: transform .2s ease, opacity .2s ease;
}

.app-brand {
  padding: 4px 8px 22px;
}

.app-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.01em;
  text-decoration: none;
  color: var(--primary);
}

.app-brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.app-brand-sub {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 500;
  margin-top: 2px;
}

.brand-meaning {
  line-height: 1.45;
}

.brand-meaning strong {
  color: var(--secondary);
  font-weight: 800;
}

.topbar-client img,
.login-client-brand img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.topbar-client > span,
.login-client-brand > span {
  color: var(--muted);
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.topbar-client strong,
.login-client-brand strong {
  font-size: .8rem;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 10px;
  padding: 10px 12px;
  text-decoration: none;
  color: #41506180;
  color: #54616f;
  font-weight: 600;
  font-size: .9rem;
  transition: background .12s ease, color .12s ease;
}

.app-nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  stroke: currentColor;
}

.app-nav-item:hover {
  background: #f1f5f9;
  color: var(--primary);
}

.app-nav-item.active {
  background: var(--secondary-soft);
  color: var(--secondary-strong);
}

.app-nav-item.active svg {
  stroke: var(--secondary);
}

.app-sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
}

.sidebar-developer-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-size: .68rem;
  line-height: 1.25;
  transition: color .15s ease, background .15s ease;
}

.sidebar-developer-link:hover,
.sidebar-developer-link:focus-visible {
  color: var(--primary);
  background: #f6f8fb;
  outline: none;
}

.sidebar-developer-link svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.sidebar-developer-link span,
.sidebar-developer-link strong {
  display: block;
}

.sidebar-developer-link strong {
  font-size: .74rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.sidebar-user .avatar-square {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
}

.sidebar-user .avatar-square svg {
  width: 18px;
  height: 18px;
}

.sidebar-user-name {
  font-weight: 700;
  font-size: .82rem;
  line-height: 1.1;
  color: var(--primary);
}

.sidebar-user-sub {
  font-size: .72rem;
  color: var(--muted);
  margin-top: 2px;
  word-break: break-all;
}

/* ---------- Main / topbar ---------- */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
}

.menu-trigger {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--primary);
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  cursor: pointer;
}

.menu-trigger:hover,
.menu-trigger:focus-visible {
  background: var(--secondary-soft);
  outline: none;
}

.menu-trigger svg {
  width: 21px;
  height: 21px;
}

.sidebar-backdrop {
  display: none;
}

.topbar-client {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.topbar-search {
  position: relative;
  flex: 0 1 320px;
}

.topbar-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--muted);
}

.topbar-search input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  background: #f8fafc;
  border-radius: 9px;
  padding: 0 12px 0 36px;
  font-size: .85rem;
  color: var(--text);
  outline: none;
}

.topbar-search input::placeholder {
  color: #94a3b8;
}

.topbar-search input:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(45, 159, 117, .12);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
}

.topbar-link {
  color: #475569;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
}

.topbar-link:hover {
  color: var(--primary);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  cursor: pointer;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.icon-btn:hover {
  background: #f1f5f9;
  color: var(--primary);
}

.icon-btn::after {
  display: none;
}

.profile-menu {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 220px;
  box-shadow: var(--shadow);
  padding: 8px;
}

.profile-trigger {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--secondary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.profile-trigger:hover,
.profile-trigger:focus-visible {
  background: #d7f7e8;
  outline: none;
}

.profile-trigger svg {
  width: 20px;
  height: 20px;
}

.profile-trigger::after {
  display: none;
}

.profile-menu-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px 6px;
}

.profile-menu-name {
  color: var(--primary);
  font-size: .9rem;
  font-weight: 700;
}

.profile-menu-role {
  color: var(--muted);
  font-size: .78rem;
}

.app-content {
  padding: 26px 28px;
  flex: 1 1 auto;
}

/* ---------- Page heading ---------- */
.page-heading {
  margin-bottom: 20px;
}

.page-heading h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.01em;
  margin: 0 0 4px;
  color: var(--primary);
}

.page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
}

/* ---------- Footer ---------- */
.app-footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--muted);
}

.app-footer .footer-brand strong {
  color: var(--primary);
  letter-spacing: .03em;
  margin-right: 8px;
}

.app-footer .footer-links {
  display: flex;
  gap: 22px;
}

.app-footer a {
  color: var(--muted);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--primary);
}

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card-pad {
  padding: 18px 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 16px;
}

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.dashboard-filter-fields {
  display: contents;
}

.dashboard-filter-actions,
.dashboard-mobile-export,
.vote-detail-mobile-export,
.served-mobile-actions,
.page-filter-disclosure > summary,
.vote-detail-filter-disclosure > summary {
  display: none;
}

.page-filter-disclosure,
.vote-detail-filter-disclosure {
  position: static;
}

.page-filter-disclosure:not([open]) > .page-collapsible-filters,
.vote-detail-filter-disclosure:not([open]) > .vote-detail-filters {
  display: flex;
}

.vote-detail-filter-disclosure:not([open]) > .vote-detail-filters {
  display: grid;
}

.page-filter-disclosure > .filter-bar {
  margin-bottom: 22px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 10px;
  height: 40px;
}

.filter-pill svg {
  width: 15px;
  height: 15px;
  stroke: var(--muted);
  flex: 0 0 15px;
}

.filter-pill select,
.filter-pill input {
  border: none;
  background: transparent;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  outline: none;
  padding: 0;
  min-width: 96px;
}

.lookup-filter {
  min-width: min(260px, 100%);
}

.lookup-filter input[type="text"] {
  min-width: 180px;
}

.unit-lookup {
  position: relative;
}

.unit-lookup input[type="text"]::-ms-clear {
  display: none;
}

.unit-lookup-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 7px);
  left: 0;
  width: max(100%, 240px);
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 34px rgba(15, 43, 60, .16);
}

.unit-lookup-option {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--primary);
  padding: 9px 10px;
  text-align: left;
  font-size: .84rem;
  font-weight: 650;
}

.unit-lookup-option:hover,
.unit-lookup-option:focus-visible {
  outline: none;
  background: var(--secondary-soft);
  color: var(--secondary-strong);
}

/* ---------- Unit transfer selector ---------- */
.unit-link-section,
.access-settings {
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: linear-gradient(145deg, #fff, #fbfcfe);
  padding: 18px;
}

.section-title-row h2,
.access-settings h2 {
  margin: 0;
  color: var(--primary);
  font-size: 1rem;
  font-weight: 800;
}

.section-title-row p,
.access-settings p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .8rem;
}

.voting-unit-readonly {
  background: linear-gradient(145deg, #f8fafc, #eef3f8);
}

.readonly-unit-value {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px dashed #b8c5d3;
  border-radius: 10px;
  background: #edf2f7;
  color: #4c6073;
  font-size: .86rem;
  font-weight: 700;
}

.readonly-unit-value svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: var(--neutral);
}

.access-all-notice {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--secondary-soft);
  color: var(--secondary-strong);
  font-size: .86rem;
  font-weight: 700;
}

.unit-transfer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.unit-transfer-column {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.unit-transfer-column.is-selected {
  border-color: rgba(45, 159, 117, .35);
  background: linear-gradient(160deg, #fff, #f0faf5);
}

.unit-transfer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: .82rem;
}

.unit-transfer-heading span {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
}

.unit-transfer-hint {
  min-height: 18px;
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: .72rem;
}

.unit-transfer-list {
  display: grid;
  gap: 7px;
  max-height: 250px;
  margin-top: 10px;
  overflow-y: auto;
}

.unit-transfer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #fff;
  color: var(--primary);
  padding: 9px 10px;
  text-align: left;
  font-size: .82rem;
  font-weight: 700;
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.unit-transfer-item:hover {
  border-color: var(--secondary);
  box-shadow: 0 6px 14px rgba(45, 159, 117, .12);
  transform: translateY(-1px);
}

.unit-transfer-item b {
  color: var(--secondary);
  font-size: 1.15rem;
  line-height: 1;
}

.unit-transfer-item.is-linked {
  border-color: rgba(45, 159, 117, .3);
  background: rgba(214, 243, 229, .52);
}

.unit-transfer-item.is-linked b {
  color: var(--danger);
}

.unit-transfer-empty {
  margin: 14px 2px;
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
}

@media (max-width: 680px) {
  .unit-transfer {
    grid-template-columns: 1fr;
  }
}

.filter-spacer {
  margin-left: auto;
}

/* ---------- Buttons ---------- */
.btn-dark-solid {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: 10px;
  height: 40px;
  padding: 0 18px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
}

.btn-dark-solid:hover {
  background: var(--primary-700);
  color: #fff;
}

.btn-soft {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  height: 40px;
  padding: 0 16px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
}

.btn-soft svg {
  width: 15px;
  height: 15px;
  stroke: var(--muted);
}

.btn-soft:hover {
  border-color: var(--neutral);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-700);
  border-color: var(--primary-700);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--line-strong);
}

.btn-outline-secondary {
  color: var(--neutral);
  border-color: var(--line-strong);
}

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  min-height: 156px;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--primary);
  line-height: 1.1;
  margin-top: 6px;
}

.stat-value small {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .76rem;
  font-weight: 600;
  color: var(--secondary);
  margin-top: 8px;
}

.stat-card-split {
  justify-content: space-between;
}

.stat-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 0;
}

.stat-split-item {
  min-width: 0;
  padding-right: 18px;
}

.stat-split-served {
  padding-right: 0;
  padding-left: 20px;
  border-left: 1px solid var(--line-strong);
}

.stat-split-served .stat-value {
  color: var(--secondary-strong);
}

.stat-progress {
  height: 7px;
  border-radius: 999px;
  background: #eef2f7;
  margin-top: 14px;
  overflow: hidden;
}

.stat-progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--secondary);
}

.stat-card-wide {
  display: flex;
  flex-direction: column;
}

.stat-wide-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-stars {
  color: var(--primary);
  font-size: 1.2rem;
  letter-spacing: 2px;
}

.stat-stars .off {
  color: #cbd5e1;
}

.stat-quote {
  margin-top: 10px;
  font-style: italic;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.35;
  margin-bottom: 0;
}

/* ---------- Analytics row ---------- */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1.55fr 1fr;
  gap: 18px;
}

/* Donut */
.donut-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0 14px;
}

.donut {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 22px;
  background: var(--panel);
  border-radius: 50%;
}

.donut-center {
  position: relative;
  z-index: 1;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

/* Full pie (no center hole) */
.pie {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .06) inset;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-row {
  display: flex;
  align-items: center;
  font-size: .85rem;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 8px;
  flex: 0 0 9px;
}

.legend-row .legend-val {
  margin-left: auto;
  font-weight: 700;
  color: var(--primary);
}

.rating-great { --rating-color: var(--rating-great); --rating-soft: var(--rating-great-soft); }
.rating-good { --rating-color: var(--rating-good); --rating-soft: var(--rating-good-soft); }
.rating-regular { --rating-color: var(--rating-regular); --rating-soft: var(--rating-regular-soft); }
.rating-bad { --rating-color: var(--rating-bad); --rating-soft: var(--rating-bad-soft); }

.rating-legend {
  min-height: 36px;
  padding: 4px 8px;
  border-radius: 9px;
  background: var(--rating-soft);
  color: var(--rating-color);
  font-weight: 700;
}

.rating-legend img {
  width: 28px;
  height: 28px;
  margin-right: 8px;
  object-fit: contain;
}

.rating-legend .legend-val {
  color: var(--rating-color);
}

/* ---------- Vote-by-vote details ---------- */
.vote-details-section {
  margin-top: 20px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.vote-details-heading,
.vote-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.vote-details-heading h2 {
  margin: 2px 0 4px;
  color: var(--primary);
  font-size: 1.08rem;
  font-weight: 800;
}

.vote-details-heading p {
  margin: 0;
  color: var(--muted);
  font-size: .8rem;
}

.vote-details-period {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--bg);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
}

.vote-detail-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.vote-detail-kpis.no-regular {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.vote-detail-kpi {
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 9px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--rating-color) 28%, white);
  border-radius: 12px;
  background: var(--rating-soft);
}

.vote-detail-kpi img {
  grid-row: 1 / 3;
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.vote-detail-kpi span {
  color: var(--rating-color);
  font-size: .67rem;
  font-weight: 800;
  text-transform: uppercase;
}

.vote-detail-kpi strong {
  color: var(--primary);
  font-size: 1.25rem;
  line-height: 1;
}

.vote-detail-total {
  --rating-color: var(--primary);
  --rating-soft: var(--bg);
  grid-template-columns: 1fr;
}

.vote-detail-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(170px, 1.1fr) minmax(145px, 1fr) minmax(145px, 1fr) auto auto;
  align-items: end;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.vote-detail-filters label {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.vote-detail-filters label > span {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.vote-detail-filters select,
.vote-detail-filters input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--primary);
  font: inherit;
  font-size: .8rem;
}

.vote-detail-filters select:disabled {
  color: var(--muted);
  background: #eef2f7;
  cursor: not-allowed;
}

.vote-filter-clear {
  height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  text-decoration: none;
}

.vote-results-head {
  margin: 18px 0 10px;
  color: var(--primary);
  font-size: .8rem;
}

.vote-results-head span {
  color: var(--muted);
  font-size: .72rem;
}

.vote-details-list {
  display: grid;
  gap: 8px;
}

.vote-detail-row {
  --rating-color: var(--muted);
  --rating-soft: var(--bg);
  position: relative;
  display: grid;
  grid-template-columns: minmax(180px, .9fr) minmax(130px, .65fr) minmax(240px, 1.7fr) minmax(150px, auto);
  align-items: center;
  gap: 16px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--rating-color);
  border-radius: 12px;
  background: linear-gradient(90deg, var(--rating-soft), #fff 22%);
}

.vote-detail-rating {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vote-detail-rating img {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  object-fit: contain;
}

.vote-detail-rating > div,
.vote-detail-origin,
.vote-detail-comment {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.vote-detail-rating strong {
  color: var(--rating-color);
  font-size: .84rem;
}

.vote-detail-rating time,
.vote-detail-origin span,
.vote-detail-origin small,
.vote-detail-comment > span {
  overflow: hidden;
  color: var(--muted);
  font-size: .68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vote-detail-origin strong {
  color: var(--primary);
  font-size: .78rem;
}

.vote-detail-comment p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--primary);
  font-size: .78rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.vote-detail-comment.is-empty p {
  color: var(--muted);
  font-style: italic;
}

.vote-detail-flags {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.reason-popover {
  position: relative;
}

.reason-popover summary {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--rating-bad-soft);
  color: var(--rating-bad);
  font-size: .7rem;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.reason-popover summary::-webkit-details-marker {
  display: none;
}

.reason-popover-content {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: min(280px, 78vw);
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(15, 23, 42, .18);
}

.reason-popover:not([open]) .reason-popover-content {
  display: none;
}

.reason-popover-content > strong {
  display: block;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: .76rem;
}

.reason-popover-content > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reason-popover-content span {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--rating-bad-soft);
  color: #b91c1c;
  font-size: .7rem;
  font-weight: 700;
}

@media (hover: hover) and (pointer: fine) {
  .reason-popover:hover .reason-popover-content {
    display: block;
  }
}

.vote-no-reason,
.vote-offline-badge {
  color: var(--muted);
  font-size: .67rem;
}

.vote-offline-badge {
  padding: 5px 7px;
  border-radius: 999px;
  background: var(--bg);
  font-weight: 700;
}

.vote-details-empty {
  padding: 34px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  font-size: .82rem;
}

.vote-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}

.vote-pagination a {
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--primary);
  font-size: .75rem;
  font-weight: 700;
  text-decoration: none;
}

.vote-pagination span {
  color: var(--muted);
  font-size: .72rem;
}

@media (max-width: 1100px) {
  .vote-detail-kpis,
  .vote-detail-kpis.no-regular {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .vote-detail-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .vote-detail-row {
    grid-template-columns: minmax(180px, .9fr) minmax(120px, .6fr) minmax(220px, 1.4fr);
  }

  .vote-detail-flags {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-left: 52px;
  }
}

@media (max-width: 720px) {
  .vote-details-section {
    padding: 16px;
  }

  .vote-details-heading,
  .vote-results-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .vote-detail-kpis,
  .vote-detail-kpis.no-regular,
  .vote-detail-filters,
  .vote-detail-row {
    grid-template-columns: 1fr;
  }

  .vote-detail-row {
    align-items: start;
  }

  .vote-detail-flags {
    grid-column: auto;
    justify-content: flex-start;
    padding-left: 0;
  }

  .reason-popover-content {
    position: static;
    width: 100%;
    margin-top: 8px;
  }

  .dashboard-filter-bar {
    display: block;
  }

  .dashboard-filter-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .dashboard-filter-toggle,
  .dashboard-mobile-export,
  .page-filter-disclosure > summary,
  .vote-detail-filter-disclosure > summary {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 13px;
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  .dashboard-filter-toggle,
  .page-filter-disclosure > summary,
  .vote-detail-filter-disclosure > summary {
    text-transform: none;
  }

  .dashboard-mobile-export {
    margin-left: auto;
  }

  .dashboard-filter-fields {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
  }

  .dashboard-filter-bar.filters-open .dashboard-filter-fields {
    display: grid;
  }

  .dashboard-filter-fields .filter-pill,
  .dashboard-filter-fields .lookup-filter {
    width: 100%;
    min-width: 0;
  }

  .dashboard-filter-fields .lookup-filter,
  .dashboard-filter-fields label:nth-of-type(1) {
    grid-column: 1 / -1;
  }

  .dashboard-filter-fields input,
  .dashboard-filter-fields select {
    width: 100%;
    min-width: 0;
  }

  .dashboard-desktop-export {
    display: none;
  }

  .page-filter-disclosure,
  .vote-detail-filter-disclosure {
    margin-bottom: 18px;
  }

  .vote-detail-filter-disclosure {
    position: relative;
    min-height: 40px;
  }

  .vote-detail-mobile-export {
    position: absolute;
    top: 0;
    right: 0;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 13px;
    color: #fff;
    font-size: .78rem;
    font-weight: 800;
    text-decoration: none;
    text-transform: uppercase;
  }

  .page-filter-disclosure > summary,
  .vote-detail-filter-disclosure > summary {
    width: fit-content;
  }

  .page-filter-disclosure:not([open]) > .page-collapsible-filters,
  .vote-detail-filter-disclosure:not([open]) > .vote-detail-filters {
    display: none;
  }

  .page-filter-disclosure[open] > .page-collapsible-filters,
  .vote-detail-filter-disclosure[open] > .vote-detail-filters {
    display: grid;
  }

  .page-collapsible-filters,
  .vote-detail-filters {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
  }

  .page-collapsible-filters .filter-pill,
  .page-collapsible-filters .lookup-filter,
  .page-collapsible-filters .btn-soft {
    width: 100%;
    min-width: 0;
    margin-left: 0;
  }

  .page-collapsible-filters .filter-pill input,
  .page-collapsible-filters .filter-pill select {
    width: 100%;
    min-width: 0;
  }
}

/* Bar chart */
.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chip-week {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
}

.chip-week::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 150px;
  padding-top: 8px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}

.bar-fill {
  width: 60%;
  max-width: 26px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--secondary), #7fd3b0);
  min-height: 4px;
}

.bar-label {
  font-size: .68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

/* Negative reasons */
.reason-row {
  margin-bottom: 16px;
}

.reason-row:last-child {
  margin-bottom: 0;
}

.reason-top {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  margin-bottom: 6px;
}

.reason-top .reason-name {
  color: #334155;
}

.reason-top .reason-val {
  font-weight: 700;
  color: var(--primary);
}

.reason-bar {
  height: 6px;
  border-radius: 999px;
  background: #f1f5f9;
  overflow: hidden;
}

.reason-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--danger);
}

.empty-hint {
  color: var(--muted);
  font-size: .85rem;
}

/* ---------- Toolbar (Units) ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.filter-disclosure {
  position: relative;
}

.filter-disclosure > summary {
  list-style: none;
  cursor: pointer;
}

.filter-disclosure > summary::-webkit-details-marker {
  display: none;
}

.filter-disclosure > summary::after {
  content: "+";
  font-size: 1rem;
  line-height: 1;
  margin-left: 2px;
}

.filter-disclosure[open] > summary::after {
  content: "-";
}

.user-filter-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  width: min(360px, calc(100vw - 40px));
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid #dbe4ef;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(15, 43, 60, .14);
}

.user-filter-panel label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.user-filter-panel .form-select {
  min-height: 38px;
  color: var(--primary);
  font-size: .86rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

.user-filter-clear {
  justify-content: center;
  color: var(--muted);
}

.toolbar form {
  display: flex;
  gap: 10px;
  margin: 0;
}

.toolbar .search-field {
  position: relative;
}

.toolbar .search-field svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  stroke: var(--muted);
}

.toolbar .search-field input {
  height: 40px;
  width: 260px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: 10px;
  padding: 0 12px 0 34px;
  font-size: .85rem;
  outline: none;
}

.toolbar .search-field input:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(45, 159, 117, .12);
}

/* ---------- Data table ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  text-align: left;
  padding: 14px 20px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.data-table tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: .9rem;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.cell-title {
  font-weight: 700;
  color: var(--primary);
}

.cell-sub {
  font-size: .74rem;
  color: var(--muted);
  margin-top: 2px;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.badge-status.is-active {
  background: var(--secondary-soft);
  color: var(--secondary-strong);
}

.badge-status.is-inactive {
  background: #fde5e5;
  color: #b03434;
}

.config-cell {
  display: flex;
  align-items: center;
  gap: 22px;
}

.toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.toggle-group .toggle-label {
  font-size: .82rem;
  color: #475569;
  font-weight: 500;
}

.switch {
  position: relative;
  width: 38px;
  height: 21px;
  flex: 0 0 38px;
  border: none;
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
  padding: 0;
  transition: background .15s ease;
}

.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .15s ease;
}

.switch.on {
  background: var(--secondary);
}

.switch.on::before {
  transform: translateX(17px);
}

.actions-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}

.action-icon svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
}

.action-icon:hover {
  background: #f1f5f9;
}

.action-icon.muted {
  color: #cbd5e1;
  border-color: var(--line);
  cursor: default;
  pointer-events: none;
}

.action-icon.danger:hover {
  color: var(--danger);
}

/* Table footer */
.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  font-size: .82rem;
  color: var(--muted);
}

.pager {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pager .page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
}

.pager .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---------- Summary cards (Units bottom) ---------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-height: 130px;
}

.summary-card .summary-icon {
  color: var(--muted);
  margin-bottom: 10px;
}

.summary-card .summary-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.summary-card .summary-label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--primary);
}

.summary-card .summary-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--primary);
  margin-top: 4px;
}

.summary-card .summary-text {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}

.summary-card.is-feature {
  background: var(--secondary-soft);
  border-color: #bfe9d3;
}

.summary-card.is-feature .summary-label,
.summary-card.is-feature .summary-value {
  color: var(--secondary-strong);
}

.summary-card.is-feature .summary-sub {
  font-size: .8rem;
  color: #2f6b4f;
}

.summary-card.is-feature .summary-unit {
  font-size: 1rem;
  font-weight: 700;
  color: var(--secondary-strong);
  margin-top: 2px;
}

/* ---------- Equal 3-col stat grid ---------- */
.stat-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

/* ---------- Generic 2-col page grid ---------- */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 18px;
  align-items: start;
}

/* ---------- Soft / neutral badge ---------- */
.badge-soft {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .03em;
  background: #eef2f7;
  color: #475569;
}

.badge-soft.is-yes {
  background: var(--secondary-soft);
  color: var(--secondary-strong);
}

/* ---------- Form helpers ---------- */
.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-hint {
  font-size: .76rem;
  color: var(--muted);
  margin-top: 6px;
}

.btn-block-dark {
  width: 100%;
  justify-content: center;
}

.btn-danger-soft {
  background: #fde5e5;
  border: 1px solid #f5c9c9;
  color: #b03434;
  border-radius: 10px;
  height: 40px;
  padding: 0 16px;
  font-size: .85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
}

.btn-danger-soft:hover {
  background: #fbd5d5;
}

/* ---------- Login ---------- */
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(8, 17, 28, .35);
  padding: 34px 32px;
}

.login-brand {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--primary);
}

.login-product-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  text-align: center;
}

.login-product-brand > img {
  width: 56px;
  height: 56px;
}

.brand-meaning-login {
  max-width: 320px;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}

.login-client-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: fit-content;
  margin: 18px auto 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

/* ---------- Access denied ---------- */
.access-denied-card {
  width: min(560px, 100%);
  margin: 64px auto;
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.access-denied-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--secondary-soft);
  color: var(--secondary-strong);
}

.access-denied-icon svg {
  width: 30px;
  height: 30px;
}

.access-denied-card h1 {
  margin: 8px 0 10px;
  color: var(--primary);
  font-size: 1.65rem;
  font-weight: 800;
}

.access-denied-card p {
  margin: 0 auto 24px;
  color: var(--muted);
}

.login-brand-sub {
  color: var(--muted);
  font-size: .88rem;
  margin: 4px 0 24px;
}

/* ---------- Alerts ---------- */
.alert {
  border-radius: 10px;
  font-size: .88rem;
}

/* ---------- Guest / login ---------- */
.guest-wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 0 0, #243446 0, #243446 2px, transparent 2px) 0 0/16px 16px,
    var(--primary);
}

.guest-main {
  width: min(440px, 92vw);
}

.form-control,
.form-select {
  border-radius: 10px;
  border-color: var(--line-strong);
  background: #fff;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(45, 159, 117, .12);
}

.form-label {
  font-size: .82rem;
  font-weight: 600;
  color: #334155;
}

/* ---------- Generic bootstrap tables fallback ---------- */
.table thead th {
  color: var(--muted);
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .04em;
}

/* ---------- Dashboard BI treatment ---------- */
.stat-card-bi,
.bi-chart-card {
  isolation: isolate;
  overflow: hidden;
  position: relative;
  border-color: rgba(203, 213, 225, .72);
  box-shadow: 0 14px 30px rgba(15, 43, 60, .07), 0 2px 5px rgba(15, 43, 60, .035);
  transition: transform .22s ease, box-shadow .22s ease;
}

.stat-card-bi::before,
.bi-chart-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 100% 0%, rgba(45, 159, 117, .11), transparent 33%),
    linear-gradient(145deg, rgba(255, 255, 255, .98), rgba(248, 251, 254, .84));
}

.stat-card-bi::after {
  content: "";
  position: absolute;
  width: 104px;
  height: 104px;
  right: -52px;
  bottom: -58px;
  z-index: -1;
  border: 1px solid rgba(45, 159, 117, .16);
  border-radius: 50%;
  box-shadow: 0 0 0 16px rgba(45, 159, 117, .035), 0 0 0 32px rgba(45, 159, 117, .025);
}

.stat-card-bi:hover,
.bi-chart-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 38px rgba(15, 43, 60, .11), 0 3px 8px rgba(15, 43, 60, .04);
}

.chart-kicker {
  display: block;
  color: var(--secondary);
  font-size: .63rem;
  font-weight: 800;
  letter-spacing: .1em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.chart-metric {
  align-self: flex-start;
  border: 1px solid rgba(45, 159, 117, .16);
  border-radius: 999px;
  background: rgba(45, 159, 117, .08);
  color: #207758;
  font-size: .68rem;
  font-weight: 800;
  padding: 5px 8px;
  white-space: nowrap;
}

.stat-card-bi .stat-progress > span {
  box-shadow: 0 2px 5px currentColor;
  position: relative;
}

.stat-card-bi .stat-progress > span::after {
  content: "";
  position: absolute;
  inset: 1px 8px auto 4px;
  height: 1px;
  border-radius: inherit;
  background: rgba(255, 255, 255, .78);
}

.donut-wrap-bi {
  min-height: 178px;
  align-items: center;
  perspective: 820px;
}

.donut-bi,
.pie-bi {
  transform: rotateX(10deg) rotateZ(-8deg);
  box-shadow:
    0 12px 0 rgba(15, 43, 60, .09),
    0 18px 28px rgba(15, 43, 60, .20),
    inset 0 1px 1px rgba(255, 255, 255, .7);
  transition: transform .32s cubic-bezier(.2, .8, .2, 1), filter .25s ease;
}

.bi-chart-card:hover .donut-bi,
.bi-chart-card:hover .pie-bi {
  transform: rotateX(0) rotateZ(0) scale(1.045);
  filter: saturate(1.08);
}

.donut-bi::before,
.pie-bi::before {
  content: "";
  position: absolute;
  inset: 7px 12px 46%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.donut-bi::after {
  background: linear-gradient(145deg, #ffffff, var(--panel));
  box-shadow: inset 2px 2px 5px rgba(15, 43, 60, .08), inset -1px -1px 2px rgba(255, 255, 255, .9);
}

.pie-bi {
  position: relative;
}

.bi-chart-card .legend-row {
  padding: 5px 7px;
  margin: 0 -7px;
  border-radius: 9px;
  transition: background .16s ease, transform .16s ease;
}

.bi-chart-card .legend-row:hover {
  background: rgba(45, 159, 117, .07);
  transform: translateX(3px);
}

.bi-chart-card .legend-dot {
  box-shadow: 0 2px 4px rgba(15, 43, 60, .2), inset 0 1px 1px rgba(255, 255, 255, .68);
}

.bi-chart-card .bars {
  padding: 16px 8px 0;
  border-bottom: 1px solid #dbe5ee;
  border-radius: 12px 12px 0 0;
  background:
    repeating-linear-gradient(to top, transparent 0, transparent 35px, rgba(145, 163, 184, .12) 36px, transparent 37px),
    linear-gradient(180deg, rgba(240, 247, 250, .72), rgba(255, 255, 255, 0));
}

.volume-chart-card {
  display: flex;
  flex-direction: column;
}

.volume-chart-scroll {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 12px;
  overscroll-behavior-x: contain;
  scrollbar-color: #9fb4c5 #edf3f7;
  scrollbar-width: thin;
}

.volume-chart-scroll::-webkit-scrollbar {
  height: 8px;
}

.volume-chart-scroll::-webkit-scrollbar-track {
  background: #edf3f7;
  border-radius: 999px;
}

.volume-chart-scroll::-webkit-scrollbar-thumb {
  background: #9fb4c5;
  border-radius: 999px;
}

.volume-chart-card .bars {
  flex: 1 1 auto;
  width: max(100%, calc(var(--volume-days) * 38px));
  height: 320px;
  min-height: 320px;
  margin-top: 12px;
}

.volume-chart-card .bar-col {
  flex: 1 0 28px;
}

.bi-chart-card .bar-col {
  position: relative;
  min-width: 22px;
  outline: none;
}

.volume-votes-tooltip {
  position: absolute;
  top: 24px;
  left: 50%;
  z-index: 30;
  width: 188px;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 11px;
  background: #102238;
  box-shadow: 0 14px 30px rgba(15, 34, 56, .28);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity .14s ease, transform .14s ease;
}

.volume-votes-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #102238;
  transform: translateX(-50%) rotate(45deg);
}

.bar-col:hover .volume-votes-tooltip,
.bar-col:focus .volume-votes-tooltip,
.bar-col:focus-within .volume-votes-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.bar-col:first-child .volume-votes-tooltip {
  left: 0;
  transform: translate(0, 6px);
}

.bar-col:first-child:hover .volume-votes-tooltip,
.bar-col:first-child:focus .volume-votes-tooltip {
  transform: translate(0, 0);
}

.bar-col:last-child .volume-votes-tooltip {
  right: 0;
  left: auto;
  transform: translate(0, 6px);
}

.bar-col:last-child:hover .volume-votes-tooltip,
.bar-col:last-child:focus .volume-votes-tooltip {
  transform: translate(0, 0);
}

.volume-tooltip-date {
  margin-bottom: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  font-size: .75rem;
  font-weight: 800;
  text-align: left;
}

.volume-tooltip-date span,
.volume-tooltip-date small {
  display: block;
}

.volume-tooltip-date small {
  margin-top: 3px;
  color: #b9c8d8;
  font-size: .66rem;
  font-weight: 600;
  text-transform: capitalize;
}

.volume-tooltip-total,
.volume-tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-size: .7rem;
}

.volume-tooltip-total {
  margin-bottom: 4px;
  color: #fff;
  font-weight: 800;
}

.volume-tooltip-row span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #dbe5ee;
}

.volume-tooltip-row span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rating-color);
}

.volume-tooltip-row strong {
  color: var(--rating-color);
}

.bi-chart-card .bar-fill {
  height: var(--bar-height);
  border-radius: 7px 7px 2px 2px;
  background: linear-gradient(90deg, #227e5d 0%, var(--secondary) 45%, #8ce2bd 100%);
  position: relative;
  transform-origin: bottom;
  animation: bi-bar-rise .6s cubic-bezier(.2, .8, .2, 1) both;
  box-shadow: 5px 5px 0 rgba(45, 159, 117, .11), 0 8px 12px rgba(45, 159, 117, .19);
}

.bi-chart-card .bar-fill::after {
  content: "";
  position: absolute;
  inset: 3px 3px auto;
  height: 2px;
  background: rgba(255, 255, 255, .55);
  border-radius: 999px;
}

.bi-chart-card .bar-col:nth-child(2) .bar-fill { animation-delay: .05s; }
.bi-chart-card .bar-col:nth-child(3) .bar-fill { animation-delay: .1s; }
.bi-chart-card .bar-col:nth-child(4) .bar-fill { animation-delay: .15s; }
.bi-chart-card .bar-col:nth-child(5) .bar-fill { animation-delay: .2s; }
.bi-chart-card .bar-col:nth-child(6) .bar-fill { animation-delay: .25s; }
.bi-chart-card .bar-col:nth-child(7) .bar-fill { animation-delay: .3s; }
.bi-chart-card .bar-col:nth-child(8) .bar-fill { animation-delay: .35s; }

.bar-value {
  min-height: 15px;
  color: var(--primary);
  font-size: .68rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .16s ease, transform .16s ease;
}

.bi-chart-card .bar-col:hover .bar-value {
  opacity: 1;
  transform: translateY(0);
}

@keyframes bi-bar-rise {
  from { transform: scaleY(.04); filter: saturate(.65); }
  to { transform: scaleY(1); filter: saturate(1); }
}

@media (prefers-reduced-motion: reduce) {
  .stat-card-bi,
  .bi-chart-card,
  .donut-bi,
  .pie-bi,
  .bar-fill,
  .legend-row,
  .bar-value {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stat-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 991px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: fixed;
    top: 60px;
    right: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 32px rgba(15, 34, 56, .18);
    transform: translateY(calc(-100% - 64px));
    opacity: 0;
    pointer-events: none;
  }

  .app-shell.sidebar-open .app-sidebar {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 60px 0 0;
    z-index: 140;
    border: 0;
    background: rgba(15, 34, 56, .28);
  }

  .app-shell.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .app-topbar {
    height: 60px;
    padding: 0 14px;
  }

  .menu-trigger {
    display: inline-flex;
  }

  .app-content {
    padding: 20px 16px;
  }

  .app-brand {
    padding-bottom: 14px;
  }

  .app-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-sidebar-footer {
    margin-top: 16px;
  }
}

@media (max-width: 720px) {
  .dashboard-filter-toggle,
  .filter-disclosure > summary {
    width: 116px;
    min-width: 116px;
    height: 42px;
    min-height: 42px;
    flex: 0 0 116px;
    justify-content: center;
    padding: 0 12px;
    font-size: .8rem;
    font-weight: 700;
  }

  .dashboard-filter-actions,
  .served-filter-toolbar {
    position: relative;
    width: 100%;
    min-height: 42px;
  }

  .dashboard-mobile-export,
  .vote-detail-mobile-export,
  .served-mobile-actions .btn-dark-solid,
  .served-mobile-actions .btn-danger-soft {
    height: 42px;
    min-height: 42px;
  }

  .served-heading-actions {
    display: none !important;
  }

  .served-filter-toolbar {
    margin-bottom: 18px;
  }

  .served-filter-toolbar .page-filter-disclosure {
    width: 100%;
    margin-bottom: 0;
  }

  .served-mobile-actions {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
  }

  .served-mobile-actions button {
    justify-content: center;
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .topbar-client > span,
  .topbar-client strong {
    display: none;
  }

  .topbar-client img {
    width: 32px;
    height: 32px;
  }

  .app-nav {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .toolbar form {
    width: 100%;
    flex-wrap: wrap;
  }

  .toolbar form {
    display: contents;
  }

  .toolbar .search-field {
    order: 1;
  }

  .toolbar .filter-disclosure {
    order: 2;
  }

  .toolbar > .btn-dark-solid {
    order: 3;
    height: 42px;
    margin-left: auto;
  }

  .toolbar .search-field {
    flex: 1 1 100%;
  }

  .toolbar .search-field input {
    width: 100%;
  }

  .page-heading.d-flex {
    flex-direction: column;
    gap: 12px;
  }

  .page-heading.d-flex > .d-flex {
    width: 100%;
    flex-wrap: wrap;
  }

  .page-heading.d-flex > .d-flex > button {
    flex: 1 1 auto;
    justify-content: center;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .data-table thead,
  .data-table tbody {
    display: table;
    width: 100%;
    min-width: 680px;
  }

  .shifts-layout {
    grid-template-columns: 1fr;
  }

  .shift-create-card,
  .shift-list-card {
    min-width: 0;
  }

  .shifts-table,
  .served-people-table {
    display: table;
    overflow: visible;
    padding: 0 12px 12px;
    border-collapse: separate;
    border-spacing: 0 10px;
    white-space: normal;
  }

  .shifts-table thead,
  .served-people-table thead {
    display: none;
  }

  .shifts-table tbody,
  .served-people-table tbody {
    display: table-row-group;
    min-width: 0;
  }

  .shifts-table .shift-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    margin-bottom: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
  }

  .shifts-table .shift-row td {
    display: grid;
    gap: 3px;
    padding: 0;
    border: 0;
    font-size: .84rem;
  }

  .shifts-table .shift-row td:first-child {
    grid-column: 1 / -1;
  }

  .shifts-table .shift-row td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .64rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
  }

  .shift-list-card .table-foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .served-people-table .served-people-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 0 12px 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
  }

  .served-people-table .served-people-row td {
    display: grid;
    gap: 3px;
    padding: 0;
    border: 0;
    font-size: .86rem;
  }

  .served-people-table .served-people-row td:last-child {
    text-align: right !important;
  }

  .served-people-table .served-people-row td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .64rem;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
  }

  .served-people-table + .table-foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-width: 390px) {
  .served-mobile-delete {
    width: 42px;
    padding: 0;
  }

  .served-mobile-delete span {
    display: none;
  }
}
