/* ============================================================
   MyFlowChamp — Shared Component Library
   Import AFTER tokens.css + main.css, BEFORE page CSS.
   Define here ONCE. Never redefine in page-level files.
   ============================================================ */

/* ── Shell layout ─────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 220px;
  display: flex;
  flex-direction: column;
  background: var(--mfc-surface);
  border-right: 1px solid var(--mfc-border);
  padding: 0;
  overflow: hidden;
  transition: width 0.22s ease;
  z-index: var(--z-sidebar);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--mfc-border);
  flex-shrink: 0;
}

.logo {
  height: 38px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  transition: max-width 0.22s ease;
}

/* Sidebar toggle button */
.icon-toggle {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--mfc-border);
  border-radius: var(--r-sm);
  background: rgba(108, 99, 255, 0.10);
  color: var(--mfc-text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.icon-toggle:hover {
  color: var(--mfc-text);
  background: rgba(108, 99, 255, 0.18);
  border-color: rgba(108, 99, 255, 0.32);
}

/* Nav group */
.nav-group {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--mfc-text-mid);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover {
  background: rgba(108, 99, 255, 0.08);
  color: var(--mfc-text);
}
.nav-item.active,
.nav-item[aria-current="page"] {
  background: rgba(108, 99, 255, 0.15);
  color: var(--mfc-indigo);
}

/* Nav icon wrapper */
.nav-item .nav-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(108, 99, 255, 0.08);
  color: inherit;
  transition: background 0.15s ease;
}
.nav-item.active .nav-icon,
.nav-item[aria-current="page"] .nav-icon {
  background: rgba(108, 99, 255, 0.18);
}

/* Sidebar cards (coach note, identity rank) */
.sidebar-card {
  margin: 0 12px 12px;
  border: 1px solid rgba(108, 99, 255, 0.2);
  background: rgba(108, 99, 255, 0.06);
  border-radius: var(--r-sm);
  padding: 14px;
  flex-shrink: 0;
}

/* Account / profile footer */
.account {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--mfc-border);
  color: var(--mfc-text);
  text-decoration: none;
  transition: background 0.15s ease;
  flex-shrink: 0;
  overflow: hidden;
}
.account:hover {
  background: rgba(108, 99, 255, 0.08);
}

/* Avatar */
.avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--mfc-indigo), #9B8FFF);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
}
.avatar.lg {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 22px;
}

/* ── Collapsed sidebar state ──────────────────────────────── */
.shell.sidebar-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}
.shell.sidebar-collapsed .sidebar {
  width: 64px;
}
.shell.sidebar-collapsed .sidebar-head {
  justify-content: center;
  padding: 16px 10px;
}
.shell.sidebar-collapsed .logo {
  display: none;
}
.shell.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 9px 0;
  font-size: 0;
  gap: 0;
}
.shell.sidebar-collapsed .nav-item .nav-icon {
  margin: 0;
}
.shell.sidebar-collapsed .sidebar-card,
.shell.sidebar-collapsed .account-text {
  display: none;
}
.shell.sidebar-collapsed .account {
  justify-content: center;
  padding: 12px 0;
}
.shell.sidebar-collapsed .icon-toggle {
  font-size: 0;
  width: 30px;
  height: 30px;
  padding: 0;
}
.shell.sidebar-collapsed .icon-toggle::after {
  content: "›";
  font-size: 18px;
  line-height: 1;
}

/* ── Top bar (used inside .main) ──────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  min-height: 68px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 28px;
  background: rgba(15, 17, 23, 0.88);
  border-bottom: 1px solid var(--mfc-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mobile-logo { display: none; }

/* ── Hamburger (mobile sidebar open) ─────────────────────── */
.menu-btn {
  display: none;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--mfc-border);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--mfc-text-mid);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.menu-btn:hover {
  color: var(--mfc-text);
  background: rgba(108, 99, 255, 0.08);
}

/* ── Button system ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: all 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary — filled indigo */
.btn-primary {
  background: var(--mfc-indigo);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(108, 99, 255, 0.3);
}
.btn-primary:hover {
  background: var(--mfc-indigo-dim);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

/* Secondary — ghost indigo */
.btn-secondary,
.btn-ghost {
  background: transparent;
  color: var(--mfc-indigo);
  border-color: var(--mfc-indigo);
}
.btn-secondary:hover,
.btn-ghost:hover {
  background: rgba(108, 99, 255, 0.1);
  transform: translateY(-1px);
}

/* Soft — surface tint (for topbar actions) */
.btn-soft {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--mfc-border);
  color: var(--mfc-text);
}
.btn-soft:hover {
  background: rgba(108, 99, 255, 0.08);
  border-color: rgba(108, 99, 255, 0.35);
  color: var(--mfc-text);
}

