/* D2CTap Reports — matches OMS theme (client/src/styles/_theme.scss) */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&display=swap');

:root {
  --font-sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --color-primary: #ff6b35;
  --color-primary-dark: #e55a2b;
  --color-primary-darker: #c44a1f;
  --color-primary-light: #fff7ed;
  --color-primary-border: #fed7aa;
  --color-primary-muted: rgb(255 107 53 / 0.13);
  --color-primary-focus: rgb(255 107 53 / 0.15);

  --sidebar-bg: #111318;
  --sidebar-border: rgb(255 255 255 / 0.07);
  --sidebar-width: 252px;
  --topbar-height: 58px;

  --nav-hover-bg: rgb(255 255 255 / 0.055);
  --nav-active-bg: rgb(255 107 53 / 0.13);
  --nav-active-color: #ff6b35;

  --bg-main: #f4f5f7;
  --topbar-bg: #ffffff;
  --topbar-border: #e9eaec;

  --color-text-1: #111827;
  --color-text-2: #6b7280;
  --color-text-3: #9ca3af;

  --color-surface: #ffffff;
  --color-border: #e5e7eb;

  --radius: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;

  --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.06), 0 1px 2px rgb(0 0 0 / 0.04);
  --shadow: 0 4px 16px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.12);

  --gradient-primary: linear-gradient(135deg, #ff6b35 0%, #ff9558 100%);
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

.btn {
  appearance: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-1);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.95rem;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}

.btn:hover {
  background: #fafafa;
  border-color: #d1d5db;
}

.btn--primary {
  background: var(--gradient-primary);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgb(255 107 53 / 0.28);
}

.btn--primary:hover {
  background: linear-gradient(135deg, #e55a2b 0%, #ff6b35 100%);
  border-color: var(--color-primary-dark);
}

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

.btn--ghost:hover {
  background: rgb(0 0 0 / 0.04);
  color: var(--color-text-1);
}

.btn--block {
  width: 100%;
}

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

/* ── Auth (OMS login look) ── */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 12% 15%, rgb(40 116 240 / 0.12), transparent 48%),
    radial-gradient(circle at 88% 8%, rgb(244 51 151 / 0.12), transparent 42%),
    radial-gradient(circle at 50% 100%, rgb(255 107 53 / 0.08), transparent 40%),
    linear-gradient(160deg, #f4f7ff 0%, #fff8fb 50%, #fff 100%);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--color-surface);
  border: 1px solid rgb(40 116 240 / 0.1);
  border-radius: 1.25rem;
  box-shadow:
    0 24px 60px rgb(15 27 51 / 0.12),
    0 2px 8px rgb(15 27 51 / 0.05);
  padding: 1.75rem;
}

.auth-brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 1.4rem;
}

.auth-brand__logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 8px 20px rgb(255 107 53 / 0.25);
  flex-shrink: 0;
}

.auth-brand__mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--gradient-primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.03em;
  flex-shrink: 0;
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.auth-brand p {
  margin: 0.2rem 0 0;
  color: var(--color-text-2);
  font-size: 0.9rem;
}

.auth-form {
  display: grid;
  gap: 0.9rem;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
}

.auth-form span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-2);
}

.auth-form input,
.filters input,
.filters select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text-1);
}

.auth-form input:focus,
.filters input:focus,
.filters select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-focus);
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.auth-handoff {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--color-primary-light);
  color: var(--color-primary-darker);
  border: 1px solid var(--color-primary-border);
  font-weight: 600;
  font-size: 0.9rem;
}

.auth-foot {
  margin: 1.2rem 0 0;
  text-align: center;
  color: var(--color-text-2);
  font-size: 0.86rem;
}

.auth-foot a {
  color: var(--color-primary);
  font-weight: 600;
}

