:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #fff;
  --text: #17202d;
  --muted: #6f7a89;
  --line: #d7dde6;
  --blue: #0873df;
  --green: #16803d;
  --red: #d31625;
  --amber: #a86600;
  --shadow: 0 12px 28px rgba(17, 24, 39, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 20px 28px;
  background: #111827;
  color: #fff;
}

.panel-top h1,
.auth-card h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 6px;
  color: #ff3348;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel-top nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-top a,
.panel-top span {
  color: #fff;
  text-decoration: none;
  font-weight: 750;
}

.panel-top a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 7px;
}

.panel-shell {
  width: min(1360px, calc(100% - 28px));
  margin: 18px auto 44px;
}

.filter-bar,
.metric-grid,
.panel-grid {
  display: grid;
  gap: 14px;
}

.filter-bar {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

label span,
.muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

button {
  height: 42px;
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-weight: 850;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
}

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

.metric-grid article {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 16px;
}

.metric-grid span,
.card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric-grid strong {
  font-size: 24px;
  line-height: 1;
}

.pos {
  color: var(--green);
  font-weight: 850;
}

.neg {
  color: var(--red);
  font-weight: 850;
}

.panel-grid {
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.4fr);
  margin-top: 16px;
}

.panel-card {
  margin-top: 16px;
  overflow: hidden;
}

.panel-grid .panel-card {
  margin-top: 0;
}

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

.card-head h2 {
  margin: 0;
  font-size: 18px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

td:first-child,
th:first-child {
  white-space: normal;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

code {
  display: inline-block;
  max-width: 190px;
  overflow: hidden;
  color: #334155;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  vertical-align: top;
}

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

.order-summary-row:hover td,
.order-summary-row.is-open td {
  background: #f4f9ff;
}

.row-hint {
  color: var(--blue);
  font-weight: 750;
}

.order-detail-row td {
  padding: 0;
  white-space: normal;
  background: #fbfdff;
}

.order-detail-box {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.order-detail-head {
  display: grid;
  grid-template-columns: minmax(150px, 0.25fr) minmax(150px, 0.25fr) minmax(260px, 1fr) minmax(190px, 0.35fr);
  gap: 12px;
}

.order-detail-head > div,
.status-form {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.status-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.status-form label {
  display: grid;
  gap: 6px;
}

.status-form select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
}

.status-form button {
  height: 36px;
  border: 0;
  border-radius: 7px;
  padding: 0 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 850;
  cursor: pointer;
}

.order-detail-head strong {
  display: block;
  margin-top: 3px;
}

.address-cell strong {
  font-size: 13px;
  font-weight: 700;
}

.order-lines-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.order-lines-table th,
.order-lines-table td {
  padding: 10px 12px;
}

.source-link {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border-radius: 7px;
  padding: 0 10px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: #eef2f7;
  color: #475569;
  font-size: 12px;
  font-weight: 850;
}

.badge.paid {
  background: #e5f7ec;
  color: var(--green);
}

.badge.preparing {
  background: #e8f2ff;
  color: #0b63ce;
}

.badge.shipped {
  background: #e6f7ff;
  color: #087990;
}

.badge.completed {
  background: #ddf7e7;
  color: #077a3f;
}

.badge.failed {
  background: #fde8ea;
  color: var(--red);
}

.badge.cancelled {
  background: #eef2f7;
  color: #64748b;
}

.badge.token_created {
  background: #fff3d6;
  color: var(--amber);
}

.status-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

.status-list strong {
  font-size: 20px;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 22px;
}

.auth-card {
  width: min(440px, 100%);
  padding: 24px;
}

.panel-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.error {
  margin-top: 14px;
  border: 1px solid #f1b8bf;
  border-radius: 7px;
  background: #fff0f2;
  color: var(--red);
  padding: 10px 12px;
  font-weight: 750;
}

@media (max-width: 980px) {
  .panel-top,
  .filter-bar,
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .panel-top {
    display: grid;
  }

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

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

@media (max-width: 560px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

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