*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #F0F2F5;
  color: #1a1a2e;
  font-size: 14.5px;
  line-height: 1.55;
}

a { text-decoration: none; color: inherit; }

/* ── Login ─────────────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #072712 0%, #0A3A1B 60%, #1F5C38 100%);
}
.login-card {
  background: #fff;
  border-radius: 22px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
}
.login-logo  { height: 52px; display: block; margin: 0 auto 28px; }
.login-card h1 { text-align: center; font-size: 22px; margin-bottom: 28px; color: #072712; }

/* ── Layout ────────────────────────────────────────────────────────── */
.admin-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; width: 100%; }
.mobile-admin-bar { display: none; }

.sidebar {
  background: #072712;
  color: #A9C2B2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background-color: white;
}
.sidebar-brand img  { height: 38px; }
.sidebar-brand span { font-weight: 700; font-size: 15px; color: #fff; }

.sidebar-nav    { flex: 1; padding: 12px 0; }
.nav-section    { padding: 14px 20px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: #5E8A72; font-weight: 700; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 20px;
  font-size: 14px;
  color: #A9C2B2;
  transition: background .18s, color .18s;
  border-left: 3px solid transparent;
}
.nav-item:hover  { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: #D9A521; }
.nav-item svg    { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.sidebar-footer .admin-name { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer a { color: #D9A521; font-size: 12px; flex-shrink: 0; }
.sidebar-footer a:hover { text-decoration: underline; }

.admin-main    { display: block; width: 100%; min-width: 0; overflow-x: hidden; }
.sidebar-overlay { display: none; }
.admin-topbar  {
  background: #fff;
  padding: 14px 32px;
  border-bottom: 1px solid #E8E8E8;
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-topbar h1 { font-size: 20px; font-weight: 700; flex: 1; }
.admin-content { padding: 28px 32px; }

/* ── Stat cards ─────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  border: 1px solid #EBEBEB;
}
.stat-card.accent { background: #0A3A1B; border-color: #0A3A1B; }
.stat-value  { font-size: 38px; font-weight: 800; line-height: 1; color: #072712; }
.stat-label  { font-size: 12.5px; color: #888; margin-top: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-card.accent .stat-value,
.stat-card.accent .stat-label { color: #D1FAE5; }
.stat-card.accent .stat-value { color: #fff; }

/* ── Card ───────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
  border: 1px solid #EBEBEB;
  margin-bottom: 24px;
  overflow-x: auto;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-head h2 { font-size: 16px; font-weight: 700; }

/* ── Data table ─────────────────────────────────────────────────────── */
.data-table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left;
  padding: 10px 14px;
  background: #F7F8FA;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #666;
  white-space: nowrap;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid #F2F2F2; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #FAFAFA; }
.data-table .actions { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.data-table .thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.empty-row td { text-align: center; padding: 40px; color: #aaa; }
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 22px 0 8px;
}
.admin-page-numbers { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.admin-pagination .page-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid #D1D5DB;
  border-radius: 7px;
  color: #374151;
  font-size: 13px;
  font-weight: 600;
}
.admin-pagination .page-number:hover { border-color: #0A3A1B; color: #0A3A1B; }
.admin-pagination .page-number.active { background: #0A3A1B; border-color: #0A3A1B; color: #fff; }
.admin-pagination .disabled { opacity: .45; pointer-events: none; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn-primary {
  background: #0A3A1B;
  color: #fff;
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .2s;
  text-decoration: none;
}
.btn-primary:hover { background: #1F5C38; }
.btn-sm { padding: 6px 14px; font-size: 12.5px; }
.btn-danger  { background: #DC2626; color: #fff; padding: 6px 14px; border: none; border-radius: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.btn-danger:hover { background: #B91C1C; }
.btn-ghost   { background: transparent; border: 1.5px solid #D1D5DB; color: #374151; padding: 6px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-ghost:hover { border-color: #9CA3AF; }
.btn-block   { width: 100%; text-align: center; justify-content: center; }
.btn-warn    { background: #D97706; color: #fff; padding: 6px 14px; border: none; border-radius: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer; }

/* ── Forms ──────────────────────────────────────────────────────────── */
.form-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.field       { margin-bottom: 20px; }
.field.full  { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; color: #555; text-transform: uppercase; letter-spacing: .04em; }
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid #D8D8D8;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus,
.field select:focus,
.field textarea:focus { outline: none; border-color: #0A3A1B; box-shadow: 0 0 0 3px rgba(10,58,27,.08); }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 44px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  padding: 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #6B7280;
  cursor: pointer;
}
.password-toggle:hover { background: #F3F4F6; color: #0A3A1B; }
.password-toggle:focus-visible { outline: 2px solid #0A3A1B; outline-offset: 1px; }
.password-eye { display: block; width: 20px; height: 20px; }
.field textarea { resize: vertical; min-height: 90px; }
.field .hint    { font-size: 12px; color: #888; margin-top: 4px; }
.field .preview-img { max-height: 120px; border-radius: 8px; margin-top: 8px; display: block; }
.media-library-label { margin-top: 12px; }
.image-source-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.image-source-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-height: 86px;
  padding: 12px;
  border: 1px solid #D8D8D8;
  border-radius: 9px;
  background: #fff;
  color: #1a1a2e;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.image-source-option:hover,
.image-source-option:focus-visible { border-color: #0A3A1B; background: #F7FBF8; box-shadow: 0 0 0 3px rgba(10,58,27,.08); outline: none; }
.image-source-option input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.image-source-option strong { font-size: 13px; }
.image-source-option small { color: #777; font-size: 11px; }
.source-icon { color: #0A3A1B; font-size: 20px; line-height: 1; }
.selected-image-note { min-height: 20px; margin-top: 8px; color: #666; font-size: 12px; }
.image-gallery-modal[hidden] { display: none; }
.image-gallery-modal { position: fixed; inset: 0; z-index: 1400; display: grid; place-items: center; padding: 20px; }
.image-gallery-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.image-gallery-dialog { position: relative; z-index: 1; display: flex; flex-direction: column; width: min(760px, 100%); max-height: min(720px, 90vh); background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.24); overflow: hidden; }
.image-gallery-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid #E5E7EB; }
.image-gallery-head h2 { font-size: 17px; }
.modal-close { width: 34px; height: 34px; border: 0; border-radius: 7px; background: transparent; color: #555; font-size: 24px; line-height: 1; cursor: pointer; }
.modal-close:hover, .modal-close:focus-visible { background: #F3F4F6; outline: 2px solid #0A3A1B; }
.image-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; overflow-y: auto; padding: 18px; }
.gallery-tile { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 6px; border: 2px solid transparent; border-radius: 9px; background: #F9FAFB; color: #444; text-align: left; cursor: pointer; font: inherit; }
.gallery-tile:hover, .gallery-tile:focus-visible { border-color: #0A3A1B; outline: none; background: #F1F8F3; }
.gallery-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; }
.gallery-tile span { overflow: hidden; padding: 0 2px; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
body.modal-open { overflow: hidden; }
.media-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  max-height: 270px;
  overflow-y: auto;
  padding: 10px;
  margin-top: 8px;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  background: #F9FAFB;
}
.media-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 5px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s;
}
.media-tile:hover { border-color: #A9C2B2; }
.media-tile:has(input:checked) { border-color: #0A3A1B; box-shadow: 0 0 0 2px rgba(10,58,27,.12); }
.media-tile input { position: absolute; opacity: 0; pointer-events: none; }
.media-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; }
.media-tile span { overflow: hidden; color: #555; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.toggle-wrap { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.toggle-wrap input[type=checkbox] { width: 18px; height: 18px; accent-color: #0A3A1B; cursor: pointer; }

/* ── Status badges ──────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 100px; font-size: 11.5px; font-weight: 700; text-transform: capitalize; white-space: nowrap; }
.badge-pending    { background: #FEF3C7; color: #92400E; }
.badge-confirmed  { background: #D1FAE5; color: #065F46; }
.badge-processing { background: #DBEAFE; color: #1E40AF; }
.badge-ready      { background: #EDE9FE; color: #5B21B6; }
.badge-delivered  { background: #D1FAE5; color: #065F46; }
.badge-cancelled  { background: #FEE2E2; color: #991B1B; }
.badge-in_stock   { background: #D1FAE5; color: #065F46; }
.badge-low_stock  { background: #FEF3C7; color: #92400E; }
.badge-out_of_stock { background: #FEE2E2; color: #991B1B; }
.badge-active     { background: #D1FAE5; color: #065F46; }
.badge-inactive   { background: #F3F4F6; color: #6B7280; }

/* ── Alerts ─────────────────────────────────────────────────────────── */
.alert          { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 20px; }
.alert-error    { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }
.alert-success  { background: #D1FAE5; color: #065F46; border: 1px solid #6EE7B7; }

/* ── Filters bar ─────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.filter-bar input,
.filter-bar select { padding: 7px 12px; border: 1.5px solid #D8D8D8; border-radius: 8px; font-size: 13.5px; background: #fff; }
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: #0A3A1B; }

/* ── Order detail ────────────────────────────────────────────────────── */
.order-meta { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-bottom: 24px; }
.meta-block { background: #F7F8FA; border-radius: 10px; padding: 16px; }
.meta-block .label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #888; margin-bottom: 4px; }
.meta-block .value { font-size: 14.5px; font-weight: 600; color: #1a1a2e; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  body { overflow-x: hidden; }
  .mobile-admin-bar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 1100;
    align-items: center;
    gap: 14px;
    min-height: 56px;
    padding: 10px 16px;
    background: #072712;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,.14);
  }
  .mobile-admin-bar strong { font-size: 15px; }
  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 7px;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 8px;
    background: transparent;
    color: #fff;
    cursor: pointer;
  }
  .mobile-menu-toggle svg { width: 21px; height: 21px; }
  .admin-layout { display: block; min-height: calc(100vh - 56px); }
  .sidebar {
    display: flex;
    position: fixed;
    z-index: 1200;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .25s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,.2);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1150;
    background: rgba(0,0,0,.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  .sidebar-overlay.is-visible { opacity: 1; pointer-events: auto; }
  .admin-topbar { padding: 16px; }
  .admin-content { padding: 20px 16px; }
  .stat-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 600px) {
  .admin-topbar { align-items: flex-start; }
  .admin-topbar h1 { font-size: 18px; }
  .admin-topbar .btn-primary,
  .admin-topbar .btn-ghost { padding: 8px 10px; font-size: 0; }
  .admin-topbar .btn-primary::before { content: '+'; font-size: 18px; line-height: 1; }
  .admin-topbar .btn-ghost::before { content: '\2190'; font-size: 18px; line-height: 1; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 30px; }
  .stat-label { font-size: 10px; }
  .card { border-radius: 10px; padding: 16px; }
  .card[style*="padding:0"] { padding: 0 !important; overflow-x: auto; }
  .card-head { align-items: flex-start; gap: 12px; }
  .filter-bar { align-items: stretch; }
  .filter-bar input, .filter-bar select, .filter-bar .btn-ghost { flex: 1 1 100%; min-height: 40px; }
  .filter-bar span { width: 100%; margin-left: 0 !important; }
  .order-meta { grid-template-columns: 1fr; gap: 10px; }
  .admin-content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .image-source-options { grid-template-columns: 1fr; }
  .image-gallery-modal { padding: 10px; }
  .image-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; gap: 8px; }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 10px; }
  .data-table .actions { gap: 5px; }
  .data-table .actions .btn-ghost,
  .data-table .actions .btn-danger { font-size: 0; width: 34px; height: 34px; padding: 7px; justify-content: center; }
  .data-table .actions .btn-ghost::before { content: '\270E'; font-size: 16px; }
  .data-table .actions .btn-danger::before { content: '\1F5D1'; font-size: 15px; }
  .data-table td:last-child > .btn-ghost { font-size: 0; width: 34px; height: 34px; padding: 7px; justify-content: center; }
  .data-table td:last-child > .btn-ghost::before { content: '\2192'; font-size: 17px; }
}
