:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-soft: #eef3f1;
  --ink: #17241f;
  --muted: #64726d;
  --line: #dce5e1;
  --green: #176b52;
  --green-dark: #104a3b;
  --gold: #9a6a1f;
  --red: #9b3d30;
  --blue: #2f6287;
  --shadow: 0 14px 36px rgba(27, 45, 38, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Roboto, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  min-height: 42px;
  padding: 0 16px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border-radius: 8px;
  background: var(--green-dark);
  color: #fff;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: #bfe1d5;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 40px);
}

h2 {
  font-size: 18px;
}

.icon-button {
  background: #eaf3ef;
  color: var(--green-dark);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions form {
  margin: 0;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  display: grid;
  gap: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-panel h1 {
  color: var(--green-dark);
  font-size: 28px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form button {
  width: 100%;
}

.login-error {
  margin: 0;
  color: var(--red);
  font-size: 14px;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.metric,
.panel,
.filters {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 104px;
  padding: 18px;
}

.metric span,
.panel-heading span,
label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(190px, 1.2fr) repeat(2, minmax(150px, 0.8fr)) auto;
  gap: 12px;
  padding: 16px;
  margin-bottom: 18px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input,
select {
  min-height: 42px;
}

textarea {
  min-height: 150px;
  padding: 12px;
  resize: vertical;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 18px;
  margin-bottom: 18px;
}

.import-panel {
  margin-bottom: 18px;
}

.import-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(240px, 1.4fr) auto auto;
  gap: 12px;
  align-items: end;
}

.captcha-box {
  display: grid;
  grid-template-columns: auto minmax(180px, 260px) auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.captcha-box[hidden] {
  display: none;
}

.captcha-box img {
  max-width: 180px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.html-import {
  margin-top: 12px;
}

.import-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.import-actions span {
  color: var(--muted);
  font-size: 14px;
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.store-bars,
.chat-list,
.receipt-list {
  display: grid;
  gap: 10px;
}

.store-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.store-name,
.receipt-store {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.bar-track {
  grid-column: 1 / -1;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.chat-card,
.receipt-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.chat-card {
  display: grid;
  gap: 6px;
}

.chat-card strong {
  font-size: 16px;
}

.receipt-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 16px;
  align-items: center;
}

.receipt-meta {
  color: var(--muted);
  font-size: 13px;
}

.receipt-value {
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 800;
  text-align: right;
}

.receipt-card button {
  grid-column: 1 / -1;
  justify-self: start;
  background: var(--blue);
}

.status {
  margin-bottom: 12px;
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

dialog {
  width: min(760px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(12, 24, 19, 0.56);
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-heading button {
  background: var(--red);
}

#dialogBody {
  display: grid;
  gap: 12px;
  max-height: 70vh;
  overflow: auto;
  padding: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

@media (max-width: 900px) {
  .metrics,
  .content-grid,
  .filters,
  .import-grid,
  .captcha-box {
    grid-template-columns: 1fr 1fr;
  }

  .filters button,
  .import-grid button,
  .captcha-box button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .topbar,
  .panel-heading,
  .receipt-card {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .metrics,
  .filters,
  .import-grid,
  .captcha-box,
  .content-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .metrics {
    gap: 10px;
  }

  .metric {
    min-height: 88px;
  }

  .receipt-card {
    grid-template-columns: 1fr;
  }

  .receipt-value {
    text-align: left;
  }

  .pagination {
    justify-content: stretch;
  }

  .pagination button {
    flex: 1;
  }
}
