.agg-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.agg-title-row h1 {
  margin: 0;
}
.agg-info-tip {
  position: relative;
  flex-shrink: 0;
  outline: none;
}
.agg-info-i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  cursor: help;
  user-select: none;
}
.agg-info-tip:hover .agg-info-i,
.agg-info-tip:focus .agg-info-i,
.agg-info-tip:focus-within .agg-info-i {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.agg-info-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 60;
  width: min(400px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.5;
  color: var(--text);
  text-align: left;
  white-space: normal;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s, visibility 0.12s;
}
.agg-info-tip:hover .agg-info-popover,
.agg-info-tip:focus .agg-info-popover,
.agg-info-tip:focus-within .agg-info-popover {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}
.agg-info-popover p,
.agg-info-popover .agg-plain {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.agg-info-popover .agg-plain {
  color: var(--text);
}
.agg-info-popover p:last-child,
.agg-info-popover .agg-plain:last-child {
  margin-bottom: 0;
}
.agg-info-popover strong {
  color: var(--text);
}

/* Column header info icons */
.agg-th-inner {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
}
.agg-th-label {
  white-space: nowrap;
}
table.agg-table th.num .agg-th-inner {
  justify-content: flex-end;
  width: 100%;
}
.agg-col-info .agg-info-i {
  width: 15px;
  height: 15px;
  font-size: 10px;
  flex-shrink: 0;
}
.agg-col-info .agg-info-popover,
.agg-info-popover--col {
  width: min(320px, 85vw);
  max-height: min(280px, 50vh);
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.5;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}
.agg-info-popover--col .agg-plain {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 11px;
  line-height: 1.45;
}
.agg-info-popover--col .agg-plain:last-of-type {
  margin-bottom: 6px;
}
.agg-info-popover--col .agg-formula {
  display: block;
  margin: 6px 0 4px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1.4;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.agg-info-popover--col .agg-src {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
}
.agg-info-popover--col strong {
  color: var(--text);
}
table.agg-table th.num .agg-col-info .agg-info-popover {
  left: auto;
  right: 0;
  transform: none;
}
table.agg-table thead th {
  overflow: visible;
  z-index: 2;
}
table.agg-table thead {
  position: relative;
  z-index: 2;
}

.agg-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.agg-nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
}
.agg-nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}
.agg-nav-link.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.agg-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.agg-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.agg-stat-card .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.agg-stat-card .value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.agg-stat-card .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.agg-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.agg-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.agg-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.agg-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}
.agg-card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.agg-card .count {
  margin-top: 12px;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.agg-run-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.agg-run-panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
}
.agg-run-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-top: 14px;
}
.agg-run-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.agg-run-form input[type="datetime-local"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}
.agg-run-result {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  display: none;
}
.agg-run-result.visible { display: block; }

.agg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.agg-toolbar select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.agg-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
table.agg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}
table.agg-table th,
table.agg-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
table.agg-table th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}
table.agg-table th.num,
table.agg-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
table.agg-table th.mono,
table.agg-table td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
table.agg-table tbody tr:hover td {
  background: var(--surface-2);
}
table.agg-table tr:last-child td { border-bottom: none; }
.tag-yes { color: var(--error); font-weight: 600; }
.tag-no { color: var(--muted); }
.agg-empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}
.agg-json {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--muted);
}

.agg-emp { line-height: 1.35; min-width: 120px; }
.agg-emp-name { font-weight: 500; font-size: 13px; }
.agg-emp-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.agg-json-preview {
  font-size: 11px;
  line-height: 1.45;
  max-width: 220px;
  color: var(--text);
}
.agg-json-more {
  color: var(--muted);
  font-size: 10px;
}
table.agg-table td .agg-json-preview {
  white-space: normal;
}

.agg-peak-hours {
  font-size: 11px;
  line-height: 1.5;
  max-width: 240px;
  color: var(--text);
}
.agg-peak-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.agg-peak-row:last-of-type {
  border-bottom: none;
}
.agg-peak-time {
  font-weight: 600;
  color: var(--text);
}
.agg-peak-val {
  color: var(--muted);
  font-size: 10px;
}
.agg-peak-more {
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted);
}
table.agg-table td .agg-peak-hours {
  white-space: normal;
}