/* Danger */
.btn-danger {
  background: transparent;
  color: var(--mfc-red);
  border-color: var(--mfc-red);
}
.btn-danger:hover {
  background: rgba(255, 107, 107, 0.1);
}

/* Dashed add button */
.btn-dashed,
.btn-add {
  background: rgba(108, 99, 255, 0.06);
  color: var(--mfc-indigo);
  border: 1px dashed rgba(108, 99, 255, 0.4);
  width: 100%;
  justify-content: center;
}
.btn-dashed:hover,
.btn-add:hover {
  background: rgba(108, 99, 255, 0.12);
  border-style: solid;
}

/* Success */
.btn-success {
  background: rgba(61, 220, 132, 0.12);
  border-color: rgba(61, 220, 132, 0.3);
  color: var(--mfc-mint);
}
.btn-success:hover { background: rgba(61, 220, 132, 0.2); }

/* Actions group */
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── mfc-card ─────────────────────────────────────────────── */
.mfc-card,
.panel {
  background: var(--mfc-surface);
  border: 1px solid var(--mfc-border);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--sp-4);
}
.card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--mfc-text);
}
.card-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  background: var(--mfc-surface2);
  color: var(--mfc-text-mid);
  padding: 3px 8px;
  border-radius: 20px;
}

/* Accent top-border variant */
.card-accent-indigo { border-top: 2px solid var(--mfc-indigo); }
.card-accent-gold   { border-top: 2px solid var(--mfc-gold); }
.card-accent-mint   { border-top: 2px solid var(--mfc-mint); }
.card-accent-red    { border-top: 2px solid var(--mfc-red); }

/* ── Badge & Pill system ──────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  font-family: var(--font-body);
  white-space: nowrap;
}

.pill-xp {
  background: rgba(245, 166, 35, 0.12);
  color: var(--mfc-gold);
  border: 1px solid rgba(245, 166, 35, 0.25);
  font-family: var(--font-mono);
}
.pill-streak {
  background: rgba(61, 220, 132, 0.10);
  color: var(--mfc-mint);
  border: 1px solid rgba(61, 220, 132, 0.25);
  font-family: var(--font-mono);
}
.pill-active {
  background: rgba(108, 99, 255, 0.12);
  color: var(--mfc-indigo);
  border: 1px solid rgba(108, 99, 255, 0.25);
}
.pill-success {
  background: rgba(61, 220, 132, 0.12);
  color: var(--mfc-mint);
  border: 1px solid rgba(61, 220, 132, 0.25);
}
.pill-info {
  background: var(--mfc-surface2);
  color: var(--mfc-text-mid);
  border: 1px solid var(--mfc-border);
}
.pill-level {
  background: linear-gradient(135deg, var(--mfc-gold), #FFD17A);
  color: #1A1A2E;
  border: none;
  font-family: var(--font-mono);
  font-weight: 700;
}
.pill-error {
  background: rgba(255, 107, 107, 0.12);
  color: var(--mfc-red);
  border: 1px solid rgba(255, 107, 107, 0.25);
}

/* Legacy rank-pill alias — full styles copied (no @extend in plain CSS) */
.rank-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  font-family: var(--font-body);
  white-space: nowrap;
  background: rgba(61, 220, 132, 0.12);
  color: var(--mfc-mint);
  border: 1px solid rgba(61, 220, 132, 0.25);
}

