:root {
  color-scheme: light;
  --brand: #0877ff;
  --brand-dark: #0666db;
  --ink: #20242c;
  --muted: #727b8f;
  --line: #e3e7ee;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --danger: #d9363e;
  --warning: #d97706;
  --success: #138a52;
  --sidebar: #20242c;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--surface-2);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(8, 119, 255, 0.08), transparent 48%),
    #eef2f7;
}

.login-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(30, 45, 70, 0.12);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.login-title {
  margin: 20px 0 6px;
  font-size: 25px;
  line-height: 1.25;
}

.login-subtitle {
  margin: 0 0 26px;
  color: var(--muted);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: var(--sidebar);
  color: #fff;
  overflow: auto;
}

.sidebar-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 8px 18px;
  font-weight: 700;
}

.sidebar-brand small {
  display: block;
  margin-top: 2px;
  color: #99a1b3;
  font-weight: 400;
}

.nav-group {
  margin: 12px 0 4px;
  padding: 0 10px;
  color: #858da0;
  font-size: 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 42px;
  margin: 2px 0;
  padding: 0 12px;
  border-radius: 7px;
  color: #d9deea;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: #303744;
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

.content {
  padding: 24px 28px 40px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar .spacer {
  flex: 1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
}

.panel-body {
  padding: 18px;
}

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

.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 750;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.table-wrap {
  overflow: auto;
}

.data-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: #fafbfc;
  color: #596274;
  font-size: 12px;
  font-weight: 650;
}

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

.data-table td.actions {
  min-width: 170px;
}

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

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef1f5;
  color: #596274;
  font-size: 12px;
  white-space: nowrap;
}

.status.active,
.status.success,
.status.on_sale {
  background: #e7f7ef;
  color: var(--success);
}

.status.disabled,
.status.closed {
  background: #f1f2f4;
  color: #7d8491;
}

.status.pending,
.status.confirming,
.status.processing {
  background: #fff6e5;
  color: var(--warning);
}

.status.warehouse {
  background: #f0f3f8;
  color: #5e6b82;
}

.btn {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.btn:hover {
  border-color: #bdc5d2;
}

.btn.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

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

.btn.danger {
  border-color: #f1b7ba;
  color: var(--danger);
}

.btn.small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cfd5df;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(8, 119, 255, 0.1);
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.toolbar .input,
.toolbar .select {
  width: auto;
  min-width: 170px;
}

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

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

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: #566072;
  font-size: 12px;
  font-weight: 650;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.empty {
  padding: 48px 18px;
  color: var(--muted);
  text-align: center;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 25, 34, 0.46);
}

.dialog {
  width: min(760px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(20, 25, 34, 0.25);
}

.dialog.wide {
  width: min(1040px, 100%);
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.dialog-title {
  font-size: 17px;
  font-weight: 700;
}

.dialog-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: #f1f3f6;
}

.dialog-body {
  padding: 20px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
}

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

.detail-row {
  padding-bottom: 10px;
  border-bottom: 1px solid #edf0f4;
}

.detail-row label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-row strong {
  display: block;
  margin-top: 3px;
  font-weight: 600;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #20242c;
  color: #fff;
  box-shadow: 0 12px 34px rgba(20, 25, 34, 0.25);
}

.toast.error {
  background: #a92a31;
}

@media (max-width: 1040px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-two {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
  }

  .sidebar-brand,
  .nav-group {
    grid-column: 1 / -1;
  }

  .topbar {
    padding: 0 16px;
  }

  .content {
    padding: 18px 14px 30px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

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