:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #101828;
  --muted: #667085;
  --line: #d8dee8;
  --line-soft: #edf1f6;
  --nav: #111827;
  --nav-2: #1f2937;
  --primary: #0f766e;
  --primary-2: #115e59;
  --danger: #b42318;
  --ok: #047857;
  --warning: #8a4b0f;
  --shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

.login {
  max-width: 380px;
  margin: 12vh auto;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login h1 {
  margin: 0 0 6px;
}

.login button {
  width: 100%;
  margin-top: 8px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--nav);
  color: white;
  padding: 20px 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 2px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #14b8a6;
  color: #042f2e;
  font-weight: 800;
}

.brand h1 {
  font-size: 17px;
  margin: 0;
  letter-spacing: 0;
}

.brand p {
  margin: 2px 0 0;
  color: #a7b0bf;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  text-align: left;
  color: #d7dee9;
  background: transparent;
  cursor: pointer;
}

.nav button:hover {
  background: var(--nav-2);
  color: white;
}

.nav button.active {
  background: #ecfeff;
  color: #0f172a;
  font-weight: 700;
}

.content {
  min-width: 0;
  padding: 30px clamp(18px, 3vw, 38px);
}

.top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.top h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.top p {
  margin: 8px 0 0;
}

.grid {
  display: grid;
  gap: 14px;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.card, .panel, .table-wrap {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card {
  padding: 18px;
}

.card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

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

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.row, .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.actions {
  justify-content: flex-end;
  white-space: nowrap;
}

.form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #475467;
}

.check-field {
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.check-field input {
  width: 18px;
  height: 18px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: white;
  color: var(--ink);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.14);
}

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

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 13px;
  background: white;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #aab4c3;
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 700;
}

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

button.danger {
  color: var(--danger);
  background: #fffafa;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: separate;
  border-spacing: 0;
  background: white;
}

th, td {
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
}

tbody tr:hover {
  background: #fbfdff;
}

pre {
  max-width: 520px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

.pill, .id-badge, .entity {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.pill {
  background: #ecfdf3;
  color: var(--ok);
}

.pill.off {
  background: #fee4e2;
  color: var(--danger);
}

.id-badge {
  background: #eef2f6;
  color: #344054;
}

.entity {
  background: #eefcfb;
  color: #0f766e;
}

.token {
  display: inline-block;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  padding: 4px 7px;
  border-radius: 8px;
  background: #f2f4f7;
  color: #344054;
}

.token.masked {
  letter-spacing: 0;
}

.secret-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid #99f6e4;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: #f0fdfa;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.secret-panel h2 {
  margin: 3px 0 4px;
  font-size: 18px;
}

.secret-panel p {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.eyebrow {
  display: block;
  color: #0f766e;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.secret-token {
  display: block;
  padding: 12px;
  border: 1px solid #5eead4;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.5;
}

.notice {
  padding: 11px 13px;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--warning);
  border: 1px solid #fed7aa;
  margin-bottom: 14px;
}

.sales-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.sales-list {
  display: grid;
  gap: 12px;
}

.sale-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  overflow: hidden;
}

.sale-main {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 16px;
}

.sale-title {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.sale-title strong {
  font-size: 16px;
}

.sale-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.sale-amount {
  text-align: right;
  white-space: nowrap;
}

.sale-amount strong {
  display: block;
  font-size: 22px;
}

.sale-amount span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.sale-breakdown {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 16px 14px;
}

.sale-breakdown span {
  padding: 5px 8px;
  border-radius: 8px;
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.sale-card details {
  border-top: 1px solid var(--line-soft);
}

.sale-card summary {
  padding: 12px 16px;
  cursor: pointer;
  color: var(--primary);
  font-weight: 800;
}

.sale-details {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 16px;
  padding: 0 16px 16px;
}

.sale-details h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.mini-table {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}

.mini-table th,
.mini-table td {
  padding: 9px 10px;
  font-size: 12px;
}

.mini-table td span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.raw-json {
  margin: 0 16px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfdff;
}

.raw-json summary {
  padding: 10px 12px;
}

.raw-json pre {
  max-width: none;
  padding: 0 12px 12px;
}

.empty {
  padding: 30px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty strong {
  font-size: 18px;
}

.empty p {
  margin: 8px 0 0;
  color: var(--muted);
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: static;
    height: auto;
  }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 18px; }
  .top { align-items: stretch; flex-direction: column; }
  .top .row { justify-content: flex-start; }
  .sale-main { flex-direction: column; }
  .sale-amount { text-align: left; }
  .sale-details { grid-template-columns: 1fr; }
}