/* ── Progress bar ─────────────────────────────────────────── */
.progress-track,
.xp-track {
  height: 6px;
  background: var(--mfc-surface2);
  border-radius: 99px;
  overflow: hidden;
}
/* Taller variant for sidebar */
.progress-track.tall { height: 10px; }

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--mfc-indigo), #9B8FFF);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-fill.gold,
.xp-track span {
  background: linear-gradient(90deg, var(--mfc-gold), #FFD17A);
  box-shadow: 0 0 8px rgba(245, 166, 35, 0.4);
}

/* Legacy span fill inside xp-track */
.xp-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

/* ── Form inputs ──────────────────────────────────────────── */
label,
.form-label {
  display: block;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--mfc-text-mid);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--mfc-border);
  background: var(--mfc-surface2);
  color: var(--mfc-text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--mfc-text-dim);
}
.input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--mfc-indigo);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}
.input.error,
input.error,
select.error,
textarea.error {
  border-color: var(--mfc-red);
}
.input:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  background: rgba(37, 40, 54, 0.5);
  color: var(--mfc-text-dim);
  cursor: not-allowed;
}

select option {
  background: var(--mfc-surface2);
  color: var(--mfc-text);
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

.form-grid {
  display: grid;
  gap: 14px;
}

/* ── Toast notifications ──────────────────────────────────── */
.mfc-toast,
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  pointer-events: none;
  z-index: var(--z-toast);
  min-width: 220px;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  border-radius: var(--r-md);
  border: 1px solid var(--mfc-border);
  background: var(--mfc-surface);
  color: var(--mfc-text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 18px 45px rgba(2, 6, 23, 0.4);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.mfc-toast.show,
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.mfc-toast[data-tone="error"],
.toast[data-tone="error"] {
  border-color: rgba(255, 107, 107, 0.35);
  color: var(--mfc-red);
}
.mfc-toast[data-tone="success"],
.toast[data-tone="success"] {
  border-color: rgba(61, 220, 132, 0.35);
  color: var(--mfc-mint);
}

/* ── Modal ────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }

.modal-card {
  width: min(520px, 100%);
  background: var(--mfc-surface);
  border: 1px solid var(--mfc-border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  box-shadow: 0 30px 80px rgba(2, 6, 23, 0.5);
  position: relative;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--mfc-text);
  margin-bottom: var(--sp-4);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: transparent;
  border: none;
  color: var(--mfc-text-mid);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.modal-close:hover {
  color: var(--mfc-text);
  background: var(--mfc-surface2);
}

/* ── Skeleton loader ──────────────────────────────────────── */
.mfc-skeleton { display: grid; gap: 10px; }
.mfc-skeleton span {
  display: block;
  height: 14px;
  border-radius: 99px;
  background: linear-gradient(
    90deg,
    var(--mfc-surface2) 0%,
    rgba(108, 99, 255, 0.1) 50%,
    var(--mfc-surface2) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-7) var(--sp-5);
  border: 1px dashed rgba(108, 99, 255, 0.25);
  border-radius: var(--r-md);
  background: rgba(108, 99, 255, 0.03);
  gap: var(--sp-3);
}
.empty-state h3 {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--mfc-text-mid);
}
.empty-state p {
  font-size: 14px;
  color: var(--mfc-text-dim);
  max-width: 400px;
  line-height: 1.6;
}

/* ── Score ring (conic-gradient) ──────────────────────────── */
.score-ring {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--mfc-surface) 0 54%, transparent 55%),
    conic-gradient(var(--mfc-mint) 0 var(--score, 0%), var(--mfc-surface2) var(--score, 0%) 100%);
  transition: background 0.6s ease;
}
.score-ring strong {
  font-family: var(--font-mono);
  font-size: 40px;
  font-weight: 500;
  color: var(--mfc-mint);
  display: block;
  line-height: 1;
}
.score-ring span {
  display: block;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mfc-text-mid);
  margin-top: 4px;
}

/* ── Stat tile ────────────────────────────────────────────── */
.stat-tile {
  background: var(--mfc-surface2);
  border: 1px solid var(--mfc-border);
  border-radius: var(--r-sm);
  padding: 14px;
}
.stat-tile strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  color: var(--mfc-text);
  line-height: 1.1;
}
.stat-tile span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mfc-text-dim);
  margin-top: 4px;
}

/* ── Weekly bar chart ─────────────────────────────────────── */
.weekly-bars { display: grid; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 32px 1fr 30px;
  gap: 10px;
  align-items: center;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--mfc-text-mid);
}
.bar-track {
  height: 8px;
  border-radius: 99px;
  background: var(--mfc-surface2);
  overflow: hidden;
}
.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mfc-indigo), #9B8FFF);
  animation: barGrow 0.5s ease-out both;
}
.bar-track span.today {
  background: var(--mfc-indigo);
  box-shadow: 0 0 8px rgba(108, 99, 255, 0.5);
}

