:root {
  --cream: #fdf8f0;
  --dark: #0f172a;
  --green: #16a34a;
  --warm: #fff4d6;
  --panel: #fdf8f0;
  --ink: #111827;
  --mustard: #f4c430;
  --red: #dc2626;
  --shadow: #000000;
  --muted: #6b7280;
}

.pixel {
  font-family: "Press Start 2P", cursive;
}

.mono {
  font-family: "Space Mono", monospace;
}

.summary-grid,
.panel-grid {
  display: grid;
  gap: 18px;
}

.summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.panel-grid.two-cols {
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}

.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease-out;
}

.tab-panel.active {
  display: block;
}

.product-edit-form {
  gap: 10px;
}

.mini-btn {
  padding: 9px 10px;
  cursor: pointer;
}

.sales-customer-search {
  position: relative;
}

.sales-customer-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  z-index: 20;
  max-height: 220px;
  overflow: auto;
}

.sales-customer-suggestions.hidden {
  display: none;
}

.sales-customer-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.sales-customer-option strong {
  font-size: 0.72rem;
}

.sales-customer-option span {
  font-size: 0.62rem;
  color: var(--muted);
}

.customer-result.muted {
  color: var(--muted);
}

.cart-table .qty-cell {
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.cart-table .qty-cell .qty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0 3px;
  flex: 0 0 auto;
}

.cart-table .qty-cell span {
  display: inline-block;
  min-width: 1em;
  text-align: center;
  vertical-align: middle;
}

