* { box-sizing: border-box; }
body {
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: #f6f7f9;
  color: #1a1a1a;
  margin: 0;
  overflow-x: hidden; /* safety net — nothing should legitimately need page-wide horizontal scroll */
}
.page { max-width: 960px; margin: 0 auto; padding: 24px; }

a { color: #0B6E7A; }
a:hover { color: #095a63; }

@media (max-width: 600px) {
  .page { padding: 16px; }
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid #ddd;
}
.nav .brand { display: flex; align-items: center; }
.brand-logo { height: 42px; display: block; }
.admin-tag { font-weight: 700; color: #666; }
.nav .spacer { flex: 1; }
.nav .who { color: #666; }
.nav a { color: #0B6E7A; text-decoration: none; }
.nav a:hover { text-decoration: underline; }
.nav-badge {
  display: inline-block;
  background: #b3261e;
  color: white;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.75em;
  font-weight: 700;
}

.followup-list { display: flex; flex-direction: column; gap: 16px; }
.followup-card {
  display: flex;
  gap: 16px;
  background: white;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.followup-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.followup-body { flex: 1; }
.followup-heading { margin-bottom: 4px; }
.followup-question { font-weight: 600; margin: 8px 0 2px; }
.followup-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.followup-actions button { background: #efefef; color: #1a1a1a; }
.followup-actions button:hover { background: #ddd; }

.link-button {
  background: none;
  border: none;
  color: #0B6E7A;
  cursor: pointer;
  padding: 0;
  font-size: 1em;
  text-decoration: underline;
}
.link-button:hover { background: none; }
.link-button.danger { color: #b3261e; }
.inline { display: inline; }
.inline-form { display: flex; gap: 8px; margin-top: 16px; }
.inline-form input { flex: 1; }

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85em; color: #444; }
.filter-bar .spacer { flex: 1; }
.button-link {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 6px;
  background: #0B6E7A;
  color: white;
  font-size: 1em;
  text-decoration: none;
}
.button-link:hover { background: #095a63; }

.auth-card {
  max-width: 380px;
  margin: 60px auto;
  background: white;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9em; color: #444; }
.auth-card hr { border: none; border-top: 1px solid #eee; width: 100%; margin: 4px 0; }

.conditional-field { display: none; flex-direction: column; gap: 14px; }
.conditional-field.visible { display: flex; }

.company-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin: 16px 0 32px;
}
.company-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9em; color: #444; }
.company-form button { align-self: flex-start; }

.edit-receipt-layout { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.receipt-preview { max-width: 320px; width: 100%; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
  flex: 1;
  min-width: 280px;
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.edit-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9em; color: #444; }
.edit-form hr { border: none; border-top: 1px solid #eee; width: 100%; margin: 4px 0; }
.edit-form button { align-self: flex-start; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox-label input { width: auto; }

select {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1em;
  background: white;
}

input, textarea {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1em;
  font-family: inherit;
}

.ch-search-wrap { position: relative; }
.ch-results {
  display: none;
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}
.ch-results.visible { display: block; }
.ch-results li { padding: 8px 10px; cursor: pointer; font-size: 0.9em; }
.ch-results li:hover { background: #f2f2f2; }
.ch-results .ch-address { color: #777; font-size: 0.85em; }
button {
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: #0B6E7A;
  color: white;
  font-size: 1em;
  cursor: pointer;
}
button:hover { background: #095a63; }

.error { color: #b3261e; }
.hint { color: #666; font-size: 0.9em; }
.empty { color: #666; }

table.receipts, table.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; margin-bottom: 32px; }
table.receipts th, table.receipts td, table.data-table th, table.data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eee; }
table.receipts th, table.data-table th { background: #efefef; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }

/* Below 700px, tables read as a stack of cards (one per row) instead of a
   wide grid — labels come from each cell's data-label attribute. */
@media (max-width: 700px) {
  table.receipts, table.data-table { background: transparent; border-radius: 0; }
  table.receipts thead, table.data-table thead { display: none; }
  table.receipts tbody, table.data-table tbody { display: block; }
  table.receipts tr, table.data-table tr {
    display: block;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 12px;
    padding: 4px 14px;
  }
  table.receipts td, table.data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    text-align: right;
  }
  table.receipts tr td:last-child, table.data-table tr td:last-child { border-bottom: none; }
  table.receipts td::before, table.data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #666;
    text-align: left;
    flex-shrink: 0;
  }
  table.receipts td.cell-block, table.data-table td.cell-block {
    display: block;
    text-align: left;
  }
  table.receipts td.cell-block::before, table.data-table td.cell-block::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
  }
  table.receipts td.cell-photo, table.data-table td.cell-photo {
    justify-content: center;
    padding-top: 14px;
  }
  table.receipts td.cell-photo::before, table.data-table td.cell-photo::before { content: none; }
  table.receipts td.cell-photo .thumb { width: 72px; height: 72px; }
}

.kpi-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 16px 0 32px; }
.kpi-card {
  background: white;
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  min-width: 140px;
}
.kpi-card .value { font-size: 1.8em; font-weight: 700; }
.kpi-card .label { color: #666; font-size: 0.85em; }
.kpi-card.kpi-warn .value { color: #8a6100; }
.kpi-card.kpi-link { text-decoration: none; display: block; }
.kpi-breakdown { max-width: 480px; }

.status { padding: 2px 8px; border-radius: 10px; font-size: 0.8em; }
.status-processed { background: #dff5e1; color: #1e6b34; }
.status-failed { background: #fde2e1; color: #a31510; }
.status-needs_attention { background: #ffe3c2; color: #8a4b00; }
.status-needs_review { background: #fff4d6; color: #8a6100; }

.flags { display: flex; flex-direction: column; gap: 4px; max-width: 220px; }
.flag-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75em;
  cursor: default;
  width: fit-content;
  text-decoration: none;
}
a.flag-badge { cursor: pointer; }
.flag-good { background: #dff5e1; color: #1e6b34; }
.flag-warn { background: #fff4d6; color: #8a6100; }
.flag-info { background: #e6f0ff; color: #1a4d8f; }

.flag-line { display: flex; align-items: center; gap: 6px; }
.dismiss { font-size: 0.75em; color: #888; text-decoration: underline; }
.dismiss:hover { color: #444; }
.actions { display: flex; gap: 10px; align-items: center; white-space: nowrap; }

.sender-list { list-style: none; padding: 0; }
.sender-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #eee; }

.provider-list { display: flex; flex-direction: column; gap: 12px; max-width: 520px; margin-bottom: 24px; }
.provider-card {
  background: white;
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.provider-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.provider-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.provider-actions button { background: #efefef; color: #1a1a1a; font-size: 0.85em; padding: 8px 12px; }
.provider-actions button:hover { background: #ddd; }

.review-list { display: flex; flex-direction: column; gap: 16px; }
.review-card {
  background: white;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.review-card-header { display: flex; gap: 16px; margin-bottom: 14px; }
.review-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.review-reason { margin: 4px 0 0; }

table.review-items { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
table.review-items th, table.review-items td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #eee; font-size: 0.95em; }
table.review-items th { color: #666; font-weight: 600; font-size: 0.8em; }

.item-toggle { display: inline-flex; border: 1px solid #ddd; border-radius: 6px; overflow: hidden; }
.item-toggle-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 0;
  background: white;
  color: #444;
  font-size: 0.85em;
  cursor: pointer;
}
.item-toggle-btn:hover { background: #f2f2f2; }
.item-toggle-btn.active { background: #0B6E7A; color: white; }
.item-toggle-btn.active:hover { background: #095a63; }
.item-toggle-btn + .item-toggle-btn { border-left: 1px solid #ddd; }

.review-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.review-status-msg { font-size: 0.85em; color: #666; }

/* Below 700px, the review table reads as stacked rows like the receipts table. */
@media (max-width: 700px) {
  table.review-items thead { display: none; }
  table.review-items tbody { display: block; }
  table.review-items tr { display: block; padding: 6px 0; border-bottom: 1px solid #f0f0f0; }
  table.review-items td { display: flex; justify-content: space-between; align-items: center; border-bottom: none; padding: 4px 0; }
  table.review-items td::before { content: attr(data-label); font-weight: 600; color: #666; }
}

/* Split-screen login/register pages. .page's usual max-width/padding is
   reset here so the layout can run full-bleed edge to edge. */
.page.auth-shell { max-width: none; padding: 0; }
.auth-shell-inner { display: flex; min-height: 100vh; }

.auth-form-side {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: white;
}
.auth-marketing-side {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px;
  background: linear-gradient(135deg, #eaf4f5 0%, #f6f7f9 55%, #eef6f6 100%);
}
.auth-marketing-side h2 {
  font-size: 2em;
  line-height: 1.25;
  margin: 0 0 20px;
}
.auth-marketing-side p {
  color: #555;
  font-size: 1.05em;
  line-height: 1.6;
  max-width: 460px;
}

@media (max-width: 860px) {
  .auth-marketing-side { display: none; }
  .auth-form-side { padding: 32px 16px; }
}

.auth-form-card { width: 100%; max-width: 400px; }
.auth-form-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-form-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9em; color: #444; }
.auth-form-card hr { border: none; border-top: 1px solid #eee; width: 100%; margin: 4px 0; }
.auth-logo-mark { width: 48px; height: 48px; border-radius: 10px; display: block; margin: 0 auto 20px; }
.auth-form-card h1 { text-align: center; font-size: 1.5em; margin: 0 0 6px; }
.auth-subtitle { text-align: center; color: #666; margin: 0 0 24px; }

.social-row { display: flex; gap: 12px; margin-bottom: 20px; }
.social-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 0.9em;
  color: #1a1a1a;
  text-decoration: none;
}
.social-btn:visited { color: #1a1a1a; }
.social-btn:hover { background: #f7f7f7; }
.social-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.auth-divider { display: flex; align-items: center; gap: 12px; color: #999; font-size: 0.85em; margin: 4px 0 20px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: #e5e5e5; }

.form-row-2 { display: flex; gap: 12px; }
.form-row-2 label { flex: 1; }

.password-field-wrap { position: relative; }
.password-field-wrap input { width: 100%; padding-right: 42px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #888;
  display: flex;
}
.password-toggle:hover { background: none; color: #444; }
.password-toggle svg { width: 18px; height: 18px; }

.field-hint { font-size: 0.8em; color: #777; margin: 6px 0 0; }
.field-hint.field-error { color: #b3261e; display: flex; align-items: center; gap: 4px; }
.field-hint svg { width: 14px; height: 14px; flex-shrink: 0; }

.auth-form-card button[type="submit"] {
  width: 100%;
  padding: 12px;
  font-size: 1em;
  font-weight: 600;
}

.auth-below-card { text-align: center; margin-top: 20px; color: #444; }
.auth-terms { text-align: center; color: #888; font-size: 0.8em; margin: 28px auto 0; max-width: 400px; line-height: 1.5; padding: 0 16px 32px; }

.legal-content {
  max-width: 640px;
  margin: 40px auto;
  background: white;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  line-height: 1.6;
}
