:root {
  --ink: #121416;
  --muted: #66716b;
  --line: #dbe2dc;
  --bg: #f4f7f4;
  --surface: #ffffff;
  --side: #171a1d;
  --side-soft: #23282b;
  --gold: #b88a35;
  --teal: #2f7770;
  --rose: #b85f64;
  --blue: #3c6f9f;
  --green: #3d8756;
  --shadow: 0 18px 44px rgba(18, 20, 22, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.admin-menu-lock {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

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

img {
  display: block;
  max-width: 100%;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 26, 29, 0.88), rgba(47, 119, 112, 0.58)),
    url("../assets/hero-perfume.png") center / cover;
}

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-brand,
.brand,
.topbar,
.topbar-actions,
.button,
.side-link,
.nav-button,
.panel-heading,
.button-row,
.table-tools,
.segmented,
.metric-line,
.form-actions {
  display: flex;
  align-items: center;
}

.login-brand {
  gap: 10px;
  font-size: 1.1rem;
}

.login-brand span,
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--ink);
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
  line-height: 1.2;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: 0;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 90px;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 119, 112, 0.14);
}

.button {
  min-height: 42px;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 850;
}

.button-primary {
  color: #fff;
  background: var(--ink);
}

.button-secondary {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.button:hover,
.icon-action:hover,
.text-button:hover,
.nav-button:hover,
.side-link:hover,
.segmented button:hover {
  transform: translateY(-1px);
}

.form-status {
  min-height: 22px;
  margin: 0;
  color: var(--teal);
  font-size: 0.9rem;
}

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

.mobile-admin-menu-toggle,
.mobile-view-menu,
.admin-menu-scrim {
  display: none;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  display: grid;
  height: 100vh;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  padding: 22px;
  color: #f8fbf8;
  background: var(--side);
}

.brand {
  gap: 10px;
  font-weight: 950;
}

.brand-mark {
  color: var(--ink);
  background: #fff;
}

.admin-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-button,
.side-link {
  width: 100%;
  justify-content: flex-start;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(248, 251, 248, 0.82);
  background: transparent;
  font-weight: 820;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.nav-button span,
.side-link span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--side-soft);
  font-size: 0.78rem;
  font-weight: 950;
}

.nav-button.active {
  color: #fff;
  background: var(--side-soft);
}

.nav-button.active span {
  background: var(--teal);
}

.sidebar-actions {
  display: grid;
  gap: 8px;
}

.side-link {
  border-color: rgba(255, 255, 255, 0.08);
}

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

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 22px;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.topbar-actions {
  justify-content: flex-end;
  gap: 10px;
}

.admin-panel {
  display: grid;
  gap: 18px;
}

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

.stat-card,
.panel-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(18, 20, 22, 0.06);
}

.stat-card {
  display: grid;
  gap: 8px;
  min-height: 136px;
  padding: 18px;
}

.stat-card span,
.panel-note,
.panel-heading span,
td small,
.empty-state {
  color: var(--muted);
}

.stat-card strong {
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1;
}

.stat-card small {
  color: var(--teal);
  font-weight: 800;
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.74fr);
  gap: 14px;
}

.panel-block {
  min-width: 0;
  padding: 18px;
}

.panel-block.wide {
  grid-column: 1 / -1;
}

.panel-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.button-row {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-note {
  margin: 5px 0 0;
  font-size: 0.9rem;
}

.bar-list,
.rank-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 132px 1fr auto;
  align-items: center;
  gap: 12px;
}