/* ── App shell ── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--topbar-height);
  padding: 0 1.15rem;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar__brand strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar__logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
}

.topbar__menu {
  display: none;
  padding: 0.4rem 0.55rem;
  min-width: 2.25rem;
  color: var(--color-text-1);
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar__email {
  color: var(--color-text-2);
  font-size: 0.85rem;
  margin-right: 0.35rem;
}

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: #e8ecf7;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow: auto;
}

.sidebar__head {
  padding: 1rem 1rem 0.55rem;
  position: sticky;
  top: 0;
  background: var(--sidebar-bg);
  z-index: 1;
  border-bottom: 1px solid rgb(255 255 255 / 0.06);
}

.sidebar__label {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 0.45);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.5rem 1.25rem;
}

.sidebar__item {
  appearance: none;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: rgb(255 255 255 / 0.85);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition:
    background 0.12s ease,
    color 0.12s ease;
  position: relative;
}

.sidebar__item:hover {
  background: var(--nav-hover-bg);
  color: #fff;
}

.sidebar__item.is-active {
  background: var(--nav-active-bg);
  color: var(--nav-active-color);
}

.sidebar__item.is-active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--color-primary);
  border-radius: 0 3px 3px 0;
}

.sidebar__item-title {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.25;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 1.35rem 1.4rem 3rem;
}

.home-empty {
  max-width: 28rem;
  margin: 4rem auto;
  text-align: center;
  color: var(--color-text-2);
}

.home-empty h1 {
  margin: 0 0 0.5rem;
  color: var(--color-text-1);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.home-empty p {
  margin: 0;
  line-height: 1.45;
}

.view-head h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.view-head p {
  margin: 0.35rem 0 0;
  color: var(--color-text-2);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin: 1rem 0;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.filters label {
  display: grid;
  gap: 0.3rem;
  min-width: 140px;
}

.filters__grow {
  flex: 1 1 180px;
}

.filters__expense {
  min-width: 150px;
}

.filters span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-2);
}

.recon-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.recon-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
}

.recon-card__label {
  display: block;
  color: var(--color-text-2);
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.recon-card__value {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.recon-card--profit .recon-card__value {
  color: #027a48;
}

.recon-card--loss .recon-card__value {
  color: #b42318;
}

.recon-card--net {
  border-color: var(--color-primary-border);
  background: var(--color-primary-light);
  grid-column: 1 / -1;
}

.recon-card--net .recon-card__label {
  font-size: 0.85rem;
  color: var(--color-text-1);
}

.recon-card--net .recon-card__value {
  font-size: 1.55rem;
  color: var(--color-primary-darker);
}

.recon-card__hint {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--color-text-3);
}

.status-line {
  min-height: 1.25rem;
  color: var(--color-text-2);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.report-results.is-loading {
  display: none;
}

.report-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  min-height: 240px;
  margin-bottom: 1rem;
  padding: 2rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--color-text-2);
}

.report-loading.hidden {
  display: none !important;
}

.report-loading--compact {
  min-height: 140px;
  margin: 0.5rem 0 0.75rem;
  padding: 1.25rem;
  box-shadow: none;
}

.report-loading__spinner {
  width: 2.35rem;
  height: 2.35rem;
  border: 3px solid var(--color-primary-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: report-spin 0.7s linear infinite;
}

.report-loading--compact .report-loading__spinner {
  width: 1.85rem;
  height: 1.85rem;
}

.report-loading__text {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-2);
}

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

.kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  min-width: 120px;
  box-shadow: var(--shadow-sm);
}

.kpi__label {
  display: block;
  color: var(--color-text-2);
  font-size: 0.75rem;
  font-weight: 600;
}

.kpi__value {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.kpi--rto .kpi__value {
  color: #b42318;
}

.kpi--return .kpi__value {
  color: #b54708;
}

.kpi--exchange .kpi__value {
  color: #175cd3;
}

.kpi--all {
  border-color: var(--color-primary-border);
  background: var(--color-primary-light);
}

.status-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 0.85rem;
}

.status-tfoot td {
  background: #f8fafc;
  border-top: 2px solid var(--color-border);
}

.col-date {
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--color-border);
  font-size: 0.88rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table th {
  background: #fafafa;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-2);
  position: sticky;
  top: 0;
  font-weight: 700;
  z-index: 1;
}

.data-table tbody tr:hover {
  background: var(--color-primary-light);
}

.data-table .empty {
  text-align: center;
  color: var(--color-text-2);
  padding: 2rem 1rem;
  white-space: normal;
}

.col-img {
  width: 64px;
}

.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.col-product {
  min-width: 160px;
  max-width: 260px;
  white-space: normal !important;
  word-break: break-word;
}

.col-product .product-name,
.product-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
  font-weight: 600;
  line-height: 1.35;
  max-width: 100%;
}

.product-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: #fafafa;
  display: block;
  flex-shrink: 0;
}

.product-thumb--empty {
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  color: var(--color-text-3);
  text-align: center;
  line-height: 1.1;
  padding: 0.2rem;
}

.col-product--with-thumb {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.product-meta {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: var(--color-text-2);
}

.product-meta--warn {
  color: #b54708;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
}

.filters__standard {
  display: contents;
}

.async-panel {
  width: 100%;
  display: grid;
  gap: 0.85rem;
}

.async-panel__note {
  margin: 0;
  padding: 0.75rem 0.9rem;
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-1);
  font-size: 0.88rem;
  line-height: 1.45;
}

.async-panel__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.async-panel select {
  min-width: 120px;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--color-surface);
}

.async-progress {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border: 1px solid var(--color-border);
  font-size: 0.88rem;
  color: var(--color-text-2);
}

.async-progress--busy {
  border-color: var(--color-primary-border);
  background: var(--color-primary-light);
}

.async-progress__pct {
  font-weight: 700;
  color: var(--color-primary-darker);
}

.async-progress--error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b42318;
}

.async-progress--ready {
  border-color: #abefc6;
  background: #ecfdf3;
  color: #027a48;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #f3f4f6;
  color: #374151;
}

.type-badge--rto {
  background: #fee4e2;
  color: #b42318;
}

.type-badge--return {
  background: #ffead5;
  color: #b54708;
}

.type-badge--exchange {
  background: #d1e9ff;
  color: #175cd3;
}

.type-badge--unknown,
.type-badge--other {
  background: #f2f4f7;
  color: #667085;
}

.data-table tbody tr.row-drillable {
  cursor: pointer;
}

.data-table tbody tr.row-drillable:hover {
  background: #fff7ed;
}

.orders-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 80;
}

.orders-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(1100px, 100vw);
  height: 100vh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  display: flex;
  flex-direction: column;
}

.orders-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--color-border);
}

.orders-panel__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.orders-panel__sub {
  margin: 0.3rem 0 0;
  color: var(--color-text-2);
  font-size: 0.85rem;
}

.orders-panel__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1.15rem 1rem;
  gap: 0.75rem;
}

.orders-panel__status {
  color: var(--color-text-2);
  font-size: 0.88rem;
}

.orders-panel__status.is-error {
  color: var(--danger);
}

.orders-panel__table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.orders-panel__table {
  box-shadow: none;
  border: 0;
}

.orders-panel__pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.report-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding: 0.65rem 0.15rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.report-pager.hidden {
  display: none;
}

@media (max-width: 900px) {
  .topbar__menu {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    z-index: 30;
    width: min(280px, 86vw);
    height: calc(100vh - var(--topbar-height));
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .app-main {
    padding: 1.1rem 1rem 2.5rem;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: auto;
    min-height: var(--topbar-height);
    flex-wrap: wrap;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }

  .topbar__right {
    justify-content: flex-start;
  }
}
