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

:root {
  /* BKM brand */
  --orange:        #F48C3A;
  --orange-dark:   #c9721d;
  --orange-light:  #fce8d4;
  --orange-border: #f2c49a;

  /* Surfaces */
  --bg:       #e5eaed;
  --surface:  #f4f5f7;
  --white:    #ffffff;

  /* Borders & text */
  --border:   #c8d0d9;
  --text:     #1a2230;
  --muted:    #6b7a8d;

  /* Status */
  --green:    #166534;
  --green-bg: #dcfce7;
  --amber:    #b45309;
  --amber-bg: #f5ecd4;
  --red:      #b91c1c;
  --red-bg:   #fee2e2;

  --radius: 8px;
  --shadow: 0 2px 10px rgba(0,0,0,.07);
  --shadow-md: 0 4px 20px rgba(0,0,0,.10);
}

body {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 3px solid var(--orange);
  padding: 0 32px;
  height: 58px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}
.header-logo {
  height: 34px;
  width: auto;
  display: block;
}
.header-titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}
.header-app {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text);
}
.header-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: .5px;
}

/* ── Layout ─────────────────────────────────────────────────── */
.main-content { max-width: 1200px; margin: 0 auto; padding: 28px 20px 60px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 10px 22px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--orange-dark); }
.btn-primary:disabled { background: #b0bec5; cursor: not-allowed; }
.btn-primary.btn-lg { padding: 12px 30px; font-size: 14px; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 18px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color .15s, color .15s;
  letter-spacing: .3px;
}
.btn-ghost:hover {
  border-color: var(--orange);
  color: var(--orange);
  text-decoration: none;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}
.badge-gray  { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge-warn  { background: var(--amber-bg); color: var(--amber); }
.badge-error { background: var(--red-bg);   color: var(--red); }

/* ── Alert ───────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 500;
}
.alert-error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #fca5a5;
}
.alert-warn {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid #f0c97a;
}

/* ── Upload Page ─────────────────────────────────────────────── */
.upload-page {
  display: flex;
  justify-content: center;
  padding-top: 24px;
}
.upload-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px 44px;
  width: 100%;
  max-width: 540px;
}
.upload-card h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 6px;
}
.subtitle {
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.6;
  font-size: 13px;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 38px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 16px;
  background: var(--surface);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--orange);
  background: var(--orange-light);
}
.drop-zone.has-file {
  border-style: solid;
  border-color: var(--orange);
  background: var(--orange-light);
}
.drop-icon { color: var(--orange); margin-bottom: 12px; opacity: .8; }
.drop-icon svg { display: block; margin: 0 auto; }
.drop-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.file-link {
  color: var(--orange);
  cursor: pointer;
  font-weight: 700;
}
.drop-hint { font-size: 11px; color: var(--muted); letter-spacing: .3px; }

.selected-file {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--orange-light);
  border: 1px solid var(--orange-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
}
.btn-clear {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  padding: 2px 4px;
}
.btn-clear:hover { color: var(--red); }

/* ── File list (upload page) ─────────────────────────────────── */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.file-list-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 16px 0 8px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
}
.file-row-icon { font-size: 18px; flex-shrink: 0; }
.file-row-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.file-row-year {
  flex-shrink: 0;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 12px;
  font-weight: 600;
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  accent-color: var(--orange);
}
.file-row-year:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(244,140,58,.15);
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}
.footer-hint { font-size: 12px; color: var(--muted); font-weight: 600; }

.info-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.info-section h3 {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.info-section ol {
  padding-left: 18px;
  color: var(--muted);
  line-height: 2;
  font-size: 13px;
}
.info-section strong { color: var(--text); font-weight: 700; }

/* ── Verify Page ─────────────────────────────────────────────── */
.verify-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar-file {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  flex-wrap: wrap;
}
.topbar-file strong { color: var(--text); }
.file-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text);
}

