:root {
  color-scheme: light;
  --background: oklch(0.985 0.003 247);
  --foreground: oklch(0.18 0.015 260);
  --card: oklch(1 0 0);
  --popover: oklch(1 0 0);
  --primary: oklch(0.205 0.012 260);
  --primary-foreground: oklch(0.985 0.003 247);
  --secondary: oklch(0.955 0.005 247);
  --secondary-foreground: oklch(0.22 0.014 260);
  --muted: oklch(0.94 0.006 247);
  --muted-foreground: oklch(0.49 0.018 260);
  --accent: oklch(0.945 0.007 247);
  --accent-foreground: oklch(0.2 0.014 260);
  --destructive: oklch(0.55 0.19 25);
  --success: oklch(0.48 0.13 150);
  --warning: oklch(0.62 0.14 65);
  --info: oklch(0.5 0.12 250);
  --border: oklch(0.895 0.008 247);
  --border-strong: oklch(0.77 0.014 247);
  --input: oklch(0.86 0.011 247);
  --ring: oklch(0.55 0.025 260);
  --shadow-card: 0 1px 2px rgb(15 23 42 / 0.05);
  --shadow-pop: 0 18px 50px rgb(15 23 42 / 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--foreground);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
}

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

button:not(:disabled),
[role="button"]:not(:disabled) {
  cursor: pointer;
}

a {
  color: inherit;
}

.page.admin-page,
.admin-login-page {
  min-height: 100vh;
  padding: 18px 24px 48px;
  background: var(--background);
}

.admin-login-page {
  display: grid;
  place-items: center;
}

.page-content,
.admin-shell {
  width: min(100%, 1320px);
  margin: 0 auto;
}

.page-content--narrow {
  width: min(100%, 420px);
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: -18px -24px 18px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: color-mix(in oklch, var(--card) 94%, transparent);
  backdrop-filter: blur(12px);
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.admin-nav a {
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  position: relative;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.admin-nav a:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.admin-nav a[aria-current="page"] {
  border-color: var(--border);
  background: var(--secondary);
  color: var(--foreground);
}

.admin-nav a[aria-current="page"]::before {
  content: "";
  width: 2px;
  border-radius: 999px;
  position: absolute;
  left: 4px;
  top: 7px;
  bottom: 7px;
  background: var(--primary);
}

.admin-topbar form {
  margin: 0;
}

.admin-page-header {
  margin: 0 0 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.admin-page-header h1,
.admin-login h1 {
  margin: 0;
  color: var(--foreground);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
}

.admin-page-header p:not(.eyebrow),
.admin-login p:not(.eyebrow) {
  max-width: 760px;
  margin: 6px 0 0;
  color: var(--muted-foreground);
  font-size: 13px;
  line-height: 1.5;
}

.eyebrow,
.admin-section-kicker {
  margin: 0 0 6px;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.test-order-panel,
.admin-login {
  width: 100%;
  margin: 0;
  padding: 16px;
  border: 1px solid color-mix(in oklch, var(--border) 75%, transparent);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow-card);
}

.admin-login {
  max-width: 420px;
}

.admin-login__header {
  margin-bottom: 18px;
}

.admin-error {
  margin: 10px 0 0;
  color: var(--destructive);
  font-size: 13px;
}

label {
  color: var(--foreground);
  font-size: 12px;
  font-weight: 650;
}

.test-order-panel label,
.admin-login label,
.bridge-panel label {
  display: block;
  margin: 12px 0 6px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--input);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--card);
  color: var(--foreground);
  font-size: 13px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}

select {
  appearance: auto;
}

input::placeholder,
textarea::placeholder {
  color: color-mix(in oklch, var(--muted-foreground) 78%, white);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--ring) 24%, transparent);
}

button,
.admin-header-link,
.bridge-link,
.receipt-table-link {
  min-height: 32px;
  border: 1px solid var(--input);
  border-radius: 6px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--foreground);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease;
}

button:hover,
.admin-header-link:hover,
.bridge-link:hover,
.receipt-table-link:hover {
  border-color: var(--border-strong);
  background: var(--accent);
}

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

