:root {
  --app-bg: #f5f7fb;
  --app-card: #ffffff;
  --app-text: #172033;
  --app-muted: #6b7280;
  --app-border: #e6eaf0;

  --app-primary: #2563eb;
  --app-primary-dark: #1d4ed8;
  --app-primary-soft: #eff6ff;

  --app-success: #16a34a;
  --app-success-soft: #ecfdf3;

  --app-warning: #f59e0b;
  --app-warning-soft: #fffbeb;

  --app-danger: #dc2626;
  --app-danger-soft: #fef2f2;

  --app-radius: 20px;
  --app-shadow: 0 12px 34px rgba(15, 23, 42, 0.07);
}

* {
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
          radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 32rem),
          var(--app-bg);
  color: var(--app-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
.btn,
.form-control,
.form-select {
  min-height: 40px;
}

.btn {
  border-radius: 12px;
  font-weight: 600;
}

.app-navbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--app-border);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.04);
}

.navbar-brand {
  min-width: 0;
}

.brand-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--app-primary-soft);
  color: var(--app-primary);
  font-size: 1.2rem;
}

.navbar-brand strong {
  color: var(--app-text);
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}

.brand-tagline {
  font-size: 0.74rem;
  color: var(--app-muted);
  margin-top: -2px;
}

.navbar-toggler {
  border: 0;
  box-shadow: none !important;
}

main.container-fluid {
  max-width: 980px;
  margin: 0 auto;
}

.hero-card {
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
  padding: 1.25rem;
}

.hero-card h1 {
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.hero-card p {
  color: var(--app-muted);
}

.search-box {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--app-border);
  background: #ffffff;
}

.search-box .input-group-text,
.search-box .form-control,
.search-box .btn {
  border: 0;
  background: #ffffff;
  box-shadow: none !important;
}

.search-box .form-control {
  font-size: 0.95rem;
}

/* Summary chips */

.summary-chips-container {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.summary-chips-container::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Opera */
}

.summary-chip {
  flex: 0 0 auto;
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: 100px;
  padding: 0.35rem 0.8rem 0.35rem 0.35rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.summary-chip-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.summary-chip-content {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.summary-chip-value {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.summary-chip-label {
  font-size: 0.8rem;
  color: var(--app-muted);
  font-weight: 500;
}

.summary-primary .summary-chip-icon {
  background: var(--app-primary-soft);
  color: var(--app-primary);
}

.summary-info .summary-chip-icon {
  background: #eef2ff;
  color: #4f46e5;
}

.summary-warning .summary-chip-icon {
  background: var(--app-warning-soft);
  color: var(--app-warning);
}

.summary-success .summary-chip-icon {
  background: var(--app-success-soft);
  color: var(--app-success);
}

.summary-muted .summary-chip-icon {
  background: #f3f4f6;
  color: #4b5563;
}

/* Inventory */

.inventory-card {
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}

.category-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem;
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  border-bottom: 1px solid var(--app-border);
}

.category-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  color: var(--app-text);
}

.category-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--app-primary-soft);
  color: var(--app-primary);
  font-size: 1rem;
}

