/* ─── tokens (Anthropic-inspired light palette) ─── */
:root {
  /* page surfaces */
  --bg-0: #FAF9F5;          /* book-white, page background */
  --bg-1: #F2F0E8;          /* panel background */
  --bg-2: #FFFFFF;          /* row background */
  --bg-row-hover: #F6F4EC;
  --border: #E6E3D7;
  --border-strong: #CFCBBD;

  /* text */
  --text-1: #1A1915;        /* near-black, high contrast on cream */
  --text-2: #524D44;        /* dark gray-brown */
  --text-3: #837E74;        /* muted gray */

  /* brand */
  --accent: #CC785C;        /* terracotta */
  --accent-2: #3B6373;      /* deep muted teal */

  /* semantic — tuned for bright light bg */
  --green-flash: #4FAE58;
  --green-glow:  rgba(79, 174, 88, 0.45);
  --green-tint:  rgba(79, 174, 88, 0.18);

  --blue-pulse:  #3E7FAE;
  --blue-glow:   rgba(62, 127, 174, 0.50);

  --amber: #C98017;
  --red:   #C0433F;

  /* fonts */
  --font-sans: "Inter", "SF Pro Display", -apple-system, "Segoe UI",
    system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  --fs-kpi: 92px;
  --fs-kpi-label: 18px;
  --fs-h1: 28px;
  --fs-h2: 20px;
  --fs-h2-sub: 14px;
  --fs-row-id: 32px;
  --fs-row-id-xl: 40px;
  --fs-row-name: 24px;
  --fs-row-meta: 16px;
  --fs-row-total: 28px;
  --fs-row-time: 14px;
  --fs-footer: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ─── layout ─── */
.app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100vh;
  padding: 16px 24px;
  gap: 14px;
}
.app--no-footer { grid-template-rows: auto auto 1fr; }

/* ─── topbar ─── */
.topbar {
  display: flex;
  align-items: center;
  padding: 8px 6px 0;
}
.topbar__title {
  font-size: var(--fs-h1);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--text-1);
}

/* ─── KPI strip ─── */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) 1.3fr;
  gap: 12px;
}
.kpis--compact {
  grid-template-columns: repeat(2, minmax(0, 240px));
  justify-content: start;
}
.kpis--compact .kpi { min-height: 96px; padding: 12px 20px; }
.kpis--compact .kpi__num { font-size: 52px; }

.kpi {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 150px;
  transition: transform 180ms ease, border-color 180ms ease;
}
.kpi.is-bump { animation: kpi-bump 450ms cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes kpi-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); border-color: var(--accent); }
  100% { transform: scale(1); }
}
.kpi__num {
  font-size: var(--fs-kpi);
  font-weight: 700;
  line-height: 1.0;
  letter-spacing: -0.02em;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}
.kpi__label {
  font-size: var(--fs-kpi-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
}

/* ─── panels ─── */
.panels {
  display: grid;
  grid-template-columns: 40fr 60fr;
  gap: 14px;
  min-height: 0;
}
.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.panel__header {
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--border);
}
.panel__title {
  margin: 0;
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-1);
}
.panel__subtitle {
  margin: 4px 0 0;
  font-size: var(--fs-h2-sub);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.panel__body {
  flex: 1;
  min-height: 0;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.panel__body--scroll { overflow-y: auto; }
.panel__body--scroll::-webkit-scrollbar { width: 8px; }
.panel__body--scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.panel__body--scroll::-webkit-scrollbar-track { background: transparent; }
.panel__body--scroll {
  -webkit-mask-image: linear-gradient(to bottom, black 92%, transparent 100%);
          mask-image: linear-gradient(to bottom, black 92%, transparent 100%);
}

/* ─── left column: new-order cards ─── */
.new-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 4px;
  animation:
    card-in 550ms cubic-bezier(0.22, 1, 0.36, 1) both,
    card-flash 1400ms ease-out 220ms both;
  will-change: transform, opacity, background-color;
}
.new-card.is-aging { animation: card-age 800ms ease-in forwards; }
.new-card__id {
  font-family: var(--font-mono);
  font-size: var(--fs-row-id);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-1);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}
