:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --danger: #b42318;
  --success: #067647;
  --warning: #b54708;
  --shadow: 0 20px 50px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, #eef2ff 0, transparent 34rem), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

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

button {
  border: 0;
  border-radius: 0.75rem;
  cursor: pointer;
  font-weight: 700;
  padding: 0.75rem 1rem;
}

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

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  color: var(--text);
  outline: none;
  padding: 0.75rem 0.9rem;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

textarea {
  min-height: 180px;
  resize: vertical;
}

code {
  background: #f2f4f7;
  border-radius: 0.35rem;
  padding: 0.15rem 0.35rem;
}

.shell {
  margin: 0 auto;
  max-width: none;
  padding: clamp(0.75rem, 2vw, 2rem);
  width: 100%;
}

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

.eyebrow {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0 0 0.4rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  letter-spacing: -0.06em;
  line-height: 0.95;
  margin-bottom: 0.7rem;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

.subtitle {
  color: var(--muted);
  margin-bottom: 0;
  max-width: 720px;
}

.hero-actions,
.table-actions,
.toolbar,
.inline-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-actions {
  display: grid;
  flex: 1 1 720px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  justify-content: flex-end;
  max-width: 1120px;
  width: 100%;
}

.primary {
  background: var(--primary);
  color: white;
}

.primary:hover {
  background: var(--primary-dark);
}

.ghost {
  background: #eef2ff;
  color: var(--primary-dark);
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  margin-bottom: 1rem;
}

.card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(228, 231, 236, 0.9);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  padding: 1.25rem;
}

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

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.9rem;
  font-weight: 700;
  gap: 0.45rem;
}

.compact-label {
  min-width: 0;
}

.compact-label input,
.compact-label select {
  padding: 0.5rem 0.65rem;
}

#searchInput {
  min-width: 0;
}

.muted {
  color: var(--muted);
}

.balance-box {
  display: grid;
  gap: 0.55rem;
}

.metric-row {
  display: flex;
  justify-content: space-between;
}

.counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

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

.pager-actions {
  align-items: center;
  display: flex;
  gap: 0.6rem;
}

.pill,
.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
}

.pill {
  background: #f2f4f7;
  color: #344054;
}

.status {
  background: #eef2ff;
  color: var(--primary-dark);
}

.status.success {
  background: #dcfae6;
  color: var(--success);
}

.status.error,
.status.failed,
.status.submit_failed,
.status.refunded {
  background: #fee4e2;
  color: var(--danger);
}

.status.pending,
.status.running,
.status.submitting,
.status.processing {
  background: #fef0c7;
  color: var(--warning);
}

.check {
  align-items: center;
  display: inline-flex;
  gap: 0.4rem;
}

.check input {
  width: auto;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 1rem;
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 1080px;
  table-layout: fixed;
  width: 100%;
}

.col-email {
  width: 14%;
}

.col-secret {
  width: 9%;
}

.col-link {
  width: 6%;
}

.col-status {
  width: 16%;
}

.col-error {
  width: 17%;
}

.col-pixel {
  width: 8%;
}

.col-mode {
  width: 8%;
}

.col-channel {
  width: 5%;
}

.col-updated {
  width: 8%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f9fafb;
  color: #475467;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-width: 140px;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
}

.email-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-cell {
  cursor: pointer;
}

.copy-cell:hover {
  background: #f8faff;
}

.secret-cell {
  align-items: center;
  display: flex;
  gap: 0.35rem;
  min-width: 0;
}