/* Property Card */
.property-fields {
  display: grid;
  grid-template-columns: 2fr 1fr 2fr;
  gap: 24px;
  align-items: start;
}
.field-required {
  color: var(--orange);
  margin-left: 2px;
  cursor: help;
}
.field-group label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.field-group input[type="text"],
.field-group input[type="number"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
.field-group input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(244,140,58,.15);
  background: var(--white);
}
.occ-fields { display: flex; gap: 10px; }
.occ-year { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.occ-year span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .5px;
}
.occ-input { width: 64px; text-align: center; }

/* Year Card */
.year-card { background: var(--surface); }
.section-hint { font-size: 12px; color: var(--muted); margin-bottom: 14px; margin-top: -10px; line-height: 1.6; }
.year-assignments { display: flex; flex-direction: column; gap: 10px; }
.year-row, .year-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.year-raw-label, .chip-raw {
  min-width: 150px;
  background: var(--white);
  border: 1px solid var(--border);
  padding: 6px 11px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
}
.arrow { color: var(--muted); font-size: 16px; }
.chip-year {
  font-weight: 700;
  color: var(--orange);
  min-width: 60px;
  font-size: 12px;
}
.year-detected-list { display: flex; flex-wrap: wrap; gap: 12px; }
.year-select {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 12px;
  background: var(--white);
  cursor: pointer;
  color: var(--text);
}
.year-select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(244,140,58,.15);
}

/* Legend */
.legend {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
  letter-spacing: .3px;
}
.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
}
.dot-high { background: var(--green); }
.dot-med  { background: var(--amber); }
.dot-low  { background: var(--red); }
.dot-none { background: #b0bec5; }

/* Mapping Table */
.mapping-card { padding: 0; overflow: hidden; }
.mapping-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.mapping-header h2 { margin-bottom: 0; }
.unmapped-label { font-size: 12px; color: var(--muted); font-weight: 600; }

.table-wrap { overflow-x: auto; margin-top: 16px; }
.mapping-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.mapping-table thead tr {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
}
.mapping-table th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  white-space: nowrap;
}
.mapping-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #eef0f2;
  vertical-align: middle;
}
.map-row:last-child td { border-bottom: none; }
.map-row:hover td { background: #fdfaf7; }

/* Row highlight by confidence */
.map-row.conf-high   td:first-child { border-left: 3px solid var(--green); }
.map-row.conf-medium td:first-child { border-left: 3px solid var(--amber); }
.map-row.conf-low    td:first-child { border-left: 3px solid var(--red); }
.map-row.conf-none   td:first-child { border-left: 3px solid #b0bec5; }
.map-row.row-ignored { opacity: .4; }
.map-row.row-assigned td:first-child { border-left-color: var(--orange); }

.source-label { font-weight: 600; color: var(--text); }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.no-val { color: #c8d0d9; }

.slot-select {
  width: 100%;
  min-width: 200px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 12px;
  background: var(--white);
  cursor: pointer;
  color: var(--text);
  transition: border-color .15s;
}
.slot-select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(244,140,58,.15);
}

.conf-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 3px 9px;
  border-radius: 12px;
  white-space: nowrap;
  text-transform: uppercase;
}
.conf-badge.conf-high   { background: var(--green-bg); color: var(--green); }
.conf-badge.conf-medium { background: var(--amber-bg); color: var(--amber); }
.conf-badge.conf-low    { background: var(--red-bg);   color: var(--red); }
.conf-badge.conf-none   { background: var(--bg);       color: var(--muted); }

/* Bottom bar */
.bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
}

/* Loading Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,34,48,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.overlay-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 56px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.overlay-box p {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .3px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(244,140,58,.2);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ──────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.app-footer a { color: var(--orange); font-weight: 600; }
.app-footer a:hover { color: var(--orange-dark); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 700px) {
  .property-fields { grid-template-columns: 1fr; }
  .verify-topbar   { flex-direction: column; align-items: flex-start; }
  .bottom-bar      { flex-direction: column; gap: 12px; }
  .upload-card     { padding: 28px 20px; }
}