.bar-label,
.rank-item strong {
  font-weight: 850;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee9;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.rank-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rank-thumb,
.product-thumb {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: #eef2ef;
}

.text-button,
.icon-action {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 850;
}

.text-button {
  min-height: 34px;
  padding: 0 12px;
}

.icon-action {
  display: grid;
  min-width: 38px;
  height: 38px;
  place-items: center;
}

.icon-action.danger {
  color: var(--rose);
}

.icon-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.56fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

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

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

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

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

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

.upload-box {
  min-height: 92px;
  align-content: center;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.upload-box input {
  padding: 9px;
  background: #fff;
}

#image-preview {
  width: 100%;
  min-height: 160px;
  max-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.gallery-preview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

.gallery-preview img {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
}

.form-actions {
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.table-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.table-tools input {
  width: min(220px, 100%);
}

.table-tools select {
  width: auto;
  min-width: 150px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

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

.product-cell,
.customer-cell {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.customer-cell {
  grid-template-columns: 1fr;
}

.product-cell strong,
.customer-cell strong {
  display: block;
}

.product-cell span,
.customer-cell span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.price-cell {
  display: grid;
  gap: 4px;
}

.price-cell strong {
  font-size: 0.98rem;
}

.price-cell span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 820;
}

.small-button.danger {
  color: var(--rose);
}

.stock-toggle {
  padding: 0;
  border: 0;
  background: transparent;
}

.orders-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.segmented {
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.segmented button {
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
}

.segmented button.active {
  color: #fff;
  background: var(--ink);
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  color: #fff;
  background: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.status-pill[data-status="Received"] {
  background: var(--blue);
}

.status-pill[data-status="Processing"] {
  background: var(--gold);
}

.status-pill[data-status="Shipped"] {
  background: var(--teal);
}

.status-pill[data-status="Delivered"] {
  background: var(--green);
}

.status-pill[data-status="Out of stock"] {
  color: #8d454a;
  background: #f8e2e3;
}

.status-pill[data-status="Cancelled"] {
  background: var(--rose);
}

.status-select {
  min-width: 150px;
}

@media (max-width: 760px) {
  .admin-app {
    display: block;
  }

  .admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(82vw, 300px);
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 220ms ease;
    box-shadow: 18px 0 45px rgba(0, 0, 0, 0.2);
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-menu-scrim:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    background: rgba(18, 20, 22, 0.52);
  }

  .mobile-admin-menu-toggle,
  .mobile-view-menu {
    display: grid;
    width: 42px;
    height: 42px;
    place-content: center;
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: var(--surface);
  }

  .mobile-admin-menu-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 40;
  }

  .mobile-admin-menu-toggle span,
  .mobile-view-menu span {
    display: block;
    width: 17px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
  }

  .admin-main {
    padding: 72px 14px 22px;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
    margin-bottom: 16px;
  }

  .topbar h1 {
    font-size: clamp(1.7rem, 8vw, 2.5rem);
    overflow-wrap: anywhere;
  }

  .mobile-view-menu {
    grid-column: 2;
    grid-row: 1;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .topbar-actions .button {
    flex: 1;
    min-height: 44px;
  }

  .stat-grid,
  .analytics-grid,
  .split-layout,
  .orders-layout {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    gap: 10px;
  }

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

  .panel-block {
    padding: 14px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .panel-heading > .segmented {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    flex-wrap: nowrap;
  }

  .segmented button {
    flex: 0 0 auto;
    min-height: 40px;
  }

  .form-grid.two,
  .form-grid.three,
  .upload-grid,
  .preview-grid {
    grid-template-columns: 1fr;
  }

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

  .form-actions,
  .form-actions .button {
    width: 100%;
  }

  .form-actions {
    align-items: stretch;
  }

  .table-tools {
    width: 100%;
    justify-content: stretch;
  }

  .table-tools input,
  .table-tools select,
  .table-tools .button {
    width: 100%;
    min-height: 44px;
  }

  .table-wrap {
    margin-right: -14px;
    padding-right: 14px;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 700px;
  }

  .order-detail {
    position: static;
  }

  .detail-line {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .detail-line strong {
    max-width: 62%;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .button,
  .small-button,
  .status-select,
  input,
  select,
  textarea {
    min-height: 44px;
  }
}

.order-detail {
  position: sticky;
  top: 24px;
}

.detail-list {
  display: grid;
  gap: 12px;
}

.detail-list h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.detail-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
}

.detail-line strong {
  color: var(--ink);
}

.order-items {
  display: grid;
  gap: 8px;
}

.order-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8faf8;
  text-align: center;
}

.compact-table {
  display: grid;
  gap: 8px;
}

.compact-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-row strong,
.compact-row span {
  min-width: 0;
}

.danger-text {
  color: var(--rose);
}

@media (max-width: 1160px) {
  .admin-app {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .brand span:last-child,
  .nav-button:not(.active),
  .side-link {
    font-size: 0;
  }

  .nav-button,
  .side-link {
    justify-content: center;
    padding: 0;
  }

  .nav-button span,
  .side-link span {
    margin: 0;
  }

  .split-layout,
  .orders-layout {
    grid-template-columns: 1fr;
  }

  .order-detail {
    position: static;
  }
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .topbar-actions .button {
    flex: 1;
  }

  .stat-grid,
  .analytics-grid,
  .form-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .admin-sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
    box-shadow: 0 14px 30px rgba(18, 20, 22, 0.16);
  }

  .brand span:last-child,
  .nav-button:not(.active),
  .side-link {
    font-size: inherit;
  }

  .admin-nav {
    grid-template-columns: repeat(4, minmax(116px, 1fr));
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-button,
  .side-link {
    justify-content: flex-start;
    padding: 0 12px;
  }

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

  .admin-main {
    padding: 14px;
  }

  .topbar-actions,
  .form-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-block,
  .stat-card {
    padding: 14px;
  }

  .stat-grid,
  .analytics-grid,
  .form-grid.two,
  .form-grid.three,
  .upload-grid,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-tools,
  .segmented {
    width: 100%;
    justify-content: flex-start;
  }

  .table-tools input,
  .table-tools select {
    width: 100%;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .compact-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .login-card {
    padding: 20px;
  }

  .admin-nav,
  .sidebar-actions,
  .topbar-actions,
  .form-actions {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 2rem;
  }

  .button,
  .small-button {
    width: 100%;
  }

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

/* Keep the mobile navigation as a real drawer after the legacy breakpoints above. */
@media (max-width: 760px) {
  .admin-app {
    display: block;
    grid-template-columns: none;
  }

  .admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    display: grid;
    width: min(82vw, 300px);
    height: 100dvh;
    grid-template-rows: auto 1fr auto;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 220ms ease;
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-menu-scrim:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: block;
    pointer-events: auto;
    background: rgba(18, 20, 22, 0.58);
  }

  .admin-sidebar .admin-nav {
    display: grid;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .admin-sidebar .nav-button,
  .admin-sidebar .side-link {
    width: 100%;
    min-height: 52px;
    justify-content: flex-start;
    padding: 0 12px;
    font-size: inherit;
  }

  .admin-sidebar .sidebar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .mobile-admin-menu-toggle,
  .mobile-view-menu {
    position: fixed;
    display: grid;
    place-content: center;
    gap: 5px;
    width: 46px;
    height: 46px;
    z-index: 80;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    background: var(--surface);
    box-shadow: 0 8px 20px rgba(18, 20, 22, 0.1);
  }

  .mobile-admin-menu-toggle {
    top: 12px;
    left: 12px;
  }

  .mobile-view-menu {
    position: static;
    grid-column: 2;
    grid-row: 1;
  }

  .mobile-admin-menu-toggle span,
  .mobile-view-menu span {
    display: block;
    width: 19px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
  }

  .admin-main {
    padding-top: 72px;
  }
}
