:root {
  --canvas: #f3f6f5;
  --paper: #ffffff;
  --paper-soft: #f8fafc;
  --ink: #15171d;
  --muted: #66717e;
  --line: #dfe6ec;
  --line-strong: #c8d2dc;
  --brand: #18a875;
  --brand-dark: #087650;
  --blue: #306fe8;
  --amber: #d99021;
  --rose: #dc4f68;
  --danger: #dc3d42;
  --sidebar: #15171d;
  --sidebar-soft: #1e2228;
  --shadow-sm: 0 8px 24px rgba(22, 27, 33, .06);
  --shadow-md: 0 18px 48px rgba(22, 27, 33, .10);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(21, 23, 29, .035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(21, 23, 29, .028) 1px, transparent 1px),
    linear-gradient(180deg, #edf4f1 0, #f6f8fb 520px, #ffffff 100%);
  background-size: 44px 44px, 44px 44px, auto;
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid rgba(48, 111, 232, .24);
  outline-offset: 2px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(24, 168, 117, .10), transparent 42%),
    var(--sidebar);
  color: #f6f8fb;
  box-shadow: 14px 0 40px rgba(21, 23, 29, .12);
}

.admin-brand {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .04);
  font-size: 19px;
  font-weight: 900;
}

.admin-brand span,
.login-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(24, 168, 117, .22), rgba(48, 111, 232, .12));
  color: #7cf0bd;
  font-size: 24px;
  box-shadow: inset 0 0 0 1px rgba(124, 240, 189, .18);
}

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

.sidebar nav a,
.logout {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: var(--radius);
  color: #b9c3cf;
  font-size: 14px;
  font-weight: 800;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.sidebar nav a:hover,
.logout:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
}

.sidebar nav a.active {
  background: rgba(24, 168, 117, .16);
  color: #fff;
  box-shadow: inset 3px 0 0 #38d79a;
}

.logout {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, .08);
}

.admin-main {
  min-width: 0;
  padding: 28px;
}

.admin-top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -28px -28px 24px;
  padding: 24px 28px 18px;
  background: rgba(243, 246, 245, .78);
  backdrop-filter: blur(18px) saturate(145%);
  border-bottom: 1px solid rgba(223, 230, 236, .72);
}

.admin-top p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.admin-top h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  font-weight: 950;
}

.visit {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid rgba(21, 23, 29, .14);
  border-radius: var(--radius);
  background: #15171d;
  color: #fff;
  font-weight: 850;
  box-shadow: var(--shadow-sm);
}

.flash {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(48, 111, 232, .18);
  border-radius: var(--radius);
  background: rgba(239, 246, 255, .88);
  color: #1d4ed8;
  box-shadow: var(--shadow-sm);
}

.flash.success {
  border-color: rgba(24, 168, 117, .22);
  background: rgba(236, 253, 245, .90);
  color: #047857;
}

.flash.error {
  border-color: rgba(220, 61, 66, .22);
  background: rgba(254, 242, 242, .92);
  color: #b91c1c;
}

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

.stats-grid article,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow-sm);
}

.stats-grid article {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 20px;
}

.stats-grid article::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--blue), var(--amber), var(--rose));
}

.stats-grid span,
.muted {
  color: var(--muted);
}

.stats-grid span {
  font-size: 13px;
  font-weight: 850;
}

.stats-grid strong {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 950;
}

.panel {
  min-width: 0;
  padding: 22px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head p {
  margin: 6px 0 0;
}

.panel-head h2,
.panel h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 950;
}

.panel-head a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(48, 111, 232, .20);
  border-radius: var(--radius);
  background: rgba(48, 111, 232, .08);
  color: #1d4ed8;
  font-weight: 850;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: rgba(248, 250, 252, .78);
}

tbody tr {
  transition: background .16s ease;
}

tbody tr:hover {
  background: rgba(24, 168, 117, .045);
}

