:root {
  --bg: #f4efe7;
  --panel: rgba(255, 255, 255, 0.88);
  --text: #132321;
  --muted: #5e6d69;
  --line: rgba(19, 35, 33, 0.08);
  --accent: #4285F4;
  --accent-strong: #1f5fc4;
  --accent-soft: #e8f0fe;
  --sun: #8ab4f8;
  --danger: #c54f45;
  --success: #2d8f60;
  --shadow-lg: 0 28px 70px rgba(24, 42, 40, 0.15);
  --shadow-md: 0 18px 48px rgba(24, 42, 40, 0.1);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(66, 133, 244, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(138, 180, 248, 0.18), transparent 24%),
    linear-gradient(180deg, #fbf7f1 0%, #f1e8dd 100%);
  font-family: "Manrope", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
body.modal-open { overflow: hidden; }
.admin-shell { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 28px;
  background: rgba(19, 35, 33, 0.92); color: #f6fbfa; backdrop-filter: blur(24px);
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 18px;
  background: linear-gradient(135deg, #8ab4f8, #4285F4);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}
.brand-logo {
  width: 168px;
  height: auto;
  display: block;
}
.brand-text strong, .section-title, .panel-card h3, .page-title h1, .stat-card strong, .login-card h1 {
  font-family: "Space Grotesk", sans-serif;
}
.brand-text small, .sidebar-note, .muted, .table-muted { color: rgba(246, 251, 250, 0.7); }
.nav-links { display: grid; gap: 10px; margin-top: 24px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 18px;
  color: rgba(246, 251, 250, 0.82); transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}
.nav-link:hover, .nav-link.is-active {
  color: #fff; background: linear-gradient(135deg, rgba(138, 180, 248, 0.32), rgba(66, 133, 244, 0.54)); transform: translateX(4px);
}
.nav-icon {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.08); font-size: 14px; font-weight: 800;
}
.main-content { padding: 30px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 24px; }
.page-title { min-width: 0; }
.page-title h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.1rem); line-height: 0.95; }
.page-title p { margin: 10px 0 0; color: #5e6d69; }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pill, .status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.8); color: var(--muted); box-shadow: var(--shadow-md);
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); }
.layout-grid { display: grid; gap: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.stat-card, .panel-card, .table-card, .form-card, .highlight-card {
  border: 1px solid rgba(255, 255, 255, 0.55); background: var(--panel); box-shadow: var(--shadow-lg); backdrop-filter: blur(18px);
}
.stat-card { padding: 20px; border-radius: var(--radius-lg); display: grid; gap: 16px; animation: rise 520ms ease both; }
.stat-card strong { font-size: 2rem; }
.stat-card span, .stat-card small { color: #5e6d69; }
.grid-two { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr); gap: 20px; }
.panel-card, .table-card, .form-card, .highlight-card { border-radius: var(--radius-xl); padding: 24px; min-width: 0; }
.panel-card h3, .table-card h3, .form-card h3, .highlight-card h3 { margin: 0 0 10px; font-size: 1.3rem; }
.panel-header, .table-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.search-inline { min-width: 0; width: min(100%, 280px); }
.search-inline input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(19, 35, 33, 0.12);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}
.kpi-list, .mini-list { display: grid; gap: 14px; }
.kpi-item, .mini-item {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 16px;
  border-radius: 18px; background: rgba(255, 255, 255, 0.68); border: 1px solid var(--line);
}
.bar-chart { display: grid; align-items: end; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; height: 220px; }
.bar-chart figure { margin: 0; display: grid; gap: 10px; align-items: end; justify-items: center; }
.bar-chart .bar {
  width: 100%; border-radius: 18px 18px 8px 8px; min-height: 20px;
  background: linear-gradient(180deg, #4285F4 0%, #1f5fc4 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.bar-chart figcaption { font-size: 0.84rem; color: var(--muted); }
.bar-chart strong { font-size: 0.88rem; }
.flash { margin-bottom: 18px; padding: 14px 18px; border-radius: 18px; box-shadow: var(--shadow-md); }
.flash.success { background: rgba(45, 143, 96, 0.12); color: #1e6f4b; }
.flash.error { background: rgba(197, 79, 69, 0.12); color: #8e322b; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 14px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; }
.table-thumb {
  width: 58px; height: 58px; border-radius: 16px; object-fit: cover;
  background: linear-gradient(135deg, #d9ebe7, #fbf1dd); border: 1px solid var(--line);
}
.badge {
  display: inline-flex; align-items: center; justify-content: center; padding: 7px 12px;
  border-radius: 999px; font-size: 0.82rem; font-weight: 700;
}
.badge.active, .badge.success { background: rgba(45, 143, 96, 0.14); color: #1e6f4b; }
.badge.inactive, .badge.warning { background: rgba(243, 167, 18, 0.18); color: #8f5c00; }
.badge.danger { background: rgba(197, 79, 69, 0.14); color: #8e322b; }
.table-actions, .inline-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.table-actions--stack {
  flex-direction: column;
  align-items: stretch;
  min-width: 132px;
}
.table-actions--stack > * {
  width: 100%;
}
.table-actions--stack .btn {
  width: 100%;
}
.products-table__product {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}
.products-table__product > div {
  min-width: 0;
}
.products-table td,
.products-table__product strong,
.products-table__product .muted {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.products-table__status-badge {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  min-width: 78px;
}
.products-table__actions-cell {
  width: 1%;
  white-space: nowrap;
}
.btn, .btn-link, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}
.btn { padding: 12px 16px; border-radius: 16px; font-weight: 700; }
.btn-sm { padding: 10px 14px; border-radius: 14px; }
.btn:hover, .icon-btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, #4285F4, #1f5fc4); color: #fff; box-shadow: 0 18px 30px rgba(66, 133, 244, 0.28); }
.btn-secondary { background: rgba(255, 255, 255, 0.92); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: rgba(197, 79, 69, 0.12); color: #8e322b; }
.btn-link { background: transparent; color: var(--accent-strong); padding: 0; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; background: rgba(255, 255, 255, 0.92); border: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; padding: 14px 16px; border-radius: 16px; border: 1px solid rgba(19, 35, 33, 0.12);
  background: rgba(255, 255, 255, 0.9); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.field textarea { min-height: 110px; resize: vertical; }
.referral-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
}
.referral-card__qr {
  width: 132px;
  height: 132px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: cover;
}
.referral-card__content {
  display: grid;
  gap: 10px;
}
.referral-card__content strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.35rem;
}
.details-card { margin-top: 12px; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.6); }
.details-card summary { list-style: none; cursor: pointer; padding: 14px 18px; font-weight: 700; }
.details-card summary::-webkit-details-marker { display: none; }
.details-content { padding: 0 18px 18px; }
.sale-reference-actions { margin-top: 12px; }
.sale-contact-actions { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.sale-contact-text { color: var(--text); }
.sale-item-meta { color: var(--text); }
.sale-modal {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px;
}
.sale-modal[hidden] { display: none; }
.sale-modal__backdrop {
  position: absolute; inset: 0; background: rgba(19, 35, 33, 0.52); backdrop-filter: blur(8px);
}
.sale-modal__dialog {
  position: relative; z-index: 1; width: min(1180px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  padding: 26px; border-radius: 30px; border: 1px solid rgba(255, 255, 255, 0.58);
  background: rgba(251, 247, 241, 0.96); box-shadow: 0 40px 90px rgba(19, 35, 33, 0.22);
}
.sale-modal__header, .sale-modal__meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sale-modal__header { margin-bottom: 18px; }
.sale-modal__meta { margin-bottom: 18px; flex-wrap: wrap; justify-content: flex-start; }
.sale-modal__status-form {
  display: flex;
  align-items: end;
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}
.sale-modal__status-form .field { min-width: 240px; }
.sale-modal__eyebrow {
  margin: 0 0 8px; font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text);
}
.sale-modal__grid { display: grid; grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.2fr); gap: 18px; }
.sale-modal__panel {
  padding: 20px; border-radius: 24px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.72);
}
.sale-modal__items { display: grid; gap: 12px; }
.sale-modal__notes {
  margin-top: 16px; padding: 14px 16px; border-radius: 18px; background: rgba(66, 133, 244, 0.08); color: var(--text);
}
.sale-modal__notes--soft { background: rgba(19, 35, 33, 0.05); }
.sale-contact-card { display: grid; gap: 8px; }
.sale-contact-card strong { font-size: 1.25rem; }
.sale-modal__items .mini-item {
  align-items: flex-start;
  padding: 16px 18px;
}
.sale-modal .muted,
.sale-modal .panel-header .muted,
.sale-summary-card span {
  color: var(--text);
}
.sale-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.sale-summary-card {
  display: grid; gap: 8px; padding: 16px; border-radius: 20px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.88);
}
.sale-summary-card span { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; }
.sale-summary-card strong { font-family: "Space Grotesk", sans-serif; font-size: 1.2rem; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 26px; }
.login-card {
  width: min(1080px, 100%); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  overflow: hidden; border-radius: 36px; box-shadow: var(--shadow-lg); background: rgba(255, 255, 255, 0.82); backdrop-filter: blur(24px);
}
.login-aside {
  padding: 42px; color: #f8fffe;
  background: radial-gradient(circle at 20% 20%, rgba(138, 180, 248, 0.48), transparent 24%),
    radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.18), transparent 12%),
    linear-gradient(145deg, #14325f 0%, #4285F4 100%);
}
.login-hero { max-width: 520px; }
.eyebrow {
  display: inline-flex; padding: 9px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.12);
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.14em;
}
.login-hero h2 { margin: 18px 0 14px; font-family: "Space Grotesk", sans-serif; font-size: clamp(2rem, 4vw, 3.7rem); line-height: 0.95; }
.login-list { display: grid; gap: 14px; margin-top: 24px; }
.login-list div { padding: 14px 16px; border-radius: 18px; background: rgba(255, 255, 255, 0.1); }
.login-form { padding: 42px; }
.login-logo {
  width: min(260px, 100%);
  height: auto;
  margin-bottom: 18px;
}
.login-form form { display: grid; gap: 16px; margin-top: 26px; }
.login-form .btn { width: 100%; margin-top: 6px; }
.login-meta { margin-top: 18px; color: var(--muted); font-size: 0.92rem; }
.mobile-toggle { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(18px);} to { opacity: 1; transform: translateY(0);} }
@media (max-width: 1400px) {
  .stats-grid, .grid-two, .login-card { grid-template-columns: 1fr; }
  .bar-chart { height: 180px; }
}
@media (max-width: 920px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: min(320px, 86vw); transform: translateX(-100%);
    transition: transform 220ms ease; z-index: 30;
  }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-toggle { display: inline-flex; }
  .main-content { padding: 18px; }
  .topbar { flex-direction: column; align-items: stretch; }
}
@media (max-width: 1280px) {
  .products-table thead {
    display: none;
  }
  .products-table,
  .products-table tbody,
  .products-table tr,
  .products-table td {
    display: block;
    width: 100%;
  }
  .products-table {
    overflow: visible;
  }
  .products-table tbody {
    display: grid;
    gap: 14px;
  }
  .products-table tr {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.72);
  }
  .products-table td {
    padding: 0;
    border: 0;
  }
  .products-table td + td {
    margin-top: 10px;
  }
  .products-table td[data-label] {
    display: grid;
    grid-template-columns: minmax(92px, 120px) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
  }
  .products-table td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
  .products-table td:first-child {
    margin-bottom: 8px;
  }
  .products-table td:first-child::before {
    display: none;
  }
  .products-table__product { align-items: flex-start; }
  .products-table__actions-cell {
    width: auto;
    white-space: normal;
  }
  .products-table__actions-cell .table-actions--stack {
    min-width: 0;
    width: 100%;
  }
}
@media (max-width: 720px) {
  .form-grid, .stats-grid { grid-template-columns: 1fr; }
  .panel-card, .table-card, .form-card, .highlight-card, .login-form, .login-aside { padding: 20px; }
  .data-table { display: block; overflow-x: auto; }
  .products-table__product {
    align-items: flex-start;
  }
  .products-table td[data-label] {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .products-table td[data-label]::before {
    margin-bottom: 2px;
  }
  .table-actions--stack { min-width: 0; }
  .sale-modal { padding: 12px; }
  .sale-modal__dialog { padding: 18px; max-height: calc(100vh - 24px); }
  .sale-modal__grid, .sale-summary-grid { grid-template-columns: 1fr; }
  .referral-card { flex-direction: column; align-items: flex-start; }
}
