/* ===========================================================================
 * RETAIL ENGINEER — SUITE THEME
 * One skin for the whole estate: platform, Queue, Displays, Shifts & Leave,
 * Inventory, Ticketing, Mailing, Webmail.
 *
 * Served from the platform at /suite/suite-theme.css (vendor a copy per
 * engine if you prefer no cross-app fetch). Adopt in two steps:
 *   1. <link rel="stylesheet" href="/suite/suite-theme.css">
 *   2. <script src="/suite/suite-switcher.js" defer></script>
 * Tokens land on :root, so an engine inherits the palette even before its
 * components move to the .re-* classes.
 *
 * Sources of truth: Wave 19 design-tokens.css (the platform) + the unified
 * shell developed in retail-engineer-next (aurora identity, hero bands,
 * stat tiles, bar-race viz). If a screen disagrees with this file, the
 * screen is wrong.
 * ======================================================================== */

:root {
  /* Surfaces & structure (Wave 19) */
  --canvas: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f4f5f7;
  --surface-raised: #ffffff;
  --border: #e1e3e6;
  --border-strong: #c8ccd2;

  /* Ink ladder */
  --ink-900: #1e1f22;
  --ink-700: #2b2d31;
  --ink-500: #6a6f76;
  --ink-400: #686d74;
  --ink-300: #6f747b;
  --ink-200: #9ca1a7; /* decorative ONLY */

  /* RE identity (live estate: gradient monogram blue→violet→teal) */
  --re-ink: #0b0f1e;
  --re-blue: #4353e8;
  --re-violet: #7c3aed;
  --re-teal: #10b981;
  --re-brand-050: #f3f1fc;
  --re-brand-100: #e9e5fa;
  --re-brand-300: #a99be8;
  --re-brand-400: #8b7bf0;
  --re-brand-500: #6d5ae6;
  --re-brand-600: #5b4bc4;
  --re-brand-700: #4a3d9e;
  --gradient-aurora: linear-gradient(135deg, #4353e8 0%, #7c3aed 58%, #10b981 130%);
  --gradient-gate: linear-gradient(160deg, #f6f4fb 0%, #ece9f7 55%, #e4e6f6 100%);

  /* Status = meaning, never a hue */
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: var(--re-brand-500);
  --info-soft: var(--re-brand-050);

  /* Motion */
  --motion-fast: 140ms;
  --motion-base: 200ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --touch: 44px;
  --radius: 12px;
  --radius-sm: 8px;

  color-scheme: light;
}

.dark,
:root[data-theme='dark'] {
  --canvas: #0f1012;
  --surface: #1c1d21;
  --surface-soft: #16171a;
  --surface-raised: #22232a;
  --border: #2b2d31;
  --border-strong: #3a3d42;
  --ink-900: #ededed;
  --ink-700: #c5c7cc;
  --ink-500: #a7a9ac;
  --ink-400: #a2a7ae;
  --ink-300: #969ba2;
  --ink-200: #6a6f76;
  --re-ink: #ededed;
  --re-brand-050: #221f33;
  --re-brand-100: #2a2644;
  --re-brand-400: #8b7bf0;
  --re-brand-500: #8b7bf0;
  --re-brand-600: #a79af5;
  --gradient-gate: linear-gradient(160deg, #131120 0%, #16141f 60%, #121420 100%);
  color-scheme: dark;
}

/* ---- Estate canvas ------------------------------------------------------ */

.re-canvas {
  background: var(--gradient-gate);
  background-attachment: fixed;
  color: var(--ink-900);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
}

/* ---- Suite app bar (rendered by suite-switcher.js) ---------------------- */

.re-suitebar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 44px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.re-suitebar-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 11px;
  color: var(--re-ink);
  text-decoration: none;
}

.re-suitebar-mark svg {
  display: block;
}

.re-suitebar-apps {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.re-suitebar-apps a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  color: var(--ink-500);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}

.re-suitebar-apps a:hover {
  background: var(--surface-soft);
  color: var(--ink-900);
}

.re-suitebar-apps a.active {
  background: var(--re-brand-050);
  color: var(--re-brand-600);
  position: relative;
}

.re-suitebar-tag {
  margin-left: auto;
  color: var(--ink-300);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  white-space: nowrap;
}

/* ---- Shared primitives -------------------------------------------------- */

.re-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  padding: 16px;
}

.re-band {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(
    120deg,
    color-mix(in srgb, var(--re-brand-500) 9%, var(--surface)) 0%,
    var(--surface) 46%,
    color-mix(in srgb, var(--re-teal) 8%, var(--surface)) 100%
  );
  padding: 18px 20px;
}

.re-band::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--gradient-aurora);
  opacity: 0.85;
}

