:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-soft: #f6f8fa;
  --ink: #1c1e21;
  --ink-soft: #44464a;
  --muted: #65676b;
  --line: #e3e6ea;
  --line-strong: #ced0d4;
  --accent: #1877f2;
  --accent-dark: #0f63d8;
  --accent-soft: #e7f0fe;
  --violet: #6d4aff;
  --teal: #0e9384;
  --teal-soft: #e3f6f3;
  --amber: #b76e00;
  --amber-soft: #fbf0db;
  --red: #d92d20;
  --red-soft: #fdeceb;
  --green: #1f9d57;
  --green-soft: #e4f5ea;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(24, 119, 242, 0.3);
  outline-offset: 2px;
}

/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.main {
  min-width: 0;
  padding: 0 26px 44px;
  display: grid;
  gap: 18px;
  align-content: start;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 6px 8px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #1877f2, #4f9bff);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 6px rgba(24, 119, 242, 0.35);
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.brand-text p {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.nav-group-label {
  padding: 10px 12px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
  transition: background 130ms ease, color 130ms ease;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  flex: none;
  color: var(--muted);
  transition: color 130ms ease;
}

.nav-item:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.nav-item:hover svg {
  color: var(--ink-soft);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.nav-item.active svg {
  color: var(--accent);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

/* User card (sidebar footer) */
.user-card {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.user-card .uc-text {
  min-width: 0;
}

.user-card .uc-text strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card .uc-text span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

/* Avatar */
.avatar {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #1877f2, #6d4aff);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* ---------- Page top bar ---------- */
.page-topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 -26px;
  padding: 14px 26px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.page-title-wrap {
  min-width: 0;
}

.page-title-wrap h2 {
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.page-title-wrap p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 1px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 260px;
  max-width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
  transition: border-color 130ms ease, background 130ms ease;
}

.search:focus-within {
  border-color: var(--accent);
  background: #fff;
}

.search svg {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--muted);
}

.search input {
  width: 100%;
  min-height: auto;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 14px;
}

.search input:focus-visible {
  outline: none;
}

.icon-button {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  transition: background 130ms ease, color 130ms ease;
}

.icon-button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.icon-button.has-alerts::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--surface);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: border-color 130ms ease, background 130ms ease;
}

.user-chip:hover {
  border-color: var(--accent);
}

.user-chip .uc-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Buttons ---------- */
.primary-button,
.ghost-button,
.mini-button,
.filter-button,
.link-button {
  border-radius: var(--radius-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, transform 120ms ease, color 140ms ease;
}

.primary-button,
.ghost-button {
  min-height: 40px;
  padding: 0 16px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(24, 119, 242, 0.3);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
}

.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mini-button {
  min-height: 32px;
  padding: 0 11px;
  font-size: 13px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
}

.mini-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.link-button {
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  padding: 4px 2px;
}

.link-button:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* ---------- KPI grid ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.kpi {
  display: grid;
  gap: 4px;
  align-content: start;
  text-align: left;
  padding: 16px 18px;
  min-width: 0;
  min-height: 122px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.kpi:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.kpi-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  margin-bottom: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}

.kpi-icon svg {
  width: 19px;
  height: 19px;
}

.kpi-icon.blue { background: var(--accent-soft); color: var(--accent); }
.kpi-icon.green { background: var(--green-soft); color: var(--green); }
.kpi-icon.violet { background: #ece8ff; color: var(--violet); }
.kpi-icon.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-icon.teal { background: var(--teal-soft); color: var(--teal); }
.kpi-icon.red { background: var(--red-soft); color: var(--red); }

.kpi-label {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.kpi strong {
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi-sub {
  color: var(--muted);
  font-size: 12px;
}

.kpi-alert strong {
  color: var(--red);
}

.kpi-alert.is-clear strong {
  color: var(--green);
}

/* ---------- Panels / tab content ---------- */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 18px;
}

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.module-meta {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.module-header h2 {
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-top: 3px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  min-width: 0;
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- Trend cards ---------- */
.trend-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.trend-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.trend-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.trend-figure {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 6px;
}

.trend-figure strong {
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.trend-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.delta {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.delta.up {
  color: var(--green);
  background: var(--green-soft);
}

.delta.down {
  color: var(--red);
  background: var(--red-soft);
}

.delta.flat {
  color: var(--muted);
  background: var(--surface-soft);
}

/* CSS bar chart */
.bar-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 8px;
  height: 92px;
}

.bar-col {
  display: grid;
  align-items: end;
  justify-items: center;
  gap: 8px;
  height: 100%;
  grid-template-rows: 1fr auto;
}

.bar-track {
  width: 100%;
  max-width: 28px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar-fill {
  width: 100%;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, #bcd6fb, #7eb1f7);
  min-height: 4px;
  transition: height 200ms ease;
}

.bar-fill.teal {
  background: linear-gradient(180deg, #9be6dc, #2dd4bf);
}

.bar-fill.is-today {
  background: linear-gradient(180deg, #4f9bff, var(--accent));
}

.bar-fill.teal.is-today {
  background: linear-gradient(180deg, #14b8a6, var(--teal));
}

.bar-label {
  color: var(--muted);
  font-size: 11px;
}

/* ---------- Overview grid ---------- */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.span-2 {
  grid-column: span 2;
}

/* ---------- Attendance health (overview) ---------- */
.progress-row {
  display: grid;
  gap: 8px;
}

.progress-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.progress-top strong {
  font-size: 24px;
  letter-spacing: -0.02em;
}

.progress-bar {
  height: 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width 220ms ease;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.mini-stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  gap: 3px;
}

.mini-stat strong {
  font-size: 22px;
  letter-spacing: -0.02em;
}

.mini-stat span {
  color: var(--muted);
  font-size: 12px;
}

.rep-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rep-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
  color: var(--ink-soft);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.in {
  background: var(--green);
}

.dot.out {
  background: var(--red);
}

/* ---------- Segmented bar (task status) ---------- */
.seg-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.seg {
  height: 100%;
}

.seg.open {
  background: #7eb1f7;
}

.seg.done {
  background: var(--teal);
}

.seg.overdue {
  background: var(--red);
}

.legend {
  display: grid;
  gap: 8px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.legend-row .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.swatch.open {
  background: #7eb1f7;
}

.swatch.done {
  background: var(--teal);
}

.swatch.overdue {
  background: var(--red);
}

.legend-row b {
  margin-left: auto;
  color: var(--ink);
}

/* ---------- Territory coverage ---------- */
.coverage-list {
  display: grid;
  gap: 12px;
}

.coverage-item {
  display: grid;
  gap: 6px;
}

.coverage-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.coverage-meta span {
  color: var(--muted);
}

.coverage-meta strong {
  font-weight: 600;
}

/* ---------- Activity / risk lists ---------- */
.activity-feed {
  display: grid;
  gap: 2px;
  max-height: 320px;
  overflow: auto;
}

.activity-item {
  display: grid;
  gap: 2px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-item strong {
  font-size: 13.5px;
  font-weight: 600;
}

.activity-item span {
  color: var(--muted);
  font-size: 12px;
}

.risk-list {
  display: grid;
  gap: 10px;
}

.risk-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.risk-item .badge {
  margin-top: 1px;
}

.risk-item .risk-body strong {
  display: block;
  font-size: 13.5px;
}

.risk-item .risk-body span {
  color: var(--muted);
  font-size: 12.5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  flex: none;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.danger {
  background: var(--red-soft);
  color: var(--red);
}

.badge.ok {
  background: var(--green-soft);
  color: var(--green);
}

/* ---------- Forms ---------- */
input,
select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: #fff;
}

input::placeholder {
  color: #8a8d91;
}

.inline-form,
.task-form {
  display: grid;
  gap: 10px;
}

.inline-form {
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
}

.task-form {
  grid-template-columns: minmax(180px, 1.4fr) minmax(120px, 0.8fr) minmax(140px, 0.7fr) minmax(110px, 0.6fr) auto;
}

.inline-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

/* ---------- Lists / rows ---------- */
.list-stack {
  display: grid;
  gap: 12px;
}

.data-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(150px, 0.9fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.data-row.task-row {
  grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(120px, 0.7fr)) auto;
}

.row-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.row-title strong {
  font-size: 14.5px;
  overflow-wrap: anywhere;
}

.row-title span,
.row-meta {
  color: var(--muted);
  font-size: 13px;
}

.row-meta {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.row-control {
  display: grid;
  gap: 5px;
}

.row-control label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.row-control select {
  min-height: 34px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 700;
}

.status-in,
.status-done {
  background: var(--green-soft);
  color: var(--green);
}

.status-out {
  background: var(--red-soft);
  color: var(--red);
}

.status-open {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.status-overdue {
  background: var(--red-soft);
  color: var(--red);
}

/* ---------- Timeline (tracking) ---------- */
.timeline {
  display: grid;
  gap: 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 14px;
  padding: 0 0 18px;
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 32px;
  bottom: -2px;
  width: 2px;
  background: var(--line);
}

.timeline-item:last-child::before {
  display: none;
}

.tl-marker {
  z-index: 1;
  box-shadow: 0 0 0 3px var(--surface);
}

.timeline-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.tl-headline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.timeline-body strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.timeline-body span {
  color: var(--muted);
  font-size: 13px;
}

.timeline-time {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 4px;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

/* ---------- Tracking toolbar ---------- */
.track-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.toolbar-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.toolbar-select {
  width: auto;
  min-width: 160px;
  max-width: 220px;
}

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-button {
  min-height: 36px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
}

.filter-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Insights ---------- */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.insight-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.insight-card .insight-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.insight-card strong {
  font-size: 14px;
}

.insight-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- Reporting ---------- */
.report-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.report-content {
  display: grid;
  gap: 16px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.report-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: grid;
  gap: 5px;
}

.report-box span {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.report-box strong {
  font-size: 26px;
  letter-spacing: -0.02em;
}

.report-box .sub {
  font-size: 12px;
  font-weight: 400;
}

.report-text {
  border-radius: var(--radius);
  border: 1px solid #2a2f36;
  background: #1c1e21;
  color: #e4e6eb;
  padding: 18px 20px;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

/* ---------- Empty states ---------- */
.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--muted);
  text-align: center;
  font-size: 13.5px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 36px));
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: #1c1e21;
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Trend cards (refined) ---------- */
.trend-head {
  display: flex;
  align-items: center;
  gap: 11px;
}

.trend-icon {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}

.trend-icon svg {
  width: 18px;
  height: 18px;
}

.trend-icon.blue { background: var(--accent-soft); color: var(--accent); }
.trend-icon.teal { background: var(--teal-soft); color: var(--teal); }
.trend-icon.green { background: var(--green-soft); color: var(--green); }

.trend-titles {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.trend-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.trend-unit {
  color: var(--muted);
  font-size: 12px;
}

.trend-vs {
  color: var(--muted);
  font-size: 11.5px;
}

.trend-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.trend-foot b {
  color: var(--ink);
  font-weight: 700;
}

/* ---------- Attendance health (refined) ---------- */
.att-health {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.att-ring {
  --size: 100px;
  width: var(--size);
  height: var(--size);
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--line) 0);
  display: grid;
  place-items: center;
}

.att-ring-center {
  width: calc(var(--size) - 22px);
  height: calc(var(--size) - 22px);
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  text-align: center;
}

.att-ring-center strong {
  font-size: 23px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.att-ring-center span {
  color: var(--muted);
  font-size: 10.5px;
}

.att-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  flex: 1;
  min-width: 200px;
}

.att-stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  gap: 2px;
}

.att-stat strong {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.att-stat span {
  color: var(--muted);
  font-size: 11.5px;
}

.roster {
  display: grid;
  gap: 14px;
}

.roster-group {
  display: grid;
  gap: 8px;
}

.roster-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.roster-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.roster-text {
  display: grid;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.roster-text strong {
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.roster-text span {
  color: var(--muted);
  font-size: 12px;
}

.roster-status {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.roster-status.is-in {
  color: var(--green);
}

.roster-status.is-out {
  color: var(--muted);
}

/* ---------- Avatars + presence ---------- */
.avatar.sm {
  width: 30px;
  height: 30px;
  font-size: 11.5px;
  font-weight: 700;
}

.avatar.xs {
  width: 22px;
  height: 22px;
  font-size: 9.5px;
  font-weight: 700;
}

.av-wrap {
  position: relative;
  display: inline-flex;
  flex: none;
}

.presence {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.presence.in {
  background: var(--green);
}

.presence.out {
  background: var(--muted);
}

.rep-chip .av-wrap .presence {
  width: 8px;
  height: 8px;
}

/* Identity cell (avatar + name/role) */
.id-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.id-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.id-text strong {
  font-size: 14.5px;
  overflow-wrap: anywhere;
}

.id-text span {
  color: var(--muted);
  font-size: 13px;
}

.performer {
  display: flex;
  align-items: center;
  gap: 9px;
}

.performer strong {
  font-size: 16px;
}

/* ---------- Task row chips ---------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink-soft);
}

.chip-overdue {
  background: var(--red-soft);
  border-color: transparent;
  color: var(--red);
}

.chip-today {
  background: var(--amber-soft);
  border-color: transparent;
  color: var(--amber);
}

.muted-xs {
  color: var(--muted);
  font-size: 12px;
}

.prio-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  background: var(--muted);
}

.prio-high {
  background: var(--red);
}

.prio-normal {
  background: var(--accent);
}

.prio-low {
  background: var(--teal);
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .trend-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  /* Keep the nav on the left — just a narrower sidebar. */
  .app-shell {
    grid-template-columns: 208px minmax(0, 1fr);
  }

  .main {
    padding: 0 18px 40px;
  }

  .page-topbar {
    margin: 0 -18px;
    padding: 12px 18px;
  }

  .sidebar {
    padding: 16px 12px;
  }

  .nav-item {
    font-size: 14px;
    padding: 0 10px;
  }

  .search {
    width: 200px;
  }
}

@media (max-width: 720px) {
  .page-topbar {
    position: static;
    margin: 0 -18px;
  }

  .topbar-actions {
    flex: 1 1 100%;
  }

  .search {
    flex: 1;
    width: auto;
  }

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

  .span-2 {
    grid-column: span 1;
  }

  .task-form {
    grid-template-columns: 1fr 1fr;
  }

  .data-row,
  .data-row.task-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .brand-text p {
    display: none;
  }
}

@media (max-width: 640px) {
  /* Only on phone widths does the left sidebar fold up to a sticky top bar. */
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
  }

  .brand {
    padding: 0;
    margin: 0;
    border: 0;
    flex: none;
  }

  .nav-group-label {
    display: none;
  }

  .side-nav {
    flex: 1;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
  }

  .nav-item {
    white-space: nowrap;
    padding: 0 12px;
  }

  .nav-item.active::before {
    display: none;
  }

  .user-card {
    display: none;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 14px;
  }

  .brand-text {
    display: none;
  }

  .user-chip .uc-name {
    display: none;
  }

  .inline-form,
  .task-form {
    grid-template-columns: 1fr;
  }

  .kpi strong {
    font-size: 26px;
  }
}
