body {
  margin: 0;
  padding: 0;
  color: #1d1d1f;
}

/* ---- Page Layout ---- */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

/* ---- Header ---- */
.page-header {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e5e5e7;
}
.page-header h1 {
  color: #1d1d1f;
  font-size: 32px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.5px;
}
.page-header .subtitle {
  color: #86868b;
  margin: 6px 0 0;
  font-size: 15px;
}
.btn-logout {
  color: #86868b;
}

/* ---- Filter Panel ---- */
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid #d2d2d7;
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #1d1d1f;
  margin-bottom: 16px;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.filter-toggle:hover { background: #f5f5f7; border-color: #b0b0b5; }
.filter-toggle .chevron {
  font-size: 10px;
  color: #86868b;
  transition: transform 0.25s ease;
}
.filter-toggle .chevron.open { transform: rotate(180deg); }
.filter-badge {
  background: #0066cc;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.filter-panel {
  background: white;
  border: 1px solid #e5e5e7;
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
  display: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.filter-panel.open { display: block; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.filter-group > label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #86868b;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.filter-group input,
.filter-group select {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: #f5f5f7;
  color: #1d1d1f;
  transition: all 0.2s;
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: #0066cc;
  background: white;
  box-shadow: 0 0 0 3px rgba(0,102,204,0.12);
}
.filter-group input::placeholder { color: #b0b0b5; }
.date-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  margin-top: 16px;
  font-size: 12px;
  font-weight: 600;
  color: #86868b;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.15s;
}
.date-toggle:hover { color: #1d1d1f; }
.date-toggle-icon {
  font-size: 8px;
  transition: transform 0.2s;
  display: inline-block;
}
.date-toggle-icon.open {
  transform: rotate(90deg);
}
.date-toggle-badge {
  background: #0066cc;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}
.filter-date-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.filter-date-pair label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #86868b;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.date-range {
  display: flex;
  gap: 8px;
  align-items: center;
}
.date-range input {
  flex: 1;
  padding: 9px 10px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: #f5f5f7;
  color: #1d1d1f;
  transition: all 0.2s;
}
.date-range input:focus {
  outline: none;
  border-color: #0066cc;
  background: white;
  box-shadow: 0 0 0 3px rgba(0,102,204,0.12);
}
.date-range span { color: #b0b0b5; font-size: 12px; font-weight: 500; }
.filter-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f2;
  display: flex;
  gap: 12px;
  align-items: center;
}
.btn-apply {
  background: #0066cc;
  color: white;
  border: none;
  padding: 9px 28px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-apply:hover { background: #0055b3; }
.btn-reset {
  background: none;
  border: none;
  color: #86868b;
  font-size: 14px;
  cursor: pointer;
  padding: 9px 16px;
  font-weight: 500;
  transition: color 0.2s;
}
.btn-reset:hover { color: #1d1d1f; }

/* ---- Tab Bar ---- */
.tab-bar {
  display: inline-flex;
  gap: 0;
  background: #f0f0f2;
  padding: 3px;
  border-radius: 10px;
  margin-bottom: 20px;
}
.tab-btn {
  padding: 9px 28px;
  font-size: 14px;
  border: none;
  background: transparent;
  color: #86868b;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.tab-btn:hover { color: #1d1d1f; }
.tab-btn.active {
  background: white;
  color: #1d1d1f;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  font-weight: 600;
}

/* ---- Results Toolbar ---- */
.results-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  color: #86868b;
}
.results-count { font-weight: 600; color: #1d1d1f; }
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sort-control {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sort-control label {
  font-size: 13px;
  font-weight: 500;
  color: #86868b;
  white-space: nowrap;
}
.sort-control select {
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: white;
  color: #1d1d1f;
  cursor: pointer;
  transition: all 0.2s;
}
.sort-control select:focus {
  outline: none;
  border-color: #0066cc;
}
.sort-dir-btn {
  width: 34px;
  height: 34px;
  border: 1px solid #d2d2d7;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #1d1d1f;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.sort-dir-btn:hover { background: #f5f5f7; border-color: #b0b0b5; }
.btn-export {
  background: white;
  border: 1px solid #d2d2d7;
  padding: 7px 16px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  color: #1d1d1f;
  font-weight: 500;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn-export:hover { background: #f5f5f7; border-color: #b0b0b5; }

/* ---- Table ---- */
.table-wrapper {
  max-height: 620px;
  overflow: auto;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  background: white;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
th {
  background: #0066cc;
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  color: white;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  position: sticky;
  top: 0;
  z-index: 10;
  cursor: default;
  user-select: none;
  border-bottom: none;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f2;
  color: #1d1d1f;
}
tbody tr:nth-child(even) td { background: #fafafa; }
tbody tr:hover td { background: #f0f4ff; }
td.num {
  text-align: right;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  letter-spacing: -0.2px;
}
td.po-col {
  font-weight: 600;
  color: #0066cc;
}
a.po-link {
  color: #0066cc;
  text-decoration: none;
  font-weight: 600;
}
a.po-link:hover {
  text-decoration: underline;
}

/* Sticky first column */
th.col-sticky, td.col-sticky {
  position: sticky;
  left: 0;
  z-index: 5;
}
th.col-sticky {
  z-index: 15;
  background: #0066cc;
}
td.col-sticky { background: white; }
tbody tr:nth-child(even) td.col-sticky { background: #fafafa; }
tbody tr:hover td.col-sticky { background: #f0f4ff; }

/* Flags */
.flags-cell { display: flex; gap: 3px; flex-wrap: nowrap; }
.flag-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 13px;
  cursor: help;
  border-radius: 6px;
  transition: background 0.15s;
}
.flag-badge:hover { background: #e8f0fe; }

/* ---- Pagination ---- */
.pagination-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  font-size: 13px;
  color: #86868b;
  flex-wrap: wrap;
  gap: 12px;
}
.pagination-info { font-weight: 500; color: #6e6e73; }
.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pg-btn {
  width: 34px;
  height: 34px;
  border: 1px solid #d2d2d7;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  color: #1d1d1f;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.pg-btn:hover { background: #f5f5f7; border-color: #b0b0b5; }
.pg-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.pg-input {
  width: 52px;
  text-align: center;
  padding: 6px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 13px;
  background: #f5f5f7;
}
.pg-input:focus { outline: none; border-color: #0066cc; background: white; }
.pg-current {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6e6e73;
}
.pagination-size select {
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: white;
  color: #1d1d1f;
  cursor: pointer;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 72px 20px;
  color: #b0b0b5;
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.6; }
.empty-state h3 {
  margin: 0 0 8px;
  color: #6e6e73;
  font-size: 17px;
  font-weight: 600;
}
.empty-state p { margin: 0; font-size: 14px; }

/* ---- Column Config Modal ---- */
.btn-columns {
  background: white;
  border: 1px solid #d2d2d7;
  padding: 7px 16px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  color: #1d1d1f;
  font-weight: 500;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn-columns:hover { background: #f5f5f7; border-color: #b0b0b5; }
.col-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.col-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.col-modal {
  background: white;
  border-radius: 14px;
  width: 440px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: scale(0.95);
  transition: transform 0.2s;
}
.col-modal-overlay.open .col-modal {
  transform: scale(1);
}
.col-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #f5f5f7;
  border-radius: 14px 14px 0 0;
  border-bottom: 1px solid #e5e5e7;
}
.col-modal-header span {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
}
.col-modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 20px;
  color: #86868b;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.col-modal-close:hover { background: #e5e5e7; color: #1d1d1f; }
.col-modal-views {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid #f0f0f2;
}
.col-modal-views label {
  font-size: 13px;
  font-weight: 500;
  color: #86868b;
  white-space: nowrap;
}
.col-modal-views select {
  flex: 1;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: white;
  color: #1d1d1f;
  cursor: pointer;
}
.col-modal-views select:focus { outline: none; border-color: #0066cc; }
.col-view-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.col-view-save {
  background: #0066cc;
  color: white;
}
.col-view-save:hover { background: #0055b3; }
.col-view-delete {
  background: transparent;
  color: #ff3b30;
}
.col-view-delete:hover { background: #fff0f0; }
.col-view-delete:disabled {
  color: #d2d2d7;
  cursor: not-allowed;
  background: transparent;
}
.col-modal-list {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  padding: 4px 0;
}
.col-modal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  border-bottom: 1px solid #f5f5f7;
  transition: background 0.1s;
}
.col-modal-item:hover { background: #f5f5f7; }
.col-modal-item.dragging { opacity: 0.4; background: #e8f0fe; }
.col-modal-item.drag-over { box-shadow: 0 -2px 0 0 #0066cc inset; }
.col-modal-item.unchecked { opacity: 0.5; }
.col-modal-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #0066cc;
  flex-shrink: 0;
}
.col-modal-item .col-label {
  flex: 1;
  font-size: 14px;
  color: #1d1d1f;
  user-select: none;
}
.col-drag-handle {
  cursor: grab;
  color: #b0b0b5;
  font-size: 15px;
  user-select: none;
  padding: 2px 4px;
  line-height: 1;
}
.col-drag-handle:active { cursor: grabbing; }
.col-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid #e5e5e7;
  background: #f5f5f7;
  border-radius: 0 0 14px 14px;
}
.col-modal-footer .col-footer-left {
  display: flex;
  gap: 4px;
}
.col-footer-btn {
  background: none;
  border: none;
  color: #86868b;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 12px;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s;
}
.col-footer-btn:hover { color: #1d1d1f; background: #e5e5e7; }
.col-apply-btn {
  background: #0066cc;
  color: white;
  border: none;
  padding: 8px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.col-apply-btn:hover { background: #0055b3; }

/* ---- Analytics Dashboard ---- */
.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  text-align: center;
}
.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.kpi-card .kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi-card.kpi-alert .kpi-value { color: #ff3b30; }
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) {
  .chart-row { grid-template-columns: 1fr; }
}
.chart-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.chart-card h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
}
.chart-card canvas {
  max-height: 260px;
}
.analytics-tables {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 1100px) {
  .analytics-tables { grid-template-columns: 1fr; }
}
.analytics-table-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  overflow-x: auto;
}
.analytics-table-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
}
.analytics-table-card table {
  font-size: 12px;
  white-space: nowrap;
}
.analytics-table-card th {
  background: #f5f5f7;
  color: #1d1d1f;
  font-size: 11px;
  padding: 8px 10px;
  position: static;
}
.analytics-table-card td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0f2;
}
.analytics-loading {
  text-align: center;
  padding: 80px 20px;
  color: #86868b;
  font-size: 15px;
}
.analytics-loading::before {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  border: 2.5px solid #e5e5e7;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 14px;
}

.hidden { display: none !important; }
