:root {
  color-scheme: dark;
  --bg: #071014;
  --panel: rgba(13, 27, 34, 0.82);
  --panel-strong: rgba(20, 39, 47, 0.94);
  --line: rgba(151, 232, 255, 0.16);
  --text: #eef9fb;
  --muted: #93aab1;
  --cyan: #20d7f5;
  --green: #62f0a8;
  --pink: #ff5ea8;
  --gold: #f4c95d;
  --red: #ff6f61;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(32, 215, 245, 0.22), transparent 30%),
    radial-gradient(circle at 82% 4%, rgba(255, 94, 168, 0.16), transparent 28%),
    linear-gradient(135deg, #071014 0%, #0c1719 48%, #111318 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.75), transparent);
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  min-height: 210px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(10, 25, 31, 0.88), rgba(17, 19, 24, 0.78));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255,255,255,0.05);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  right: -120px;
  top: -130px;
  width: 420px;
  height: 420px;
  background: conic-gradient(from 160deg, transparent, rgba(32,215,245,0.26), rgba(98,240,168,0.12), transparent);
  filter: blur(10px);
}

.hero > * { position: relative; z-index: 1; }
.compact-hero {
  min-height: 150px;
}

.app-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-nav a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(32, 215, 245, 0.22);
  background: rgba(255,255,255,0.045);
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 800;
}

.nav-group {
  position: relative;
}

.nav-group summary {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(32, 215, 245, 0.22);
  background: rgba(255,255,255,0.045);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary::after {
  content: "▾";
  color: rgba(238,249,251,0.58);
  font-size: 0.7rem;
}

.nav-group[open] summary::after {
  transform: rotate(180deg);
}

.nav-group summary.is-active,
.app-nav a.is-active {
  color: var(--text);
  border-color: rgba(32, 215, 245, 0.66);
  background: linear-gradient(135deg, rgba(32,215,245,0.22), rgba(98,240,168,0.08));
}

.nav-menu {
  position: fixed;
  top: 92px;
  right: 24px;
  z-index: 1000;
  width: min(320px, calc(100vw - 32px));
  min-width: 210px;
  max-height: calc(100vh - 124px);
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  background: rgba(13, 27, 34, 0.98);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(0,0,0,0.34);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
}

.nav-menu a {
  width: 100%;
  justify-content: flex-start;
}

.nav-button,
.nav-user {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 800;
}

.nav-button {
  border-color: rgba(255, 94, 168, 0.34);
  background: rgba(255, 94, 168, 0.1);
  color: var(--text);
}

.nav-user {
  border: 1px solid rgba(151, 232, 255, 0.14);
  background: rgba(255,255,255,0.035);
  color: var(--muted);
}

.panel-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(32, 215, 245, 0.38);
  background: rgba(32, 215, 245, 0.1);
  color: var(--text);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(98, 240, 168, 0.3);
  background: rgba(98, 240, 168, 0.1);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.empty-state {
  color: var(--muted);
  font-weight: 700;
  padding: 12px 0;
}

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

.metric-list div {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(151, 232, 255, 0.12);
  background: rgba(255,255,255,0.035);
  border-radius: 8px;
  padding: 10px 12px;
}

.metric-list span {
  color: var(--muted);
  font-weight: 700;
}

.metric-list strong {
  color: var(--text);
  font-size: 1.08rem;
}

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

.chart-switcher {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 560px;
}

.chart-view-btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.chart-view-btn.is-active {
  border-color: rgba(98, 240, 168, 0.62);
  background: rgba(98, 240, 168, 0.14);
}

.search-field {
  display: grid;
  gap: 6px;
  min-width: min(320px, 100%);
}

.search-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.search-field input {
  min-height: 42px;
  border: 1px solid rgba(151, 232, 255, 0.18);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 12px;
  font-size: clamp(2.1rem, 6vw, 5.4rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.subtitle {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

button {
  border: 1px solid rgba(32, 215, 245, 0.38);
  background: rgba(32, 215, 245, 0.1);
  color: var(--text);
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.login-shell {
  width: min(520px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-items: center;
  padding: 28px 0;
}

.login-panel {
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(10, 25, 31, 0.92), rgba(17, 19, 24, 0.84));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 28px;
}

.login-panel h1 {
  font-size: clamp(2.2rem, 12vw, 4.2rem);
  margin-bottom: 24px;
}

.auth-form,
.settings-form {
  display: grid;
  gap: 14px;
}

.auth-form label,
.settings-form label,
.search-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-form input,
.settings-form input,
.settings-form select {
  min-height: 42px;
  border: 1px solid rgba(151, 232, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.74);
  color: var(--text);
  padding: 9px 11px;
  font: inherit;
  color-scheme: dark;
}

.form-error {
  min-height: 20px;
  color: var(--red);
  font-weight: 800;
  margin: 0;
}

.form-message {
  min-height: 20px;
  color: var(--green);
  font-weight: 800;
  margin: 0;
}

.statusbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.statusbar span {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
}

.filterbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.045);
  border-radius: 8px;
}

.attendance-filterbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.15fr) minmax(140px, 0.6fr) minmax(320px, 1.4fr) minmax(240px, 1fr) auto;
  align-items: end;
}

.attendance-filterbar > button {
  min-height: 38px;
  white-space: nowrap;
}

.company-picker {
  min-width: 180px;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.company-picker select {
  min-height: 38px;
  border: 1px solid rgba(151, 232, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.74);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-weight: 700;
  color-scheme: dark;
}

.company-check-picker {
  position: relative;
  min-width: 240px;
}

.company-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(151, 232, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.74);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-weight: 800;
  text-align: left;
}

.company-toggle span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 60;
  width: min(520px, calc(100vw - 32px));
  border: 1px solid rgba(151, 232, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.98);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  padding: 8px;
}