.new-card__chip {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-2);
  background: var(--bg-1);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 400;
  letter-spacing: 0.04em;
}
.new-card__name {
  font-size: var(--fs-row-name);
  color: var(--text-1);
  font-weight: 500;
  line-height: 1.2;
}
.new-card__meta {
  font-size: var(--fs-row-meta);
  color: var(--text-3);
  letter-spacing: 0.02em;
}
.new-card__total {
  font-size: var(--fs-row-total);
  color: var(--text-1);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
@keyframes card-in {
  0%   { transform: translateY(-48px) scale(0.99); opacity: 0; }
  60%  { transform: translateY(3px) scale(1.02);   opacity: 1; }
  100% { transform: translateY(0) scale(1);        opacity: 1; }
}
@keyframes card-flash {
  0%   { background: var(--green-flash); color: #fff; box-shadow: 0 0 0 2px var(--green-glow), 0 0 48px 10px var(--green-glow); }
  20%  { background: var(--green-flash); color: #fff; box-shadow: 0 0 0 2px var(--green-glow), 0 0 48px 10px var(--green-glow); }
  100% { background: var(--bg-2);        color: inherit; box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; }
}
@keyframes card-age {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px) scale(0.98); }
}

/* ─── right column: registry rows ─── */
.all-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  cursor: default;
  transition: background-color 180ms ease;
  min-height: 78px;
  overflow: hidden;
}
.all-row.is-new { animation: row-insert 900ms ease-out 1 both; }
.all-row.is-read::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(62, 127, 174, 0.28) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  animation: row-shimmer 1500ms ease-out 1;
}
.all-row.is-read {
  animation: row-ring 3000ms ease-out 1;
  z-index: 1;
}
@keyframes row-insert {
  0%   { background: var(--green-tint); box-shadow: 0 0 0 1px rgba(79, 174, 88, 0.5); }
  100% { background: var(--bg-2);       box-shadow: 0 0 0 0 transparent; }
}
@keyframes row-ring {
  0%   { box-shadow: inset 0 0 0 0 transparent,            0 0 0 0 transparent; }
  15%  { box-shadow: inset 0 0 0 2px var(--blue-pulse),    0 0 24px 4px var(--blue-glow); }
  100% { box-shadow: inset 0 0 0 0 transparent,            0 0 0 0 transparent; }
}
@keyframes row-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.all-row.is-removing { animation: row-remove 600ms ease-in forwards; }
@keyframes row-remove {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(16px); }
}

.all-row__id {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: var(--fs-row-id-xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text-1);
  cursor: pointer;
  user-select: all;
  white-space: nowrap;
  transition: color 180ms ease, transform 120ms ease;
  line-height: 1;
}
.all-row__id:hover { color: var(--accent); }
.all-row__id.is-copied {
  animation: id-copied 500ms ease-out;
  color: var(--green-flash);
}
@keyframes id-copied {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.all-row__info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.all-row__name {
  font-size: var(--fs-row-name);
  color: var(--text-1);
  font-weight: 500;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.all-row__sub {
  font-size: var(--fs-row-meta);
  color: var(--text-3);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.all-row__sub .sep { color: var(--border-strong); margin: 0 6px; }

.all-row__right {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 110px;
}
.all-row__total {
  font-size: var(--fs-row-total);
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.1;
}
.all-row__datetime {
  font-family: var(--font-mono);
  font-size: var(--fs-row-time);
  color: var(--text-3);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.all-row__status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  background: rgba(204, 120, 92, 0.14);
  color: #9C5238;   /* deeper terracotta for contrast on light */
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-pill[data-status="confirmed"]   { background: rgba(59, 99, 115, 0.14);  color: #2C4C57; }
.status-pill[data-status="shipped"]     { background: rgba(201, 128, 23, 0.15); color: #7D4F0B; }
.status-pill[data-status="delivered"]   { background: rgba(79, 174, 88, 0.16);  color: #2E6E36; }
.status-pill[data-status="cancelled"]   { background: rgba(192, 67, 63, 0.14);  color: #852A27; }

.all-row__reads {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.all-row__reads.is-active { color: var(--accent); font-weight: 500; }

/* ─── empty state ─── */
.empty {
  flex: 1;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 24px;
  text-align: center;
}
.empty.is-visible { display: flex; }
.empty__text {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-2);
}
.dots { display: flex; gap: 12px; }
.dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-3);
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: 0.12s; }
.dots span:nth-child(3) { animation-delay: 0.24s; }
@keyframes dot-bounce {
  0%, 100% { opacity: 0.3; transform: translateY(0) scale(0.9); }
  50%      { opacity: 1;   transform: translateY(-6px) scale(1.1); }
}

/* ─── toast ─── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%) translateY(40px);
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  padding: 12px 22px;
  border-radius: 999px;
  color: var(--text-1);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 10;
  font-family: var(--font-mono);
  box-shadow: 0 6px 24px rgba(26, 25, 21, 0.08);
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── reset flash ─── */
.app.is-resetting { animation: page-flash 900ms ease-out 1; }
@keyframes page-flash {
  0%   { background: var(--bg-0); }
  30%  { background: #F5E4E3; }
  100% { background: var(--bg-0); }
}

/* ─── reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
