body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  margin: 0;
  color: #111;
  background: #fafafa;
}
header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 20px 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.header-left {
  flex: 1;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

header h1 {
  margin: 0 0 12px 0;
  font-size: 24px;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
}

header h1::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  background-color: #4f46e5;
  border-radius: 4px;
  margin-right: 4px;
}

.action-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 4px;
}

.action-buttons a {
  color: #1f2937;
  text-decoration: none;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 6px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  transition: all 0.15s;
}

.action-buttons a:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

.action-buttons .icon-home {
  width: 14px;
  height: 14px;
  color: #374151;
}

.updated {
  color: #555;
  font-size: 12px;
  text-align: right;
}

#visitor-counter {
  color: #4b5563;
  font-size: 12px;
}
.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 6px 0 4px 0;
}
.filters { display: flex; gap: 10px; margin: 8px 0; }
.filters input[type="text"] { padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; min-width: 240px; }
.filters select { padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; }
.filters button { padding: 6px 10px; border: 1px solid #d1d5db; background: #f9fafb; border-radius: 6px; cursor: pointer; }
.filters button:hover { background: #f3f4f6; }

.updated { color: #555; font-size: 12px; }
main { 
  padding: 20px 24px; 
  width: 100%;
  box-sizing: border-box;
}

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e5e7eb; }
th { text-align: left; background: #f3f4f6; font-weight: 600; font-size: 13px; user-select: none; }
th[data-key] { cursor: pointer; }

/* Sort icon cluster */
th .sort-icons { display: inline-flex; align-items: center; margin-left: 6px; position: relative; top: 2px; }
.icon { width: 12px; height: 12px; color: #9aa0a6; }
.icon-asc, .icon-desc { display: none; }

/* Neutral state */
th .icon-sort { display: inline-block; opacity: 0.45; }
/* Active states toggle in JS via classes */
th.sort-asc .icon-sort, th.sort-desc .icon-sort { display: none; }
th.sort-asc .icon-asc { display: inline-block; color: #111; }
th.sort-desc .icon-desc { display: inline-block; color: #111; }

td { font-size: 13px; }
.num { text-align: right; }

tbody tr:hover { background: #f9fafb; }

#definitions { margin-top: 20px; background: #fff; border: 1px solid #e5e7eb; padding: 12px 14px; border-radius: 6px; }
#definitions h2 { font-size: 16px; margin: 0 0 8px 0; }
#definitions ul { margin: 0; padding-left: 18px; }
#definitions li { margin: 6px 0; }
footer { padding: 12px 20px; color: #666; font-size: 12px; }

.notice { margin-top: 8px; padding: 10px 12px; border-radius: 6px; font-size: 13px; }
.notice.error { background: #FEF2F2; color: #991B1B; border: 1px solid #FCA5A5; }
.notice.info { background: #EFF6FF; color: #1E40AF; border: 1px solid #93C5FD; }

.history-controls {
  margin: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.model-selector-container {
  margin-bottom: 1rem;
  flex: 1;
  min-width: 250px;
  max-width: 350px;
}

.model-selector-container > label {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: bold;
  color: #333;
  font-size: 14px;
}

.model-filter-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.model-filter-controls button {
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  flex: 1;
  transition: all 0.2s;
  font-weight: 500;
  color: #4b5563;
}

.model-filter-controls button:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #111827;
}

.model-filter-controls button:active {
  background: #e5e7eb;
}

.checkbox-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.75rem;
  background: white;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) inset;
  margin-top: 10px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  margin-bottom: 0.4rem;
  padding: 5px 6px;
  border-radius: 4px;
  transition: background-color 0.15s;
}

.checkbox-item:hover {
  background-color: #f3f4f6;
}

.checkbox-item:first-child {
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.checkbox-item:first-child label {
  font-weight: 600;
  color: #111827;
}

.checkbox-item input[type="checkbox"] {
  margin-right: 8px;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #4f46e5;
}

.checkbox-item label {
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  padding: 2px 0;
  max-width: 180px;
}

.chart-container {
  width: 100%;
  height: 650px;
  margin: 0 0 20px 0;
  padding: 1rem;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  max-width: 100%;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin: 0;
  width: 100%;
  padding-bottom: 2rem;
}

.metric-chart {
  background-color: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}

.metric-chart:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.metric-chart h3 {
  margin: 0 0 1rem 0;
  font-size: 16px;
  text-align: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
}

.metric-chart .chart-container {
  height: 350px;
  margin: 0;
  padding: 0;
  border: none;
  box-shadow: none;
}

.view-controls {
  margin: 1rem 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.view-controls label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.view-controls select {
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #d1d5db;
}

.two-column-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 30px;
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 600px;
}

.sidebar {
  grid-column: 1;
  width: 100%;
  height: 100%;
  background: #f9fafb;
  border-right: 1px solid #e5e7eb;
  padding: 20px 15px 20px 0;
}

.sidebar-content {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 20px;
}

.sidebar-title {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: #111827;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f0f0;
  font-weight: 600;
}

.main-content {
  grid-column: 2;
  width: 100%;
  min-width: 0; /* Prevent items from overflowing */
  padding-left: 20px;
  padding-right: 20px;
}

#history-view {
  padding: 0;
  max-width: 100%;
}

.no-data-message {
  text-align: center;
  padding: 2rem;
  color: #666;
  font-style: italic;
  background: #f9f9f9;
  border: 1px dashed #ddd;
  border-radius: 8px;
  margin: 2rem 0;
}

/* Styles for highlighted legend items */
.chart-legend-highlight {
  font-weight: bold !important;
  text-decoration: underline !important;
  transform: scale(1.05);
  transition: all 0.1s ease-in-out;
  background-color: rgba(255, 255, 0, 0.2) !important;
  border-radius: 4px;
  padding: 2px 4px !important;
  margin: -2px -4px !important;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
}