.company-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 260px;
  overflow: auto;
}

.company-check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid rgba(151, 232, 255, 0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.035);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 750;
  line-height: 1.2;
  text-transform: none;
}

.company-check input {
  width: 16px;
  min-width: 16px;
  min-height: 16px;
  accent-color: var(--cyan);
}

.company-check span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.heatmap-cell {
  min-height: 76px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  border: 1px solid rgba(151, 232, 255, 0.13);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255,255,255,0.04);
}

.heatmap-cell strong {
  color: var(--text);
  font-size: 0.9rem;
}

.heatmap-cell span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.rank-bars {
  display: grid;
  gap: 10px;
}

.rank-bar {
  display: grid;
  gap: 5px;
}

.rank-action {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.rank-action:hover .rank-fill,
.rank-action:focus-visible .rank-fill {
  filter: brightness(1.18);
}

.rank-bar header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
}

.rank-bar small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-bar header span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}

.rank-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink), var(--gold));
}

.preset-group {
  display: grid;
  grid-template-columns: repeat(6, minmax(96px, auto));
  gap: 8px;
}

.filter-btn {
  min-height: 38px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
}

.filter-btn.is-active {
  color: var(--text);
  border-color: rgba(32, 215, 245, 0.66);
  background: linear-gradient(135deg, rgba(32,215,245,0.22), rgba(98,240,168,0.08));
  box-shadow: 0 0 22px rgba(32,215,245,0.12);
}

.date-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
}

.date-range label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.date-range input {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(151, 232, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.74);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  color-scheme: dark;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.kpi, .panel {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.22);
}

.kpi {
  padding: 18px;
  min-height: 138px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-top: 3px solid var(--cyan);
}