.category-title-wrap,
.subcategory-title-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-title,
.subcategory-title {
  font-weight: 750;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-title {
  font-size: 1.08rem;
}

.category-count,
.subcategory-count {
  color: var(--app-muted);
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.toggle-chevron {
  transition: transform 0.2s ease;
}

.category-toggle[aria-expanded="true"] .toggle-chevron,
.subcategory-toggle[aria-expanded="true"] .toggle-chevron {
  transform: rotate(90deg);
}

.category-actions,
.subcategory-actions,
.product-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.action-main-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.icon-action-btn {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.subcategory-list {
  padding: 0.85rem;
}

.subcategory-card {
  border: 1px solid var(--app-border);
  background: #ffffff;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.subcategory-card:last-child {
  margin-bottom: 0;
}

.subcategory-title {
  font-size: 0.98rem;
}

.product-list {
  padding: 0 0.85rem 0.65rem;
}

.product-row {
  border-top: 1px dashed #e5e7eb;
}

.product-info {
  min-width: 0;
}

.product-name {
  font-weight: 650;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  margin-bottom: 0.4rem;
}

.status-badge {
  border: 0;
  border-radius: 999px;
  min-height: auto;
  padding: 0.28rem 0.65rem;
  font-size: 0.74rem;
  font-weight: 750;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.status-in-use {
  background: var(--app-success-soft);
  color: var(--app-success);
}

.status-finished {
  background: #f3f4f6;
  color: #4b5563;
}

.small-empty-row {
  color: var(--app-muted);
  font-size: 0.9rem;
  padding: 0.8rem;
}

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
}

.empty-state i {
  font-size: 3rem;
  color: var(--app-primary);
}

.empty-state h3 {
  margin-top: 1rem;
  font-size: 1.25rem;
  font-weight: 750;
}

.empty-state p {
  color: var(--app-muted);
}

/* Backups / Modals / Toast */

.backup-item {
  border: 1px solid var(--app-border);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: #fff;
}

.modal-content {
  border: 0;
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
}

.modal-header,
.modal-footer {
  border-color: var(--app-border);
}

.toast {
  border-radius: 16px;
}

/* Mobile */

@media (max-width: 768px) {
  body {
    font-size: 0.95rem;
  }

  main.container-fluid {
    padding: 0.85rem !important;
  }

  .app-navbar .container-fluid {
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
  }

  .brand-icon {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .navbar-brand strong {
    font-size: 1rem;
  }

  .brand-tagline {
    display: none !important;
  }

  #topNavbar .ms-auto {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem !important;
    width: 100%;
    margin-top: 0.85rem !important;
  }

  #topNavbar .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .hero-card {
    padding: 1rem;
    border-radius: 18px;
    margin-bottom: 0.85rem !important;
  }

  .hero-card h1 {
    font-size: 1.05rem;
    margin-bottom: 0.25rem !important;
  }

  .hero-card p {
    font-size: 0.84rem;
    line-height: 1.35;
  }

  #summaryCards {
    margin-bottom: 0.5rem !important;
  }

  section.d-flex.flex-wrap.justify-content-between {
    align-items: stretch !important;
    margin-bottom: 0.8rem !important;
  }

  section.d-flex.flex-wrap.justify-content-between > div:first-child {
    width: 100%;
  }

  section.d-flex.flex-wrap.justify-content-between h2 {
    font-size: 1.05rem;
    margin-bottom: 0.1rem !important;
  }

  section.d-flex.flex-wrap.justify-content-between .text-muted {
    font-size: 0.8rem;
  }

  section.d-flex.flex-wrap.justify-content-between > div:last-child {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem !important;
    width: 100%;
  }

  #btnSeedSampleData,
  #btnAddCategory {
    width: 100%;
    min-height: 44px;
  }

  .inventory-card {
    border-radius: 18px;
    margin-bottom: 0.85rem;
  }

  .category-actions .btn,
  .subcategory-actions .btn {
    min-height: 42px;
  }

  .icon-action-btn {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    font-size: 0.9rem;
  }

  .subcategory-list {
    padding: 0.75rem;
  }

  .subcategory-card {
    border-radius: 16px;
  }

  .product-actions {
    justify-content: flex-start;
  }

  .modal-dialog {
    margin: 0.75rem;
  }

  .modal-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }

  .modal-footer .btn {
    width: 100%;
    margin: 0 !important;
    min-height: 44px;
  }

  .toast-container {
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    padding: 0.75rem !important;
  }

  .toast {
    width: 100%;
  }
}

@media (max-width: 420px) {
  #topNavbar .ms-auto {
    grid-template-columns: 1fr;
  }

  section.d-flex.flex-wrap.justify-content-between > div:last-child {
    grid-template-columns: 1fr;
  }

  .category-title,
  .subcategory-title {
    white-space: normal;
  }

  .icon-action-btn {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    font-size: 0.85rem;
  }
}