.qty-btn {
  width: 24px;
  height: 24px;
  cursor: pointer;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card.block {
  padding: 20px;
}

.summary-card {
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.label {
  margin: 0 0 14px;
  font-size: 10px;
}

.value {
  margin: 0;
  font-size: clamp(1.3rem, 2vw, 2rem);
  font-weight: 700;
}

.block {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section-heading {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.block label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.block textarea:not(.form-control) {
  resize: vertical;
}

.customer-search-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.customer-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.customer-result {
  padding: 10px 12px;
  font-size: 0.75rem;
}

.customer-result strong {
  display: block;
  margin-bottom: 5px;
}

.customer-result-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.customer-result-actions form {
  margin: 0;
}

.day-separator {
  background: #f5d68e;
}

.day-separator td {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--shadow);
  border-top: 3px solid var(--shadow);
  border-bottom: 3px solid var(--shadow);
}

.results-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  background: #fff8ea;
  border: 3px solid var(--shadow);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 4px 4px 0 var(--shadow);
}

.results-date-shortcuts,
.results-date-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.results-date-form label {
  min-width: 140px;
}

.chart-card {
  margin-top: 18px;
}

.chart-bars {
  display: flex;
  align-items: end;
  gap: 12px;
  height: 220px;
  padding-top: 18px;
  border-top: 3px solid var(--shadow);
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: end;
}

.chart-bar {
  width: 100%;
  min-height: 10px;
  max-height: 100%;
  background: linear-gradient(180deg, var(--mustard) 0%, var(--red) 100%);
  border: 3px solid var(--shadow);
  border-radius: 10px 10px 0 0;
  box-shadow: 4px 4px 0 var(--shadow);
}

.chart-col span,
.chart-col small {
  display: block;
  text-align: center;
  font-size: 0.62rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.78rem;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 2px solid rgba(15, 23, 42, 0.25);
  vertical-align: top;
}

th {
  font-family: "Press Start 2P", cursive;
  font-size: 0.56rem;
  color: var(--ink);
}

.totals-row {
  font-weight: 700;
  background: rgba(244, 196, 48, 0.12);
}

.result-table-card {
  margin-top: 18px;
}

.result-step.card,
.result-indicator.card {
  min-width: 0;
  border: 3px solid #000 !important;
  border-radius: 12px !important;
  background: var(--warm) !important;
  box-shadow: 3px 3px 0 #000 !important;
}

.result-step-label {
  color: #475569;
  font-size: 0.8rem;
  font-weight: 800;
}

.result-step-value,
.result-indicator-value {
  color: var(--dark);
  font-family: "Space Mono", monospace;
  font-size: clamp(0.9rem, 1.8vw, 1.2rem);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.result-indicator.card {
  min-height: 132px;
}

.result-indicator-value {
  font-size: clamp(1.05rem, 2vw, 1.45rem);
}

.result-indicator small {
  color: #475569;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.5;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0 !important;
  background: rgba(15, 23, 42, 0.78);
}

.modal-dialog {
  position: relative;
  width: min(480px, 100%);
  z-index: 1;
  pointer-events: auto;
  border: 4px solid #000;
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 6px 6px 0 #000;
  padding: 18px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border-bottom: 3px solid var(--dark);
}

.modal-header h3 {
  margin: 0;
  font-size: 0.85rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 3px solid var(--dark);
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  box-shadow: 3px 3px 0 var(--dark);
  font-size: 1.3rem;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.status-pill {
  display: inline-block;
  border: 2px solid var(--dark);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.8rem;
  font-family: "Nunito", sans-serif;
  font-weight: 900;
  background: #d1fae5;
}

.status-pill.cancelled {
  background: var(--red);
  color: #fff;
}

.cancelled-row {
  opacity: 0.72;
  background: rgba(220, 38, 38, 0.04);
}

.inline-form {
  margin: 0;
}

@media (max-width: 820px) {
  .panel-grid.two-cols,
  .field-row {
    grid-template-columns: 1fr;
  }
}

body {
  min-height: 100vh;
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%) !important;
  color: var(--dark);
  font-family: "Space Mono", monospace;
  font-size: 1rem;
  font-weight: 700;
}

h1,
h2,
h3,
h4,
h5,
h6,
.pixel {
  color: var(--dark);
  font-family: "Press Start 2P", cursive;
  font-weight: 700;
}

.app-navbar {
  padding: 24px 12px 0;
  background: transparent !important;
}

.topbar {
  width: 100%;
  max-width: none;
  min-height: 142px;
  padding: 16px 22px;
  justify-content: space-between;
  gap: 18px;
  border: 4px solid #000;
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 6px 6px 0 #000;
}

.navbar .navbar-brand,
.navbar .navbar-brand:hover,
.navbar .navbar-brand:focus {
  margin: 0;
  color: var(--dark);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: normal;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.eyebrow {
  margin: 0;
  color: #64748b;
  font-size: 0.58rem;
}

.title {
  margin: 0;
  font-size: clamp(1.25rem, 2.4vw, 2rem);
  letter-spacing: 1px;
}

.brand-logo {
  display: block;
  width: 100px;
  height: 100px;
  border: 4px solid #000;
  border-radius: 50%;
  background: #fff;
  padding: 5px;
  object-fit: cover;
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px;
  border: 4px solid #000;
  border-radius: 18px;
  background: var(--dark);
  box-shadow: 6px 6px 0 #000;
}

.nav-pills .nav-link {
  padding: 10px 12px;
  border: 3px solid #000;
  border-radius: 12px;
  background: var(--cream);
  color: var(--dark);
  font-family: "Press Start 2P", cursive;
  font-size: 0.55rem;
  font-weight: 700;
  box-shadow: 3px 3px 0 #000;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.nav-pills .nav-link:hover {
  color: var(--dark);
  transform: translate(-1px, -1px);
}

.nav-pills .nav-link.active,
.nav-pills .nav-link.active:hover {
  border-color: #000;
  background: var(--mustard) !important;
  color: var(--dark) !important;
}

.page-shell {
  width: 100%;
  max-width: none;
  margin: 24px auto;
  padding: 0 clamp(12px, 2vw, 28px);
}

.card {
  overflow: hidden;
  border: 4px solid #000 !important;
  border-radius: 18px !important;
  background: var(--cream) !important;
  color: var(--dark);
  box-shadow: 6px 6px 0 #000 !important;
}

.inventory-panel .card {
  background: #fbf8f1 !important;
}

.inventory-panel .btn-primary,
.inventory-panel .nav-pills .nav-link.active {
  background: #f5b82e !important;
  color: var(--dark) !important;
}

.card-body {
  padding: 1rem;
}

.card-footer {
  border-top: 3px solid #000;
  background: #fff;
}

.product-card {
  overflow: hidden;
  border: 3px solid #000 !important;
  border-radius: 14px !important;
  background: #fff !important;
  box-shadow: 4px 4px 0 #000 !important;
}

.product-placeholder {
  border-bottom: 3px solid #000;
  background: linear-gradient(180deg, #e2e8f0, #f8fafc);
  color: var(--dark);
  font-size: 1.1rem;
  letter-spacing: 1px;
}

.product-card .ratio {
  border-bottom: 3px solid #000;
}

.product-card .ratio img {
  object-fit: cover;
}

.btn,
.mini-btn,
.qty-btn {
  border: 3px solid #000 !important;
  border-radius: 10px !important;
  box-shadow: 3px 3px 0 #000 !important;
  color: var(--dark);
  font-family: "Press Start 2P", cursive;
  font-size: 0.5rem;
  font-weight: 900 !important;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn {
  padding: 0.65rem 0.9rem;
}

.btn:active,
.mini-btn:active,
.qty-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #000 !important;
}

.btn-primary,
.btn-warning,
.mini-btn,
.customer-edit-toggle,
.btn-success,
.btn-secondary {
  background: var(--mustard) !important;
  color: var(--dark) !important;
}

.btn-danger,
.mini-btn.danger {
  background: #f9b4b4 !important;
  color: var(--dark) !important;
}

.btn-secondary,
.btn-outline-secondary,
.btn-outline-primary {
  background: var(--cream) !important;
  color: var(--dark) !important;
}

.btn-outline-secondary:hover,
.btn-outline-primary:hover {
  background: var(--mustard) !important;
  color: var(--dark) !important;
}

.form-label,
label {
  color: var(--dark);
  font-weight: 800;
}

input,
textarea,
select,
.form-control,
.form-select {
  min-height: 42px;
  border: 3px solid #000 !important;
  border-radius: 12px !important;
  background-color: #fff !important;
  color: var(--dark) !important;
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  font-weight: 400;
  box-shadow: none !important;
}

input:focus,
textarea:focus,
select:focus,
.form-control:focus,
.form-select:focus {
  border-color: #000 !important;
  box-shadow: 3px 3px 0 var(--mustard) !important;
}

input[type="file"] {
  padding: 0.35rem;
}

.table-responsive {
  border: 3px solid #000;
  border-radius: 12px;
  background: #fff;
}

.table {
  --bs-table-bg: #fff;
  --bs-table-color: var(--dark);
  --bs-table-striped-bg: var(--warm);
  --bs-table-striped-color: var(--dark);
  margin-bottom: 0;
  color: var(--dark);
  font-weight: 700;
}

.table > :not(caption) > * > * {
  border-bottom: 2px solid var(--dark);
  padding: 0.65rem;
  vertical-align: middle;
}

.table thead th,
.table thead td,
th {
  border: 2px solid rgba(15, 23, 42, 0.25) !important;
  background: #fff !important;
  color: var(--dark) !important;
  font-family: "Press Start 2P", cursive;
  font-size: 0.56rem;
  font-weight: 700;
}

.history-table {
  width: 100%;
  table-layout: fixed;
  font-size: 0.58rem;
}

.history-table th,
.history-table td {
  overflow-wrap: anywhere;
  white-space: normal;
}

.history-table.table > :not(caption) > * > * {
  padding: 5px 4px;
  font-size: 0.58rem;
}

.history-table th:nth-child(1) { width: 17%; }
.history-table th:nth-child(2) { width: 16%; }
.history-table th:nth-child(3) { width: 10%; }
.history-table th:nth-child(4) { width: 12%; }
.history-table th:nth-child(5) { width: 15%; }
.history-table th:nth-child(6) { width: 12%; }
.history-table th:nth-child(7) { width: 18%; }

.expense-history-table th:nth-child(1) { width: 24%; }
.expense-history-table th:nth-child(2) { width: 16%; }
.expense-history-table th:nth-child(3) { width: 40%; }
.expense-history-table th:nth-child(4) { width: 20%; }

.history-table .btn {
  padding: 5px 6px;
  font-size: 0.4rem;
  white-space: normal;
}

.history-table th:nth-child(3),
.history-table td:nth-child(3) {
  text-align: center;
  white-space: nowrap;
}

.history-table .badge,
.history-table .status-pill {
  border: 2px solid #000;
  border-radius: 999px;
  padding: 3px 5px;
  font-family: "Nunito", sans-serif;
  font-size: 0.48rem;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

.cart-total {
  border: 3px solid #000;
  border-radius: 12px;
  background: var(--mustard);
  color: var(--dark);
  box-shadow: 4px 4px 0 #000;
}

.cart-total strong {
  font-size: 1.4rem;
}

.order-summary-dialog {
  width: min(720px, 100%);
  max-height: min(90vh, 900px);
  overflow-y: auto;
  background: #fbf8f1;
}

.order-summary-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.order-summary-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 0;
}

.order-summary-details > div,
.order-summary-notes {
  min-width: 0;
  padding: 10px;
  border: 3px solid #000;
  border-radius: 10px;
  background: #fff;
  overflow-wrap: anywhere;
}

.order-summary-details dt,
.order-summary-label,
.order-summary-notes strong {
  margin: 0 0 6px;
  font-family: "Press Start 2P", cursive;
  font-size: 0.58rem;
}

.order-summary-details dd {
  margin: 0;
  font-size: 0.9rem;
}

.order-summary-total {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border: 4px solid #000;
  border-radius: 12px;
  background: #f5b82e;
  box-shadow: 4px 4px 0 #000;
  font-family: "Press Start 2P", cursive;
  font-size: 0.75rem;
}

.order-summary-total strong {
  font-size: clamp(1.1rem, 3vw, 1.7rem);
}

.order-summary-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.tab-panel .sales-checkout-button,
.order-summary-actions .order-save-button {
  border-color: #000 !important;
  background: #f5b82e !important;
  color: var(--dark) !important;
}

.order-summary-actions .order-print-button,
.order-summary-actions .order-print-button:hover,
.order-summary-actions .order-print-button:focus {
  border-color: #000 !important;
  background: #111827 !important;
  color: #fff !important;
}

#ticket-impresion {
  display: none;
}

.qty-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--mustard);
  line-height: 1;
}

.sales-customer-suggestions {
  border: 3px solid var(--dark);
  border-radius: 8px;
  background: var(--cream);
  box-shadow: 4px 4px 0 var(--dark);
}

.sales-customer-option {
  border: 2px solid var(--dark);
  border-radius: 8px;
  background: #fff;
  color: var(--dark);
  font-family: "Nunito", sans-serif;
  font-weight: 700;
}

.customer-result {
  border: 3px solid var(--dark);
  border-radius: 8px;
  background: #fff;
  color: var(--dark);
  font-weight: 700;
}

.accent-gold,
.accent-cream,
.accent-red,
.accent-blue {
  background: var(--warm) !important;
}

.results-controls,
.customer-result,
.sales-customer-option {
  border-color: var(--dark);
  box-shadow: 3px 3px 0 var(--dark);
}

.status-pill.active,
.badge.text-bg-success {
  background: var(--green) !important;
  color: #fff !important;
}

.status-pill.cancelled,
.badge.text-bg-danger {
  background: var(--red) !important;
  color: #fff !important;
}

@media (max-width: 575.98px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px;
  }

  .topbar .tab-bar {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
    padding: 8px;
  }

  .nav-pills .nav-link {
    padding: 8px;
    font-size: 0.45rem;
  }

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

  .title {
    font-size: 1rem;
  }

  .cart-total {
    font-size: 1rem !important;
  }

  .cart-total strong {
    font-size: 1.1rem;
  }

  .order-summary-actions {
    flex-direction: column-reverse;
  }

  .order-summary-actions .btn {
    width: 100%;
  }
}

@media (min-width: 576px) and (max-width: 991.98px) {
  .topbar {
    align-items: flex-start;
  }

  .tab-bar {
    justify-content: flex-start;
  }
}

@media print {
  @page {
    size: 80mm auto;
    margin: 4mm;
  }

  html,
  body {
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  body > *:not(#ticket-impresion) {
    display: none !important;
  }

  #ticket-impresion {
    display: block !important;
    width: 100%;
    max-width: 72mm;
    position: static !important;
    margin: 0;
    padding: 4mm;
    background: #fff !important;
    color: #000 !important;
    font-family: "Courier New", monospace;
    font-size: 11pt;
    font-weight: 400;
    line-height: 1.35;
    box-shadow: none !important;
  }

  #ticket-impresion h1,
  #ticket-impresion h2,
  #ticket-impresion p {
    margin: 0;
    color: #000 !important;
    font-family: "Courier New", monospace;
    font-size: inherit;
    font-weight: 400;
  }

  #ticket-impresion .ticket-center {
    text-align: center;
  }

  #ticket-impresion .ticket-divider {
    margin: 3mm 0;
    border-top: 1px dashed #000;
  }

  #ticket-impresion .ticket-items {
    width: 100%;
    border-collapse: collapse;
    font: inherit;
  }

  #ticket-impresion .ticket-items th,
  #ticket-impresion .ticket-items td {
    padding: 1mm 0;
    border: 0 !important;
    background: #fff !important;
    color: #000 !important;
    font: inherit;
    text-align: left;
  }

  #ticket-impresion .ticket-items th:last-child,
  #ticket-impresion .ticket-items td:last-child {
    text-align: right;
  }

  #ticket-impresion .ticket-total {
    margin-top: 3mm;
    font-weight: 700;
    text-align: right;
  }
}