.kpi-action {
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.kpi-action:hover,
.kpi-action:focus-visible {
  transform: translateY(-2px);
  background: rgba(255,255,255,0.075);
  outline: none;
}

.kpi span, .kpi small, .panel p {
  color: var(--muted);
}

.kpi strong {
  display: block;
  font-size: clamp(1.75rem, 3vw, 2.7rem);
  line-height: 1;
  margin: 14px 0;
}

.accent-green { border-top-color: var(--green); }
.accent-pink { border-top-color: var(--pink); }
.accent-gold { border-top-color: var(--gold); }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.wide { grid-column: span 2; }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.search-box {
  min-width: min(320px, 100%);
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.search-box input {
  min-height: 38px;
  border: 1px solid rgba(151, 232, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.74);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

.filterbar select {
  min-height: 38px;
  border: 1px solid rgba(151, 232, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.74);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

.table-sort {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.explorer-panel {
  margin-top: 18px;
}

.explorer-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}

.explorer-breadcrumb span,
.breadcrumb-chip {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(32, 215, 245, 0.22);
  border-radius: 8px;
  background: rgba(255,255,255,0.045);
  color: var(--muted);
  padding: 6px 10px;
  font-weight: 800;
}

.breadcrumb-chip {
  width: auto;
  cursor: pointer;
}

.breadcrumb-chip:hover,
.breadcrumb-chip:focus-visible {
  color: var(--text);
  border-color: rgba(32, 215, 245, 0.6);
  background: rgba(32, 215, 245, 0.12);
  outline: none;
}

.explorer-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.explorer-choice {
  min-height: 108px;
  border: 1px solid rgba(151, 232, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(32,215,245,0.12), rgba(255,255,255,0.045));
  color: var(--text);
  padding: 14px;
  text-align: left;
  cursor: pointer;
}

.explorer-choice:hover {
  border-color: rgba(32, 215, 245, 0.62);
  background: linear-gradient(135deg, rgba(32,215,245,0.2), rgba(98,240,168,0.08));
}

.explorer-choice strong,
.explorer-choice span,
.explorer-choice small {
  display: block;
}

.explorer-choice strong {
  min-height: 34px;
  margin-bottom: 10px;
  font-size: 0.98rem;
}

.explorer-choice span {
  color: var(--cyan);
  font-size: 1.16rem;
  font-weight: 900;
}

.explorer-choice small {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 800;
}

.panel h2 {
  margin-bottom: 5px;
  font-size: 1.05rem;
}

.panel p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0));
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
}

.ppm-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.ppm-card-full {
  grid-column: 1 / -1;
}

.ppm-card-wide {
  grid-column: span 2;
}

.ppm-site-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.ppm-site-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  border: 1px solid rgba(151, 232, 255, 0.16);
  background: rgba(255,255,255,0.045);
  color: var(--text);
  border-radius: 8px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
}

.ppm-site-card:hover {
  border-color: rgba(32, 215, 245, 0.48);
  background: rgba(255,255,255,0.07);
}

.ppm-gauge {
  --pct: 0;
  --gauge: var(--cyan);
  flex: 0 0 128px;
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(13,27,34,0.98) 0 55%, transparent 56%),
    conic-gradient(var(--gauge) calc(var(--pct) * 1%), rgba(151,232,255,0.14) 0);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}

.ppm-gauge span {
  font-size: 1.18rem;
  font-weight: 900;
}

.ppm-site-info {
  min-width: 0;
  flex: 1;
}

.ppm-site-info h3 {
  margin: 0 0 3px;
  font-size: 1rem;
}

.ppm-site-info p {
  margin: 0 0 8px;
}

.ppm-site-info div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px dashed rgba(151,232,255,0.14);
  font-size: .85rem;
}

.ppm-site-info div:last-child {
  border-bottom: 0;
}

.ppm-site-info span {
  color: var(--muted);
  white-space: nowrap;
}

.ppm-site-info strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ppm-site-info .good,
.ppm-stage strong,
.ppm-badge.good {
  color: var(--green);
}

.ppm-site-info .bad,
.ppm-badge.bad {
  color: var(--red);
}

.ppm-stages {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.ppm-stage {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  font-size: .84rem;
}

.ppm-stage .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.ppm-funnel {
  display: grid;
  gap: 8px;
}

.ppm-funnel-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.ppm-funnel-row span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.ppm-funnel-row div {
  min-width: 0;
}

.ppm-funnel-row strong {
  min-width: 42px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 10px;
  color: #fff;
  font-size: .78rem;
  white-space: nowrap;
}

.ppm-expiry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  border: 1px solid rgba(151,232,255,0.14);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(255,255,255,0.035);
}

.ppm-expiry.good { border-left-color: var(--green); }
.ppm-expiry.warn { border-left-color: var(--gold); }
.ppm-expiry.bad { border-left-color: var(--red); }

.ppm-expiry span,
.ppm-expiry small {
  display: block;
  color: var(--muted);
}

.ppm-expiry b {
  align-self: start;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  padding: 4px 8px;
  font-size: .76rem;
}

.ppm-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  padding: 3px 8px;
  font-size: .76rem;
  font-weight: 900;
}

.ppm-badge.warn {
  color: var(--gold);
}

.chart-tooltip {
  position: fixed;
  z-index: 40;
  max-width: min(360px, calc(100vw - 24px));
  padding: 10px 12px;
  color: var(--text);
  background: rgba(7, 16, 20, 0.96);
  border: 1px solid rgba(32, 215, 245, 0.34);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.42);
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.chart-tooltip strong {
  display: block;
  white-space: normal;
  font-size: 0.86rem;
}