.test-order-panel > button,
.admin-login button,
[data-create-room],
[data-connect-room],
[data-check-room],
[data-cleanup-start],
[data-open-cleanup-create],
[data-refresh-receipts],
[data-refresh-status],
[data-refresh-cleanup] {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.test-order-panel > button:hover,
.admin-login button:hover,
[data-create-room]:hover,
[data-connect-room]:hover,
[data-check-room]:hover,
[data-cleanup-start]:hover,
[data-open-cleanup-create]:hover,
[data-refresh-receipts]:hover,
[data-refresh-status]:hover,
[data-refresh-cleanup]:hover {
  background: color-mix(in oklch, var(--primary) 88%, white);
}

[data-cleanup-stop] {
  border-color: color-mix(in oklch, var(--destructive) 32%, white);
  background: color-mix(in oklch, var(--destructive) 8%, white);
  color: color-mix(in oklch, var(--destructive) 84%, black);
}

[data-cleanup-stop]:hover {
  border-color: color-mix(in oklch, var(--destructive) 44%, white);
  background: color-mix(in oklch, var(--destructive) 13%, white);
}

.admin-topbar button,
.copy-input__button,
.receipt-pagination button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.copy-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
}

.copy-input__button {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

.bridge-workflow-panel {
  padding: 14px;
}

.bridge-dashboard {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.admin-workflow-header {
  margin: 0 0 12px;
}

.admin-workflow-header h2,
.bridge-panel__header h2,
.receipt-table-toolbar h2,
.receipt-recent-header h2,
.admin-section-header h2,
.receipt-config-panel h2 {
  margin: 0;
  color: var(--foreground);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

.admin-workflow-header p,
.bridge-panel__header p,
.admin-section-header p,
.receipt-table-toolbar p,
.receipt-admin-empty {
  margin: 4px 0 0;
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 1.45;
}

.bridge-panel__header {
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.bridge-panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  background: var(--card);
}

.bridge-panel > button,
.bridge-panel .bridge-actions {
  margin-top: auto;
}

.bridge-step {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--secondary);
  color: var(--foreground);
  font-size: 12px;
  font-weight: 800;
}

.bridge-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.bridge-actions .bridge-link {
  margin-top: 12px;
}

.bridge-output {
  min-height: 18px;
  margin-top: 10px;
  display: block;
  color: var(--muted-foreground);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.test-order-panel.admin-settings-panel {
  display: grid;
  gap: 12px;
}

.test-order-panel.admin-settings-panel .receipt-toggle {
  width: min(100%, 640px);
  min-height: 44px;
  padding: 8px 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.test-order-panel.admin-settings-panel .receipt-toggle + .receipt-toggle {
  border-top: 1px solid var(--border);
}

.test-order-panel.admin-settings-panel .receipt-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.test-order-panel.admin-settings-panel .receipt-switch {
  width: 32px;
  height: 18px;
  border: 1px solid var(--input);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  background: var(--muted);
  transition: background 150ms ease, border-color 150ms ease;
}

.test-order-panel.admin-settings-panel .receipt-switch::after {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.16);
  transition: transform 150ms ease;
}

.test-order-panel.admin-settings-panel .receipt-toggle input:checked + .receipt-switch {
  border-color: var(--primary);
  background: var(--primary);
}

.test-order-panel.admin-settings-panel .receipt-toggle input:checked + .receipt-switch::after {
  transform: translateX(14px);
}

.test-order-panel.admin-settings-panel .receipt-toggle input:focus-visible + .receipt-switch {
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--ring) 24%, transparent);
}

.test-order-panel.admin-settings-panel .receipt-toggle--number {
  grid-template-columns: minmax(0, 1fr) 120px;
}

.test-order-panel.admin-settings-panel .receipt-toggle--number input {
  position: static;
  width: 100%;
  height: 36px;
  min-height: 36px;
  opacity: 1;
  pointer-events: auto;
}

.test-order-panel.admin-settings-panel .receipt-toggle strong,
.test-order-panel.admin-settings-panel .receipt-toggle small {
  display: block;
}

.test-order-panel.admin-settings-panel .receipt-toggle small {
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.test-order-panel.admin-settings-panel .bridge-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 2px;
}

.test-order-panel.admin-settings-panel [data-save-settings] {
  min-height: 32px;
  padding: 0 12px;
}

.bridge-json {
  min-height: 112px;
  max-height: 260px;
  margin: 12px 0 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  color: var(--foreground);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.receipt-ai-stats,
.chat-cleanup-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.chat-cleanup-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.receipt-ai-stat,
.chat-cleanup-kpis div {
  min-width: 0;
  min-height: 76px;
  padding: 12px;
  border: 1px solid color-mix(in oklch, var(--border) 82%, transparent);
  border-radius: 8px;
  background: color-mix(in oklch, var(--muted) 68%, white);
}

.receipt-ai-stat span,
.chat-cleanup-kpis span {
  display: block;
  color: var(--foreground);
  font-size: 21px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.receipt-ai-stat strong {
  display: block;
  margin-top: 8px;
  color: var(--foreground);
  font-size: 12px;
}

.receipt-ai-stat small,
.chat-cleanup-kpis small {
  display: block;
  margin-top: 5px;
  color: var(--muted-foreground);
  font-size: 11px;
  line-height: 1.35;
}

.receipt-ai-stat--success {
  border-color: color-mix(in oklch, var(--success) 26%, white);
  background: color-mix(in oklch, var(--success) 8%, white);
}

.receipt-ai-stat--bad {
  border-color: color-mix(in oklch, var(--destructive) 22%, white);
  background: color-mix(in oklch, var(--destructive) 7%, white);
}

.receipt-ai-stat--warning {
  border-color: color-mix(in oklch, var(--warning) 24%, white);
  background: color-mix(in oklch, var(--warning) 9%, white);
}

.receipt-table-panel,
.chat-cleanup-events {
  overflow: hidden;
}

.receipt-table-toolbar,
.receipt-recent-header {
  margin: 0 0 12px;
  padding: 8px;
  border: 1px solid color-mix(in oklch, var(--border) 75%, transparent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: color-mix(in oklch, var(--card) 82%, var(--muted));
}

.receipt-table-filters {
  min-width: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 190px 190px 150px;
  align-items: end;
  gap: 8px;
}

.upload-log-filters {
  grid-template-columns: minmax(260px, 1fr) 190px 190px 150px;
}

.upload-log-table {
  min-width: 1180px;
}

.upload-log-request {
  max-width: 220px;
  margin-top: 3px;
  display: block;
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-log-error {
  max-width: 280px;
  color: var(--muted-foreground);
}

.receipt-table-filters label {
  display: grid;
  gap: 4px;
  margin: 0;
}

.receipt-table-filters span {
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 800;
}

.receipt-table-search {
  min-width: 0;
}

.admin-toolbar-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.admin-toolbar-actions button,
.order-status-toolbar button,
.receipt-uploads-toolbar button,
.cleanup-table-toolbar button {
  min-height: 34px;
}

.receipt-admin-table-wrap {
  min-height: 180px;
  overflow: auto;
  border: 1px solid color-mix(in oklch, var(--border) 75%, transparent);
  border-radius: 10px;
  background: var(--card);
}

.receipt-admin-table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.order-status-table {
  min-width: 980px;
}

.order-status-panel .receipt-admin-table-wrap {
  min-height: 140px;
}

.order-status-row {
  cursor: pointer;
}

.order-status-row:hover,
.order-status-row:focus {
  background: var(--accent);
  outline: none;
}

.order-status-toolbar__left,
.order-status-toolbar__right {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.receipt-admin-table th,
.receipt-admin-table td {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.receipt-admin-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-top: 0;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.receipt-row {
  cursor: pointer;
}

.receipt-row:hover,
.receipt-row:focus {
  background: var(--accent);
  outline: none;
}

.receipt-table-link {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.receipt-pagination {
  min-height: 36px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted-foreground);
  font-size: 12px;
}

.receipt-pagination__buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.receipt-page-size {
  height: 28px;
  border: 1px solid var(--input);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  background: var(--card);
}

.receipt-page-size > span {
  padding: 0 8px;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 800;
}

.receipt-page-size button {
  min-height: 26px;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.receipt-page-size button[aria-current="true"] {
  background: var(--secondary);
  color: var(--foreground);
}

.admin-badge,
.receipt-status-ok,
.receipt-status-bad {
  min-height: 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  background: var(--secondary);
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.admin-badge--success,
.receipt-status-ok {
  border-color: color-mix(in oklch, var(--success) 26%, white);
  background: color-mix(in oklch, var(--success) 10%, white);
  color: color-mix(in oklch, var(--success) 78%, black);
}

.admin-badge--warning {
  border-color: color-mix(in oklch, var(--warning) 28%, white);
  background: color-mix(in oklch, var(--warning) 12%, white);
  color: color-mix(in oklch, var(--warning) 78%, black);
}

.receipt-status-bad {
  border-color: color-mix(in oklch, var(--destructive) 26%, white);
  background: color-mix(in oklch, var(--destructive) 10%, white);
  color: color-mix(in oklch, var(--destructive) 80%, black);
}

.receipt-webhook-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.receipt-admin-details {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.receipt-admin-details div,
.receipt-admin-files li {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
}

.receipt-admin-details dt {
  margin: 0 0 4px;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 800;
}

.receipt-admin-details dd {
  margin: 0;
  color: var(--foreground);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.receipt-copy-block {
  margin-top: 12px;
}

.receipt-copy-block label {
  display: block;
  margin: 0 0 6px;
}

.receipt-copy-block a {
  margin-top: 6px;
  display: inline-flex;
  color: var(--foreground);
  font-size: 12px;
  font-weight: 700;
}

.receipt-admin-subtitle {
  margin: 16px 0 8px;
  font-size: 14px;
}

.receipt-admin-files {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.receipt-admin-files a {
  display: block;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 700;
}

.receipt-admin-files span {
  margin-top: 4px;
  display: block;
  color: var(--muted-foreground);
  font-size: 11px;
}

.receipt-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.receipt-modal-actions button {
  min-height: 32px;
}

.chat-cleanup-grid {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

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

.chat-cleanup-panel .bridge-actions {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.chat-cleanup-conditions {
  margin: 14px 0 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 9px;
  background: var(--muted);
}

.chat-cleanup-conditions legend,
.chat-cleanup-status-filter > label {
  padding: 0 6px;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-cleanup-conditions label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--foreground);
  font-size: 13px;
}

.chat-cleanup-conditions input {
  width: 16px;
  height: 16px;
}

.chat-cleanup-status-filter {
  margin: 14px 0 4px;
  display: grid;
  gap: 8px;
}

.chat-cleanup-status-chips {
  min-height: 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-cleanup-status-chip {
  gap: 6px;
}

.chat-cleanup-status-chip button {
  width: 16px;
  height: 16px;
  min-height: 16px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: transparent;
  color: inherit;
}

.chat-cleanup-status-chip button:hover {
  background: color-mix(in oklch, var(--border) 60%, transparent);
}

.chat-cleanup-status-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.chat-cleanup-reasons {
  margin-top: 12px;
}

.chat-cleanup-events {
  width: 100%;
  margin-top: 12px;
}

.chat-cleanup-events code,
.chat-cleanup-msid,
.receipt-admin-table td:nth-child(6) {
  color: var(--muted-foreground);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.admin-section-header {
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.admin-header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-back-link {
  min-height: 28px;
  margin: 0 0 8px;
  display: inline-flex;
  align-items: center;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.admin-back-link:hover {
  color: var(--foreground);
}

.cleanup-runs-panel,
.cleanup-detail-summary {
  width: 100%;
}

.cleanup-table-toolbar {
  min-height: 50px;
}

.cleanup-table-heading {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cleanup-runs-table th,
.cleanup-runs-table td,
.cleanup-events-table th,
.cleanup-events-table td {
  white-space: nowrap;
}

.cleanup-runs-table th:first-child,
.cleanup-runs-table td:first-child,
.cleanup-events-table th:last-child,
.cleanup-events-table td:last-child {
  white-space: normal;
}

.cleanup-create-modal .receipt-modal__dialog {
  width: min(760px, calc(100vw - 32px));
}

.cleanup-create-form {
  display: grid;
  gap: 16px;
}

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

.cleanup-form-grid label,
.cleanup-form-section {
  min-width: 0;
}

.cleanup-form-grid label {
  margin: 0;
  display: grid;
  gap: 6px;
}

.cleanup-form-grid label > span,
.cleanup-form-section h3 {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
}

.cleanup-form-section {
  display: grid;
  gap: 8px;
}

.cleanup-option-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  overflow: hidden;
  background: var(--card);
}

.cleanup-option-list label {
  min-height: 40px;
  margin: 0;
  padding: 0 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--foreground);
  font-size: 13px;
  font-weight: 700;
}

.cleanup-option-list label:first-child {
  border-top: 0;
}

.cleanup-option-list input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

.cleanup-rule-builder {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  overflow: hidden;
  background: var(--card);
}

.cleanup-rule-row {
  min-height: 48px;
  padding: 10px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 74px minmax(130px, 0.8fr) auto minmax(140px, 1fr) 42px;
  align-items: center;
  gap: 8px;
}

.cleanup-rule-row:first-child {
  border-top: 0;
}

.cleanup-rule-row select,
.cleanup-rule-actions select {
  min-width: 0;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--muted);
  color: var(--foreground);
  font: inherit;
  font-weight: 700;
}

.cleanup-rule-row select:disabled {
  opacity: 1;
  color: var(--foreground);
  -webkit-text-fill-color: var(--foreground);
}

.cleanup-rule-join,
.cleanup-rule-operator {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 850;
}

.cleanup-rule-join {
  text-transform: uppercase;
}

.cleanup-rule-value {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  background: var(--muted);
  color: var(--foreground);
  font-size: 13px;
  font-weight: 800;
}

.cleanup-rule-days {
  min-width: 0;
  margin: 0;
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(72px, 100px) auto;
  align-items: center;
  gap: 8px;
}

.cleanup-rule-days input {
  height: 34px;
}

.cleanup-rule-days span {
  color: var(--foreground);
  font-size: 13px;
  font-weight: 800;
}

.cleanup-rule-status-value {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.cleanup-rule-remove {
  width: 34px;
  height: 34px;
  justify-self: end;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--muted-foreground);
  font-size: 18px;
  font-weight: 850;
  line-height: 1;
}

.cleanup-rule-remove:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.cleanup-rule-actions {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px;
}

.cleanup-rule-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.cleanup-rule-empty {
  padding: 14px;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 700;
}

.cleanup-dialog-footer {
  margin: 4px -16px -16px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.cleanup-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.test-order-panel .receipt-toggle,
.receipt-toggle {
  width: auto;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--foreground);
  font-size: 12px;
  font-weight: 700;
}

.test-order-panel .receipt-toggle input,
.receipt-toggle input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
}

.integration-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}

.integration-row {
  min-height: 68px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.integration-row h3 {
  margin: 0;
  font-size: 14px;
}

.integration-row p {
  margin: 4px 0 0;
  color: var(--muted-foreground);
  font-size: 12px;
}

.integration-switch {
  width: 46px;
  min-height: 26px;
  height: 26px;
  border: 1px solid var(--input);
  border-radius: 999px;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  background: var(--secondary);
}

.integration-switch__thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: block;
  background: var(--card);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.2);
  transition: transform 150ms ease;
}

.integration-switch.is-on {
  border-color: var(--primary);
  background: var(--primary);
}

.integration-switch.is-on .integration-switch__thumb {
  transform: translateX(20px);
}

.has-open-modal {
  overflow: hidden;
}

.receipt-modal[hidden] {
  display: none;
}

.receipt-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
}

.receipt-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 0.42);
}

.receipt-modal__dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(840px, calc(100vh - 32px));
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  background: var(--popover);
  box-shadow: var(--shadow-pop);
}

.upload-log-modal__dialog {
  width: min(900px, calc(100vw - 32px));
}

.upload-log-details dd {
  overflow-wrap: anywhere;
}

.receipt-modal__header {
  min-height: 64px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.receipt-modal__header h2 {
  margin: 0;
  font-size: 17px;
}

.receipt-modal__close {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  color: var(--muted-foreground);
}

.receipt-modal__body {
  max-height: calc(min(840px, calc(100vh - 32px)) - 64px);
  overflow: auto;
  padding: 16px;
}

@media (max-width: 980px) {
  .bridge-dashboard,
  .chat-cleanup-grid {
    grid-template-columns: 1fr;
  }

  .receipt-ai-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cleanup-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .upload-log-filters {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .page.admin-page,
  .admin-login-page {
    padding: 14px 14px 40px;
  }

  .admin-topbar {
    margin: -14px -14px 14px;
    padding: 8px 14px;
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-page-header,
  .receipt-table-toolbar,
  .receipt-recent-header,
  .admin-section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .receipt-table-filters label,
  .receipt-table-search {
    min-width: 100%;
    width: 100%;
  }

  .receipt-ai-stats,
  .receipt-table-filters,
  .upload-log-filters,
  .cleanup-form-grid,
  .cleanup-kpi-grid,
  .chat-cleanup-form-grid,
  .chat-cleanup-kpis,
  .receipt-admin-details {
    grid-template-columns: 1fr;
  }

  .admin-header-actions,
  .admin-toolbar-actions,
  .cleanup-dialog-footer {
    width: 100%;
  }

  .admin-header-actions > *,
  .admin-toolbar-actions > *,
  .cleanup-dialog-footer > * {
    flex: 1 1 auto;
  }

  .bridge-actions,
  .chat-cleanup-panel .bridge-actions,
  .cleanup-rule-actions,
  .chat-cleanup-status-input-row {
    grid-template-columns: 1fr;
  }

  .cleanup-rule-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .cleanup-rule-remove {
    justify-self: stretch;
    width: 100%;
  }

  .receipt-pagination {
    align-items: stretch;
    flex-direction: column;
  }
}
