/*
  Cracckers Hub — unified responsive layout
  This file intentionally loads LAST so it can normalize older
  breakpoint rules without changing Flask routes or business logic.
*/

/* ---------- Global sizing & large screens ---------- */

html {
  width: 100%;
  min-width: 320px;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

button,
input,
select,
textarea {
  max-width: 100%;
}

.page {
  width: min(94vw, 1400px);
  margin-inline: auto;
}

/* ---------- Comfortable desktop / laptop ---------- */

@media (min-width: 769px) {
  .site-header {
    padding-inline: clamp(24px, 4vw, 72px);
  }

  .site-header nav {
    justify-content: flex-end;
  }

  .section-heading {
    align-items: center;
  }

  .table-panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .product-table {
    min-width: 760px;
  }

  .split-layout {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  }

  .actions {
    align-items: center;
  }

  .button {
    width: auto;
  }

  .admin-shell {
    min-width: 0;
  }

  .admin-main {
    min-width: 0;
  }

  .admin-panel,
  .admin-hero,
  .admin-topbar {
    width: 100%;
  }
}

/* ---------- Laptop: 769–1200px ---------- */

@media (min-width: 769px) and (max-width: 1200px) {
  .page {
    width: min(94vw, 1120px);
  }

  .site-header {
    gap: 14px;
  }

  .brand {
    font-size: 1.2rem;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
  }

  .nav-link,
  .install-app-button {
    font-size: 0.86rem;
    padding: 8px 9px;
  }

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

  .welcome-section,
  .story-section {
    gap: 24px;
  }

  .split-layout {
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 18px;
  }

  .admin-main {
    padding: 18px;
  }

  .admin-sidebar {
    width: 240px;
    flex-basis: 240px;
    padding-inline: 14px;
  }

  .admin-stats-grid {
    gap: 12px;
  }
}

/* ---------- Large desktop ---------- */

@media (min-width: 1401px) {
  .page {
    width: min(92vw, 1500px);
  }

  .site-header {
    padding-inline: max(4vw, 40px);
  }

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

  .product-image {
    min-height: 190px;
  }

  .admin-main {
    padding: 30px;
  }

  .admin-sidebar {
    width: 280px;
    flex-basis: 280px;
  }

  .admin-panel {
    padding: 24px;
  }

  .admin-hero {
    padding: 28px;
  }
}

/* ---------- Medium/tablet ---------- */

@media (max-width: 1024px) {
  .page {
    width: 94vw;
  }

  .site-header {
    flex-wrap: wrap;
  }

  .site-header > nav {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .section-heading {
    gap: 14px;
  }

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

  .welcome-section,
  .story-section {
    grid-template-columns: 1fr;
    gap: 20px;
  }

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

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

  /* Admin data tables stay tables and scroll instead of becoming cramped cards. */
  .admin-panel:has(.admin-table),
  .admin-table-wrap,
  .table-panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table {
    min-width: 760px;
  }

  .admin-table th,
  .admin-table td {
    white-space: nowrap;
  }

  .admin-table td[data-label="Description"] {
    white-space: normal;
    min-width: 180px;
  }
}

/* ---------- Phone ---------- */

@media (max-width: 768px) {
  body {
    font-size: 15px;
    padding-bottom: 72px;
  }

  .page {
    width: calc(100% - 20px);
    margin: 16px auto 48px;
  }

  /* Customer header */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
  }

  .site-header .brand {
    flex: 0 0 auto;
    max-width: 48%;
    min-width: 0;
    font-size: 1rem;
  }

  .site-header .brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .site-header > nav {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 3px;
    justify-content: flex-start;
    scrollbar-width: none;
  }

  .site-header > nav::-webkit-scrollbar {
    display: none;
  }

  .nav-link,
  .install-app-button {
    flex: 0 0 auto;
    width: auto;
    min-height: 42px;
    padding: 8px 11px;
    border-radius: 10px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .nav-link svg,
  .install-app-button svg {
    width: 16px;
    height: 16px;
  }

  /* Page headings */
  .section-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 16px;
  }

  .section-heading > * {
    min-width: 0;
  }

  h1 {
    font-size: clamp(1.45rem, 7vw, 2rem);
    line-height: 1.15;
  }

  h2 {
    font-size: 1.3rem;
  }

  h3 {
    font-size: 1rem;
  }

  /* Hero and content sections */
  .page-hero {
    padding: 24px 18px !important;
    border-radius: 16px;
  }

  .welcome-section,
  .story-section,
  .gift-note,
  .solutions-section,
  .collection-section {
    margin-top: 18px;
    padding: 18px !important;
  }

  .welcome-section,
  .story-section {
    display: grid;
    grid-template-columns: 1fr;
  }

  .solution-grid,
  .collection-grid,
  .stats-grid,
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Product cards */
  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .product-details {
    padding: 13px;
  }

  .product-details h3 {
    font-size: 0.95rem;
  }

  .product-image {
    height: 140px;
  }

  .product-pricing .price {
    font-size: 1.05rem;
  }

  /* Customer shopping tables */
  .shop-products-table,
  .table-panel {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .shop-products-table .product-table,
  .product-table {
    min-width: 650px;
    width: 100%;
  }

  .shop-products-table .product-table thead {
    display: table-header-group;
  }

  .shop-products-table .product-table tr {
    display: table-row;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
  }

  .shop-products-table .product-table th,
  .shop-products-table .product-table td {
    display: table-cell;
    padding: 10px 8px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .shop-products-table .product-table td::before {
    content: none;
  }

  .shop-products-table .product-table img {
    width: 48px !important;
    height: 48px !important;
    object-fit: cover;
  }

  .quantity-input {
    width: 76px;
    min-width: 76px;
    min-height: 44px;
    font-size: 16px;
    text-align: center;
  }

  /* Generic tables that aren't shopping tables */
  .product-table:not(.shop-mobile-table) {
    min-width: 600px;
  }

  /* Forms */
  .form-card,
  .summary-card,
  .auth-card,
  .lookup-form,
  .inline-form {
    width: 100%;
    padding: 16px;
    border-radius: 14px;
  }

  .form-card {
    display: grid;
    gap: 13px;
  }

  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  textarea {
    min-height: 110px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 14px 0;
  }

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

  .button {
    min-height: 44px;
    padding: 10px 14px;
  }

  /* Checkout */
  .split-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .form-card {
    order: 1;
  }

  .summary-card {
    order: 2;
  }

  .summary-row,
  .summary-total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }

  .summary-row > *,
  .summary-total > * {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* Contact */
  .contact-card {
    min-width: 0;
    width: 100%;
    padding: 16px;
  }

  .contact-card strong,
  .contact-card p {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Bills */
  .bill {
    width: 100%;
    overflow-x: auto;
    padding: 14px;
  }

  .bill table {
    min-width: 560px;
  }

  /* Floating controls */
  .floating-contact {
    right: 10px;
    bottom: 12px;
    gap: 8px;
  }

  .floating-icon {
    width: 44px;
    height: 44px;
  }

  .floating-icon svg {
    width: 25px;
    height: 25px;
  }

  /* Footer */
  .site-footer {
    grid-template-columns: 1fr !important;
    gap: 18px;
    padding: 24px 16px !important;
    text-align: center;
  }

  /* Messages */
  .messages {
    width: calc(100% - 20px);
    margin: 10px auto;
  }

  .message {
    font-size: 0.88rem;
    padding: 11px;
  }
}

/* ---------- Small phones ---------- */

@media (max-width: 480px) {
  .page {
    width: calc(100% - 14px);
    margin-top: 12px;
  }

  .site-header {
    padding: 8px;
  }

  .site-header .brand {
    font-size: 0.9rem;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  .nav-link,
  .install-app-button {
    min-height: 40px;
    padding: 7px 9px;
    font-size: 0.74rem;
  }

  .nav-link svg,
  .install-app-button svg {
    width: 15px;
    height: 15px;
  }

  .products-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .product-image {
    height: 165px;
  }

  .page-hero {
    padding: 20px 14px !important;
  }

  .welcome-section,
  .story-section,
  .gift-note,
  .solutions-section,
  .collection-section {
    padding: 14px !important;
  }

  .shop-products-table .product-table {
    min-width: 620px;
  }

  .shop-products-table .product-table th,
  .shop-products-table .product-table td {
    padding: 8px 6px;
    font-size: 0.77rem;
  }

  .shop-products-table .product-table img {
    width: 42px !important;
    height: 42px !important;
  }

  .quantity-input {
    min-width: 68px;
    width: 68px;
  }

  .form-card,
  .summary-card,
  .auth-card,
  .lookup-form {
    padding: 13px;
  }

  .button {
    width: 100%;
  }

  .button.small {
    width: auto;
  }

  .bill {
    padding: 10px;
  }

  .bill table {
    min-width: 520px;
  }
}

/* ---------- Very small phones ---------- */

@media (max-width: 360px) {
  .site-header .brand {
    max-width: 44%;
  }

  .nav-link,
  .install-app-button {
    padding-inline: 8px;
    font-size: 0.7rem;
  }

  .shop-products-table .product-table {
    min-width: 600px;
  }
}

/* ---------- Admin: desktop ---------- */

@media (min-width: 769px) {
  .admin-sidebar {
    flex: 0 0 265px;
  }

  .admin-main {
    min-width: 0;
  }

  .admin-table-wrap,
  .admin-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table {
    min-width: 760px;
  }
}

/* ---------- Admin: tablet/phone ---------- */

@media (max-width: 820px) {
  .admin-shell {
    display: block;
    min-height: 100vh;
  }

  .admin-sidebar {
    width: 100%;
    height: auto;
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 1100;
    padding: 10px;
    gap: 8px;
  }

  .admin-sidebar .brand {
    padding: 8px 10px;
  }

  .admin-sidebar .brand img {
    width: 38px;
    height: 38px;
  }

  .admin-sidebar nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    margin-top: 2px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .admin-sidebar nav::-webkit-scrollbar {
    display: none;
  }

  .admin-sidebar nav a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 9px 11px;
    font-size: 0.78rem;
  }

  .admin-sidebar-footer {
    display: none;
  }

  .admin-main {
    width: 100%;
    padding: 12px;
  }

  .admin-topbar {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 16px;
  }

  .admin-topbar .topbar-left,
  .admin-topbar .topbar-right {
    width: 100%;
    min-width: 0;
  }

  .admin-topbar .search {
    width: 100%;
    min-width: 0;
  }

  .admin-hero {
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
    border-radius: 18px;
  }

  .admin-actions {
    width: 100%;
    gap: 8px;
  }

  .admin-actions .admin-btn {
    min-height: 44px;
  }

  .admin-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0;
  }

  .stat-card {
    min-width: 0;
    padding: 14px;
    border-radius: 16px;
  }

  .stat-card strong {
    font-size: 1.15rem;
    overflow-wrap: anywhere;
  }

  .admin-panel {
    width: 100%;
    padding: 14px;
    margin-bottom: 12px;
    border-radius: 16px;
    min-width: 0;
  }

  /* Do not convert wide admin tables into tiny cards.
     Keep them usable and horizontally scrollable. */
  .admin-table {
    display: table !important;
    width: max-content;
    min-width: 760px;
    border-collapse: collapse;
  }

  .admin-table thead {
    display: table-header-group !important;
  }

  .admin-table tbody tr {
    display: table-row !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .admin-table th,
  .admin-table td {
    display: table-cell !important;
    padding: 9px 8px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .admin-table td::before {
    content: none !important;
  }

  .admin-table img {
    width: 45px !important;
    height: 45px !important;
  }

  .admin-table input,
  .admin-table select,
  .admin-table textarea {
    min-height: 40px;
    font-size: 16px;
  }

  .admin-table input[type="number"] {
    width: 85px;
  }

  .admin-table td[data-label="Description"] {
    min-width: 200px;
    max-width: 280px;
    white-space: normal;
  }

  .admin-table td[data-label="Description"] input {
    min-width: 190px;
  }

  .admin-table-wrap,
  .admin-table-scroll,
  .admin-panel > .table-scroll,
  .admin-panel > .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-compact {
    flex-wrap: nowrap;
  }

  .admin-compact .admin-btn {
    min-height: 40px;
  }
}

/* ---------- Admin: small phones ---------- */

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

  .admin-sidebar {
    padding: 7px;
  }

  .admin-sidebar nav a {
    padding: 8px 9px;
    font-size: 0.72rem;
  }

  .admin-topbar {
    padding: 10px;
  }

  .admin-hero {
    padding: 14px;
  }

  .admin-hero h1 {
    font-size: 1.25rem;
  }

  .admin-stats-grid {
    gap: 8px;
  }

  .stat-card {
    padding: 11px;
  }

  .stat-card .stat-icon {
    width: 36px;
    height: 36px;
  }

  .admin-panel {
    padding: 10px;
  }

  .admin-table {
    min-width: 720px;
  }

  .admin-table th,
  .admin-table td {
    padding: 7px 6px;
    font-size: 0.73rem;
  }

  .admin-actions {
    flex-direction: column;
  }

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

/* ---------- Accessibility / touch ---------- */

@media (hover: none) and (pointer: coarse) {
  .button,
  .admin-btn,
  .nav-link,
  .install-app-button,
  button {
    -webkit-tap-highlight-color: transparent;
  }

  .button,
  .admin-btn,
  button {
    min-height: 44px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* ---------- Sales report ---------- */

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

.sales-top-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.sales-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sales-table-scroll .admin-table {
  min-width: 520px;
}

@media (max-width: 768px) {
  .report-container {
    width: 100%;
    padding: 8px 0;
  }

  .sales-summary-grid,
  .sales-top-grid {
    grid-template-columns: 1fr;
  }

  .category-card-header {
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 14px;
  }

  .category-card-header h2 {
    font-size: 1.2rem;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .category-submetrics {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    gap: 12px;
  }

  .category-card > .sales-table-scroll {
    padding-bottom: 6px;
  }
}

@media (max-width: 480px) {
  .category-card-header {
    gap: 8px;
  }

  .category-card-header .icon {
    font-size: 22px;
  }

  .category-card-header h2 {
    font-size: 1.05rem;
  }

  .metric {
    font-size: 12px;
  }

  .metric strong {
    font-size: 14px;
  }
}
<<<<<<< HEAD


/* =========================================================
   FINAL TABLE ALIGNMENT FIX
   Keeps every cell under its corresponding header.
   ========================================================= */

.table-panel,
.table-responsive,
.shop-products-table,
.admin-table-wrap,
.admin-table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.table-panel > table,
.table-responsive > table,
.shop-products-table > table,
.admin-table-wrap > table,
.admin-table-scroll > table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

/* Never let a cell's content change the column alignment unpredictably. */
.product-table th,
.product-table td,
.admin-table th,
.admin-table td,
.data-table th,
.data-table td {
    box-sizing: border-box;
    vertical-align: middle;
}

/* Header and body use identical horizontal alignment. */
.product-table th,
.admin-table th,
.data-table th {
    text-align: left;
    white-space: nowrap;
}

.product-table td,
.admin-table td,
.data-table td {
    text-align: left;
}

/* Numeric columns */
.product-table th:first-child,
.product-table td:first-child {
    text-align: center;
}

.product-table th:nth-child(4),
.product-table td:nth-child(4),
.product-table th:nth-last-child(1),
.product-table td:nth-last-child(1) {
    text-align: right;
}

/* Images remain centered in their own column. */
.product-table th:nth-child(2),
.product-table td:nth-child(2) {
    text-align: center;
}

/* Inputs stay inside their cells instead of pushing columns. */
.product-table input,
.product-table select,
.product-table textarea,
.admin-table input,
.admin-table select,
.admin-table textarea {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Keep long text inside the correct column. */
.product-table td,
.admin-table td,
.data-table td {
    overflow-wrap: anywhere;
}

/* Wide tables: preserve a consistent minimum width so columns
   cannot collapse and drift away from their headers. */
@media (max-width: 768px) {
    .admin-table {
        width: max-content;
        min-width: 1000px;
    }

    .product-table.shop-mobile-table,
    .shop-products-table .product-table {
        width: max-content;
        min-width: 720px;
    }

    .product-table th,
    .product-table td,
    .admin-table th,
    .admin-table td {
        white-space: nowrap;
    }

    /* Allow descriptions to wrap while keeping their column. */
    .admin-table td.description-cell,
    .admin-table td.product-description,
    .product-table td.description-cell {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

@media (min-width: 769px) {
    .admin-table {
        width: 100%;
    }

    .product-table {
        width: 100%;
    }
}

/* Tables converted to mobile cards should not use this rule.
   It only applies to actual tabular layouts. */
@media (max-width: 640px) {
    .shop-products-table .product-table {
        display: table;
    }

    .shop-products-table .product-table thead {
        display: table-header-group;
    }

    .shop-products-table .product-table tbody {
        display: table-row-group;
    }

    .shop-products-table .product-table tr {
        display: table-row;
    }

    .shop-products-table .product-table th,
    .shop-products-table .product-table td {
        display: table-cell;
    }
}
=======
>>>>>>> 71e99db8e5ba1fafd78e9ee94fa1bb6209fd8365

/*
  Cracckers Hub — unified responsive layout
  This file intentionally loads LAST so it can normalize older
  breakpoint rules without changing Flask routes or business logic.
*/

/* ---------- Global sizing & large screens ---------- */

html {
  width: 100%;
  min-width: 320px;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

button,
input,
select,
textarea {
  max-width: 100%;
}

.page {
  width: min(94vw, 1400px);
  margin-inline: auto;
}

/* ---------- Comfortable desktop / laptop ---------- */

@media (min-width: 769px) {
  .site-header {
    padding-inline: clamp(24px, 4vw, 72px);
  }

  .site-header nav {
    justify-content: flex-end;
  }

  .section-heading {
    align-items: center;
  }

  .table-panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .product-table {
    min-width: 760px;
  }

  .split-layout {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  }

  .actions {
    align-items: center;
  }

  .button {
    width: auto;
  }

  .admin-shell {
    min-width: 0;
  }

  .admin-main {
    min-width: 0;
  }

  .admin-panel,
  .admin-hero,
  .admin-topbar {
    width: 100%;
  }
}

/* ---------- Laptop: 769–1200px ---------- */

@media (min-width: 769px) and (max-width: 1200px) {
  .page {
    width: min(94vw, 1120px);
  }

  .site-header {
    gap: 14px;
  }

  .brand {
    font-size: 1.2rem;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
  }

  .nav-link,
  .install-app-button {
    font-size: 0.86rem;
    padding: 8px 9px;
  }

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

  .welcome-section,
  .story-section {
    gap: 24px;
  }

  .split-layout {
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 18px;
  }

  .admin-main {
    padding: 18px;
  }

  .admin-sidebar {
    width: 240px;
    flex-basis: 240px;
    padding-inline: 14px;
  }

  .admin-stats-grid {
    gap: 12px;
  }
}

/* ---------- Large desktop ---------- */

@media (min-width: 1401px) {
  .page {
    width: min(92vw, 1500px);
  }

  .site-header {
    padding-inline: max(4vw, 40px);
  }

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

  .product-image {
    min-height: 190px;
  }

  .admin-main {
    padding: 30px;
  }

  .admin-sidebar {
    width: 280px;
    flex-basis: 280px;
  }

  .admin-panel {
    padding: 24px;
  }

  .admin-hero {
    padding: 28px;
  }
}

/* ---------- Medium/tablet ---------- */

@media (max-width: 1024px) {
  .page {
    width: 94vw;
  }

  .site-header {
    flex-wrap: wrap;
  }

  .site-header > nav {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .section-heading {
    gap: 14px;
  }

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

  .welcome-section,
  .story-section {
    grid-template-columns: 1fr;
    gap: 20px;
  }

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

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

  /* Admin data tables stay tables and scroll instead of becoming cramped cards. */
  .admin-panel:has(.admin-table),
  .admin-table-wrap,
  .table-panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table {
    min-width: 760px;
  }

  .admin-table th,
  .admin-table td {
    white-space: nowrap;
  }

  .admin-table td[data-label="Description"] {
    white-space: normal;
    min-width: 180px;
  }
}

/* ---------- Phone ---------- */

@media (max-width: 768px) {
  body {
    font-size: 15px;
    padding-bottom: 72px;
  }

  .page {
    width: calc(100% - 20px);
    margin: 16px auto 48px;
  }

  /* Customer header */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
  }

  .site-header .brand {
    flex: 0 0 auto;
    max-width: 48%;
    min-width: 0;
    font-size: 1rem;
  }

  .site-header .brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .site-header > nav {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 3px;
    justify-content: flex-start;
    scrollbar-width: none;
  }

  .site-header > nav::-webkit-scrollbar {
    display: none;
  }

  .nav-link,
  .install-app-button {
    flex: 0 0 auto;
    width: auto;
    min-height: 42px;
    padding: 8px 11px;
    border-radius: 10px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .nav-link svg,
  .install-app-button svg {
    width: 16px;
    height: 16px;
  }

  /* Page headings */
  .section-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 16px;
  }

  .section-heading > * {
    min-width: 0;
  }

  h1 {
    font-size: clamp(1.45rem, 7vw, 2rem);
    line-height: 1.15;
  }

  h2 {
    font-size: 1.3rem;
  }

  h3 {
    font-size: 1rem;
  }

  /* Hero and content sections */
  .page-hero {
    padding: 24px 18px !important;
    border-radius: 16px;
  }

  .welcome-section,
  .story-section,
  .gift-note,
  .solutions-section,
  .collection-section {
    margin-top: 18px;
    padding: 18px !important;
  }

  .welcome-section,
  .story-section {
    display: grid;
    grid-template-columns: 1fr;
  }

  .solution-grid,
  .collection-grid,
  .stats-grid,
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Product cards */
  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .product-details {
    padding: 13px;
  }

  .product-details h3 {
    font-size: 0.95rem;
  }

  .product-image {
    height: 140px;
  }

  .product-pricing .price {
    font-size: 1.05rem;
  }

  /* Customer shopping tables */
  .shop-products-table,
  .table-panel {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .shop-products-table .product-table,
  .product-table {
    min-width: 650px;
    width: 100%;
  }

  .shop-products-table .product-table thead {
    display: table-header-group;
  }

  .shop-products-table .product-table tr {
    display: table-row;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
  }

  .shop-products-table .product-table th,
  .shop-products-table .product-table td {
    display: table-cell;
    padding: 10px 8px;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .shop-products-table .product-table td::before {
    content: none;
  }

  .shop-products-table .product-table img {
    width: 48px !important;
    height: 48px !important;
    object-fit: cover;
  }

  .quantity-input {
    width: 76px;
    min-width: 76px;
    min-height: 44px;
    font-size: 16px;
    text-align: center;
  }

  /* Generic tables that aren't shopping tables */
  .product-table:not(.shop-mobile-table) {
    min-width: 600px;
  }

  /* Forms */
  .form-card,
  .summary-card,
  .auth-card,
  .lookup-form,
  .inline-form {
    width: 100%;
    padding: 16px;
    border-radius: 14px;
  }

  .form-card {
    display: grid;
    gap: 13px;
  }

  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  textarea {
    min-height: 110px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 14px 0;
  }

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

  .button {
    min-height: 44px;
    padding: 10px 14px;
  }

  /* Checkout */
  .split-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .form-card {
    order: 1;
  }

  .summary-card {
    order: 2;
  }

  .summary-row,
  .summary-total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }

  .summary-row > *,
  .summary-total > * {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* Contact */
  .contact-card {
    min-width: 0;
    width: 100%;
    padding: 16px;
  }

  .contact-card strong,
  .contact-card p {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Bills */
  .bill {
    width: 100%;
    overflow-x: auto;
    padding: 14px;
  }

  .bill table {
    min-width: 560px;
  }

  /* Floating controls */
  .floating-contact {
    right: 10px;
    bottom: 12px;
    gap: 8px;
  }

  .floating-icon {
    width: 44px;
    height: 44px;
  }

  .floating-icon svg {
    width: 25px;
    height: 25px;
  }

  /* Footer */
  .site-footer {
    grid-template-columns: 1fr !important;
    gap: 18px;
    padding: 24px 16px !important;
    text-align: center;
  }

  /* Messages */
  .messages {
    width: calc(100% - 20px);
    margin: 10px auto;
  }

  .message {
    font-size: 0.88rem;
    padding: 11px;
  }
}

/* ---------- Small phones ---------- */

@media (max-width: 480px) {
  .page {
    width: calc(100% - 14px);
    margin-top: 12px;
  }

  .site-header {
    padding: 8px;
  }

  .site-header .brand {
    font-size: 0.9rem;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  .nav-link,
  .install-app-button {
    min-height: 40px;
    padding: 7px 9px;
    font-size: 0.74rem;
  }

  .nav-link svg,
  .install-app-button svg {
    width: 15px;
    height: 15px;
  }

  .products-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .product-image {
    height: 165px;
  }

  .page-hero {
    padding: 20px 14px !important;
  }

  .welcome-section,
  .story-section,
  .gift-note,
  .solutions-section,
  .collection-section {
    padding: 14px !important;
  }

  .shop-products-table .product-table {
    min-width: 620px;
  }

  .shop-products-table .product-table th,
  .shop-products-table .product-table td {
    padding: 8px 6px;
    font-size: 0.77rem;
  }

  .shop-products-table .product-table img {
    width: 42px !important;
    height: 42px !important;
  }

  .quantity-input {
    min-width: 68px;
    width: 68px;
  }

  .form-card,
  .summary-card,
  .auth-card,
  .lookup-form {
    padding: 13px;
  }

  .button {
    width: 100%;
  }

  .button.small {
    width: auto;
  }

  .bill {
    padding: 10px;
  }

  .bill table {
    min-width: 520px;
  }
}

/* ---------- Very small phones ---------- */

@media (max-width: 360px) {
  .site-header .brand {
    max-width: 44%;
  }

  .nav-link,
  .install-app-button {
    padding-inline: 8px;
    font-size: 0.7rem;
  }

  .shop-products-table .product-table {
    min-width: 600px;
  }
}

/* ---------- Admin: desktop ---------- */

@media (min-width: 769px) {
  .admin-sidebar {
    flex: 0 0 265px;
  }

  .admin-main {
    min-width: 0;
  }

  .admin-table-wrap,
  .admin-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table {
    min-width: 760px;
  }
}

/* ---------- Admin: tablet/phone ---------- */

@media (max-width: 820px) {
  .admin-shell {
    display: block;
    min-height: 100vh;
  }

  .admin-sidebar {
    width: 100%;
    height: auto;
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 1100;
    padding: 10px;
    gap: 8px;
  }

  .admin-sidebar .brand {
    padding: 8px 10px;
  }

  .admin-sidebar .brand img {
    width: 38px;
    height: 38px;
  }

  .admin-sidebar nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    margin-top: 2px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .admin-sidebar nav::-webkit-scrollbar {
    display: none;
  }

  .admin-sidebar nav a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 9px 11px;
    font-size: 0.78rem;
  }

  .admin-sidebar-footer {
    display: none;
  }

  .admin-main {
    width: 100%;
    padding: 12px;
  }

  .admin-topbar {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 16px;
  }

  .admin-topbar .topbar-left,
  .admin-topbar .topbar-right {
    width: 100%;
    min-width: 0;
  }

  .admin-topbar .search {
    width: 100%;
    min-width: 0;
  }

  .admin-hero {
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
    border-radius: 18px;
  }

  .admin-actions {
    width: 100%;
    gap: 8px;
  }

  .admin-actions .admin-btn {
    min-height: 44px;
  }

  .admin-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0;
  }

  .stat-card {
    min-width: 0;
    padding: 14px;
    border-radius: 16px;
  }

  .stat-card strong {
    font-size: 1.15rem;
    overflow-wrap: anywhere;
  }

  .admin-panel {
    width: 100%;
    padding: 14px;
    margin-bottom: 12px;
    border-radius: 16px;
    min-width: 0;
  }

  /* Do not convert wide admin tables into tiny cards.
     Keep them usable and horizontally scrollable. */
  .admin-table {
    display: table !important;
    width: max-content;
    min-width: 760px;
    border-collapse: collapse;
  }

  .admin-table thead {
    display: table-header-group !important;
  }

  .admin-table tbody tr {
    display: table-row !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .admin-table th,
  .admin-table td {
    display: table-cell !important;
    padding: 9px 8px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .admin-table td::before {
    content: none !important;
  }

  .admin-table img {
    width: 45px !important;
    height: 45px !important;
  }

  .admin-table input,
  .admin-table select,
  .admin-table textarea {
    min-height: 40px;
    font-size: 16px;
  }

  .admin-table input[type="number"] {
    width: 85px;
  }

  .admin-table td[data-label="Description"] {
    min-width: 200px;
    max-width: 280px;
    white-space: normal;
  }

  .admin-table td[data-label="Description"] input {
    min-width: 190px;
  }

  .admin-table-wrap,
  .admin-table-scroll,
  .admin-panel > .table-scroll,
  .admin-panel > .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-compact {
    flex-wrap: nowrap;
  }

  .admin-compact .admin-btn {
    min-height: 40px;
  }
}

/* ---------- Admin: small phones ---------- */

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

  .admin-sidebar {
    padding: 7px;
  }

  .admin-sidebar nav a {
    padding: 8px 9px;
    font-size: 0.72rem;
  }

  .admin-topbar {
    padding: 10px;
  }

  .admin-hero {
    padding: 14px;
  }

  .admin-hero h1 {
    font-size: 1.25rem;
  }

  .admin-stats-grid {
    gap: 8px;
  }

  .stat-card {
    padding: 11px;
  }

  .stat-card .stat-icon {
    width: 36px;
    height: 36px;
  }

  .admin-panel {
    padding: 10px;
  }

  .admin-table {
    min-width: 720px;
  }

  .admin-table th,
  .admin-table td {
    padding: 7px 6px;
    font-size: 0.73rem;
  }

  .admin-actions {
    flex-direction: column;
  }

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

/* ---------- Accessibility / touch ---------- */

@media (hover: none) and (pointer: coarse) {
  .button,
  .admin-btn,
  .nav-link,
  .install-app-button,
  button {
    -webkit-tap-highlight-color: transparent;
  }

  .button,
  .admin-btn,
  button {
    min-height: 44px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* ---------- Sales report ---------- */

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

.sales-top-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.sales-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sales-table-scroll .admin-table {
  min-width: 520px;
}

@media (max-width: 768px) {
  .report-container {
    width: 100%;
    padding: 8px 0;
  }

  .sales-summary-grid,
  .sales-top-grid {
    grid-template-columns: 1fr;
  }

  .category-card-header {
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 14px;
  }

  .category-card-header h2 {
    font-size: 1.2rem;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .category-submetrics {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    gap: 12px;
  }

  .category-card > .sales-table-scroll {
    padding-bottom: 6px;
  }
}

@media (max-width: 480px) {
  .category-card-header {
    gap: 8px;
  }

  .category-card-header .icon {
    font-size: 22px;
  }

  .category-card-header h2 {
    font-size: 1.05rem;
  }

  .metric {
    font-size: 12px;
  }

  .metric strong {
    font-size: 14px;
  }
}


/* =========================================================
   FINAL TABLE ALIGNMENT FIX
   Keeps every cell under its corresponding header.
   ========================================================= */

.table-panel,
.table-responsive,
.shop-products-table,
.admin-table-wrap,
.admin-table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.table-panel > table,
.table-responsive > table,
.shop-products-table > table,
.admin-table-wrap > table,
.admin-table-scroll > table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

/* Never let a cell's content change the column alignment unpredictably. */
.product-table th,
.product-table td,
.admin-table th,
.admin-table td,
.data-table th,
.data-table td {
    box-sizing: border-box;
    vertical-align: middle;
}

/* Header and body use identical horizontal alignment. */
.product-table th,
.admin-table th,
.data-table th {
    text-align: left;
    white-space: nowrap;
}

.product-table td,
.admin-table td,
.data-table td {
    text-align: left;
}

/* Numeric columns */
.product-table th:first-child,
.product-table td:first-child {
    text-align: center;
}

.product-table th:nth-child(4),
.product-table td:nth-child(4),
.product-table th:nth-last-child(1),
.product-table td:nth-last-child(1) {
    text-align: right;
}

/* Images remain centered in their own column. */
.product-table th:nth-child(2),
.product-table td:nth-child(2) {
    text-align: center;
}

/* Inputs stay inside their cells instead of pushing columns. */
.product-table input,
.product-table select,
.product-table textarea,
.admin-table input,
.admin-table select,
.admin-table textarea {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Keep long text inside the correct column. */
.product-table td,
.admin-table td,
.data-table td {
    overflow-wrap: anywhere;
}

/* Wide tables: preserve a consistent minimum width so columns
   cannot collapse and drift away from their headers. */
@media (max-width: 768px) {
    .admin-table {
        width: max-content;
        min-width: 1000px;
    }

    .product-table.shop-mobile-table,
    .shop-products-table .product-table {
        width: max-content;
        min-width: 720px;
    }

    .product-table th,
    .product-table td,
    .admin-table th,
    .admin-table td {
        white-space: nowrap;
    }

    /* Allow descriptions to wrap while keeping their column. */
    .admin-table td.description-cell,
    .admin-table td.product-description,
    .product-table td.description-cell {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

@media (min-width: 769px) {
    .admin-table {
        width: 100%;
    }

    .product-table {
        width: 100%;
    }
}

/* Tables converted to mobile cards should not use this rule.
   It only applies to actual tabular layouts. */
@media (max-width: 640px) {
    .shop-products-table .product-table {
        display: table;
    }

    .shop-products-table .product-table thead {
        display: table-header-group;
    }

    .shop-products-table .product-table tbody {
        display: table-row-group;
    }

    .shop-products-table .product-table tr {
        display: table-row;
    }

    .shop-products-table .product-table th,
    .shop-products-table .product-table td {
        display: table-cell;
    }
}


/* =========================================================
   CATEGORY MANAGEMENT - FINAL BUG FIX
   1. Keep category name/description inputs readable.
   2. Keep all nine columns aligned.
   3. Keep row forms valid and Edit buttons reliable.
   ========================================================= */

.modern-category-table {
    width: max-content !important;
    min-width: 1320px;
    table-layout: fixed !important;
}

.modern-category-table .category-col-icon {
    width: 85px;
}

.modern-category-table .category-col-name {
    width: 230px;
}

.modern-category-table .category-col-description {
    width: 360px;
}

.modern-category-table .category-col-order {
    width: 130px;
}

.modern-category-table .category-col-count {
    width: 125px;
}

.modern-category-table .category-col-status {
    width: 130px;
}

.modern-category-table .category-col-actions {
    width: 390px;
}

.modern-category-table th,
.modern-category-table td {
    box-sizing: border-box;
}

.modern-category-table th {
    vertical-align: middle;
    white-space: nowrap;
}

.modern-category-table td {
    vertical-align: middle;
    overflow: hidden;
}

.modern-category-table input:not([type="checkbox"]),
.modern-category-table textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin: 0;
}

.modern-category-table .category-icon-input {
    width: 58px;
    min-width: 58px;
    text-align: center;
}

.modern-category-table .category-name-input {
    width: 100%;
    min-width: 200px;
    height: 44px;
    padding: 9px 11px;
}

.modern-category-table .category-description-input {
    width: 100%;
    min-width: 320px;
    min-height: 64px;
    resize: vertical;
    padding: 9px 11px;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
}

.modern-category-table .category-order-input {
    width: 100px;
    min-width: 100px;
}

.modern-category-table .category-status-control {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.modern-category-table .category-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.modern-category-table .category-actions .admin-btn {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 40px;
}

.category-reorder-actions {
    margin-top: 14px;
}

@media (max-width: 768px) {
    .category-table-wrap {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .modern-category-table {
        min-width: 1320px !important;
        width: 1320px !important;
    }

    .modern-category-table th,
    .modern-category-table td {
        white-space: nowrap;
        padding: 10px 8px;
    }

    .modern-category-table .category-name-input {
        min-width: 200px;
    }

    .modern-category-table .category-description-input {
        min-width: 320px;
    }

    .modern-category-table .category-actions {
        flex-wrap: nowrap;
    }

    .modern-category-table .category-actions .admin-btn {
        flex: 0 0 auto;
    }
}

@media (max-width: 480px) {
    .modern-category-table {
        min-width: 1320px !important;
        width: 1320px !important;
    }

    .modern-category-table th,
    .modern-category-table td {
        padding: 9px 7px;
        font-size: 0.78rem;
    }

    .modern-category-table .category-name-input,
    .modern-category-table .category-description-input {
        font-size: 16px;
    }
}
