/* Sprint 197 — App shell CSS (sidebar + topbar) — was completely missing
   Shell template uses .app, .sb, .sb-brand, .sb-mark, .sb-word, .sb-link, .sb-group-label, .topbar, .crumb but no CSS existed for these */

/* === Layout grid === */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: #F8F7FC;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter var", "Inter", system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* === Sidebar === */
.sb {
  background: #fff;
  border-right: 1px solid #E5E7EB;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid #F3F4F6;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: #1E1B4B;
}

.sb-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7C3AED 0%, #EC4899 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

.sb-word {
  font-weight: 700;
  font-size: 16px;
  color: #1E1B4B;
}
.sb-word span {
  background: linear-gradient(135deg, #7C3AED, #EC4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sb-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9CA3AF;
  padding: 14px 10px 6px;
  margin-top: 4px;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #64748B;
  font-weight: 500;
  font-size: 14.5px;
  text-decoration: none;
  transition: background .15s cubic-bezier(.4,0,.2,1), color .15s cubic-bezier(.4,0,.2,1);
  position: relative;
  letter-spacing: -0.005em;
  min-height: 40px;
}

.sb-link:hover {
  background: #FAFAFE;
  color: #1E1B4B;
  text-decoration: none;
}

.sb-link.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.10), rgba(236,72,153,0.06));
  color: #7C3AED;
  font-weight: 600;
}

.sb-link.active::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, #7C3AED, #EC4899);
}

.sb-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #EC4899;
  margin-left: auto;
  box-shadow: 0 0 8px rgba(236, 72, 153, 0.5);
}

/* === User pill (bottom of sidebar) === */
.user-pill, .sb-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: #FAFAFA;
  font-size: 13px;
  border: 1px solid #F3F4F6;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7C3AED, #EC4899);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.user-name {
  font-weight: 600;
  color: #1E1B4B;
  line-height: 1.2;
  font-size: 13px;
}

.user-plan, .user-email {
  font-size: 11px;
  color: #9CA3AF;
  line-height: 1.3;
}

/* === Main content area === */
.main {
  padding: 32px 40px;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
}

/* === Top bar — Apple-bar === */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid #F1F5F9;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
@media(max-width:768px){.topbar{padding:14px 18px}}

.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #64748B;
  letter-spacing: -0.005em;
}

.crumb-cur {
  color: #1E1B4B;
  font-weight: 600;
}

.crumb-sep {
  color: #CBD5E1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* === Buttons — Apple-bar === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 11px;
  font-weight: 600;
  font-size: 14.5px;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s cubic-bezier(.4,0,.2,1), box-shadow 0.15s cubic-bezier(.4,0,.2,1), background 0.15s ease, border-color 0.15s ease;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-decoration: none;
  min-height: 42px;
}

.btn-primary {
  background: linear-gradient(135deg, #7C3AED 0%, #EC4899 100%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(124, 58, 237, 0.15), 0 4px 14px rgba(124, 58, 237, 0.25);
}

.btn-primary:hover:not([disabled]) {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(124, 58, 237, 0.2), 0 8px 20px rgba(124, 58, 237, 0.32);
}

.btn-primary:active:not([disabled]) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(124, 58, 237, 0.2);
}

.btn-ghost {
  background: #fff;
  color: #1E1B4B;
  border: 1px solid #E2E8F0;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

.btn-ghost:hover {
  background: #FAFAFE;
  border-color: #C4B5FD;
  color: #7C3AED;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15,23,42,.06);
}

.btn-lg {
  padding: 12px 20px;
  font-size: 14px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* === Cards / Stats — Apple-bar === */
.card {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 4px 16px rgba(15,23,42,0.06);
  transition: border-color .18s cubic-bezier(.4,0,.2,1), box-shadow .18s cubic-bezier(.4,0,.2,1);
  padding: 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

.stat {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04);
  transition: border-color .18s cubic-bezier(.4,0,.2,1), box-shadow .18s cubic-bezier(.4,0,.2,1);
}
.stat:hover {
  border-color: #C4B5FD;
  box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 4px 16px rgba(15,23,42,0.06);
}

.stat-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #64748B;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #1E1B4B;
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter var", "Inter", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 13px;
  color: #64748B;
  margin-top: 8px;
}

/* === Page loader (initial spinner) === */
.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #E5E7EB;
  border-top-color: #7C3AED;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

/* === Lang picker === */
.lang-picker-btn {
  background: transparent;
  border: 1px solid #E5E7EB;
  color: #6B7280;
  cursor: pointer;
  border-radius: 8px;
  padding: 6px 10px;
}

.lang-picker-btn:hover {
  background: #F9FAFB;
  border-color: #D1D5DB;
}

/* === Mobile === */
@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sb {
    position: relative;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 12px;
    gap: 8px;
  }
  .sb-brand { display: none; }
  .sb-group-label { display: none; }
  .user-pill, .sb-user { display: none; }
  .sb-link { white-space: nowrap; padding: 8px 12px; }
  .main { padding: 16px 20px; }
  .topbar { padding: 12px 16px; }
}

/* ─────────── v55.13 Sprint 199 — Sidebar bottom stats + KPI cards ─────────── */

