* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f3f5f8;
  color: #172033;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  padding: 0.8rem 1rem;
  background: #0f62fe;
  color: #ffffff;
}

button:hover {
  opacity: 0.95;
}

input {
  width: 100%;
  border: 1px solid #c8d1e0;
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  background: #ffffff;
  pointer-events: auto;
  cursor: text;
}

input[readonly] {
  background: #f7f9fc;
  color: #51607a;
}

select {
  border: 1px solid #c8d1e0;
  border-radius: 8px;
  padding: 0.8rem 2.5rem 0.8rem 0.9rem;
  background: #ffffff;
  pointer-events: auto;
  cursor: pointer;
}

textarea {
  width: 100%;
  border: 1px solid #c8d1e0;
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  background: #ffffff;
  resize: vertical;
  pointer-events: auto;
  cursor: text;
}

h1,
h2,
h3,
p {
  margin: 0;
}

label {
  pointer-events: auto;
  cursor: pointer;
}

.eyebrow {
  color: #51607a;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.muted-text {
  color: #51607a;
  line-height: 1.5;
  margin-top: 0.75rem;
}

.hidden {
  display: none;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 1.5rem;
  background: #ffffff;
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(23, 32, 51, 0.08);
}

.login-form {
  display: grid;
  gap: 0.85rem;
}

.error-text {
  color: #b42318;
  background: #fee4e2;
  border-radius: 8px;
  padding: 0.85rem 1rem;
}

.app-shell {
  min-height: 100vh;
  padding: 1.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-control {
  display: grid;
  gap: 0.35rem;
  color: #51607a;
  font-size: 0.85rem;
}

.phone-search-form {
  display: grid;
  gap: 0.35rem;
}

.phone-search-row {
  display: grid;
  grid-template-columns: minmax(220px, 280px) auto;
  gap: 0.5rem;
  align-items: center;
}

.field-error {
  color: #b42318;
  font-size: 0.82rem;
}

.field-success {
  color: #12715b;
  font-size: 0.82rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

.queue-panel,
.detail-panel {
  background: #ffffff;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 16px 36px rgba(23, 32, 51, 0.06);
}

.queue-panel-wide {
  width: 100%;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.pill,
.status-badge,
.flag-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  background: #e7eefc;
  color: #1c4ed8;
  font-size: 0.85rem;
}

.table-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid #e8edf5;
  border-radius: 8px;
  background: #ffffff;
}

.table-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 0.85rem;
  background: rgba(255, 255, 255, 0.88);
  color: #51607a;
  text-align: center;
  z-index: 2;
}

.table-loader.hidden,
.table-empty-state.hidden {
  display: none;
}

.table-loader p {
  font-size: 0.95rem;
}

.table-empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: #51607a;
  text-align: center;
  padding: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.receipt-table {
  min-width: 100%;
}

th,
td {
  text-align: left;
  padding: 0.95rem 0.85rem;
  border-bottom: 1px solid #e8edf5;
  vertical-align: top;
  white-space: normal;
}

th {
  position: sticky;
  top: 0;
  background: #f7f9fc;
  z-index: 1;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #51607a;
}

.receipt-table td {
  min-width: 100px;
  font-size: 0.92rem;
  line-height: 1.4;
}

tbody tr {
  cursor: pointer;
}

tbody tr.selected,
tbody tr:hover {
  background: #f7faff;
}

.row-action-button {
  padding: 0.55rem 0.85rem;
  white-space: nowrap;
}

.detail-stage {
  display: grid;
  align-content: start;
}

.detail-loader {
  min-height: 220px;
  display: grid;
  place-items: center;
  gap: 0.85rem;
  color: #51607a;
  text-align: center;
}

.detail-loader.hidden,
.detail-content.hidden {
  display: none;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #dbe4f2;
  border-top-color: #0f62fe;
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

.detail-content {
  display: grid;
  gap: 1.25rem;
}

.detail-subtitle {
  margin-top: 0.5rem;
  color: #51607a;
  line-height: 1.5;
}

.dialog-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: start center;
  padding: 2rem;
  z-index: 20;
  overflow-y: auto;
  pointer-events: auto;
}

.dialog-shell.hidden {
  display: none;
  pointer-events: none;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  z-index: -1;
}

.dialog-panel {
  position: relative;
  width: min(1480px, calc(100vw - 3rem));
  max-height: calc(100vh - 3rem);
  overflow: auto;
  margin-top: 1rem;
  padding: 1.5rem;
}

.review-dialog-panel {
  position: relative;
  width: min(760px, calc(100vw - 3rem));
  margin-top: 4rem;
}

.review-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-header {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 1rem;
}

.decision-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.decision-actions button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.approve-button {
  background: #12715b;
}

.deny-button {
  background: #b42318;
}

.secondary-button {
  background: #dbe4f2;
  color: #172033;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 30%) minmax(0, 70%);
  gap: 1rem;
  align-items: start;
}

.image-panel {
  background: #f7f9fc;
  border-radius: 8px;
  padding: 1rem;
  min-height: 420px;
  display: grid;
  align-content: start;
  gap: 0.75rem;
  position: sticky;
  top: 0;
}

.image-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.image-tool-button {
  min-width: 68px;
}

.receipt-image-frame {
  width: 100%;
  min-height: 360px;
  max-height: 560px;
  overflow: auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
}

.image-panel img {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  transform-origin: center center;
  transition: transform 0.15s ease;
}

.items-section {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.review-form-section {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid #e8edf5;
  border-radius: 8px;
  background: #f7f9fc;
}

.review-submit-row {
  display: flex;
  justify-content: flex-end;
}

.review-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.review-form-span-2 {
  grid-column: span 2;
}

.items-table-wrap {
  overflow: auto;
}

.items-table {
  table-layout: fixed;
}

.items-table th,
.items-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.items-table th:nth-child(1),
.items-table td:nth-child(1),
.items-table th:nth-child(2),
.items-table td:nth-child(2) {
  width: 24%;
}

.items-table th:nth-child(3),
.items-table td:nth-child(3) {
  width: 8%;
}

.items-table th:nth-child(4),
.items-table td:nth-child(4),
.items-table th:nth-child(5),
.items-table td:nth-child(5) {
  width: 12%;
}

.items-table th:nth-child(6),
.items-table td:nth-child(6),
.items-table th:nth-child(7),
.items-table td:nth-child(7) {
  width: 10%;
}

.empty-state-cell,
.image-placeholder {
  color: #51607a;
  text-align: center;
}

.empty-state-cell {
  padding: 1.25rem 0.85rem;
}

.image-placeholder {
  width: 100%;
  min-height: 360px;
  display: grid;
  place-items: center;
  border: 1px dashed #c8d1e0;
  border-radius: 8px;
  background: #ffffff;
  padding: 1.5rem;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1080px) {
  .phone-search-row {
    grid-template-columns: 1fr;
  }

  .review-form-grid {
    grid-template-columns: 1fr;
  }

  .review-form-span-2 {
    grid-column: span 1;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .image-panel {
    position: static;
  }

  .topbar,
  .topbar-actions,
  .detail-header {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-shell {
    padding: 0.75rem;
  }

  .dialog-panel {
    width: 100%;
    max-height: calc(100vh - 1.5rem);
    margin-top: 0;
  }

  .receipt-table,
  .items-table {
    min-width: 1200px;
  }
}
