:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #d7dee8;
  --text: #132238;
  --muted: #64748b;
  --primary: #1e3a5f;
  --primary-2: #274f7a;
  --accent: #2f855a;
  --warn: #c05621;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eef2f7 0%, #f7f9fb 100%);
  overflow-x: hidden;
}

.portal {
  width: min(1680px, calc(100vw - 24px));
  margin: 18px auto 28px;
  min-height: calc(100vh - 46px);
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.brand-title {
  font-family: "Merriweather", serif;
  font-size: 1.3rem;
  font-weight: 700;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav-link {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  text-decoration: none;
  color: var(--primary);
  border: 1px solid #c9d4e3;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.nav-link.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: var(--primary);
  color: #fff;
}

.nav-link.disabled {
  color: #9aa8ba;
  background: #f2f6fb;
  cursor: default;
}

.nav-btn {
  cursor: pointer;
}

.hero {
  margin-top: 14px;
  background: linear-gradient(140deg, #1b3557, #274f7a);
  border-radius: 16px;
  border: 1px solid #23496f;
  padding: 20px;
  color: #fff;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.hero-copy h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 2.2vw, 2rem);
}

.hero-copy p {
  margin: 0;
  color: #d6e3f3;
}

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

.stat-card {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 12px;
}

.stat-card .k {
  color: #d8e6f5;
  font-size: 0.83rem;
}

.stat-card .v {
  margin-top: 4px;
  font-size: 1.2rem;
  font-weight: 700;
}

.filter-card,
.table-card {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
}

.filter-head {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.filter-head strong {
  font-size: 0.95rem;
  line-height: 1.1;
}

.filter-toggle {
  min-width: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  transform: translateY(-1px);
}

.filter-toggle:focus,
.filter-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(39, 79, 122, 0.22);
  border-color: #9fb3cd;
}

.filters {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.85rem;
}

input,
select {
  height: 40px;
  border: 1px solid #cfd8e6;
  border-radius: 10px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid rgba(39, 79, 122, 0.2);
  border-color: var(--primary-2);
}

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  height: 40px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.btn.ghost {
  background: #f8fafc;
  color: #334155;
  border-color: #cbd5e1;
}

.btn.mini {
  height: 32px;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 0.82rem;
}

.btn:disabled {
  opacity: 0.66;
  cursor: not-allowed;
}

.error {
  margin: 0 16px 14px;
  color: var(--danger);
  font-size: 0.9rem;
}

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

.table-head span {
  color: var(--muted);
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 10px;
  text-align: left;
  font-size: 0.9rem;
}

thead th {
  background: #0f2239;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1;
}

.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.sortable-th:hover {
  background: #132a47;
}

.sort-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1em;
  margin-left: 6px;
  font-weight: 700;
  font-size: 0.74rem;
  line-height: 1;
  vertical-align: middle;
}

.sort-mark::before {
  content: "↕";
  color: #88a0bd;
  opacity: 0.7;
}

.sort-mark.is-asc::before {
  content: "▲";
  color: #dbeafe;
  opacity: 1;
}

.sort-mark.is-desc::before {
  content: "▼";
  color: #dbeafe;
  opacity: 1;
}

.sort-mark.is-none::before {
  content: "↕";
  color: #88a0bd;
  opacity: 0.7;
}

tbody tr:nth-child(odd) {
  background: #fbfdff;
}

tbody tr:hover {
  background: #f1f6fc;
}

.stock-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 28px;
  border-radius: 999px;
  font-weight: 700;
}

.stock-pill.low {
  color: #fff;
  background: linear-gradient(135deg, #dd6b20, var(--warn));
}

.stock-pill.medium {
  color: #fff;
  background: linear-gradient(135deg, #2b6cb0, #2c5282);
}

.stock-pill.high {
  color: #fff;
  background: linear-gradient(135deg, #2f855a, var(--accent));
}

.photo-col {
  width: 146px;
}

.photo-btn {
  border: 0;
  padding: 0;
  background: transparent;
  height: auto;
  position: relative;
}

.thumb {
  width: 140px;
  height: 105px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #d6e0ec;
  background: #fff;
  image-rendering: auto;
  image-rendering: -webkit-optimize-contrast;
}

.photo-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(15, 34, 57, 0.88);
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.photo-badge.large {
  right: 10px;
  bottom: 10px;
  font-size: 0.85rem;
}

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

.pager {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.pager-actions {
  display: flex;
  gap: 8px;
}

.pager-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d3ddea;
  background: #f7fafd;
}

.meta-chip strong {
  color: var(--text);
  font-weight: 700;
}

.footer {
  margin-top: auto;
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.84rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.46);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(420px, 92vw);
  background: #fff;
  border-left: 1px solid #d5dfeb;
  box-shadow: -12px 0 32px rgba(15, 23, 42, 0.2);
  transform: translateX(105%);
  transition: transform 0.24s ease;
  z-index: 50;
  display: grid;
  grid-template-rows: auto 1fr;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  padding: 14px 16px;
  border-bottom: 1px solid #dbe4ef;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-head h3 {
  margin: 0;
}

.drawer-body {
  padding: 14px 16px;
  overflow: auto;
}

.detail-photo-btn {
  border: 0;
  padding: 0;
  background: transparent;
  position: relative;
  height: auto;
  width: 100%;
}

.detail-photo {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #d6e0ec;
  background: #f8fafc;
  margin-bottom: 14px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #e7edf5;
}

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

.kv strong {
  text-align: right;
}

.image-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 23, 0.72);
  z-index: 70;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  padding: 20px;
}

.image-stage {
  max-width: min(1200px, 94vw);
  margin: 0 auto;
  background: rgba(15, 23, 42, 0.3);
  border: 1px solid rgba(226, 232, 240, 0.35);
  border-radius: 14px;
  padding: 14px;
}

.image-title {
  color: #dbeafe;
  font-size: 0.95rem;
  margin-bottom: 10px;
  text-align: center;
}

.image-main {
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  background: #0b1220;
  border-radius: 10px;
}

.image-meta {
  margin-top: 10px;
  text-align: center;
  color: #e2e8f0;
  font-size: 0.9rem;
}

.image-nav {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.68);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  align-self: center;
  justify-self: center;
  cursor: pointer;
}