/* Sidebar bottom container */
.sb-foot {
  margin-top: auto;
  padding: 16px 12px 12px;
  border-top: 1px solid #EFEBE2;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Sidebar stats group */
.sb-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sb-stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: default;
  transition: background 0.15s;
}
.sb-stat-row:hover { background: #F8F7FC; }

.sb-stat-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #F3F0FF, #FCE7F3);
  color: #7C3AED;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sb-stat-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sb-stat-label {
  font-size: 11px;
  font-weight: 500;
  color: #6B7280;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.sb-stat-value {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #1E1B4B;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.sb-stat-value.is-loading { color: #C4B5FD; }

/* Sidebar plan card */
.sb-plan {
  background: linear-gradient(135deg, #F3F0FF 0%, #FCE7F3 100%);
  border: 1px solid #E9D5FF;
  border-radius: 12px;
  padding: 12px 14px;
}

.sb-plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sb-plan-label {
  font-size: 13px;
  font-weight: 600;
  color: #1E1B4B;
}

.sb-plan-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7C3AED;
  background: rgba(124, 58, 237, 0.12);
  padding: 2px 7px;
  border-radius: 10px;
}

.sb-plan-note {
  font-size: 11px;
  color: #6B7280;
  margin-top: 6px;
  line-height: 1.4;
}

.sb-plan-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 7px 12px;
  background: linear-gradient(135deg, #7C3AED, #EC4899);
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  transition: transform 0.15s, box-shadow 0.15s;
}
.sb-plan-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

/* ─────────── KPI cards (.kpi-grid, .kpi, .kpi-label, .kpi-value, .kpi-delta) ─────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 32px;
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; gap: 12px; }
}

.kpi {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform 0.18s cubic-bezier(.4,0,.2,1), box-shadow 0.18s cubic-bezier(.4,0,.2,1), border-color 0.18s cubic-bezier(.4,0,.2,1);
  min-height: 134px;
}

.kpi.interactive { cursor: pointer; }
.kpi.interactive:hover {
  transform: translateY(-2px);
  border-color: #C4B5FD;
  box-shadow: 0 1px 3px rgba(15,23,42,.04), 0 8px 24px rgba(124,58,237,0.10);
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  line-height: 1.2;
}

.kpi-value {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter var", "Inter", system-ui, sans-serif;
  font-size: 34px;
  font-weight: 700;
  color: #1E1B4B;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: block;
}

.kpi-value .unit {
  font-size: 18px;
  font-weight: 600;
  color: #94A3B8;
  margin-left: 3px;
  letter-spacing: -0.01em;
}

.kpi-delta {
  font-size: 12px;
  font-weight: 500;
  color: #6B7280;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kpi-delta.up { color: #059669; }
.kpi-delta.warn { color: #D97706; }
.kpi-delta.down { color: #DC2626; }

/* ─────────── v55.77 Sprint 283 — Apple-quality premium loader (redesign) ─────────── */

.premium-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px 20px;
  background: transparent;
}
.pl-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: pl-fade-in 320ms cubic-bezier(.4,0,.2,1) both;
}

/* Single brand mark — soft radial glow, gentle breathing scale */
.pl-mark {
  position: relative;
  width: 56px;
  height: 56px;
  animation: pl-breathe 3.6s cubic-bezier(.45,0,.55,1) infinite;
}
.pl-mark::before {
  content: "";
  position: absolute;
  inset: -22px;
  border-radius: 28px;
  background: radial-gradient(closest-side, rgba(139,92,246,.16), transparent 70%);
  filter: blur(8px);
  z-index: -1;
  animation: pl-glow 3.6s cubic-bezier(.45,0,.55,1) infinite;
}
.pl-mark svg {
  display: block;
  border-radius: 14px;
  box-shadow: 0 12px 36px -10px rgba(139,92,246,.32), 0 4px 12px -2px rgba(15,23,42,.08);
}

/* Single line of route-aware copy */
.pl-copy {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter var", "Inter", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #52525B;
  letter-spacing: -.005em;
  line-height: 1.4;
}

/* Thin indeterminate sweep bar */
.pl-bar {
  width: 160px;
  height: 2px;
  background: rgba(139,92,246,.12);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.pl-bar > span {
  position: absolute;
  top: 0;
  height: 100%;
  width: 32%;
  left: -32%;
  background: linear-gradient(90deg, transparent, #8B5CF6, transparent);
  border-radius: 999px;
  animation: pl-sweep 1.4s cubic-bezier(.4,0,.2,1) infinite;
}

@keyframes pl-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pl-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}
@keyframes pl-glow {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}
@keyframes pl-sweep {
  0% { left: -32%; }
  100% { left: 100%; }
}

/* Reduced motion fallback */
@media (prefers-reduced-motion: reduce) {
  .pl-mark, .pl-mark::before, .pl-bar > span { animation: none; }
  .pl-bar > span { left: 34%; }
}

/* Dark mode comfort */
@media (prefers-color-scheme: dark) {
  .pl-copy { color: #A1A1AA; }
  .pl-bar { background: rgba(139,92,246,.18); }
}
