:root {
  --ink: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --surface: #ffffff;
  --bg: #f9fafb;
  --accent: #166534;
  --accent-hover: #14532d;
  --accent-soft: #f0fdf4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 8px;
  --shadow: 0 4px 16px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, system-ui, sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  z-index: 4;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px 20px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
}

.brand-text {
  display: grid;
  gap: 2px;
}

.brand-mark strong {
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-mark span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-card {
  display: grid;
  gap: 2px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  color: var(--muted);
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-weight: 600;
  font-size: 0.92rem;
  text-align: left;
}

.nav-button:hover {
  background: var(--bg);
}

.nav-button.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-icon {
  width: 18px;
  color: var(--muted);
  font-size: 16px;
}

.nav-button.active .nav-icon {
  color: var(--accent);
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sync-status {
  display: none;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.sync-status.visible {
  display: flex;
}

.sync-status::before {
  content: "";
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--muted);
}

.sync-status.loading::before {
  background: var(--accent);
  animation: sync-pulse 1s ease-in-out infinite;
}

.sync-status.ok {
  color: var(--success, #166534);
}

.sync-status.ok::before {
  background: currentColor;
  animation: none;
}

.sync-status.error {
  color: var(--danger);
}

.sync-status.error::before {
  background: currentColor;
  animation: none;
}

@keyframes sync-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.sidebar-account {
  display: grid;
  gap: 1px;
}

.sidebar-account span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sidebar-account strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.84rem;
}

.logout-button:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.workspace {
  position: relative;
  z-index: 2;
  padding: 32px clamp(20px, 4vw, 48px) 64px;
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

.stat-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 800;
}

.stat-card.warn strong {
  color: var(--danger);
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.5rem, 2.4vw, 1.9rem);
  font-weight: 800;
  line-height: 1.2;
}

h2 {
  font-size: 1.05rem;
  font-weight: 700;
}

.subtitle,
.panel-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.primary-button,
.secondary-button,
.inline-form button,
.invoice-add-row button {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 16px;
  font-weight: 700;
  font-size: 0.9rem;
}

.primary-button,
.inline-form button,
.invoice-add-row button {
  color: #fff;
  background: var(--accent);
}

.primary-button:hover,
.inline-form button:hover,
.invoice-add-row button:hover {
  background: var(--accent-hover);
}

.secondary-button {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
}

.secondary-button:hover {
  background: var(--bg);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 190px 180px;
  gap: 12px;
  margin-bottom: 20px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-field span {
  color: var(--muted);
  font-size: 1.1rem;
}

.search-field input,
.toolbar select,
label input,
label select,
.invoice-add-row select,
.invoice-add-row input,
.inline-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

label textarea {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  resize: vertical;
}

.dialog-note-inline {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: normal;
}

.search-field input {
  border: 0;
  background: transparent;
  outline: 0;
  padding: 0;
}

.panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  padding: 20px;
  background: var(--surface);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.inline-form {
  display: flex;
  gap: 10px;
  min-width: 280px;
}

.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-prompt {
  margin: -4px 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.category-chip-dot {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-size: 0.68rem;
}

.category-chip-name {
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--ink);
}

.category-chip-count {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.category-chip-remove {
  display: inline-grid;
  flex: 0 0 20px;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
}

.category-chip-remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.small-action,
.icon-button {
  width: 32px;
  height: 32px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.small-action:hover,
.icon-button:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  font-weight: 600;
  transform: translateY(12px);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.warn {
  border-color: rgba(220, 38, 38, 0.3);
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td {
  font-size: 0.9rem;
  font-weight: 500;
}

.table-wrap table th:last-child,
.table-wrap table td:last-child {
  position: sticky;
  right: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.table-wrap table tbody tr {
  transition: background 0.12s ease;
}

.table-wrap table tbody tr:hover {
  background: var(--bg);
}

.product-row-clickable {
  cursor: pointer;
}

.table-wrap table tbody tr:hover td:last-child {
  background: var(--bg);
}

.product-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-cell img,
.product-cell span {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 10px;
}

.product-cell img {
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.1);
}

.product-cell span {
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.1);
}

.product-cell strong {
  font-size: 0.96rem;
}

.category-tag {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.status.low {
  color: var(--warn);
}

.status.low::before {
  background: var(--warn);
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.text-button {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
}

.text-button:hover {
  background: var(--bg);
}

.text-button.delete {
  color: var(--danger);
}

.clear-items-button {
  width: 100%;
  margin-top: 12px;
  min-height: 40px;
}

.empty-state {
  display: grid;
  place-items: center;
  padding: 32px;
  color: var(--muted);
}

/* Wins over any later `display:` rule on the same element - several components
   (.photo-uploading, .pagination, ...) declare their own display further down
   the file and, at equal specificity, used to beat this and stay visible. */
.hidden {
  display: none !important;
}

.invoice-layout {
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

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

.span-2 {
  grid-column: 1 / -1;
}

.due-date-field {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.due-date-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.due-date-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.due-pill {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.84rem;
}

.due-pill:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.due-pill.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.due-date-value {
  margin-top: 12px;
}

.due-date-value span {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.due-date-value input[type="date"] {
  width: auto;
  min-height: 38px;
}

.payments-search {
  max-width: 360px;
  margin-bottom: 16px;
}

.controls-subheading {
  margin: 18px 0 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.controls-subheading.first {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.photo-field-hint {
  margin: -8px 0 10px;
  text-transform: none;
  letter-spacing: normal;
}

.photo-uploading {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.photo-uploading::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  animation: sync-pulse 1s ease-in-out infinite;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.invoice-add-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 10px;
  margin-top: 16px;
}

.invoice-add-row button {
  grid-column: 1 / -1;
}

.invoice-sheet {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.invoice-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 28px 0;
}

.invoice-doc-title {
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.invoice-brand {
  margin: 0;
  flex-direction: row-reverse;
  text-align: right;
}

.invoice-brand-text {
  gap: 2px;
}

.invoice-brand-text span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.invoice-brand-text span:empty {
  display: none;
}

.invoice-info-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 22px 0 0;
  padding: 22px 28px;
  background: var(--accent-soft);
}

.invoice-bill-to {
  display: grid;
  gap: 4px;
  align-content: start;
}

.invoice-bill-to span,
.invoice-details > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.invoice-details {
  display: grid;
  gap: 8px;
  align-content: start;
  justify-items: end;
  text-align: right;
}

.invoice-details div {
  display: flex;
  gap: 10px;
}

.invoice-details label {
  display: inline;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.invoice-details strong {
  font-size: 0.86rem;
  font-weight: 700;
}

.invoice-table {
  margin: 0 28px;
  width: calc(100% - 56px);
}

.col-index {
  width: 32px;
  color: var(--muted);
}

.invoice-table th:last-child,
.invoice-table td:last-child {
  position: static;
  width: 42px;
  background: transparent;
  border-left: 0;
}

.invoice-qty-input {
  width: 64px;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 8px;
  text-align: center;
}

.invoice-empty {
  padding: 24px 28px;
  color: var(--muted);
  text-align: center;
}

.totals {
  display: grid;
  gap: 8px;
  max-width: 260px;
  margin: 22px 28px 28px auto;
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.totals strong {
  color: var(--ink);
}

.grand-total {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-size: 1.05rem;
  font-weight: 700;
}

.payment-summary {
  margin: -4px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--ink);
  background: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
}

.check-thumb {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
}

.tracking-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 20px;
  align-items: start;
}

.tracking-side {
  display: grid;
  gap: 20px;
}

.stock-list,
.rank-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.stock-row,
.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.stock-row:hover,
.rank-row:hover {
  border-color: var(--accent);
  background: var(--bg);
}

.stock-avatar {
  display: inline-grid;
  flex: 0 0 34px;
  place-items: center;
  overflow: hidden;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.84rem;
}

.stock-avatar img,
.stock-avatar span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.stock-avatar img {
  object-fit: cover;
}

.stock-info {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 2px;
}

.stock-row .stock-name,
.rank-row .rank-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row .rank-name {
  flex: 1;
  min-width: 0;
}

.stock-row .stock-amt {
  color: var(--muted);
  font-size: 0.8rem;
}

.stock-qty-badge,
.rank-count-badge {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
}

.stock-row.zero .stock-qty-badge {
  background: var(--danger-soft);
  color: var(--danger);
}

.rank-row .rank-index {
  display: inline-grid;
  flex: 0 0 22px;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.76rem;
}

dialog {
  width: min(92vw, 560px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  animation: dialog-in 0.16s ease;
}

dialog::backdrop {
  background: rgba(17, 24, 39, 0.4);
  animation: backdrop-in 0.16s ease;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.dialog-sm {
  width: min(92vw, 400px);
}

.dialog-lg {
  width: min(94vw, 900px);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px;
  padding: 20px;
}

.detail-gallery {
  display: grid;
  gap: 12px;
}

.detail-main-image {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: zoom-in;
}

.detail-main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.06s ease-out;
  transform-origin: center;
}

.detail-main-image.zoomed img {
  transform: scale(2.2);
}

.detail-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  font-size: 3rem;
}

.zoom-hint {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.6);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  pointer-events: none;
}

.detail-main-image.zoomed .zoom-hint {
  opacity: 0;
}

.detail-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-thumb {
  width: 60px;
  height: 60px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  padding: 0;
}

.detail-thumb.active {
  border-color: var(--accent);
}

.detail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-info {
  display: grid;
  align-content: start;
  gap: 10px;
}

.detail-category {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-price {
  margin: 0;
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 800;
}

.detail-stock {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.detail-stock.out {
  color: var(--danger);
}

.detail-description {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.detail-description h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.detail-description p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-line;
}

.detail-description.hidden {
  display: none;
}

@media (max-width: 640px) {
  .detail-layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .detail-main-image.zoomed img {
    transform: scale(1.6);
  }
}

.confirm-dialog-message {
  margin: 0;
  padding: 20px 22px;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.5;
}

.dialog-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg);
}

.auth-tabs.hidden {
  display: none;
}

.auth-tab {
  flex: 1;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.86rem;
  white-space: nowrap;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.1);
}

.order-identity {
  margin: -4px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.6;
}

.order-identity span {
  color: var(--muted);
}

.order-identity .text-button {
  margin-top: 8px;
}

.account-dialog-actions {
  justify-content: space-between;
}

.account-dialog-actions-right {
  display: flex;
  gap: 10px;
}

.primary-button.danger {
  background: var(--danger);
}

.primary-button.danger:hover {
  background: #b91c1c;
}

.product-form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.photo-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.photo-input-row {
  display: flex;
  gap: 10px;
}

.photo-input-button {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
}

.sr-only-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.photo-preview {
  width: 88px;
  height: 88px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.photo-gallery-item {
  position: relative;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.photo-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-gallery-main {
  position: absolute;
  left: 3px;
  bottom: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
}

.photo-gallery-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.photo-gallery-promote {
  position: absolute;
  left: 3px;
  bottom: 3px;
  padding: 2px 6px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  cursor: pointer;
}

/* A photo whose URL no longer loads - shown so it can be spotted and removed. */
.photo-gallery-item.photo-broken {
  border-color: var(--danger, #c0392b);
  background: repeating-linear-gradient(45deg, #f6d7d2, #f6d7d2 6px, #fbeae7 6px, #fbeae7 12px);
}

.danger-button {
  border-color: var(--danger, #c0392b);
  color: var(--danger, #c0392b);
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dialog-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}

.dialog-actions {
  justify-content: flex-end;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 0;
    padding: 14px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand-mark {
    margin: 0;
  }

  .sidebar-footer {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .sidebar-account {
    display: none;
  }

  .logout-button {
    min-height: 36px;
    padding: 0 14px;
  }

  .workspace {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .nav-card {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
    width: 100%;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 -4px 16px rgba(17, 24, 39, 0.08);
  }

  .nav-button {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 50px;
    padding: 0 2px;
    color: var(--muted);
    font-size: 0.62rem;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
  }

  .nav-button.active {
    border-radius: 10px;
  }

  .nav-icon {
    width: auto;
    font-size: 16px;
  }

  .toolbar,
  .invoice-layout,
  .tracking-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sidebar,
  .page-header,
  .panel-heading,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 10px;
  }

  .brand-mark {
    order: 1;
  }

  .sidebar-footer {
    order: 2;
    margin: 0 0 0 auto;
  }

  .page-header {
    display: grid;
    gap: 14px;
    margin-bottom: 16px;
  }

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

  h1 {
    font-size: 1.65rem;
  }

  h2 {
    font-size: 1rem;
  }

  .primary-button,
  .secondary-button,
  .inline-form button,
  .invoice-add-row button {
    width: 100%;
  }

  .toolbar {
    gap: 10px;
    margin-bottom: 16px;
  }

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

  .stat-card {
    padding: 12px 14px;
  }

  .stat-card strong {
    font-size: 1.35rem;
  }

  .panel {
    padding: 14px;
    margin-bottom: 14px;
  }

  .field-grid,
  .invoice-add-row {
    grid-template-columns: 1fr;
  }

  .nav-button {
    font-size: 0.64rem;
  }

  .inline-form {
    min-width: 0;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
  }

  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 40px;
    padding: 10px 12px;
    white-space: normal;
    position: static;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  td:first-child {
    align-items: flex-start;
    background: var(--bg);
  }

  td:first-child::before {
    display: none;
  }

  .product-cell {
    width: 100%;
  }

  .row-actions {
    width: 100%;
    justify-content: stretch;
  }

  .text-button {
    flex: 1;
  }

  dialog,
  .dialog-sm {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .product-form {
    min-height: 100%;
    padding: 16px;
    overflow-y: auto;
  }

  .dialog-header {
    position: sticky;
    top: -16px;
    z-index: 1;
    margin: -16px -16px 0;
    padding: 16px;
  }

  .dialog-actions {
    position: sticky;
    bottom: -16px;
    margin: 4px -16px -16px;
    padding: 14px 16px;
  }

  .invoice-top {
    flex-direction: column;
    gap: 14px;
    padding: 18px 18px 0;
  }

  .invoice-brand {
    text-align: left;
  }

  .invoice-info-band {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 18px;
  }

  .invoice-details {
    justify-items: start;
    text-align: left;
  }

  .invoice-table {
    margin: 0 18px;
    width: calc(100% - 36px);
  }

  .invoice-empty {
    padding: 20px 18px;
  }

  .totals {
    max-width: none;
    margin: 22px 18px 18px auto;
  }
}

@media (max-width: 430px) {
  .nav-button {
    font-size: 0.6rem;
  }
}

/* Auth pages */

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: min(100%, 380px);
  padding: 32px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card .brand-mark {
  flex-direction: column;
  text-align: center;
  margin: 0 0 24px;
}

.auth-card .brand-logo {
  width: 56px;
  height: 56px;
}

.auth-card h1 {
  margin-bottom: 6px;
  font-size: 1.4rem;
  text-align: center;
}

.auth-card p.subtitle {
  margin: 0 0 26px;
  text-align: center;
  font-size: 0.9rem;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-error {
  margin: -4px 0 0;
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 0.86rem;
  font-weight: 600;
}

.auth-form button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

.auth-form button:hover {
  background: var(--accent-hover);
}

.auth-form button:disabled {
  opacity: 0.65;
  cursor: default;
}

.auth-footnote {
  margin: 20px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.8rem;
}

.auth-loading {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.auth-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

body:not(.authed) .app-shell {
  display: none;
}

/* Pagination */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.pagination.hidden {
  display: none;
}

.pagination-info {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.page-gap {
  padding: 0 4px;
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 640px) {
  .pagination {
    justify-content: center;
  }

  .pagination-info {
    flex-basis: 100%;
    text-align: center;
  }
}

/* Discounts (admin) */

.discount-submit {
  margin-top: 16px;
}

.discount-preview {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}

.discount-preview.hidden {
  display: none;
}

.was-price {
  color: var(--muted);
  text-decoration: line-through;
}

.sale-price {
  color: var(--accent);
  font-weight: 700;
}

.status.scheduled::before {
  background: var(--warn);
}

.status.scheduled {
  color: var(--warn);
}

.status.expired::before {
  background: var(--muted);
}

.status.expired {
  color: var(--muted);
}

/* Sale styling shared with the storefront */

.sale-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.shop-card-image {
  position: relative;
}

.shop-card-price .was-price {
  margin-right: 6px;
  font-size: 0.86rem;
  font-weight: 600;
}

.shop-section-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 14px;
}

.shop-section-heading h2 {
  font-size: 1.15rem;
  font-weight: 800;
}

.shop-section-heading span {
  color: var(--muted);
  font-size: 0.88rem;
}

.shop-section {
  margin-bottom: 34px;
}

/* Public storefront */

.storefront-body {
  background: var(--bg);
}

.shop-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.shop-header .brand-mark {
  margin: 0;
  flex-shrink: 0;
}

.shop-search {
  flex: 1;
  max-width: 480px;
}

.shop-cart-button {
  flex-shrink: 0;
}

#account-button {
  flex-shrink: 0;
  margin-left: auto;
}

.cart-count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.shop-main {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: start;
  gap: 32px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px clamp(20px, 4vw, 48px) 64px;
}

.shop-sidebar {
  position: sticky;
  top: 20px;
}

.shop-sidebar h3 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.shop-category-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shop-category-btn {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.shop-category-btn:hover {
  background: var(--bg);
}

.shop-category-btn.active {
  background: var(--accent);
  color: #fff;
}

.shop-content {
  min-width: 0;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

@media (max-width: 900px) {
  .shop-main {
    grid-template-columns: 1fr;
  }

  .shop-sidebar {
    position: static;
  }

  .shop-sidebar h3 {
    margin-bottom: 8px;
  }

  .shop-category-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .shop-category-btn {
    width: auto;
    white-space: nowrap;
    background: var(--bg);
  }
}

@media (max-width: 640px) {
  .shop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .shop-card-body {
    padding: 10px;
    gap: 6px;
  }

  .shop-card-body h3 {
    font-size: 0.84rem;
  }

  .shop-card-price {
    font-size: 0.9rem;
  }
}

.shop-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.shop-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.shop-card-image {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg);
}

.shop-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shop-card-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  font-size: 2.4rem;
}

.shop-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
  padding: 14px;
}

.shop-card-body h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.3;
  /* Clamp to two lines so a long name never pushes the price/button apart
     from a short one in the same row. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.shop-card-price {
  margin: 0;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 800;
}

.shop-add-btn {
  width: 100%;
  margin-top: auto;
}

.cart-dialog .cart-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.cart-subtotal {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 700;
}

.cart-lines {
  display: grid;
  gap: 10px;
  max-height: 360px;
  margin: 0;
  padding: 18px 22px;
  overflow-y: auto;
  list-style: none;
}

.cart-line {
  display: grid;
  grid-template-columns: 48px 1fr auto auto;
  align-items: center;
  gap: 10px;
}

.cart-line img,
.cart-line-placeholder {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--accent);
}

.cart-line-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.cart-line-info strong {
  overflow: hidden;
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-line-info span {
  color: var(--muted);
  font-size: 0.78rem;
}

.cart-line-qty {
  width: 52px;
  min-height: 32px;
  text-align: center;
}

.cart-line-remove {
  color: var(--muted);
}

@media (max-width: 640px) {
  .shop-header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
  }

  .shop-header .brand-text span {
    display: none;
  }

  #account-button,
  .shop-cart-button {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.84rem;
  }

  .shop-cart-button {
    margin-left: 0;
  }

  .shop-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }

  .cart-line {
    grid-template-columns: 40px 1fr auto;
    grid-template-areas: "img info remove" "img qty remove";
  }

  .cart-line img,
  .cart-line-placeholder {
    grid-area: img;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
  }

  .cart-line-info {
    grid-area: info;
  }

  .cart-line-qty {
    grid-area: qty;
    justify-self: start;
  }

  .cart-line-remove {
    grid-area: remove;
  }

  .account-dialog-actions {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 10px;
  }

  .account-dialog-actions-right {
    flex-direction: column-reverse;
    width: 100%;
  }

  .account-dialog-actions-right .primary-button,
  .account-dialog-actions-right .secondary-button {
    width: 100%;
  }

  #account-logout {
    text-align: center;
  }
}

@media print {
  @page {
    margin: 0.55in;
  }

  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body {
    background: #fff;
    color: #111;
    font-family: Arial, sans-serif;
  }

  .invoice-qty-input {
    border: 0;
    background: transparent;
    padding: 0;
    width: auto;
    color: #111;
    text-align: left;
  }

  .sidebar,
  .page-header,
  .invoice-controls,
  .screen-only,
  #inventory-view,
  #payments-view,
  #tracking-view {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .view.active,
  .invoice-layout {
    display: block;
    min-height: auto;
    padding: 0;
  }

  .invoice-layout {
    width: 100%;
  }

  .invoice-sheet {
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }

  .invoice-top {
    padding: 0;
    border-bottom: 1px solid #222;
    padding-bottom: 14px;
  }

  .invoice-doc-title {
    color: #111;
    font-family: Arial, sans-serif;
    font-size: 1.45rem;
  }

  .invoice-info-band {
    margin: 0;
    padding: 14px 0;
    background: transparent;
  }

  .invoice-bill-to span,
  .invoice-details > span,
  .totals div,
  th {
    color: #555;
  }

  .invoice-table {
    margin: 0;
    width: 100%;
  }

  th,
  td {
    border-bottom: 1px solid #ddd;
    padding: 10px 8px;
    white-space: normal;
  }

  .invoice-empty {
    padding: 20px 0;
  }

  .totals {
    margin: 22px 0 0 auto;
  }

  .grand-total {
    border-top: 1px solid #222;
  }
}

/* --------------------------------------------------------------------------
   Savraj visual refresh — shared customer store and operations workspace
   -------------------------------------------------------------------------- */

:root {
  --ink: #1d2a28;
  --muted: #68736c;
  --border: #e4ded3;
  --surface: #fffdf9;
  --bg: #f5f1e9;
  --accent: #176b55;
  --accent-hover: #105642;
  --accent-soft: #e3f0e9;
  --danger: #c54232;
  --danger-soft: #fbe8e3;
  --warn: #a86112;
  --warn-soft: #fff4df;
  --radius: 14px;
  --shadow: 0 18px 42px rgba(39, 50, 40, 0.09);
}

body {
  background:
    radial-gradient(circle at 8% 0%, rgba(222, 149, 52, 0.1), transparent 25rem),
    radial-gradient(circle at 100% 20%, rgba(23, 107, 85, 0.08), transparent 26rem),
    var(--bg);
}

button,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(222, 149, 52, 0.28);
  outline-offset: 2px;
}

/* Admin workspace */

.app-shell {
  background: linear-gradient(135deg, rgba(255, 253, 249, 0.64), rgba(240, 245, 239, 0.58));
}

.sidebar {
  padding: 28px 20px 22px;
  border-right-color: rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 8% 0%, rgba(225, 154, 59, 0.22), transparent 12rem),
    #1b302d;
}

.sidebar .brand-mark {
  padding: 0 7px;
}

.sidebar .brand-logo {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.68);
  border-radius: 13px;
}

.sidebar .brand-mark strong,
.sidebar .brand-mark span,
.sidebar .sidebar-account strong {
  color: #fffdf9;
}

.sidebar .brand-mark span,
.sidebar .sidebar-account span {
  color: rgba(255, 253, 249, 0.58);
}

.nav-card {
  gap: 5px;
  padding: 8px 0;
}

.nav-button {
  min-height: 44px;
  border-radius: 10px;
  color: rgba(255, 253, 249, 0.7);
}

.nav-button:hover {
  background: rgba(255, 253, 249, 0.1);
  color: #fffdf9;
}

.nav-button.active {
  color: #19302b;
  background: #f1c268;
  box-shadow: 0 7px 16px rgba(7, 20, 18, 0.2);
}

.nav-icon,
.nav-button.active .nav-icon {
  color: currentColor;
}

.sidebar-footer {
  border-top-color: rgba(255, 255, 255, 0.14);
}

.sidebar .sync-status {
  color: rgba(255, 253, 249, 0.66);
}

.sidebar .sync-status.ok {
  color: #91e3b8;
}

.sidebar .logout-button {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 253, 249, 0.06);
  color: rgba(255, 253, 249, 0.78);
}

.sidebar .logout-button:hover {
  border-color: #f1c268;
  color: #f7cf7c;
}

.workspace {
  max-width: 1640px;
  margin: 0 auto;
  padding-top: 42px;
}

.page-header {
  margin-bottom: 30px;
}

.eyebrow {
  color: var(--accent);
  letter-spacing: 0.12em;
}

h1 {
  font-size: clamp(1.8rem, 2.7vw, 2.35rem);
  letter-spacing: -0.035em;
}

h2 {
  letter-spacing: -0.02em;
}

.subtitle,
.panel-heading p {
  line-height: 1.55;
}

.primary-button,
.secondary-button,
.inline-form button,
.invoice-add-row button {
  min-height: 42px;
  border-radius: 10px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button,
.inline-form button,
.invoice-add-row button {
  box-shadow: 0 7px 15px rgba(23, 107, 85, 0.16);
}

.primary-button:hover,
.inline-form button:hover,
.invoice-add-row button:hover {
  box-shadow: 0 10px 20px rgba(23, 107, 85, 0.22);
  transform: translateY(-1px);
}

.secondary-button:hover {
  border-color: rgba(23, 107, 85, 0.32);
  background: #fffdf9;
}

.stat-grid {
  gap: 16px;
  margin-bottom: 26px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 18px;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(39, 50, 40, 0.06);
}

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 18px;
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.stat-card:nth-child(2)::after { background: #d69231; }
.stat-card:nth-child(3)::after { background: #4d806f; }
.stat-card.warn::after { background: var(--danger); }

.stat-card strong {
  margin-top: 8px;
  font-size: clamp(1.5rem, 2.2vw, 2rem);
}

.toolbar {
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(228, 222, 211, 0.84);
  border-radius: 16px;
  background: rgba(255, 253, 249, 0.72);
  box-shadow: 0 8px 20px rgba(39, 50, 40, 0.035);
}

.search-field,
.toolbar select,
label input,
label select,
label textarea,
.invoice-add-row select,
.invoice-add-row input,
.inline-form input {
  border-color: #e4ded3;
  border-radius: 10px;
}

.panel {
  margin-bottom: 24px;
  padding: 24px;
  border-color: rgba(228, 222, 211, 0.88);
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(39, 50, 40, 0.045);
}

.category-panel {
  background: linear-gradient(105deg, #fffcf7, #f5f7ee);
}

.category-chip {
  border-color: rgba(23, 107, 85, 0.14);
  background: rgba(255, 253, 249, 0.78);
}

.category-tag,
.stock-qty-badge,
.rank-count-badge {
  border: 1px solid rgba(23, 107, 85, 0.1);
  background: var(--accent-soft);
  color: var(--accent);
}

th,
td {
  border-bottom-color: #eee8de;
}

th {
  color: #778078;
  letter-spacing: 0.08em;
}

.table-wrap table tbody tr:hover,
.table-wrap table tbody tr:hover td:last-child {
  background: #f5f7ef;
}

.text-button,
.small-action,
.icon-button,
.page-btn {
  border-radius: 9px;
}

.invoice-sheet {
  border-radius: 18px;
  box-shadow: 0 14px 36px rgba(39, 50, 40, 0.07);
}

.invoice-doc-title,
.detail-price,
.shop-card-price,
.sale-price {
  color: var(--accent);
}

.invoice-info-band {
  background: #edf5ed;
}

dialog {
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(20, 31, 26, 0.24);
}

dialog::backdrop {
  background: rgba(19, 35, 30, 0.52);
  backdrop-filter: blur(3px);
}

/* Customer store */

.storefront-body {
  background:
    radial-gradient(circle at 0 0, rgba(226, 150, 53, 0.12), transparent 24rem),
    radial-gradient(circle at 100% 36%, rgba(23, 107, 85, 0.09), transparent 30rem),
    #f7f3ec;
}

.shop-header {
  min-height: 76px;
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom-color: rgba(228, 222, 211, 0.86);
  background: rgba(255, 253, 249, 0.88);
  backdrop-filter: blur(15px);
}

.shop-header .brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 13px;
}

.shop-header .brand-mark strong {
  letter-spacing: -0.04em;
}

.shop-search {
  min-height: 44px;
  max-width: 520px;
  background: #f5f1e9;
}

.shop-header .secondary-button {
  min-height: 42px;
  border-radius: 999px;
}

.shop-main {
  gap: 38px;
  max-width: 1440px;
  padding-top: 38px;
}

.shop-sidebar {
  top: 98px;
  padding: 18px 14px;
  border: 1px solid rgba(228, 222, 211, 0.86);
  border-radius: 16px;
  background: rgba(255, 253, 249, 0.76);
  box-shadow: 0 12px 28px rgba(39, 50, 40, 0.045);
}

.shop-sidebar h3 {
  padding: 0 8px;
  color: var(--accent);
  letter-spacing: 0.1em;
}

.shop-category-nav {
  gap: 4px;
}

.shop-category-btn {
  padding: 10px 12px;
  border-radius: 9px;
}

.shop-category-btn:hover {
  background: #edf5ed;
  color: var(--accent);
}

.shop-category-btn.active {
  background: var(--accent);
  box-shadow: 0 7px 14px rgba(23, 107, 85, 0.18);
}

.shop-intro {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  overflow: hidden;
  min-height: 260px;
  margin-bottom: 40px;
  padding: clamp(28px, 4vw, 48px);
  border-radius: 24px;
  background:
    radial-gradient(circle at 91% 14%, rgba(241, 194, 104, 0.56) 0 4.5rem, transparent 4.6rem),
    radial-gradient(circle at 94% 18%, transparent 0 7.2rem, rgba(255, 255, 255, 0.18) 7.3rem 7.4rem, transparent 7.5rem),
    linear-gradient(117deg, #173d35, #155845);
  color: #fffdf9;
  box-shadow: 0 22px 40px rgba(23, 69, 57, 0.18);
}

.shop-intro::after {
  content: "SAVRAJ";
  position: absolute;
  right: -0.04em;
  bottom: -0.3em;
  color: rgba(255, 253, 249, 0.065);
  font-size: clamp(5rem, 15vw, 12rem);
  font-weight: 800;
  letter-spacing: -0.08em;
  line-height: 1;
  pointer-events: none;
}

.shop-intro-copy,
.shop-intro-note {
  position: relative;
  z-index: 1;
}

.shop-overline {
  margin: 0 0 14px;
  color: #f3c76f;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.shop-intro h1 {
  max-width: 15ch;
  margin: 0;
  color: #fffdf9;
  font-size: clamp(2rem, 3.6vw, 3.35rem);
  line-height: 1.02;
}

.shop-intro-copy > p:last-child {
  max-width: 48ch;
  margin: 18px 0 0;
  color: rgba(255, 253, 249, 0.76);
  font-size: 0.98rem;
  line-height: 1.65;
}

.shop-intro-note {
  align-self: end;
  min-width: 210px;
  padding: 18px 0 0 22px;
  border-top: 1px solid rgba(255, 253, 249, 0.38);
}

.shop-intro-note span {
  display: block;
  margin-bottom: 7px;
  color: #f3c76f;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.shop-intro-note strong {
  font-size: 1rem;
  line-height: 1.35;
}

.shop-section {
  margin-bottom: 42px;
}

.shop-section-heading {
  margin-bottom: 18px;
}

.shop-section-heading h2 {
  font-size: 1.35rem;
  letter-spacing: -0.035em;
}

.shop-grid {
  gap: 18px;
}

.shop-card {
  border-color: rgba(228, 222, 211, 0.88);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(39, 50, 40, 0.045);
}

.shop-card:hover {
  box-shadow: 0 18px 30px rgba(39, 50, 40, 0.12);
  transform: translateY(-4px);
}

.shop-card-image {
  background: linear-gradient(145deg, #f5f1e9, #edf3ea);
}

.shop-card-body {
  gap: 10px;
  padding: 16px;
}

.shop-card-body h3 {
  font-size: 0.98rem;
  letter-spacing: -0.015em;
}

.shop-add-btn {
  min-height: 38px;
  border-radius: 9px;
}

.sale-badge {
  top: 12px;
  left: 12px;
  background: #c76d2f;
  box-shadow: 0 5px 10px rgba(133, 66, 25, 0.22);
}

.cart-count-badge {
  background: #d7902f;
}

.product-detail-dialog .dialog-header,
.cart-dialog .dialog-header {
  background: #fffdf9;
}

@media (max-width: 980px) {
  .sidebar {
    padding: 14px 16px;
    background: #1b302d;
  }

  .nav-card {
    padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
    background: #1b302d;
    box-shadow: 0 -8px 24px rgba(19, 35, 30, 0.18);
  }

  .nav-button {
    color: rgba(255, 253, 249, 0.66);
  }

  .nav-button.active {
    color: #19302b;
  }

  .shop-sidebar {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .shop-category-btn {
    border: 1px solid rgba(228, 222, 211, 0.9);
    background: #fffdf9;
  }

  .shop-intro {
    margin-bottom: 32px;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 28px 16px calc(88px + env(safe-area-inset-bottom));
  }

  .toolbar {
    padding: 8px;
  }

  .panel {
    padding: 17px;
    border-radius: 15px;
  }

  .shop-main {
    gap: 24px;
    padding: 24px 16px 42px;
  }

  .shop-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px 8px;
    min-height: 0;
    padding: 12px 16px 13px;
  }

  .shop-header .brand-mark {
    grid-column: 1;
    min-width: 0;
  }

  .shop-header .brand-logo {
    width: 37px;
    height: 37px;
    border-radius: 11px;
  }

  .shop-header .brand-mark strong {
    font-size: 1rem;
  }

  #account-button,
  .shop-cart-button {
    width: auto;
    min-height: 37px;
    margin: 0;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  #account-button {
    grid-column: 2;
    grid-row: 1;
  }

  .shop-cart-button {
    grid-column: 3;
    grid-row: 1;
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 5px 12px rgba(23, 107, 85, 0.18);
  }

  .shop-cart-button:hover {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
    color: #fff;
  }

  .shop-search {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-height: 42px;
    margin: 0;
    max-width: none;
  }

  .shop-intro {
    grid-template-columns: 1fr;
    gap: 22px;
    min-height: 0;
    margin-bottom: 30px;
    padding: 28px 24px;
    border-radius: 19px;
  }

  .shop-intro-note {
    min-width: 0;
    padding-left: 0;
  }

  .shop-section-heading h2 {
    font-size: 1.18rem;
  }

  .shop-grid {
    gap: 12px;
  }

  .shop-card {
    border-radius: 13px;
  }

  .shop-card-body {
    padding: 11px;
  }
}
