* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
}

/* ---- Navbar ---- */
.navbar {
  background: #2c3e50;
  color: white;
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 60px;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1em;
  font-weight: 600;
  color: white;
  margin-right: auto;
}

.brand-icon { color: #2E86C1; }

.nav-links { display: flex; gap: 0.25rem; }

.nav-link {
  padding: 6px 14px;
  border-radius: 4px;
  color: #bdc3c7;
  text-decoration: none;
  font-size: 0.95em;
  transition: all 0.15s;
}

.nav-link:hover { background: #34495e; color: white; }
.nav-link.active { background: #eaf2f8; color: #2E86C1; font-weight: bold; }

.nav-user { display: flex; align-items: center; gap: 0.75rem; }

.user-badge {
  font-size: 0.85em;
  color: #bdc3c7;
}

.btn-logout {
  background: none;
  border: 1px solid #e74c3c;
  color: #e74c3c;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9em;
  transition: all 0.15s;
}

.btn-logout:hover { background: #e74c3c; color: white; }

/* ---- Main Content ---- */
.main-content {
  padding: 20px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ---- Page Header ---- */
.page-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #2c3e50;
}

.page-subtitle {
  font-size: 0.85rem;
  color: #888;
}

/* ---- Alerts ---- */
.alert {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-success {
  background: #eafaf1;
  border: 1px solid #a9dfbf;
  color: #1e8449;
}

.alert-error {
  background: #fdedec;
  border: 1px solid #f5b7b1;
  color: #c0392b;
}

/* ---- Stats Grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-label {
  font-size: 0.85em;
  color: #888;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.8em;
  font-weight: bold;
  color: #2E86C1;
}

.stat-tag {
  font-size: 0.75em;
  color: #aaa;
  margin-top: 4px;
}

/* ---- Charts ---- */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.charts-row.two-col {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 900px) {
  .charts-row,
  .charts-row.two-col { grid-template-columns: 1fr; }
}

.chart-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chart-title {
  font-size: 0.85em;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

/* ---- Login Page ---- */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f5f5f5;
  padding: 2rem;
}

.login-card {
  background: white;
  border-radius: 8px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-icon {
  font-size: 2rem;
  color: #2E86C1;
  margin-bottom: 0.75rem;
  display: block;
}

.login-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 0.25rem;
}

.login-header p {
  color: #888;
  font-size: 0.9rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
}

.form-group input {
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px 12px;
  color: #333;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: #2E86C1;
  box-shadow: 0 0 0 3px rgba(46,134,193,0.1);
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 10px;
  background: #2E86C1;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.15s;
  margin-top: 0.5rem;
}

.btn-primary:hover { background: #2471a3; }

.login-hint {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: #aaa;
}

.login-hint code {
  background: #f0f0f0;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  color: #555;
}

/* ---- Filter Bar ---- */
.filter-bar { margin-bottom: 16px; }

.filter-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-select {
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px 10px;
  color: #333;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
}

.filter-select:focus { border-color: #2E86C1; }

.btn-filter {
  padding: 6px 16px;
  background: #2E86C1;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-filter:hover { background: #2471a3; }

.btn-reset {
  padding: 6px 14px;
  background: transparent;
  color: #888;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-reset:hover { border-color: #888; color: #333; }

/* ---- Data Table ---- */
.table-wrapper {
  background: white;
  border-radius: 8px;
  overflow-x: auto;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table thead { background: #2E86C1; }

.data-table th {
  padding: 12px;
  text-align: left;
  color: white;
  font-weight: 600;
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  color: #333;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f9f9f9; }

.id-cell   { color: #aaa !important; font-size: 0.85rem !important; }
.page-cell { color: #2E86C1 !important; }
.session-cell { font-size: 0.8rem !important; color: #aaa !important; }
.agent-cell   { font-size: 0.85rem !important; }
.time-cell    { font-size: 0.82rem !important; white-space: nowrap; color: #888 !important; }
.empty-row    { text-align: center; padding: 2rem !important; color: #aaa !important; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-pageview      { background: #eaf2f8; color: #2E86C1; }
.badge-click         { background: #f4ecf7; color: #8e44ad; }
.badge-scroll        { background: #fef9e7; color: #d4a017; }
.badge-form_submit   { background: #eafaf1; color: #1e8449; }
.badge-video_play    { background: #fdedec; color: #c0392b; }
.badge-performance   { background: #eaf2f8; color: #2E86C1; }
.badge-activity      { background: #f4ecf7; color: #8e44ad; }
.badge-error         { background: #fdedec; color: #c0392b; }
.badge-static_extended { background: #eafaf1; color: #1e8449; }
.badge-test          { background: #fef9e7; color: #d4a017; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  color: #555;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  background: white;
}

.page-btn:hover  { border-color: #2E86C1; color: #2E86C1; }
.page-btn.active { background: #2E86C1; border-color: #2E86C1; color: white; font-weight: 600; }

.page-info {
  margin-left: auto;
  font-size: 0.85rem;
  color: #888;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row, .charts-row.two-col { grid-template-columns: 1fr; }
}