:root {
  --bg: #eef3f6;
  --panel: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #d9e2e7;
  --primary: #0f766e;
  --blue: #2563eb;
  --cyan: #0891b2;
  --amber: #b7791f;
  --red: #be123c;
  --green: #15803d;
  --sidebar: #101828;
  --sidebar-soft: #17233a;
  --shadow: 0 14px 36px rgba(16, 24, 40, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.06) 0 25%, transparent 25% 50%, rgba(37, 99, 235, 0.05) 50% 75%, transparent 75%) 0 0 / 42px 42px,
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 58%, #e7eef2 100%);
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08) 0 25%, transparent 25% 50%, rgba(37, 99, 235, 0.07) 50% 75%, transparent 75%) 0 0 / 46px 46px,
    #f4f7fa;
}

.auth-panel {
  width: min(452px, 100%);
  padding: 28px;
  border: 1px solid rgba(217, 226, 231, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.16);
  backdrop-filter: blur(16px);
}

.brand-row,
.sidebar-brand,
.topbar,
.row,
.actions {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--blue));
  color: #fff;
  font-weight: 900;
  font-size: 24px;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.24);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 26px;
}

h3 {
  margin-bottom: 14px;
  font-size: 17px;
}

.brand-row p,
.muted,
.eyebrow {
  color: var(--muted);
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  padding: 6px;
  border-radius: 8px;
  background: #e8eef2;
}

.segment button,
.ghost,
.nav,
.primary,
.danger,
.success,
.plain {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 800;
}

.segment button,
.ghost,
.plain {
  background: #f1f5f9;
  color: #334155;
}

.segment button.active,
.primary {
  background: linear-gradient(135deg, var(--primary), var(--blue));
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.16);
}

.danger {
  background: #ffe4e6;
  color: var(--red);
}

.success {
  background: #dcfce7;
  color: var(--green);
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.16);
  border-color: rgba(15, 118, 110, 0.45);
}

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

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px;
  color: #dbeafe;
  background:
    linear-gradient(180deg, rgba(23, 35, 58, 0.98), rgba(16, 24, 40, 1)),
    var(--sidebar);
  box-shadow: 18px 0 44px rgba(16, 24, 40, 0.18);
}

.sidebar-brand {
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand span {
  display: block;
  margin-top: 3px;
  color: #98a9c2;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: transparent;
  color: #aab9ce;
  border-color: transparent;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.nav span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #d9ecff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.nav.active,
.nav:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #ffffff;
  transform: translateX(3px);
}

.nav.active span,
.nav:hover span {
  background: linear-gradient(135deg, var(--primary), var(--blue));
}

#logoutBtn {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  justify-content: space-between;
  margin-bottom: 22px;
  padding: 16px 18px;
  border: 1px solid rgba(217, 226, 231, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

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

.dashboard-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.8fr);
}

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

.card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.07);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--cyan), var(--blue));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.card:hover::before {
  opacity: 1;
}

.stat-card {
  min-height: 138px;
}

.stat-value {
  margin-top: 10px;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0;
}

.stat-card .trend {
  margin-top: 12px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.stat-card .meter {
  height: 8px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef1;
}

.stat-card .meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--blue));
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.05);
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 #eef2f7;
}

.table-wrap::-webkit-scrollbar {
  height: 8px;
}

.table-wrap::-webkit-scrollbar-track {
  background: #eef2f7;
  border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--blue));
}

.card .table-wrap table {
  min-width: 620px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid #edf2f4;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
  font-weight: 900;
}

tbody tr {
  transition: background 0.16s ease;
}

tbody tr:hover {
  background: #f8fbfc;
}

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

.actions {
  gap: 8px;
  flex-wrap: wrap;
}

.link-btn {
  border: 0;
  padding: 0;
  background: transparent;
  color: #0f172a;
  font-weight: 900;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--primary);
  text-decoration: underline;
}

.inline-input {
  width: 98px;
  margin: 0;
}

.wide-input {
  width: 184px;
  margin: 0;
}

.order-cell {
  min-width: 230px;
}

.order-rank {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  margin: 9px 0;
  padding: 8px;
  border: 1px solid #d8eee8;
  border-radius: 8px;
  background: #f4fbfa;
}

.order-rank span {
  color: #10243f;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.order-rank b {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--blue));
}

.money-grid {
  display: grid;
  gap: 6px;
  min-width: 128px;
}

.money-grid span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}

.money-grid strong {
  color: var(--primary);
  font-size: 13px;
}

.tag {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef6ff;
  color: #155e75;
  font-size: 12px;
  font-weight: 900;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status.pending,
.status.open {
  background: #fef3c7;
  color: var(--amber);
}

.status.approved,
.status.available,
.status.done {
  background: #dcfce7;
  color: var(--green);
}

.status.rejected,
.status.disabled,
.status.canceled {
  background: #ffe4e6;
  color: var(--red);
}

.status.working,
.status.rented,
.status.taking,
.status.pending-ship,
.status.pending-withdraw {
  background: #e0e7ff;
  color: #3730a3;
}

.preview {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 8px;
}

.mini-grid {
  margin-top: 6px;
  grid-template-columns: repeat(2, 58px);
}

.mini-grid .preview {
  width: 58px;
  height: 58px;
}

.preview-grid .preview {
  width: 72px;
  height: 72px;
}

.preview-grid.mini-grid .preview {
  width: 58px;
  height: 58px;
}

.type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.preview-button {
  display: block;
  border: 0;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  cursor: zoom-in;
}

.preview-button:hover .preview {
  border-color: rgba(15, 118, 110, 0.56);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.16);
}

.plus {
  color: var(--green);
  font-weight: 900;
}

.minus {
  color: var(--red);
  font-weight: 900;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(8px);
}

.modal-panel {
  width: min(960px, 100%);
  max-height: min(760px, calc(100vh - 56px));
  overflow: hidden;
  border: 1px solid rgba(217, 226, 231, 0.9);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
}

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

.modal-head h3 {
  margin: 0;
}

.modal-body {
  max-height: calc(100vh - 150px);
  overflow: auto;
  padding: 16px;
}

.image-viewer {
  display: grid;
  place-items: center;
  min-height: 320px;
  background: #0f172a;
  border-radius: 8px;
}

.image-viewer img {
  max-width: 100%;
  max-height: calc(100vh - 190px);
  border-radius: 6px;
  object-fit: contain;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.form-grid textarea {
  grid-column: span 2;
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  width: min(360px, calc(100vw - 36px));
  padding: 14px 16px;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  background: #f0fdfa;
  box-shadow: 0 18px 42px rgba(16, 24, 40, 0.16);
}

.toast strong {
  display: block;
  margin-bottom: 6px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 900;
}

.live-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.14);
}

.fade-in {
  animation: fade-in 0.28s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

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

  .topbar {
    align-items: flex-start;
    gap: 14px;
  }

  #logoutBtn {
    position: static;
    margin-top: 16px;
    width: 100%;
  }

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

  .form-grid textarea {
    grid-column: auto;
  }
}
