/* ============================================================
   Return Delta — App shell (sidebar, topbar, content)
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.side {
  background: var(--gunmetal);
  color: rgba(255,255,255,.78);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.side__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  margin-bottom: 18px;
  color: #fff;
  text-decoration: none;
}
.side__brand .rd-mark__logo { width: 28px; height: 28px; }
.side__brand .name { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.side__brand .name strong { font-weight: 600; }

.side__sect {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.32);
  padding: 14px 10px 6px;
}
.side__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
}
.side__nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 8px;
  color: rgba(255,255,255,.7);
  font-size: 13.5px;
  font-weight: 400;
  transition: background .12s ease, color .12s ease;
  text-decoration: none;
}
.side__nav a:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}
.side__nav a.is-active {
  background: rgba(0,168,150,.14);
  color: #fff;
  font-weight: 500;
}
.side__nav a.is-active .ic { color: var(--teal); }
.side__nav .ic {
  display: inline-flex;
  width: 18px; height: 18px;
  color: rgba(255,255,255,.45);
}
.side__nav .badge {
  margin-left: auto;
  background: var(--teal);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}

.side__user {
  margin-top: auto;
  padding: 12px;
  background: rgba(255,255,255,.04);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.side__user .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.side__user .meta { line-height: 1.3; min-width: 0; }
.side__user .meta b { display: block; font-size: 12.5px; color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side__user .meta span { display: block; font-size: 11px; color: rgba(255,255,255,.5); }

/* ── Main column ── */
.main {
  background: var(--bg);
  min-width: 0; /* allow tables to scroll */
}

/* Topbar */
.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar__crumb {
  font-size: 13px;
  color: var(--muted);
}
.topbar__crumb b { color: var(--text); font-weight: 500; }
.topbar__search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.topbar__search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  background: var(--bg);
  outline: none;
  transition: border-color .12s ease, background .12s ease;
}
.topbar__search input:focus { border-color: var(--teal); background: var(--surface); }
.topbar__search::before {
  content: '';
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none'><circle cx='6' cy='6' r='4.5' stroke='%238fa3ab' stroke-width='1.4'/><path d='M9.5 9.5L12 12' stroke='%238fa3ab' stroke-width='1.4' stroke-linecap='round'/></svg>") center/contain no-repeat;
}
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar__icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}
.topbar__icon:hover { color: var(--text); border-color: var(--faint); }
.topbar__icon::after {
  content: '';
  position: absolute;
  top: 6px; right: 7px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--surface);
}
.topbar__icon--clean::after { display: none; }

/* Page wrapper */
.page {
  padding: 28px 28px 56px;
  max-width: 1400px;
}
.page__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}
.page__head h1 {
  font-size: 26px;
  font-weight: 500;
  color: var(--gunmetal);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.page__head p {
  font-size: 13.5px;
  color: var(--muted);
}
.page__actions { display: flex; gap: 8px; }

/* ── KPI cards ── */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 18px 20px;
}
.kpi__lbl {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi__lbl .ic { width: 14px; height: 14px; color: var(--faint); }
.kpi__val {
  font-size: 26px;
  font-weight: 500;
  color: var(--gunmetal);
  letter-spacing: -0.01em;
  line-height: 1;
  margin-bottom: 8px;
}
.kpi__val small {
  font-size: 14px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 3px;
}
.kpi__delta {
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
}
.kpi__delta--up   { background: var(--rose-pale); color: #993C1D; }
.kpi__delta--down { background: var(--teal-light); color: var(--teal-dark); }
.kpi__delta--flat { background: var(--bg-2); color: var(--muted); }
.kpi__spark {
  margin-top: 12px;
  height: 32px;
}

/* ── Card / panel ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
}
.card__head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.card__head h3 {
  font-size: 15px;
  font-weight: 500;
  color: var(--gunmetal);
}
.card__head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card__head-r { display: flex; align-items: center; gap: 8px; }
.card__body { padding: 18px 22px; }
.card__body--flush { padding: 0; }
.card__foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
}

/* ── Two-col / three-col grid layouts ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

/* ── Data table ── */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-2);
  background: var(--bg);
  position: sticky; top: 0;
}
.tbl td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
  color: var(--text);
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg); }
.tbl .tbl__sku b { display: block; font-weight: 500; color: var(--text); margin-bottom: 2px; font-size: 13px; }
.tbl .tbl__sku span { font-size: 11.5px; color: var(--faint); font-family: var(--font-mono); }
.tbl .num { font-family: var(--font-mono); font-size: 12.5px; color: var(--text); text-align: right; white-space: nowrap; }
.tbl .num--neg { color: #993C1D; }
.tbl .num--pos { color: var(--teal-dark); }

/* ── Mini sparkline / bars ── */
.bar {
  height: 6px;
  background: var(--bg-2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  width: 100%;
}
.bar__fill {
  height: 100%;
  background: var(--teal);
  border-radius: 3px;
}
.bar--amber .bar__fill { background: var(--amber); }
.bar--rose  .bar__fill { background: var(--rose); }
.bar--blue  .bar__fill { background: var(--blue); }

/* Channel donut/breakdown */
.legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.legend li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.legend li .sw {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--teal);
}
.legend li .v { color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.legend li b { color: var(--text); font-weight: 500; }

/* Channel pie (CSS conic) */
.donut {
  width: 160px; height: 160px;
  border-radius: 50%;
  position: relative;
  margin: 0 auto 14px;
  background:
    conic-gradient(
      #0000A4 0 38%,
      #FF6900 38% 60%,
      var(--teal) 60% 86%,
      #FF9900 86% 100%
    );
}
.donut::after {
  content: '';
  position: absolute;
  inset: 30px;
  background: var(--surface);
  border-radius: 50%;
}
.donut__c {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
}
.donut__c b { font-size: 22px; color: var(--gunmetal); font-weight: 500; }
.donut__c span { font-size: 11px; color: var(--muted); }

/* Bar chart (vertical) */
.barchart {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
  align-items: end;
  height: 180px;
  padding-top: 12px;
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 8px;
}
.barchart__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}
.barchart__bar {
  width: 100%;
  background: var(--teal);
  border-radius: 4px 4px 0 0;
  transition: opacity .15s ease;
  min-height: 4px;
}
.barchart__bar--alt { background: var(--blue); }
.barchart__col:hover .barchart__bar { opacity: 0.85; }
.barchart__lbl {
  font-size: 10px;
  color: var(--faint);
  margin-top: 4px;
}
.barchart__legend {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--muted);
}
.barchart__legend span { display: flex; align-items: center; gap: 6px; }
.barchart__legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--teal); }
.barchart__legend i.alt { background: var(--blue); }