.re-eyebrow {
  font-size: 10.5px;
  font-family: ui-monospace, 'SF Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--re-violet);
  font-weight: 600;
}

.re-title {
  margin: 2px 0 0;
  font-size: clamp(24px, 3.2vw, 30px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--re-ink);
}

.re-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-500);
  max-width: 64ch;
}

.re-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.re-pill.success { background: var(--success-soft); color: var(--success); }
.re-pill.warning { background: var(--warning-soft); color: var(--warning); }
.re-pill.danger { background: var(--danger-soft); color: var(--danger); }
.re-pill.info { background: var(--info-soft); color: var(--re-brand-600); }
.re-pill.neutral { background: var(--surface-soft); color: var(--ink-500); }

.re-kpi {
  display: block;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: transform var(--motion-fast) var(--ease-spring), box-shadow var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out);
}

.re-kpi:hover {
  transform: translateY(-2px);
  border-color: var(--re-brand-400);
  box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--re-brand-500) 28%, transparent);
}

.re-kpi::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2.5px;
  background: var(--gradient-aurora);
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease-out);
}

.re-kpi:hover::after {
  opacity: 1;
}

.re-kpi .label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-400);
}

.re-kpi .value {
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--re-ink);
}

.re-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--motion-fast) var(--ease-spring), filter var(--motion-fast) var(--ease-out);
}

.re-btn:active {
  transform: scale(0.97);
}

.re-btn-primary {
  background: linear-gradient(120deg, #4353e8 0%, #7c3aed 70%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 2px 10px -2px rgba(94, 70, 220, 0.45);
}

.re-btn-primary:hover {
  filter: brightness(1.08);
}

.re-btn-ghost {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border-color: var(--border);
  color: var(--ink-700);
}

.re-btn-ghost:hover {
  border-color: var(--re-brand-400);
  color: var(--re-brand-600);
}

/* ---- Bar-race viz (the chart IS navigation) ----------------------------- */

.re-viz-row {
  display: grid;
  grid-template-columns: minmax(110px, 180px) 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 34px;
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  padding: 2px 6px;
  transition: background var(--motion-fast) var(--ease-out);
}

a.re-viz-row:hover {
  background: var(--re-brand-050);
}

.re-viz-track {
  height: 14px;
  border-radius: 7px;
  background: var(--surface-soft);
  overflow: hidden;
}

.re-viz-fill {
  display: block;
  height: 100%;
  border-radius: 7px;
  background: var(--gradient-aurora);
  transform-origin: left;
  animation: re-viz-grow 700ms var(--ease-out) both;
}

@keyframes re-viz-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---- Insight context bubble (platform pattern, estate-wide) ------------- */

.re-insight {
  position: relative;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--gradient-aurora) border-box;
  border-radius: var(--radius);
  padding: 13px 15px;
  font-size: 13.5px;
}

.re-insight .re-insight-title {
  font-weight: 700;
  color: var(--re-ink);
}

.re-insight .re-insight-move {
  margin-top: 6px;
  color: var(--ink-500);
}

.re-insight .re-insight-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  .re-kpi, .re-btn, .re-viz-fill {
    animation: none !important;
    transition: none !important;
  }
}