/* ── Dot row (7-day streak dots) ──────────────────────────── */
.dot-row {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}
.dot-row span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mfc-surface2);
}
.dot-row span.done  { background: var(--mfc-mint); }
.dot-row span.today { background: var(--mfc-indigo); }

/* ── Flow item states ─────────────────────────────────────── */
.flow-card,
.goal-card {
  background: var(--mfc-surface2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 16px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.flow-card:hover {
  border-color: rgba(108, 99, 255, 0.3);
}
.flow-card.active-now {
  border-color: var(--mfc-indigo);
  box-shadow: 0 0 0 1px rgba(108, 99, 255, 0.2);
}
.flow-card.done {
  border-color: rgba(61, 220, 132, 0.3);
}
.flow-card.skipped {
  border-color: rgba(255, 107, 107, 0.2);
  opacity: 0.7;
}

/* ── Flow icon ────────────────────────────────────────────── */
.flow-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: rgba(108, 99, 255, 0.12);
  color: var(--mfc-indigo);
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

/* ── Bottom nav (mobile) ──────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: var(--z-sidebar);
  background: rgba(28, 31, 42, 0.96);
  border: 1px solid var(--mfc-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--mfc-text-mid);
  font-size: 9px;
  font-weight: 600;
  text-decoration: none;
  min-height: 56px;
  transition: color 0.15s ease, background 0.15s ease;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.bottom-nav a svg {
  flex-shrink: 0;
  transition: color 0.15s ease;
}
.bottom-nav a.active,
.bottom-nav a:hover {
  color: var(--mfc-indigo);
  background: rgba(108, 99, 255, 0.08);
}

/* ── Responsive: mobile ───────────────────────────────────── */
@media (max-width: 640px) {
  .shell {
    display: block;
  }
  .main {
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 80;
    width: 220px !important;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.7);
    z-index: 79;
  }
  .sidebar-overlay.show { display: block; }
  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 12px 14px 10px;
    gap: 10px;
  }
  .topbar > div:not(.actions) {
    order: 3;
    width: 100%;
    flex: 1 0 100%;
    min-width: 0;
  }
  .topbar > div:not(.actions) h1 {
    font-size: 18px;
  }
  .topbar > div:not(.actions) p {
    font-size: 12px;
    line-height: 1.5;
  }
  .mobile-logo {
    display: inline-flex;
    align-items: center;
    order: 2;
    margin-right: auto;
  }
  .mobile-logo .logo {
    display: block;
    max-width: 140px;
    height: 32px;
  }
  .menu-btn {
    display: inline-flex;
    order: 1;
  }
  .bottom-nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(68px, 1fr);
    overflow-x: auto;
    gap: 0;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    padding: 4px;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .bottom-nav::-webkit-scrollbar {
    display: none;
  }
  .topbar .actions {
    order: 4;
    width: 100%;
    flex: 1 0 100%;
    margin-left: 0;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .topbar .actions::-webkit-scrollbar {
    display: none;
  }
  .topbar .actions .btn,
  .topbar .actions a,
  .topbar .actions button {
    flex: 0 0 auto;
  }
  .topbar .actions .btn {
    min-height: 40px;
    padding: 10px 14px;
    font-size: 12px;
  }
  .topbar .actions .btn-soft:not(.btn-primary):not(.btn-action) { display: inline-flex; }
  .actions .profile-link { display: inline-flex; }
  .bottom-nav a {
    min-width: 0;
    min-height: 54px;
    padding: 8px 4px;
    font-size: 9px;
    gap: 3px;
  }
  .bottom-nav a svg {
    width: 16px;
    height: 16px;
  }
}

/* ── Responsive: tablet ───────────────────────────────────── */
@media (min-width: 641px) and (max-width: 1024px) {
  .shell {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .sidebar {
    width: 200px;
  }
  .sidebar-head {
    padding: 16px;
  }
  .logo {
    display: block;
    max-width: 140px;
  }
  .icon-toggle {
    display: grid;
    background: rgba(108, 99, 255, 0.10);
    border-color: rgba(108, 99, 255, 0.20);
    color: var(--mfc-text);
  }
  .nav-item {
    font-size: 12px;
  }
  .sidebar-card {
    margin: 0 10px 10px;
    padding: 12px;
  }
  .account {
    padding: 12px 14px;
  }
}
