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

:root {
  --navy: #1e3a5f;
  --navy-light: #2a4d7a;
  --navy-dark: #152d4a;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --green-light: #86efac;
  --green-dark: #22c55e;
  --red: #ef4444;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 150ms ease;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* === Navbar === */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy);
  color: var(--white);
  box-shadow: var(--shadow-md);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-logo {
  width: 32px;
  height: 32px;
  background: var(--white);
  color: var(--navy);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

.nav-title {
  font-weight: 700;
  font-size: 1.1rem;
}

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

.nav-link {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
  color: var(--white);
  background: rgba(255,255,255,0.1);
}

.nav-link.active {
  background: rgba(255,255,255,0.15);
}

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

.role-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-avatar {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  cursor: pointer;
  transition: var(--transition);
}

.nav-avatar:hover { background: rgba(255,255,255,0.2); }

.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--white);
  border-radius: 1px;
  transition: var(--transition);
}

.nav-mobile-menu {
  background: var(--navy-dark);
  padding: 0.5rem 1rem 1rem;
}

.nav-mobile-link {
  display: block;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.95rem;
}

.nav-mobile-link:hover { color: var(--white); }

@media (max-width: 768px) {
  .nav-links, .nav-user { display: none; }
  .nav-hamburger { display: flex; }
}

/* === Pages === */
.page { min-height: calc(100vh - 56px); }

.page-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-800);
}

/* === Cards === */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-100);
}

/* === Forms === */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}

input:focus, select:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500 !important;
  color: var(--gray-700) !important;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--navy);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--navy-light);
}

.btn-primary:active {
  background: var(--navy-dark);
}

.btn-primary:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
}

.btn-outline:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-full { width: 100%; }

.btn-loading { pointer-events: none; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* === Login === */
.login-container {
  min-height: 100vh;
  display: flex;
}

.login-hero {
  display: none;
  flex: 1;
  background: var(--navy);
  color: var(--white);
  align-items: center;
  justify-content: center;
}

.login-hero-inner {
  text-align: center;
  padding: 2rem;
}

.login-logo-big {
  width: 80px;
  height: 80px;
  background: var(--white);
  color: var(--navy);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 32px;
  margin-bottom: 1.5rem;
}

.login-hero h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.login-hero p {
  color: rgba(255,255,255,0.7);
  font-size: 1rem;
}

.login-form-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--white);
}

.login-form-inner {
  width: 100%;
  max-width: 360px;
}

.login-form-inner h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--gray-800);
}

@media (min-width: 769px) {
  .login-hero { display: flex; }
}

/* === Upload Zone === */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--navy);
  background: rgba(30,58,95,0.02);
}

.upload-placeholder p {
  margin-top: 0.75rem;
  font-weight: 500;
  color: var(--gray-600);
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--gray-400);
}

.upload-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.upload-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
  object-fit: contain;
}

/* === Estimate Grid === */
.estimate-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 769px) {
  .estimate-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* === Confidence Bar === */
.confidence-bar-wrap { margin-bottom: 1.25rem; }

.confidence-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 0.35rem;
}

.confidence-bar {
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  background: var(--green-dark);
  border-radius: 4px;
  transition: width 0.6s ease;
  width: 0%;
}

/* === Stats === */
.extraction-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 500px) {
  .extraction-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  text-align: center;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 500;
  margin-top: 0.15rem;
}

/* === Tables === */
.table-wrap { overflow-x: auto; }

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

.table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-100);
}

.table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.table tbody tr:hover {
  background: var(--gray-50);
}

.table tbody tr.clickable {
  cursor: pointer;
}

.text-right { text-align: right; }

.cogs-col { /* toggled by JS for manager role */ }

/* === Gauge === */
.gauge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.5rem 0 1.5rem;
  position: relative;
}

#gaugeCanvas {
  max-width: 300px;
  width: 100%;
  height: auto;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 280px;
  margin-top: -0.25rem;
}

.gauge-label {
  font-size: 0.8rem;
  font-weight: 600;
}

.gauge-low { color: var(--gray-400); }
.gauge-mid { color: #4ade80; }
.gauge-high { color: var(--green-dark); }

/* === Price Input === */
.price-input-wrap {
  margin-bottom: 1.25rem;
}

.price-input-wrap > label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0.35rem;
}

.price-input-group {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

.price-input-group:focus-within {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(30,58,95,0.1);
}

.price-prefix {
  padding: 0.6rem 0.75rem;
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 600;
  font-size: 1rem;
  border-right: 1px solid var(--gray-200);
}

.price-input-group input {
  border: none;
  box-shadow: none;
  font-size: 1.1rem;
  font-weight: 600;
}

.price-input-group input:focus {
  box-shadow: none;
}

.band-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
}

.band-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.band-indicator.band-gray {
  background: #f3f4f6;
  color: var(--gray-600);
}
.band-indicator.band-gray .band-dot { background: var(--gray-400); }

.band-indicator.band-light-green {
  background: #ecfdf5;
  color: #065f46;
}
.band-indicator.band-light-green .band-dot { background: var(--green-light); }

.band-indicator.band-dark-green {
  background: #dcfce7;
  color: #14532d;
}
.band-indicator.band-dark-green .band-dot { background: var(--green-dark); }

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
  position: relative;
}

.modal-lg {
  max-width: 600px;
  text-align: left;
  max-height: 80vh;
  overflow-y: auto;
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-icon { margin-bottom: 1rem; }

.modal h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.modal p {
  color: var(--gray-500);
  margin-bottom: 1.5rem;
}

.modal-band {
  margin-bottom: 1.25rem;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--gray-400);
}

/* === Status badges === */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-submitted {
  background: #dbeafe;
  color: #1e40af;
}

.status-draft {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* === Detail modal sections === */
.detail-section {
  margin-bottom: 1rem;
}

.detail-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 0.5rem;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.detail-meta-item {
  font-size: 0.85rem;
}

.detail-meta-item strong {
  display: block;
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 500;
}

/* === Utility === */
.text-green { color: var(--green-dark); }
.text-gray { color: var(--gray-400); }
.mt-1 { margin-top: 0.5rem; }