.chart-tooltip span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.tables {
  display: grid;
  grid-template-columns: 0.9fr 1.6fr;
  gap: 16px;
  margin-top: 16px;
}

.invoice-kpis {
  margin-top: 0;
}

.invoice-panel {
  margin-top: 16px;
}

.invoice-table {
  min-width: 1080px;
}

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

.rank-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
}

.rank-row b { font-size: 0.95rem; }
.rank-row span { color: var(--muted); font-size: 0.85rem; }

.attention-panel {
  margin-bottom: 18px;
}

.alert-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.alert-card {
  display: block;
  min-height: 112px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: rgba(255,255,255,0.045);
  color: inherit;
  text-decoration: none;
}

.alert-card:hover {
  border-color: rgba(32,215,245,0.38);
  background: rgba(32,215,245,0.08);
}

.alert-card span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.alert-card strong {
  display: block;
  font-size: 1.35rem;
  margin-top: 8px;
}

.alert-card small {
  color: var(--muted);
  display: block;
  margin-top: 8px;
}

.alert-card.is-clear {
  opacity: 0.72;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.table-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.sort-btn {
  min-height: auto;
  width: auto;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}

.sort-btn::after {
  content: "";
  display: inline-block;
  width: 0.45rem;
}

.sort-btn.is-active.asc::after {
  content: "↑";
}

.sort-btn.is-active.desc::after {
  content: "↓";
}

.num { text-align: right; }

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

.print-report {
  display: none;
}

.export-menu-wrap {
  position: relative;
}

.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  min-width: 120px;
  border: 1px solid rgba(151, 232, 255, 0.18);
  border-radius: 8px;
  background: rgba(7, 16, 20, 0.96);
  box-shadow: 0 16px 36px rgba(0,0,0,0.32);
  padding: 6px;
}

.export-menu button {
  width: 100%;
  justify-content: flex-start;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
}

.export-menu button:hover,
.export-menu button:focus-visible {
  background: rgba(32,215,245,0.12);
}

@media print {
  body {
    background: #fff;
    color: #111;
  }

  body > :not(.print-report) {
    display: none !important;
  }

  .print-report {
    display: block;
    padding: 0;
    color: #111;
    font: 11px Arial, sans-serif;
  }

  .print-report header {
    margin-bottom: 14px;
    border-bottom: 1px solid #777;
    padding-bottom: 8px;
  }

  .print-report h1 {
    margin: 0 0 4px;
    font-size: 20px;
  }

  .print-report h2 {
    margin: 14px 0 6px;
    padding: 5px 6px;
    background: #e9eef3;
    font-size: 13px;
    break-after: avoid;
  }

  .print-report h2 span {
    float: right;
    font-weight: 400;
  }

  .print-report p {
    margin: 2px 0;
  }

  .print-report table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
    break-inside: auto;
  }

  .print-report th,
  .print-report td {
    border: 1px solid #bbb;
    padding: 5px 6px;
    white-space: normal;
    color: #111;
  }

  .print-report th {
    background: #f4f6f8;
    text-transform: none;
  }
}
.pill {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(98,240,168,0.12);
  color: var(--green);
}
.pill.due {
  background: rgba(255,94,168,0.12);
  color: var(--pink);
}
.pill.partial {
  background: rgba(244,201,93,0.12);
  color: var(--gold);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  margin-top: 16px;
}

.field-title {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.checkbox-line {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  min-height: 40px;
  border: 1px solid rgba(151, 232, 255, 0.12);
  background: rgba(255,255,255,0.035);
  border-radius: 8px;
  padding: 8px 10px;
  text-transform: none !important;
  font-size: 0.9rem !important;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--cyan);
}

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

.user-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: rgba(255,255,255,0.045);
  border-color: rgba(151, 232, 255, 0.16);
}

.user-row span {
  display: grid;
  gap: 3px;
}

.user-row small {
  color: var(--muted);
  font-weight: 700;
}

.report-category {
  border-color: rgba(244, 201, 93, 0.28);
  background: linear-gradient(135deg, rgba(244, 201, 93, 0.09), rgba(32, 215, 245, 0.045));
}

