.spm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.spm-card {
  background: #fff;
  padding: 20px;
  border: 1px solid #e3e3e394;
  border-radius: 8px;
}
.spm-btn {
  background: #007cba;
  color: #fff;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 16px;
}
.spm-btn:hover {
  background: #005a87;
}
.spm-btn.success {
  background: #28a745;
}
.spm-btn.success:hover {
  background: #218838;
}
.spm-input {
  width: 100%;
  padding: 10px;
  margin: 5px 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  font-size: 16px;
}
.spm-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.stat-box {
  background: #f1f1f166;
  padding: 15px;
  flex: 1;
  margin: 0 5px;
  text-align: center;
  border-radius: 5px;
  min-width: 150px;
}
.hidden {
  display: none;
}
.spm-top-menu {
  background: #f1f1f166;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 20px;
}
.spm-top-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.spm-top-menu li {
  flex: 1 1 auto;
}
.spm-top-menu a {
  display: block;
  padding: 12px;
  background: #fff;
  text-decoration: none;
  color: #333;
  border-radius: 4px;
  border: 1px solid #eee;
  text-align: center;
  font-size: 16px;
}
.spm-top-menu a.active {
  background: #07acff;
  color: #fff;
  border-color: #007cba;
}
.spm-top-menu a img {
  vertical-align: middle;
  margin-right: 5px;
}
.spm-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #fff;
  border-top: 1px solid #ddd;
  z-index: 1000;
  justify-content: space-around;
  padding: 8px 0;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
}
.spm-bottom-nav a {
  flex: 1 1 0;
  text-align: center;
  color: #666;
  text-decoration: none;
  font-size: 12px;
  padding: 5px 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spm-bottom-nav a.active {
  color: #007cba;
}
.spm-bottom-nav .nav-icon {
  font-size: 24px;
  display: block;
}
.spm-bottom-nav .nav-label {
  display: block;
}
.spm-sub-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 2px solid #eee;
}
.spm-sub-tabs a {
  flex: 1;
  padding: 10px;
  text-align: center;
  text-decoration: none;
  color: #666;
  font-weight: bold;
}
.spm-sub-tabs a.active {
  color: #007cba;
  border-bottom: 2px solid #007cba;
}
.spm-filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}
.spm-filter-row select,
.spm-filter-row .spm-pagination {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}
.spm-pagination button {
  padding: 8px 12px;
  margin: 0 11px;
  border: 1px solid #ccc;
  background: #00a9ff;
  cursor: pointer;
}
.spm-pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.spm-table-container {
  overflow-x: auto;
}

/* ===== BOTTOM SPACING ===== */
.spm-dashboard {
  padding-bottom: 40px; /* Ensures content is not cut off at bottom on all devices */
}

/* ===== BUTTON GAPS ===== */
/* Desktop: horizontal gap between consecutive buttons inside a card */
.spm-card .spm-btn + .spm-btn {
  margin-left: 10px;
}
/* Specifically target buttons inside a paragraph (e.g., profile page) */
.spm-card p .spm-btn + .spm-btn {
  margin-left: 10px;
}

/* ===== MOBILE STYLES ===== */
@media (max-width: 768px) {
  .spm-dashboard {
    padding-bottom: 80px; /* Extra space for fixed bottom navigation */
  }

  /* Table adjustments */
  .spm-table-container table,
  .spm-table-container thead,
  .spm-table-container tbody,
  .spm-table-container th,
  .spm-table-container td,
  .spm-table-container tr {
    display: block;
  }
  .spm-table-container thead {
    display: none;
  }
  .spm-table-container tr {
    border: 1px solid #ddd;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 8px;
    background: #fafafa;
  }
  .spm-table-container td {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border: none;
  }
  .spm-table-container td:before {
    content: attr(data-label);
    font-weight: bold;
    width: 40%;
  }

  /* Grid */
  .spm-grid {
    grid-template-columns: 1fr;
  }

  /* Stats: keep in one line */
  .spm-stats {
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    margin-bottom: 15px;
  }
  .spm-stats .stat-box {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 10px 5px;
  }
  .spm-stats .stat-box h3 {
    font-size: 14px;
    margin: 0 0 5px 0;
  }
  .spm-stats .stat-box p {
    font-size: 1.2em !important;
    margin: 0;
  }

  /* General button and input sizing */
  .spm-btn {
    padding: 14px 20px;
  }
  .spm-input {
    padding: 14px;
  }

  /* Menu toggles */
  .spm-top-menu {
    display: none;
  }
  .spm-bottom-nav {
    display: flex;
  }
  .spm-bottom-nav .nav-label {
    display: none;
  }

  /* Mini stats (records/account pages) */
  .spm-mini-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
  }
  .spm-mini-stats .stat-box {
    flex: 1;
    min-width: auto;
    margin: 0;
  }

  /* Buttons inside cards: full width and vertical gap */
  .spm-card .spm-btn {
    width: 100%;
    text-align: center;
  }
  .spm-card p .spm-btn + .spm-btn {
    margin-left: 0;
    margin-top: 10px;
  }
}

/* ===== MINI STATS (already defined, but keep for clarity) ===== */
.spm-mini-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}
.spm-mini-stats .stat-box {
  flex: 1;
}

/* ===== HIDE UNWANTED TITLE ELEMENTS ===== */
.ts-breadcrumbs.breadcrumbs,
h1.heading-title.page-title.entry-title,
.spm-dashboard > h2 {
  display: none !important;
}

/* ===== CATEGORY ROWS ===== */
.category-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #f9f9f9;
  margin-bottom: 5px;
  border-radius: 4px;
}
.category-row input,
.category-row select {
  flex: 1 1 150px;
  padding: 5px;
}
.category-row .remove-cat {
  color: red;
  cursor: pointer;
  font-weight: bold;
  padding: 0 5px;
}

/* ===== MENU ITEM ROWS ===== */
.menu-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #f9f9f9;
  margin-bottom: 5px;
  border-radius: 4px;
  flex-wrap: wrap;
}
.menu-item-row .drag-handle {
  cursor: move;
  font-size: 20px;
  color: #999;
}
.menu-item-row .item-label {
  flex: 1;
  min-width: 150px;
}
.menu-item-row .item-mobile-label {
  width: 120px;
}
.menu-item-row .item-toggle {
  margin-left: auto;
}
.menu-item-row .move-up,
.menu-item-row .move-down {
  cursor: pointer;
  padding: 0 5px;
  color: #007cba;
}

/* ===== PROFILE FIELDS ===== */
.profile-field {
  margin-bottom: 15px;
}
.profile-field label {
  display: block;
  font-weight: bold;
  margin-bottom: 5px;
}
.profile-field .readonly {
  background: #f0f0f1;
  padding: 10px;
  border-radius: 4px;
  color: #666;
}

/* ===== PRINT STYLES ===== */
@media print {
  body * {
    visibility: hidden;
  }
  #qr-result,
  #qr-result * {
    visibility: visible;
  }
  #qr-result {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
  .spm-btn {
    display: none;
  }
}
