:root {
  --bg-main: #f5f7fb;
  --bg-card: #ffffff;
  --bg-card-muted: #f0f3fa;
  --border-subtle: #e4e7f1;
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-strong: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --info: #0ea5e9;
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius-lg: 16px;
  --radius-md: 10px;
  --transition-fast: 0.2s ease;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg-main);
  background-image: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(37, 99, 235, 0.06), transparent), radial-gradient(ellipse 60% 40% at 80% 100%, rgba(99, 102, 241, 0.04), transparent);
  color: var(--text-main);
  font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  margin: 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.reports-container {
  max-width: 1440px;
  margin: 24px auto;
  padding: 4px clamp(16px, 3vw, 32px) 30px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.page-title {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0b2a59;
}

.page-title span.emoji {
  font-size: 1.4rem;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.summary-chip {
  background: var(--accent-soft);
  color: #0b2a59;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
}

.right-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.right-header-actions .pill {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  flex-wrap: wrap;
}

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-group-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.filter-date {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 8px 14px;
  font-size: 0.85rem;
  background: #ffffff;
  color: var(--text-main);
  min-width: 150px;
  min-height: 38px;
}

.filter-date:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.apply-filter-btn {
  border-radius: 999px;
  border: none;
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  background: #0b2a59;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.3);
  white-space: nowrap;
  min-height: 38px;
}

.apply-filter-btn:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.4);
}

.apply-filter-btn:active {
  transform: translateY(0);
}

.download-btn {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  min-height: 38px;
}

.download-btn:hover {
  background: var(--bg-card-muted);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.6);
}

.summary-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 26px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 992px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .filter-date,
  .apply-filter-btn,
  .download-btn {
    min-height: 44px;
  }

  .filter-date {
    font-size: 16px;
  }
}

@media (max-width: 768px) {
  .table-wrapper {
    display: none;
  }

  .team-cards {
    display: flex;
  }
}

@media (max-width: 640px) {
  .reports-container {
    padding: 18px 14px 30px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .action-bar {
    flex-direction: column;
    align-items: stretch;
    border-radius: 18px;
    padding: 14px;
  }

  .filters {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .filter-date {
    flex: 1 1 auto;
    width: 100%;
  }

  .apply-filter-btn {
    width: 100%;
    justify-content: center;
  }

  .summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .details-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .download-btn {
    width: 100%;
    justify-content: center;
  }

  .primary-stat .stat-value {
    font-size: 2.2rem;
  }
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.18);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.12);
}

.large-card {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 60%, #6366f1 100%);
  color: #fff;
  border: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px;
}

.large-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
}

.card-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.primary-stat .stat-value {
  font-size: 2.8rem;
  line-height: 1.05;
}

.primary-stat .stat-value .unit {
  font-size: 0.5em;
  font-weight: 500;
  opacity: 0.9;
  margin-left: 4px;
}

.secondary-stat .stat-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.secondary-stat .stat-value {
  font-size: 1.5rem;
  color: var(--text-main);
}

.stat-trend {
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
}

.trend-up {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.trend-down {
  background: rgba(248, 113, 113, 0.12);
  color: #dc2626;
}

.stat-meta {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.details-section {
  margin-top: 4px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-lg);
  padding: 18px 18px 10px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(18px);
  transition: box-shadow 0.3s ease;
}

.details-section:hover {
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.12);
}

.details-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.details-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.table-wrapper {
  max-height: 320px;
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  -webkit-overflow-scrolling: touch;
}

.team-cards {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.team-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.team-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 600;
}

.team-card-target {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.team-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.team-card-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.team-card-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.team-card-value {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

body.dark-mode .team-card {
  background: #2a2a2a;
  border-color: #555;
  color: #f1f1f1;
}

body.dark-mode .team-card-label,
body.dark-mode .team-card-target {
  color: #ddd;
}

body.dark-mode .team-card-value {
  color: #f1f1f1;
}

.performance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.performance-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-card-muted);
}

.performance-table th,
.performance-table td {
  padding: 11px 14px;
  text-align: left;
}

.performance-table th {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.performance-table tbody tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.04);
}

.performance-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.06);
}

.performance-table td {
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-weight: 500;
  font-size: 0.85rem;
}

.stat-small-wrapper {
  display: flex;
  gap: 20px;
  margin-top: 8px;
}

.stat-small {
  text-align: center;
}

.stat-value.small {
  font-size: 22px;
  opacity: 0.8;
}

.stat-text {
  font-size: 14px;
  color: #6b7280;
  margin-top: 2px;
}

.large-card .stat-label {
  color: rgba(255, 255, 255, 0.8);
}

.large-card .stat-value {
  color: #fff !important;
}

.large-card .stat-text {
  color: rgba(255, 255, 255, 0.7);
}

.large-card .stat-value.small {
  color: rgba(255, 255, 255, 0.9) !important;
}

.unit {
  font-size: 11px;
}

#error-message {
  display: none;
  color: #dc2626;
  margin: 10px 2px;
  padding: 10px 14px;
  background: rgba(220, 38, 38, 0.08);
  border-radius: 8px;
  border-left: 3px solid #dc2626;
}

body.dark-mode {
  background-color: #1e1e1e;
  color: #f1f1f1;
}

body.dark-mode .reports-container {
  background-color: #1e1e1e;
  color: #f1f1f1;
}

body.dark-mode .stat-card {
  background-color: #2a2a2a;
  border: 1px solid #555;
  box-shadow: none;
}

body.dark-mode .large-card {
  background: linear-gradient(135deg, #1a2744 0%, #1e3a5f 60%, #2a4080 100%);
  color: #fff;
}

body.dark-mode .card-icon {
  background-color: #333;
  color: #f1f1f1;
}

body.dark-mode .stat-label,
body.dark-mode .stat-meta,
body.dark-mode .section-subtitle,
body.dark-mode .stat-text {
  color: #ddd;
}

body.dark-mode .stat-value {
  color: #f1f1f1;
}

body.dark-mode .secondary-stat .stat-value {
  color: #f1f1f1;
}

body.dark-mode .apply-filter-btn {
  background: #0b2a59;
  color: #fff;
  box-shadow: none;
}

body.dark-mode .download-btn {
  background-color: #333;
  border-color: #555;
  color: #f1f1f1;
}

body.dark-mode .action-bar {
  background-color: #2a2a2a;
  border: 1px solid #555;
  box-shadow: none;
}

body.dark-mode .details-section {
  background-color: #1e1e1e;
  color: #f1f1f1;
  border: 1px solid #555;
}

body.dark-mode .table-wrapper {
  border-color: #555;
}

body.dark-mode .performance-table thead {
  background-color: #333 !important;
  color: #fff !important;
}

body.dark-mode .performance-table tbody {
  color: #ddd;
}

body.dark-mode .performance-table td {
  border-color: #555;
  background-color: #2a2a2a;
}

body.dark-mode .filter-date {
  background-color: #333;
  border: 1px solid #555;
  color: #fff;
}