/* ── Filter bar ── */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: center;
}
.filter-chip {
  font-size: 12.5px;
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
}
.filter-chip:hover { border-color: var(--faint); }
.filter-chip.is-active {
  background: var(--gunmetal);
  border-color: var(--gunmetal);
  color: #fff;
}
.filter-chip__count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
  margin-left: 2px;
}
.filter-chip.is-active .filter-chip__count { color: rgba(255,255,255,.6); }

/* ── Status indicators ── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}
.status__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--faint);
}
.status--booked  .status__dot { background: var(--teal); }
.status--pending .status__dot { background: var(--amber); }
.status--review  .status__dot { background: var(--rose); }
.status--queued  .status__dot { background: var(--blue); }
.status--booked  { color: var(--teal-dark); }
.status--pending { color: var(--amber-dark); }
.status--review  { color: #993C1D; }
.status--queued  { color: var(--blue); }

/* ── Detail drawer (returns) ── */
.detail {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  align-items: start;
}
.detail__side { position: sticky; top: 84px; }
.detail__line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.detail__line:last-child { border-bottom: none; }
.detail__line span { color: var(--muted); }
.detail__line b { color: var(--text); font-weight: 500; }
.detail__line.total b { color: var(--teal-dark); font-size: 15px; }

/* Reconciliation list */
.recon {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border-2);
  border-radius: 10px;
  overflow: hidden;
}
.recon__row {
  display: grid;
  grid-template-columns: 32px 2fr 1fr 1fr 1fr;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  padding: 13px 18px;
  font-size: 13px;
}
.recon__check {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--teal-light);
  color: var(--teal-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  font-weight: 700;
}
.recon__check--no { background: var(--rose-pale); color: #993C1D; }
.recon__row b { font-weight: 500; }
.recon__row .num { font-family: var(--font-mono); font-size: 12.5px; }

/* Heatmap */
.heat {
  display: grid;
  grid-template-columns: 80px repeat(8, 1fr);
  gap: 4px;
  font-size: 11px;
  margin-top: 8px;
}
.heat__lbl { color: var(--muted); padding: 6px 4px; font-size: 11px; }
.heat__cell {
  height: 30px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px;
  font-family: var(--font-mono);
  background: var(--bg-2);
  color: var(--muted);
}
.heat__cell--h { color: #fff; }

/* World/country stack */
.country-row {
  display: grid;
  grid-template-columns: 100px 1fr 60px;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-2);
}
.country-row:last-child { border-bottom: none; }
.country-row .num { color: var(--muted); font-family: var(--font-mono); font-size: 12px; text-align: right; }

/* Empty/info note */
.note {
  background: var(--teal-pale);
  border: 1px solid rgba(0,168,150,.15);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--teal-dark);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.note b { font-weight: 600; }
.note .ic { color: var(--teal); flex-shrink: 0; margin-top: 1px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 18px;
}
.tabs button {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--muted);
  padding: 11px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button.is-active {
  color: var(--gunmetal);
  border-bottom-color: var(--teal);
  font-weight: 500;
}

/* Activity timeline */
.timeline {
  list-style: none;
  position: relative;
  padding-left: 26px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 8px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--border-2);
}
.timeline li {
  position: relative;
  padding: 4px 0 16px;
  font-size: 13px;
}
.timeline li::before {
  content: '';
  position: absolute;
  left: -22px; top: 7px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--teal);
}
.timeline li.is-pending::before { border-color: var(--amber); }
.timeline li.is-info::before { border-color: var(--blue); }
.timeline li b { display: block; color: var(--text); font-weight: 500; }
.timeline li span { font-size: 11.5px; color: var(--faint); font-family: var(--font-mono); }

/* Responsive */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .detail { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: relative;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 12px 16px;
    gap: 8px;
  }
  .side__brand, .side__sect, .side__user { display: none; }
  .side__nav { flex-direction: row; gap: 6px; flex-wrap: nowrap; }
  .side__nav a { white-space: nowrap; padding: 7px 11px; font-size: 12.5px; }
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar__crumb { display: none; }
  .page { padding: 18px 16px 40px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .recon__row { grid-template-columns: 24px 1fr; gap: 8px; font-size: 12px; }
  .recon__row > *:nth-child(n+3) { grid-column: 2; }
}