.creditor-category {
  border-color: rgba(167, 139, 250, 0.3);
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.1), rgba(255, 94, 168, 0.045));
}

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

.report-summary-grid div {
  border: 1px solid rgba(151, 232, 255, 0.12);
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.report-summary-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.report-summary-grid strong {
  font-size: 1.3rem;
}

.report-action-row {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 1px dashed rgba(151, 232, 255, 0.16);
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  padding: 14px;
}

.install-prompt {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 80;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(32, 215, 245, 0.38);
  background: rgba(7, 16, 20, 0.96);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.42);
  border-radius: 8px;
  padding: 12px;
}

.install-prompt div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.install-prompt strong {
  font-size: 0.95rem;
}

.install-prompt span {
  color: var(--muted);
  font-size: 0.82rem;
}

.install-prompt button {
  min-height: 36px;
  padding: 8px 12px;
}

.install-close {
  width: 36px;
  min-width: 36px;
  padding: 0 !important;
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
}

@media (max-width: 980px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .app-nav {
    display: grid;
    grid-template-columns: minmax(118px, 34vw) minmax(0, 1fr);
    align-items: start;
    justify-content: flex-start;
    width: 100%;
  }
  .app-nav > a,
  .app-nav > .nav-group,
  .app-nav > .nav-user,
  .app-nav > .nav-button {
    grid-column: 1;
  }
  .nav-group {
    width: 100%;
  }
  .nav-group summary {
    width: 100%;
    justify-content: space-between;
  }
  .nav-group[open] summary {
    border-color: rgba(32, 215, 245, 0.72);
    box-shadow: 0 0 0 1px rgba(32, 215, 245, 0.1), 0 10px 24px rgba(0,0,0,0.22);
  }
  .nav-menu {
    position: absolute;
    top: 0;
    left: calc(100% + 10px);
    right: auto;
    width: max(188px, calc(100vw - 100% - 58px));
    min-width: 0;
    max-height: min(420px, calc(100vh - 120px));
    margin-top: 0;
    border-color: rgba(151, 232, 255, 0.3);
    box-shadow:
      inset -1px 0 0 rgba(151, 232, 255, 0.32),
      0 18px 44px rgba(0,0,0,0.4),
      -8px 0 18px rgba(0,0,0,0.18);
  }
  .filterbar { align-items: stretch; flex-direction: column; }
  .attendance-filterbar { grid-template-columns: 1fr; }
  .attendance-filterbar > button { width: 100%; }
  .company-picker { min-width: 0; }
  .company-check-picker { min-width: 0; }
  .company-menu { width: 100%; }
  .company-checks { grid-template-columns: 1fr; max-height: 260px; }
  .preset-group { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .alert-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .tables, .settings-grid { grid-template-columns: 1fr; }
  .ppm-card-grid,
  .ppm-site-row {
    grid-template-columns: 1fr;
  }
  .ppm-card-wide,
  .ppm-card-full {
    grid-column: auto;
  }
  .report-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-head { flex-direction: column; }
  .search-box { width: 100%; }
  .wide { grid-column: span 1; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1440px); padding-top: 10px; }
  .hero { padding: 20px; min-height: 0; }
  .kpi-grid { grid-template-columns: 1fr; }
  .alert-grid { grid-template-columns: 1fr; }
  .panel, .kpi { padding: 14px; }
  .ppm-site-card {
    align-items: stretch;
    flex-direction: column;
  }
  .ppm-gauge {
    align-self: center;
  }
  .ppm-funnel-row {
    grid-template-columns: 1fr;
  }
  h1 { font-size: 2.3rem; }
  .subtitle { font-size: 0.95rem; }
  button { width: 100%; text-align: center; }
  .app-nav {
    grid-template-columns: minmax(112px, 36vw) minmax(0, 1fr);
    align-items: flex-start;
    justify-content: flex-start;
  }
  .app-nav a {
    flex: 0 1 auto;
    justify-content: flex-start;
  }
  .nav-menu {
    left: calc(100% + 8px);
    width: max(176px, calc(100vw - 100% - 48px));
  }
  .preset-group, .date-range { grid-template-columns: 1fr 1fr; }
  .checkbox-grid { grid-template-columns: 1fr; }
  .report-summary-grid { grid-template-columns: 1fr; }
  .install-prompt { grid-template-columns: 1fr; }
  .filter-btn { min-width: 0; width: 100%; }
}