.secret-value {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-cell {
  max-height: 128px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
}

.pixel-error {
  align-items: start;
  display: flex;
  gap: 0.35rem;
}

.pixel-error-translation {
  color: #344054;
  min-width: 0;
}

.icon-btn {
  align-items: center;
  background: #eef2ff;
  border: 0;
  border-radius: 999px;
  color: var(--primary-dark);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 900;
  height: 1.35rem;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 1.35rem;
}

.icon-btn:hover {
  background: #e0e7ff;
}

.link-cell {
  display: flex;
  gap: 0.35rem;
}

.mini {
  border-radius: 0.5rem;
  font-size: 0.78rem;
  padding: 0.35rem 0.55rem;
}

.reveal-btn {
  flex: 0 0 auto;
}

.status-line {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.status-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-cell {
  display: grid;
  gap: 0.25rem;
}

.status.review-completed {
  background: #dcfae6;
  color: var(--success);
}

.status.review-error {
  background: #fee4e2;
  color: var(--danger);
}

.status.review-skipped {
  background: #f2f4f7;
  color: #344054;
}

.status.review-none {
  background: #eef2ff;
  color: var(--primary-dark);
}

.review-note-preview {
  color: #344054;
  display: -webkit-box;
  font-size: 0.86rem;
  line-height: 1.35;
  max-height: 3.6em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.modal {
  align-items: center;
  background: rgba(16, 24, 40, 0.48);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 10;
}

.modal-card {
  background: white;
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 1rem;
  max-width: 620px;
  padding: 1.25rem;
  width: min(100%, 620px);
}

.modal-head,
.modal-actions {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

#modalReviewNote {
  min-height: 150px;
}

#translationSource,
#translationText {
  min-height: 120px;
}

.review-meta {
  font-size: 0.78rem;
}

.toast {
  background: #101828;
  border-radius: 0.9rem;
  bottom: 1rem;
  box-shadow: var(--shadow);
  color: white;
  left: 50%;
  max-width: min(90vw, 640px);
  padding: 0.8rem 1rem;
  position: fixed;
  transform: translateX(-50%);
  z-index: 5;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .shell {
    padding: 0.9rem;
  }

  .hero,
  .card-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .hero-actions,
  .toolbar,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions button,
  .toolbar button,
  .inline-form button {
    width: 100%;
  }

  .table-actions {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
    max-width: none;
  }

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

  .modal-head,
  .modal-actions {
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  h1 {
    font-size: clamp(2.25rem, 16vw, 3.25rem);
  }

  .card {
    border-radius: 1rem;
    padding: 1rem;
  }

  textarea {
    min-height: 140px;
  }

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

  .pager-actions {
    flex-wrap: wrap;
  }

  .pager-actions button {
    flex: 1 1 120px;
  }

  .table-wrap {
    border: 0;
    border-radius: 0;
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  colgroup,
  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 0.9rem;
  }

  tr {
    background: white;
    border: 1px solid var(--line);
    border-radius: 1rem;
    box-shadow: 0 12px 28px rgba(16, 24, 40, 0.06);
    padding: 0.65rem 0.85rem;
  }

  td {
    align-items: start;
    border-bottom: 1px solid #eef2f6;
    display: grid;
    gap: 0.55rem;
    grid-template-columns: minmax(92px, 32%) minmax(0, 1fr);
    padding: 0.65rem 0;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  .empty {
    display: block;
    padding: 1.25rem;
  }

  .empty::before {
    content: "";
    display: none;
  }

  .email-cell {
    white-space: normal;
    word-break: break-word;
  }

  .secret-cell,
  .link-cell {
    justify-content: flex-start;
  }

  .secret-value {
    white-space: normal;
    word-break: break-word;
  }

  .error-cell {
    max-height: none;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    border-radius: 1.25rem 1.25rem 0 0;
    max-height: 92vh;
    overflow: auto;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .shell {
    padding: 0.65rem;
  }

  .card {
    padding: 0.85rem;
  }

  button {
    padding: 0.7rem 0.85rem;
  }

  td {
    grid-template-columns: 1fr;
  }

  td::before {
    margin-bottom: -0.25rem;
  }

  .counts {
    display: grid;
  }

  .pill {
    justify-content: center;
  }

  .toast {
    bottom: 0.65rem;
    max-width: calc(100vw - 1.3rem);
  }
}
