:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  color: #15171a;
  background: #f4f5f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: #ee4d4f;
  color: #fff;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

input,
select {
  height: 38px;
  border: 1px solid #d7dbe2;
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: #15171a;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  align-content: center;
  gap: 18px;
}

.login-panel {
  width: min(380px, 100%);
  padding: 28px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(25, 29, 38, .12);
}

.login-panel h1 {
  margin: 0;
  font-size: 26px;
}

.login-panel p {
  margin: 8px 0 24px;
  color: #6b7280;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

label span {
  color: #4b5563;
  font-size: 13px;
  font-weight: 700;
}

.form-error {
  min-height: 22px;
  margin-top: 10px;
  color: #d32f2f;
  font-size: 13px;
}

.admin-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 216px 1fr;
}

.sidebar {
  min-height: 100vh;
  padding: 20px 14px;
  background: #17191f;
  color: #fff;
}

.brand {
  display: grid;
  gap: 6px;
  padding: 8px 10px 22px;
}

.brand strong {
  font-size: 20px;
}

.brand span {
  color: #b7bfcc;
  font-size: 13px;
}

.nav-btn,
.logout-btn {
  width: 100%;
  margin-bottom: 8px;
  background: transparent;
  color: #d7dce5;
  text-align: left;
}

.nav-btn.active {
  background: #ee4d4f;
  color: #fff;
}

.logout-btn {
  margin-top: 18px;
  border: 1px solid rgba(255, 255, 255, .14);
}

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

.site-footer {
  color: #8a929f;
  font-size: 12px;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: #ee4d4f;
  text-decoration: underline;
}

.content-footer {
  margin-top: 28px;
  padding-bottom: 8px;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.content-header h2 {
  margin: 0;
  font-size: 24px;
}

.content-header p {
  margin: 6px 0 0;
  color: #6b7280;
}

.ghost-btn {
  border: 1px solid #d7dbe2;
  background: #fff;
  color: #15171a;
}

.danger-btn {
  border: 1px solid #ee4d4f;
  background: #fff;
  color: #ee4d4f;
}

.view-panel {
  min-height: 420px;
}

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

.stat-card {
  padding: 20px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #eceff3;
}

.stat-card span {
  color: #6b7280;
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar input {
  width: 240px;
}

.table-wrap,
.order-list {
  border: 1px solid #eceff3;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

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

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

th {
  color: #6b7280;
  font-size: 12px;
  background: #fafbfc;
}

td.actions {
  white-space: nowrap;
}

.mini-btn {
  padding: 6px 9px;
  margin-right: 6px;
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 12px;
  background: #eef7ee;
  color: #2f7d32;
  font-size: 12px;
  font-weight: 700;
}

.status.off_sale,
.status.cancelled {
  background: #f1f2f4;
  color: #69707d;
}

.status.sold_out,
.status.pending {
  background: #fff3d8;
  color: #9a5d00;
}

.status.delivering {
  background: #e9f2ff;
  color: #1d5fbf;
}

.status.completed {
  background: #e9f7ef;
  color: #277344;
}

.order-card {
  padding: 16px;
  border-bottom: 1px solid #f0f2f5;
}

.order-card:last-child {
  border-bottom: 0;
}

.order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.order-id {
  font-weight: 800;
}

.order-meta {
  margin-top: 8px;
  color: #6b7280;
  font-size: 13px;
}

.order-items {
  margin-top: 12px;
  color: #374151;
  font-size: 14px;
}

.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 22px 80px rgba(20, 24, 31, .22);
}

dialog::backdrop {
  background: rgba(17, 24, 39, .38);
}

.dialog-form {
  width: min(520px, calc(100vw - 32px));
  padding: 22px;
  background: #fff;
}

.dialog-form h3 {
  margin: 0 0 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.product-image-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.product-image-fields label {
  margin-bottom: 0;
}

.product-image-fields input[type="file"] {
  height: auto;
  min-height: 38px;
  padding: 7px 10px;
}

.image-preview-row {
  min-height: 74px;
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid #eceff3;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fafbfc;
}

.image-preview-row img {
  width: 54px;
  height: 54px;
  border-radius: 6px;
  object-fit: cover;
  background: #eef0f3;
  display: none;
}

.image-preview-row.has-image img {
  display: block;
}

.image-preview-row span {
  color: #6b7280;
  font-size: 13px;
}

.media-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 40px));
  overflow: auto;
}

.media-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.media-dialog-head h3 {
  margin: 0;
}

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

.media-item {
  display: grid;
  grid-template-rows: 120px auto auto;
  gap: 6px;
  width: 100%;
  padding: 8px;
  border: 1px solid #e1e5eb;
  background: #fff;
  color: #15171a;
  text-align: left;
}

.media-item img {
  width: 100%;
  height: 120px;
  border-radius: 4px;
  object-fit: cover;
  background: #eef0f3;
}

.media-item span {
  min-width: 0;
  overflow: hidden;
  color: #4b5563;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-item small {
  color: #8a929f;
  font-size: 11px;
}

.media-empty {
  grid-column: 1 / -1;
  padding: 30px 14px;
  color: #6b7280;
  text-align: center;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-line input {
  height: auto;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.muted {
  color: #6b7280;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  min-width: 160px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #15171a;
  color: #fff;
  text-align: center;
  transform: translateX(-50%) translateY(80px);
  opacity: 0;
  transition: .18s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

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

  .sidebar {
    min-height: auto;
  }

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

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

  .product-image-fields {
    grid-template-columns: 1fr;
  }
}