.image-close {
  position: fixed;
  top: 16px;
  right: 16px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.86);
  color: #fff;
}

.customer-login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(1200px 380px at 15% -20%, rgba(39, 79, 122, 0.14), transparent 60%),
    radial-gradient(900px 280px at 95% 120%, rgba(30, 58, 95, 0.1), transparent 60%),
    linear-gradient(180deg, #eef2f7 0%, #f7f9fb 100%);
}

.customer-login-card {
  width: min(480px, 96vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.customer-login-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #1e3a5f, #274f7a);
}

.customer-login-head {
  margin-bottom: 14px;
}

.customer-login-kicker {
  margin: 0 0 6px;
  color: #49668a;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.customer-login-card h1 {
  margin: 0 0 2px;
  font-family: "Merriweather", serif;
  font-size: 1.7rem;
  color: #0f2640;
}

.customer-login-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.customer-login-form {
  display: grid;
  gap: 8px;
}

.customer-login-form label {
  margin-top: 6px;
  font-size: 0.86rem;
  color: #334155;
  font-weight: 700;
}

.customer-login-form input {
  height: 42px;
  border-radius: 10px;
  border-color: #c8d4e5;
  background: #fbfdff;
}

.customer-login-form input:focus {
  border-color: #3b82f6;
  outline: 2px solid rgba(59, 130, 246, 0.18);
}

.customer-login-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.customer-login-actions .btn {
  min-width: 108px;
  height: 40px;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(30, 58, 95, 0.22);
}

.customer-login-error {
  min-height: 0;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
}

.customer-login-error:empty {
  display: none;
}

.customer-login-back {
  color: var(--muted);
  font-size: 0.86rem;
}

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

  .actions {
    grid-column: span 2;
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: row;
    align-items: center;
  }

  .brand {
    min-width: 0;
  }

  .nav {
    margin-left: auto;
    align-self: center;
  }

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

  .hero-stat {
    grid-template-columns: 1fr 1fr;
  }

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

  .actions {
    grid-column: span 1;
  }

  .footer {
    justify-content: center;
    gap: 6px;
  }

  .footer span {
    width: 100%;
    text-align: center;
  }

  .pager {
    flex-direction: column;
    align-items: stretch;
  }

  .pager-actions {
    justify-content: center;
  }

  .pager-meta {
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 14px;
  }

  .thumb {
    width: 108px;
    height: 80px;
  }

  .image-modal {
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: end;
    padding: 10px;
  }

  .image-nav.left,
  .image-nav.right {
    position: fixed;
    bottom: 18px;
    width: 46px;
    height: 46px;
    font-size: 1.7rem;
  }

  .image-nav.left {
    left: 12px;
  }

  .image-nav.right {
    right: 12px;
  }

  .customer-login-page {
    padding: 16px;
  }

  .customer-login-card {
    width: min(480px, 100%);
    margin-inline: auto;
  }

  .customer-login-head {
    text-align: left;
  }

  .customer-login-actions {
    justify-content: center;
  }
}
