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

:root {
  /* Clark Construction brand */
  --navy:        #1B2B47;
  --navy-dark:   #111D36;
  --navy-mid:    #243660;
  --navy-light:  #2E4478;
  --gold:        #C8A330;
  --gold-dark:   #A88A25;
  --gold-light:  #E8C84A;
  --gold-bg:     #FBF6E7;

  /* Semantic aliases */
  --primary:      var(--navy);
  --primary-dark: var(--navy-dark);

  /* Neutrals */
  --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;

  /* Status */
  --danger:  #C81E1E;
  --success: #057A55;

  --radius:    6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
  --shadow:    0 2px 10px rgba(0,0,0,0.10);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #EEF0F4;
  color: var(--gray-800);
  min-height: 100vh;
}

/* ── NAV ───────────────────────────────────────────────── */
nav {
  background: var(--navy-dark);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  border-bottom: 3px solid var(--gold);
}
nav .brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.6px;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}
nav .brand::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 28px;
  background: var(--gold);
  border-radius: 4px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%231B2B47'%3E%3Cpath d='M9 12l-4-4 1.4-1.4L9 9.2l8.6-8.6L19 2z'/%3E%3Crect x='2' y='19' width='20' height='2' rx='1'/%3E%3Crect x='2' y='15' width='14' height='2' rx='1'/%3E%3C/svg%3E");
  background-size: 18px;
  background-repeat: no-repeat;
  background-position: center;
}
nav .nav-right { display: flex; align-items: center; gap: 16px; }
nav .nav-user  { font-size: 0.82rem; color: rgba(255,255,255,0.55); letter-spacing: 0.3px; }
nav button.nav-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.85);
  padding: 6px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
nav button.nav-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
}

/* ── LAYOUT ────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* ── LOGIN PAGE ─────────────────────────────────────────── */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(150deg, var(--navy-dark) 0%, var(--navy-mid) 60%, #1a3a5c 100%);
}
.login-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  border-top: 4px solid var(--gold);
}
.login-box h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}
.login-box .subtitle {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin-bottom: 30px;
}

/* ── FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-600);
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
input[type="text"], input[type="password"], input[type="date"],
input[type="number"], textarea, select {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.92rem;
  background: white;
  color: var(--gray-800);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--navy-light);
  box-shadow: 0 0 0 3px rgba(27,43,71,0.12);
}
textarea { resize: vertical; min-height: 80px; }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  letter-spacing: 0.2px;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--navy);
  color: white;
  box-shadow: 0 2px 6px rgba(27,43,71,0.25);
}
.btn-primary:hover { background: var(--navy-dark); box-shadow: 0 3px 10px rgba(27,43,71,0.35); }

.btn-gold {
  background: var(--gold);
  color: var(--navy-dark);
  box-shadow: 0 2px 6px rgba(200,163,48,0.3);
}
.btn-gold:hover { background: var(--gold-dark); }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #046c4e; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #a61414; }

.btn-outline {
  background: white;
  color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-300); }

.btn-sm { padding: 5px 13px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 28px;
  border: 1px solid rgba(0,0,0,0.05);
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 18px;
  background: var(--gold);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── PAGE HEADER ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
}

/* ── FILTER BAR ─────────────────────────────────────────── */
.filter-bar {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  border: 1px solid rgba(0,0,0,0.05);
}
.filter-bar h3 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-500);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.filter-actions { display: flex; gap: 10px; margin-top: 14px; }