td a {
  color: #1d4ed8;
  font-weight: 850;
}

.pill {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 900;
}

.pill.delivered,
.pill.paid,
.pill.active,
.pill.available,
.pill.published {
  background: #ecfdf5;
  color: #047857;
}

.pill.pending,
.pill.pending_payment {
  background: #fff7ed;
  color: #c2410c;
}

.pill.closed,
.pill.offline,
.pill.disabled,
.pill.draft,
.pill.sold,
.pill.rejected {
  background: #f3f4f6;
  color: #4b5563;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, .85fr);
  gap: 18px;
  align-items: start;
}

.editor-grid.wide {
  grid-template-columns: minmax(430px, .76fr) minmax(0, 1fr);
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.settings-side {
  display: grid;
  gap: 18px;
}

.site-settings-card {
  position: relative;
}

.site-settings-card::before {
  content: "";
  display: block;
  height: 4px;
  margin: -22px -22px 18px;
  background: linear-gradient(90deg, var(--brand), var(--blue), var(--amber), var(--rose));
}

.logo-preview {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper-soft);
  color: var(--muted);
}

.logo-preview img {
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: cover;
  background: #fff;
}

.compact-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.inline-edit {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(88px, .7fr) 78px 92px 64px;
  gap: 8px;
  align-items: center;
}

.inline-edit.wholesale-edit {
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) 72px;
}

.inline-edit.withdrawal-action {
  grid-template-columns: minmax(140px, 1fr) 64px 64px;
  min-width: 280px;
}

.inline-edit input,
.inline-edit select {
  min-width: 0;
  padding: 9px 10px;
}

.inline-edit button {
  min-height: 38px;
  padding: 0 10px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 10px 12px;
  outline: 0;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input[type="checkbox"] {
  width: auto;
  min-height: 0;
  accent-color: var(--brand);
}

.form-panel label span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

textarea {
  resize: vertical;
  line-height: 1.7;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(48, 111, 232, .52);
  box-shadow: 0 0 0 4px rgba(48, 111, 232, .11);
}

.form-row {
  display: grid;
  gap: 12px;
}

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

.form-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

form button,
.button-row button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: #15171d;
  color: #fff;
  padding: 0 16px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(21, 23, 29, .13);
  transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}

form button:hover,
.button-row button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 16px 32px rgba(21, 23, 29, .17);
}

form button.danger,
.button-row button.danger {
  background: var(--danger);
}

.order-detail dl,
.settings-side dl {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  margin: 18px 0;
}

.order-detail dt,
.settings-side dt {
  color: var(--muted);
  font-weight: 800;
}

.order-detail dd,
.settings-side dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.secret-box {
  white-space: pre-wrap;
  word-break: break-all;
  padding: 16px;
  border: 1px solid rgba(124, 240, 189, .16);
  border-radius: var(--radius);
  background: #11161d;
  color: #bbf7d0;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(21, 23, 29, .035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(21, 23, 29, .028) 1px, transparent 1px),
    linear-gradient(135deg, #edf4f1, #f8fafc 52%, #eef4ff);
  background-size: 44px 44px, 44px 44px, auto;
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-md);
}

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

.login-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 1180px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .admin-main {
    padding: 22px;
  }

  .admin-top {
    margin: -22px -22px 20px;
    padding: 20px 22px 16px;
  }

  .editor-grid,
  .editor-grid.wide,
  .settings-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .admin-main {
    padding: 14px;
  }

  .admin-top {
    position: static;
    align-items: flex-start;
    margin: -14px -14px 16px;
    padding: 16px 14px;
  }

  .admin-top h1 {
    font-size: 28px;
  }

  .sidebar {
    padding: 14px;
  }

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

  .panel {
    padding: 16px;
  }

  .form-row.two,
  .form-row.three,
  .inline-edit,
  .inline-edit.wholesale-edit,
  .order-detail dl,
  .settings-side dl {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
