/* Sales / login — uses shared brand.css tokens */

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink-soft);
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(245, 215, 110, 0.12), transparent 55%),
    linear-gradient(180deg, #e8edf7 0%, var(--bg-app) 40%);
  min-height: 100vh;
}

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

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(10, 26, 74, 0.78), rgba(6, 18, 51, 0.92)),
    url("/assets/cover-hero.webp") center / cover;
  padding: 1.5rem;
}
.login-view[hidden],
#appView[hidden] {
  display: none !important;
}
.login-card .primary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 1.75rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 1px solid rgba(245, 215, 110, 0.25);
}
.login-logo { width: 64px; height: 64px; object-fit: contain; align-self: center; }
.login-card h1 {
  margin: 0;
  text-align: center;
  font-family: var(--display);
  color: var(--navy);
}
.login-card p { margin: 0; text-align: center; color: var(--muted); }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.login-card input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  font: inherit;
  color: var(--ink-soft);
}
.login-card .primary,
.primary {
  border: 0;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font: inherit;
  font-weight: 700;
  background: linear-gradient(180deg, var(--gold-btn-top), var(--gold-btn));
  color: #1a1200;
  cursor: pointer;
}
.err { color: var(--danger); font-size: 0.9rem; text-align: center; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(180deg, var(--navy-mid), var(--navy-deep));
  color: #fff;
  border-bottom: 1px solid rgba(245, 215, 110, 0.22);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.brand img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
  object-fit: contain;
}
.brand strong { display: block; font-family: var(--display); letter-spacing: 0.03em; }
.brand span { font-size: 0.8rem; opacity: 0.8; color: var(--gold); }
.top-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.top-actions select,
.top-actions button,
.top-link {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 0.45rem 0.7rem;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.top-actions .ghost { background: transparent; }
.top-link:hover,
.top-actions button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.layout {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  max-width: 1280px;
  margin: 0 auto;
}
@media (min-width: 960px) {
  .layout {
    grid-template-columns: minmax(320px, 1.05fr) minmax(360px, 1fr);
    align-items: start;
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}
@media (min-width: 560px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
  .stats { grid-template-columns: repeat(5, 1fr); }
}
.stat {
  background: var(--card);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s;
}
.stat:hover,
.stat.active {
  border-color: var(--gold-btn);
  transform: translateY(-1px);
}
.stat strong {
  display: block;
  font-size: 1.2rem;
  color: var(--navy);
  font-family: var(--display);
  letter-spacing: 0.02em;
  margin-bottom: 0.15rem;
}
.stat.accent strong { color: #7a5200; }
.stat.value strong { color: #0f7a45; font-size: 1.05rem; }

.filters {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
@media (min-width: 640px) {
  .filters { grid-template-columns: 1.4fr 0.8fr 0.9fr; }
}
.filters input,
.filters select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  font: inherit;
  background: #fff;
  color: var(--ink-soft);
}
.filters input:focus,
.filters select:focus {
  outline: 2px solid rgba(240, 193, 74, 0.55);
  border-color: var(--gold-btn);
}

.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-soft);
}
.chip.active {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}
.chip .count {
  opacity: 0.75;
  margin-left: 0.2rem;
}

.list-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.order-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding-right: 2px;
}
.order-row {
  background: var(--card);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.order-row:hover { border-color: rgba(240, 193, 74, 0.55); }
.order-row.active {
  border-color: var(--gold-btn);
  box-shadow: 0 0 0 1px rgba(240, 193, 74, 0.35), var(--shadow-card);
}
.order-row .row1 {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: start;
  font-weight: 700;
  color: var(--navy);
}
.order-row .row-amount {
  font-family: var(--display);
  color: var(--navy);
  font-size: 1.05rem;
  margin-top: 0.35rem;
}
.order-row .row2 {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}
.order-row .row3 {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: #8090a8;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #e8eefc;
  color: var(--navy-mid);
  white-space: nowrap;
}
.badge.new { background: #ffe8a3; color: #7a5200; }
.badge.confirmed { background: #d7f5e5; color: var(--success); }
.badge.processing { background: #dde7ff; color: #2741a8; }
.badge.packed { background: #f3e0ff; color: #6b21a8; }
.badge.shipped { background: #d9f3ff; color: #0369a1; }
.badge.completed { background: #e5e7eb; color: #374151; }
.badge.cancelled { background: #ffe0e0; color: var(--danger); }

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-card);
  min-height: 320px;
  border: 1px solid var(--line);
  position: sticky;
  top: 4.5rem;
}
.muted { color: var(--muted); }
.empty-detail {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 0.4rem;
  min-height: 280px;
  padding: 1rem;
}
.empty-detail img {
  width: 56px;
  height: 56px;
  opacity: 0.9;
  margin-bottom: 0.35rem;
}
.empty-detail h2 {
  margin: 0;
  font-family: var(--display);
  color: var(--navy);
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}
.detail-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.4rem;
  color: var(--navy);
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.85rem 0 0.35rem;
}
.detail-actions a,
.detail-actions button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--navy);
  text-decoration: none;
}
.detail-actions .wa {
  background: #25d366;
  border-color: #1ebe57;
  color: #fff;
}
.detail-actions .gold {
  background: linear-gradient(180deg, var(--gold-btn-top), var(--gold-btn));
  border-color: transparent;
  color: #1a1200;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.55rem 0 0;
  line-height: 1.55;
}
.meta a { color: var(--navy-mid); }
.meta .block { margin-top: 0.25rem; }

.lines {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1rem 0 0.5rem;
}
.lines th,
.lines td {
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.35rem;
  text-align: left;
  vertical-align: top;
}
.lines th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lines td.num,
.lines th.num { text-align: right; }
.lines small { color: var(--muted); }

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0.75rem 0 1rem;
  padding-top: 0.65rem;
  border-top: 2px solid var(--navy);
  font-size: 1.15rem;
  color: var(--navy);
  font-family: var(--display);
}

.status-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.status-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.status-actions button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft);
  text-transform: capitalize;
}
.status-actions button.active {
  color: #fff;
  border-color: transparent;
}
.status-actions button[data-status="new"].active { background: #b45309; }
.status-actions button[data-status="confirmed"].active { background: #0f7a45; }
.status-actions button[data-status="processing"].active { background: #2741a8; }
.status-actions button[data-status="packed"].active { background: #6b21a8; }
.status-actions button[data-status="shipped"].active { background: #0369a1; }
.status-actions button[data-status="completed"].active { background: #374151; }
.status-actions button[data-status="cancelled"].active { background: #b00020; }
.status-actions button:disabled { opacity: 0.55; cursor: wait; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 100;
  font-size: 0.9rem;
  border: 1px solid rgba(245, 215, 110, 0.35);
}
.toast[hidden] { display: none !important; }
.toast.err { background: #7f1d1d; border-color: rgba(255, 180, 180, 0.35); }

.print-only { display: none; }

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.75rem 0.85rem;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions select,
  .top-actions button,
  .top-link {
    flex: 1 1 auto;
    min-height: 42px;
    justify-content: center;
  }

  .layout {
    padding: 0.75rem;
    gap: 0.85rem;
  }

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

  .filters {
    grid-template-columns: 1fr;
  }

  .filters input,
  .filters select {
    min-height: 44px;
    font-size: 1rem;
  }

  .status-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  .chip {
    flex: 0 0 auto;
    min-height: 36px;
  }

  .order-list {
    max-height: none;
  }

  .order-row {
    padding: 0.95rem 1rem;
  }

  .card {
    position: static;
    min-height: 0;
  }

  .detail-actions a,
  .detail-actions button {
    min-height: 40px;
    flex: 1 1 calc(50% - 0.4rem);
    justify-content: center;
    display: inline-flex;
    align-items: center;
  }

  .status-actions button {
    min-height: 40px;
  }

  .login-view {
    padding: 1rem;
  }

  .login-card {
    padding: 1.35rem 1.15rem;
  }

  .login-card input,
  .login-card .primary {
    min-height: 46px;
  }
}

@media (max-width: 560px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .stat.value {
    grid-column: 1 / -1;
  }

  .detail-head {
    flex-direction: column;
  }
}

@media print {
  body {
    background: #fff;
  }
  .no-print,
  .topbar,
  .list-pane,
  .toast,
  .status-actions,
  .detail-actions,
  .login-view {
    display: none !important;
  }
  .layout {
    display: block;
    padding: 0;
    max-width: none;
  }
  .detail-pane.card {
    position: static;
    border: 0;
    box-shadow: none;
    padding: 0;
    min-height: 0;
  }
  .print-only { display: block; }
  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #0a1a4a;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
  }
  .print-header img { width: 48px; height: 48px; }
}