/* ── TABLE ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  text-align: left;
  padding: 11px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
th:first-child { border-radius: var(--radius) 0 0 0; }
th:last-child  { border-radius: 0 var(--radius) 0 0; }
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-700);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #F5F7FA; }

/* ── STATUS BADGES ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-submitted { background: #E0F2FE; color: #0369A1; }
.badge-reviewed  { background: var(--gold-bg); color: #92700A; }
.badge-approved  { background: #DCFCE7; color: #166534; }
.badge-rejected  { background: #FEE2E2; color: #991B1B; }

/* ── LABORERS ───────────────────────────────────────────── */
.laborers-list { display: flex; flex-wrap: wrap; gap: 4px; }
.laborer-tag {
  background: var(--gray-100);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  color: var(--gray-600);
}
.laborer-entry { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.laborer-entry .laborer-name  { flex: 1; }
.laborer-entry .laborer-hours { width: 80px; flex-shrink: 0; }
.laborer-entry button { flex-shrink: 0; }

/* ── TABS ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--gray-200);
}
.tab-btn {
  padding: 11px 22px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-500);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s;
  letter-spacing: 0.2px;
}
.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--navy); border-bottom-color: var(--gold); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── ALERTS ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 16px;
  border-left: 4px solid;
}
.alert-error   { background: #FEF2F2; color: #991B1B; border-color: var(--danger); }
.alert-success { background: #F0FDF4; color: #166534; border-color: var(--success); }
.hidden { display: none !important; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 52px 24px; color: var(--gray-400); }
.empty-state strong { display: block; font-size: 1rem; color: var(--gray-500); margin-bottom: 6px; }
.empty-state p { font-size: 0.875rem; }

/* ── STATS ROW ──────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 0;
}
.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.05);
  border-top: 3px solid var(--gold);
}
.stat-card .stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── UPLOAD ZONE ────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--gray-50);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--navy-light);
  background: #EEF1F8;
}
.upload-zone-text {
  font-size: 0.92rem;
  color: var(--gray-600);
  margin-top: 12px;
  font-weight: 500;
}
.upload-link { color: var(--navy); font-weight: 600; text-decoration: underline; cursor: pointer; }
.upload-zone-hint { font-size: 0.78rem; color: var(--gray-400); margin-top: 4px; }

/* ── EDITABLE SCAN TABLE CELLS ──────────────────────────── */
.editable-cell {
  cursor: text;
  min-width: 80px;
  max-width: 220px;
  word-break: break-word;
  border-radius: 3px;
  transition: background 0.1s;
}
.editable-cell:focus {
  outline: none;
  background: #EEF1F8;
  box-shadow: inset 0 0 0 2px var(--navy-light);
}
.editable-cell:empty::before { content: '—'; color: var(--gray-300); pointer-events: none; }
tr.scan-error-row td { background: #FFF1F2; }

/* SCAN TABLE — horizontal scroll */
#scan-table th, #scan-table td  { white-space: nowrap; }
#scan-table .editable-cell { max-width: none; min-width: 110px; }

/* ── SCHEMA FORM BAR ────────────────────────────────────── */
.form-schema-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  margin-bottom: 18px;
  font-size: 0.82rem;
  color: var(--gray-600);
}

/* ── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none !important; }
.modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 12px 50px rgba(0,0,0,0.22);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  background: var(--navy);
  color: white;
  border-radius: 12px 12px 0 0;
}
.modal-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: white;
}
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.icon-btn {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.25); }

/* ── SCHEMA LIST ────────────────────────────────────────── */
.schema-list-item {
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--gray-700);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s;
}
.schema-list-item:hover { background: var(--gray-100); }
.schema-list-item.active { background: #EEF1F8; color: var(--navy); font-weight: 600; }
.schema-active-dot { color: var(--gold); font-size: 0.7rem; }

/* ── SCHEMA EDITOR ──────────────────────────────────────── */
.schema-field-row {
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: #FAFAFA;
  transition: border-color 0.15s;
}
.schema-field-row:hover { border-color: var(--gray-300); }
.sfe-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sfe-enabled-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.sfe-enabled-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--navy); }
.field-type-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--gray-100);
  color: var(--gray-600);
}
.field-delete-btn {
  background: none;
  border: 1px solid var(--gray-200);
  color: var(--gray-500);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.field-delete-btn:hover { color: var(--danger); background: #FEE2E2; border-color: #FCA5A5; }
.schema-laborer-opts { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.schema-laborer-opts label {
  font-size: 0.82rem;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}
.schema-laborer-opts select {
  width: auto;
  padding: 3px 6px;
  font-size: 0.82rem;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
}
.se-header { margin-bottom: 4px; }
.se-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }

/* ── SCAN PROGRESS BAR ──────────────────────────────────── */
#scan-progress {
  background: #EEF1F8;
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  color: var(--navy);
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .container { padding: 16px; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .modal-body { flex-direction: column !important; }
  .modal-body > div:first-child {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid var(--gray-200);
    padding-right: 0 !important;
    padding-bottom: 16px !important;
  }
  .stats-row { grid-template-columns: 1fr 1fr; }
}
