/* ============ Reset & Base ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
}

/* ============ Layout ============ */
.header {
  background: linear-gradient(135deg, #1a237e, #283593);
  color: #fff;
  padding: 20px 0;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header h1 {
  font-size: 1.6rem;
  font-weight: 600;
}

.header p {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-top: 4px;
}

.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}

/* ============ Cards ============ */
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  background: #f5f6fa;
  padding: 14px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  border-bottom: 1px solid #e8eaed;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 20px;
}

/* ============ Form ============ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

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

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}

.form-group input,
.form-group select {
  padding: 8px 10px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #1a237e;
  box-shadow: 0 0 0 2px rgba(26, 35, 126, 0.12);
}

/* ============ File Upload ============ */
.upload-area {
  border: 2px dashed #c5cae9;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbff;
}

.upload-area:hover {
  border-color: #1a237e;
  background: #f0f1ff;
}

.upload-area.has-file {
  border-color: #43a047;
  background: #f1f8e9;
}

.upload-area input[type="file"] {
  display: none;
}

.upload-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.upload-text {
  font-size: 0.9rem;
  color: #666;
}

.upload-filename {
  font-weight: 600;
  color: #43a047;
  margin-top: 6px;
}

/* ============ Buttons ============ */
.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: #1a237e;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #283593;
}

.btn-success {
  background: #43a047;
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: #388e3c;
}

.btn-demo {
  background: #ff8f00;
  color: #fff;
}

.btn-demo:hover:not(:disabled) {
  background: #ff6f00;
}

.btn-download {
  background: #0277bd;
  color: #fff;
}

.btn-download:hover:not(:disabled) {
  background: #01579b;
}

/* ============ Summary Stats ============ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.stat-card {
  padding: 16px;
  border-radius: 8px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  margin-top: 4px;
  font-weight: 600;
}

.stat-total {
  background: #e8eaf6;
  color: #1a237e;
}

.stat-pass {
  background: #e8f5e9;
  color: #2e7d32;
}

.stat-warning {
  background: #fff8e1;
  color: #f57f17;
}

.stat-alert {
  background: #ffebee;
  color: #c62828;
}

.stat-delta {
  background: #fce4ec;
  color: #ad1457;
}

/* ============ Delta Breakdown ============ */
.delta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.delta-table th,
.delta-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.delta-table th {
  background: #f5f6fa;
  font-weight: 600;
  color: #555;
}

.delta-table td:nth-child(n + 2) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============ Results Table ============ */
.results-table-wrap {
  overflow-x: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.results-table th {
  background: #1a237e;
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.results-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

.results-table td:nth-child(n + 5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.results-table tbody tr:hover {
  background: #f5f6fa;
}

/* Status row colors */
.row-pass {
  background: #f1f8e9;
}

.row-warning {
  background: #fff8e1;
}

.row-alert {
  background: #ffebee;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-pass {
  background: #c8e6c9;
  color: #2e7d32;
}

.badge-warning {
  background: #ffecb3;
  color: #e65100;
}

.badge-alert {
  background: #ffcdd2;
  color: #b71c1c;
}

/* ============ Filter Tabs ============ */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 6px 16px;
  border: 1px solid #d0d5dd;
  border-radius: 20px;
  font-size: 0.82rem;
  cursor: pointer;
  background: #fff;
  font-weight: 600;
  transition: all 0.2s;
}

.filter-tab:hover {
  background: #e8eaf6;
}

.filter-tab.active {
  background: #1a237e;
  color: #fff;
  border-color: #1a237e;
}

/* ============ Loading & Messages ============ */
.loading {
  text-align: center;
  padding: 40px;
  color: #888;
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid #e8eaf6;
  border-top-color: #1a237e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.error-msg {
  color: #c62828;
  background: #ffebee;
  padding: 12px 16px;
  border-radius: 6px;
  margin-top: 12px;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .btn-row {
    flex-direction: column;
  }

  .btn {
    justify-content: center;
  }
}
