:root {
  --atomy-blue: #0b5cad;
  --atomy-blue-dark: #08457f;
  --atomy-sky: #eaf4ff;
  --ink: #172033;
  --muted: #68758a;
  --line: #dbe4ef;
  --panel: #ffffff;
  --page: #f4f7fb;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app-navbar {
  background: linear-gradient(90deg, var(--atomy-blue-dark), var(--atomy-blue));
  box-shadow: 0 8px 28px rgba(10, 57, 105, .18);
}

.brand-mark {
  display: inline-grid;
  width: 32px;
  height: 32px;
  margin-right: 8px;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  color: var(--atomy-blue);
}

.navbar .nav-link {
  border: 0;
  color: rgba(255,255,255,.82);
  background: transparent;
  border-radius: 8px;
  padding: .55rem .8rem;
}

.navbar .nav-link.active,
.navbar .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.14);
}

.app-view { display: none; }
.app-view.active { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(15, 40, 80, .06);
  padding: 18px;
}

.panel-header,
.filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.filters-row > * { max-width: 360px; }

.search-input { max-width: 320px; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  max-height: 68vh;
  overflow: auto;
  padding-right: 4px;
}

.product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.product-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  background: var(--atomy-sky);
  object-fit: cover;
  display: grid;
  place-items: center;
  color: var(--atomy-blue);
  font-weight: 700;
}

.product-title {
  font-weight: 700;
  line-height: 1.2;
}

.badge-category {
  width: fit-content;
  color: var(--atomy-blue);
  background: var(--atomy-sky);
  border: 1px solid #cbe4ff;
}

.table th {
  color: #40516b;
  font-size: .84rem;
  white-space: nowrap;
}

.data-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}

.data-table th[data-sort]::after {
  content: "↕";
  color: #98a6b8;
  font-size: .74rem;
  margin-left: 6px;
}

.image-mini {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--atomy-sky);
}

.place-items-center {
  place-items: center;
}

.cart-table-wrap {
  min-height: 260px;
  max-height: 48vh;
  overflow: auto;
}

.qty-input {
  width: 76px;
  margin-inline: auto;
}

.totals-box {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: grid;
  gap: 10px;
}

.totals-box div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.totals-box .total {
  font-size: 1.25rem;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

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

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 6px;
}

.stat-card strong {
  font-size: clamp(1.35rem, 2vw, 1.85rem);
}

.chart-panel {
  min-height: 360px;
}

.chart-panel canvas {
  max-height: 300px;
}

.settings-panel {
  max-width: 960px;
}

.invoice-paper {
  background: #fff;
  color: #111827;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.invoice-logo {
  display: inline-grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--atomy-blue);
  font-size: 1.5rem;
  font-weight: 800;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 30px 12px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

@media (max-width: 991px) {
  .panel-header,
  .filters-row {
    align-items: stretch;
    flex-direction: column;
  }

  .filters-row > *,
  .search-input {
    max-width: none;
    width: 100%;
  }

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

@media (max-width: 575px) {
  main.container-fluid { padding-inline: 12px; }
  .panel { padding: 14px; }
  .stats-grid { grid-template-columns: 1fr; }
  .invoice-paper { padding: 18px; }
}

@media print {
  body * { visibility: hidden; }
  #invoicePreview, #invoicePreview * { visibility: visible; }
  #invoicePreview {
    position: absolute;
    inset: 0;
    border: 0;
    box-shadow: none;
  }
}
