/* Resquip Catalog — light, centered, read-only */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dee2e6;
  --text: #212529;
  --muted: #6c757d;
  --accent: #0d6efd;
  --accent-hover: #0b5ed7;
  --danger: #dc3545;
  --warn: #ffc107;
  --ok: #198754;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --max-w: 1100px;
  --top-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

.login-card p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.login-card input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-sync {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-sync:hover:not(:disabled) {
  background: #e9ecef;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btn-icon svg {
  display: block;
}

/* Top bar */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  z-index: 100;
}

.top-bar .brand {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.top-bar .spacer {
  flex: 1;
}

.user-label {
  font-size: 0.75rem;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: none;
}

@media (min-width: 640px) {
  .user-label {
    display: block;
  }
}

.last-synced {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  display: none;
}

@media (min-width: 900px) {
  .last-synced {
    display: block;
  }
}

/* Burger */
.burger-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 200;
}

.burger-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: min(300px, 85vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 201;
  padding: 1rem;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.burger-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.burger-user {
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

.burger-blurb {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
}

.burger-blurb strong {
  color: var(--text);
}

/* App shell */
.app-shell {
  padding-top: var(--top-h);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.main-content {
  width: 100%;
  max-width: var(--max-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 1rem 1.5rem;
  min-height: calc(100vh - var(--top-h));
}

.search-strip {
  position: sticky;
  top: var(--top-h);
  z-index: 50;
  background: var(--bg);
  padding: 1rem 0 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.search-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.main-search {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.05rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.main-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0;
  flex-shrink: 0;
}

.show-all-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  margin-left: auto;
}

.show-all-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.show-all-slider {
  width: 36px;
  height: 20px;
  background: #ced4da;
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.show-all-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.show-all-toggle input:checked + .show-all-slider {
  background: var(--accent);
}

.show-all-toggle input:checked + .show-all-slider::after {
  transform: translateX(16px);
}

.show-all-toggle input:focus-visible + .show-all-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.show-all-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.list-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.stat-inline {
  font-size: 0.75rem;
  color: var(--muted);
}

.results-table-wrap {
  flex: 1;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.results-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f9fa;
}

.results-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.results-table th.col-num,
.results-table td.col-num {
  text-align: center;
}

.results-table tbody tr.result-row {
  cursor: pointer;
  transition: background 0.12s;
}

.results-table tbody tr.result-row:hover,
.results-table tbody tr.result-row:focus {
  background: #e7f1ff;
  outline: none;
}

.results-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: middle;
}

.table-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #e9ecef;
  display: block;
}

.table-sku {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 0.8rem;
}

.col-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-price {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

td.num {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.table-message {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem !important;
}

.avail-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 2rem;
  text-align: center;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
}

.avail-ok {
  background: #d1e7dd;
  color: #0f5132;
}

.avail-low {
  background: #fff3cd;
  color: #664d03;
}

.avail-zero {
  background: #f8d7da;
  color: #842029;
}

.avail-unknown {
  background: #e9ecef;
  color: var(--muted);
}

@media (max-width: 720px) {
  .hide-sm {
    display: none;
  }
}

/* Detail modal */
.modal-open {
  overflow: hidden;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
}

@media (min-width: 640px) {
  .detail-modal {
    align-items: center;
  }
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.detail-panel {
  position: relative;
  width: 100%;
  max-width: 920px;
  max-height: 92vh;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.detail-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.detail-sku {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: 0.25rem;
}

.detail-body {
  overflow-y: auto;
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 720px) {
  .detail-body {
    grid-template-columns: 200px 1fr;
  }

  .detail-inventory-block {
    grid-column: 1 / -1;
  }
}

.detail-hero {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: zoom-in;
}

.detail-specs dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  font-size: 0.9rem;
}

.detail-specs dt {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.detail-specs dd {
  margin: 0;
}

.detail-docs {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.detail-docs h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

.detail-docs ul {
  margin: 0;
  padding-left: 1.1rem;
}

.doc-none {
  list-style: none;
  padding-left: 0;
  color: var(--muted);
}

.detail-inventory-block h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.loading-inline,
.stock-error {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
}

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

/* Stock panel (inventory-readonly) */
.stock-offline {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  margin-bottom: 1rem;
}

.stock-offline strong {
  display: block;
  color: var(--danger);
  margin-bottom: 0.35rem;
}

.stock-offline p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.stock-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.stock-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.stock-panel-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.stock-last-update {
  font-size: 0.65rem;
  color: #94a3b8;
}

.stock-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 520px) {
  .stock-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stock-cell {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.65rem;
  text-align: center;
}

.stock-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.stock-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--mono);
}

.stock-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
  font-size: 0.8rem;
  color: #64748b;
}

/* Dispatch table */
.dispatch-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
}

.dispatch-panel-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.5rem;
}

.dispatch-count {
  background: #e2e8f0;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.65rem;
}

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

.dispatch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.dispatch-table th {
  text-align: left;
  font-size: 0.6rem;
  text-transform: uppercase;
  color: #64748b;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.dispatch-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}

.dispatch-table .num {
  text-align: center;
  font-weight: 700;
}

.dispatch-table .ref {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dispatch-table .date {
  font-size: 0.6rem;
  color: #94a3b8;
}

.dispatch-empty {
  text-align: center;
  color: #94a3b8;
  padding: 1rem !important;
}

.dispatch-badge {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.dispatch-badge-in {
  background: #dbeafe;
  color: #1d4ed8;
}

.dispatch-badge-out {
  background: #fef3c7;
  color: #b45309;
}

.dispatch-status-pending {
  background: #fef3c7;
  color: #92400e;
}

.dispatch-status-partial {
  background: #cffafe;
  color: #0e7490;
}

.dispatch-status-complete {
  background: #d1fae5;
  color: #065f46;
}

.dispatch-status-other {
  background: #e2e8f0;
  color: #475569;
}
