:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --panel: #ffffff;
  --text: #16211d;
  --muted: #64716c;
  --line: #dfe5e2;
  --accent: #16745f;
  --accent-soft: #e5f3ee;
  --dark: #123c32;
  --danger: #b42318;
  --radius: 18px;
}

* { box-sizing: border-box; }

@keyframes skeleton-pulse { 50% { opacity: 0.45; } }
.is-loading #lastUpdated,
.is-loading .kpi strong,
.is-loading .section-total {
  display: inline-block;
  min-width: 100px;
  min-height: 1em;
  border-radius: 6px;
  color: transparent;
  background: var(--line);
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}
.is-loading #chartContainer,
.is-loading #chartLegend,
.is-loading .table-wrap { position: relative; pointer-events: none; }
.is-loading #chartContainer { min-height: 300px; }
.is-loading #chartLegend { min-height: 200px; }
.is-loading .table-wrap { min-height: 260px; }
.is-loading #chartContainer > *,
.is-loading #chartLegend > *,
.is-loading #sessionRows > *,
.is-loading #pagination { visibility: hidden; }
.is-loading #chartContainer::after,
.is-loading #chartLegend::after,
.is-loading .table-wrap::after {
  content: "";
  position: absolute;
  inset: 12px 0;
  border-radius: 10px;
  background: repeating-linear-gradient(to bottom, var(--line) 0 16px, transparent 16px 48px);
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}
.is-loading #chartLegend::after {
  background: repeating-linear-gradient(to right, var(--line) 0 calc(20% - 12px), transparent calc(20% - 12px) 20%);
}
.is-loading .notice { display: none; }
@media (prefers-reduced-motion: reduce) {
  .is-loading * { animation: none !important; }
  .is-loading *::after { animation: none !important; }
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select { font: inherit; }

button,
select { color: inherit; }

.shell {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 38px 0 56px;
}

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.header-copy { min-width: 0; }

.header-period { flex: 0 0 auto; }

.site-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.demo-badge,
.section-total {
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.demo-badge {
  border: 1px solid #b9ded1;
  text-transform: uppercase;
}

.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

h1,
h2 { margin: 0; }

h1 {
  font-size: clamp(28px, 3vw, 38px);
  letter-spacing: -0.035em;
}

h2 {
  font-size: 24px;
  letter-spacing: -0.025em;
}

.updated-text {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.updated-text strong { color: var(--text); font-weight: 700; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.section-filters {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.filter-group { min-width: 0; }

.machine-filter { width: min(240px, 100%); }

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.segmented button,
.pagination button {
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.segmented button { padding: 9px 12px; }

.segmented button[aria-pressed="true"] {
  background: var(--dark);
  color: #fff;
}

.segmented button:focus-visible,
.pagination button:focus-visible,
select:focus-visible { outline: 3px solid rgba(22, 116, 95, 0.25); outline-offset: 2px; }

select {
  appearance: none;
  width: 100%;
  min-height: 42px;
  padding: 0 42px 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m4 6 4 4 4-4' stroke='%2364716c' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 13px center;
  background-repeat: no-repeat;
  background-size: 16px;
  font-size: 14px;
  font-weight: 700;
}

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

.kpi {
  min-width: 0;
  padding: 22px;
}

.kpi p,
.kpi span {
  margin: 0;
  color: var(--muted);
}

.kpi p {
  font-size: 13px;
  font-weight: 750;
}

.kpi strong {
  display: block;
  margin: 9px 0 6px;
  overflow-wrap: anywhere;
  color: var(--dark);
  font-size: clamp(22px, 2.3vw, 31px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
}

#lastUsed {
  font-size: clamp(22px, 2.3vw, 31px);
  white-space: nowrap;
}

.kpi span {
  font-size: 12px;
  line-height: 1.45;
}

.activity,
.sessions {
  margin-top: 18px;
  padding: 26px 28px;
}

.machine-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.machine-card {
  min-width: 0;
  max-width: 210px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.machine-card img {
  display: block;
  width: 100%;
  height: 110px;
  margin-bottom: 10px;
  object-fit: contain;
}

.machine-card span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.machine-card small {
  display: block;
  margin: 5px 0 0 16px;
  color: var(--muted);
  font-size: 11px;
}

.machine-session-count {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--accent);
  font-size: 14px;
  font-weight: 750;
}

.machine-legend i {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.chart-wrap {
  width: 100%;
  margin-top: 8px;
  border-radius: 12px;
}

.activity-chart {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.chart-dot {
  cursor: pointer;
  opacity: 0.78;
  stroke: #fff;
  stroke-width: 2;
  transition: opacity 140ms ease, r 140ms ease;
}

.chart-dot:hover,
.chart-dot:focus,
.chart-dot.is-selected {
  opacity: 1;
  r: 8px;
}

.chart-dot:focus { outline: none; stroke: var(--dark); stroke-width: 3; }

.chart-details {
  margin-top: 12px;
  padding: 16px 18px;
  border: 1px solid #b9ded1;
  border-radius: 12px;
  background: var(--accent-soft);
}

.chart-details[hidden] { display: none; }

.chart-details-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.chart-details-head span,
.chart-details-head strong { display: block; }

.chart-details-head span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.chart-details-head strong { font-size: 17px; }

.chart-details-head button {
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
}

.chart-details dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 15px 0 0;
}

.chart-details dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.chart-details dd {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 750;
}

.chart-empty-label {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.notice {
  margin-top: 20px;
  padding: 12px 14px;
  border: 1px solid #f2c5c1;
  border-radius: 10px;
  background: #fff3f2;
  color: var(--danger);
  font-size: 14px;
  font-weight: 650;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

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

.active-time-column { text-align: right; }

.session-date th {
  padding-top: 18px;
  background: var(--bg);
  text-transform: none;
  font-weight: 700;
}

.session-machine { display: flex; align-items: center; gap: 12px; }
.session-machine img { flex: 0 0 auto; width: 48px; height: 48px; object-fit: contain; }
.session-machine strong { white-space: normal; }
.session-machine small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.empty {
  padding: 42px 12px;
  color: var(--muted);
  text-align: center;
}

.empty strong,
.empty span { display: block; }

.empty strong {
  margin-bottom: 5px;
  color: var(--text);
  font-size: 15px;
}

.empty span { font-size: 13px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.pagination[hidden] { display: none; }

.pagination div { display: flex; gap: 8px; }

.pagination button {
  padding: 9px 13px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { cursor: default; opacity: 0.45; }

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

.language-switcher {
  display: flex;
  align-items: center;
  gap: 16px;
}

.language-divider {
  width: 1px;
  height: 12px;
  background: var(--line);
}

.language-switcher button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.language-switcher button[aria-pressed="true"] {
  color: var(--text);
  font-weight: 750;
}

.language-switcher button:focus-visible {
  border-radius: 3px;
  outline: 3px solid rgba(22, 116, 95, 0.25);
  outline-offset: 3px;
}

@media (max-width: 880px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .header-period {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }

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

@media (max-width: 620px) {
  .shell {
    width: min(100% - 24px, 1160px);
    padding: 22px 0 36px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-heading { flex-wrap: wrap; }

  .segmented { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
  .segmented button { padding: 9px 6px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .activity,
  .sessions { padding: 22px 20px; }
  .sessions table { table-layout: fixed; }
  .sessions th,
  .sessions td { padding: 15px 6px; white-space: normal; }
  .sessions thead th:first-child { width: 22%; }
  .sessions thead th:nth-child(2) { width: 52%; }
  .session-machine { gap: 7px; }
  .session-machine img { width: 32px; height: 32px; }
  .sessions td.active-time-column { font-size: 14px; }
  .chart-details dl { grid-template-columns: 1fr; gap: 12px; }
  .pagination { align-items: flex-start; flex-direction: column; }
}
