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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f5f7fa;
  color: #1a1a2e;
  line-height: 1.5;
}

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

header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: white;
  padding: 20px;
  margin-bottom: 24px;
  border-radius: 12px;
}

header h1 {
  font-size: 24px;
  font-weight: 600;
}

header p {
  opacity: 0.8;
  font-size: 14px;
  margin-top: 4px;
}

.card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1a1a2e;
}

.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #444;
}

/* Dropzone */
.dropzone {
  border: 2px dashed #ccd;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfc;
}

.dropzone:hover,
.dropzone.active {
  border-color: #0066ff;
  background: #f0f7ff;
}

.dropzone p {
  color: #666;
  font-size: 14px;
}

.dropzone .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

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

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: #555;
}

.form-group input,
.form-group select {
  padding: 10px 12px;
  border: 1px solid #dde;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #0066ff;
}

/* Filters */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f5f7fa;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.filter-item:hover {
  background: #e8ecf2;
}

.filter-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.filter-item label {
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

/* Tolerances */
.tolerance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.tolerance-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tolerance-item label {
  font-size: 13px;
  color: #555;
}

.tolerance-item input[type="range"] {
  width: 100%;
}

.tolerance-value {
  font-size: 13px;
  color: #0066ff;
  font-weight: 500;
}

/* Period selector */
.period-selector {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.period-btn {
  padding: 8px 16px;
  border: 1px solid #dde;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.period-btn:hover {
  border-color: #0066ff;
}

.period-btn.active {
  background: #0066ff;
  color: white;
  border-color: #0066ff;
}

/* Button */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #0066ff;
  color: white;
}

.btn-primary:hover {
  background: #0052cc;
}

.btn-primary:disabled {
  background: #99c2ff;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
  margin-top: 20px;
}

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

.stat-item {
  text-align: center;
  padding: 16px;
  background: #f5f7fa;
  border-radius: 8px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: #0066ff;
}

.stat-label {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

/* Charts */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.chart-container {
  height: 300px;
  position: relative;
}

/* Listings */
.listings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.listings-table th,
.listings-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid #eef;
}

.listings-table th {
  font-weight: 600;
  color: #555;
  background: #f9fafc;
}

.listings-table tr:hover {
  background: #f5f7fa;
}

.listings-table a {
  color: #0066ff;
  text-decoration: none;
}

.listings-table a:hover {
  text-decoration: underline;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #666;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #eef;
  border-top-color: #0066ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

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

/* Message */
.message {
  padding: 16px;
  border-radius: 8px;
  font-size: 14px;
}

.message.info {
  background: #e3f2fd;
  color: #1565c0;
}

.message.warning {
  background: #fff3e0;
  color: #e65100;
}

/* Confidence badge */
.confidence-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.confidence-high {
  background: #e8f5e9;
  color: #2e7d32;
}

.confidence-medium {
  background: #fff3e0;
  color: #ef6c00;
}

.confidence-low {
  background: #ffebee;
  color: #c62828;
}

/* Two columns layout */
.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

/* Login page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: white;
  padding: 48px;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.login-logo {
  margin-bottom: 24px;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 8px;
}

.login-card > p {
  color: #666;
  font-size: 14px;
  margin-bottom: 32px;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 24px;
  background: white;
  border: 1px solid #dde;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-google:hover {
  background: #f5f7fa;
  border-color: #ccc;
}

.login-hint {
  margin-top: 24px;
  font-size: 12px;
  color: #999;
}

/* Loading screen */
.loading-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-screen .spinner {
  width: 40px;
  height: 40px;
  margin: 0;
}

.loading-screen p {
  color: #666;
  font-size: 14px;
}

/* User info in header */
.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info span {
  font-size: 14px;
  opacity: 0.9;
}

.btn-logout {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Screenshot upload preview */
.dropzone.has-files {
  border-color: #10b981;
  background: #f0fdf4;
}

.uploaded-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-thumbnails {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.preview-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
}

.preview-more {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
}

.btn-clear-files {
  margin-top: 8px;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear-files:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

/* Admin styles */
.btn-admin {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  color: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-admin:hover {
  background: rgba(255, 255, 255, 0.25);
}

.admin-form {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.admin-form h3 {
  margin-bottom: 16px;
}

.btn-action {
  padding: 4px 10px;
  margin-right: 4px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action:hover {
  background: #e5e7eb;
}

.btn-action.btn-danger {
  color: #dc2626;
}

.btn-action.btn-danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Repair Estimate styles */
.repair-estimate {
  border-left: 4px solid #f59e0b;
}

.repair-breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.repair-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  background: #fefce8;
  border-radius: 6px;
}

.repair-damage {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.repair-type {
  font-weight: 500;
  text-transform: capitalize;
}

.repair-panel {
  color: #666;
  font-size: 13px;
}

.repair-count {
  background: #fbbf24;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.repair-rule {
  color: #888;
  font-size: 12px;
  text-align: right;
}

.repair-cost {
  font-weight: 600;
  color: #b45309;
  min-width: 80px;
  text-align: right;
}

.repair-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 2px solid #fbbf24;
  font-weight: 600;
}

.repair-total-value {
  font-size: 24px;
  color: #b45309;
}

/* URL Input styles */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.url-input-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.url-input-row {
  display: flex;
  gap: 8px;
}

.url-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #dde;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.url-input:focus {
  outline: none;
  border-color: #0066ff;
}

.url-input:disabled {
  background: #f5f7fa;
  cursor: not-allowed;
}

.url-submit-btn {
  padding: 12px 20px;
  white-space: nowrap;
}

.url-error {
  color: #dc2626;
  font-size: 13px;
  margin: 0;
}

.upload-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #999;
  font-size: 13px;
}

.upload-divider::before,
.upload-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}
