/* ==========================================================================
   PicklePulse — Product app shell
   ========================================================================== */

body.app { background: var(--surface-2); }

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

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: var(--s-5) var(--s-4);
}
.sidebar .logo { padding: 0 var(--s-2); margin-bottom: var(--s-8); }
.side-label { font-size: var(--text-xs); font-weight: 500; color: var(--ink-400); padding: 0 var(--s-3); margin: var(--s-4) 0 var(--s-2); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: var(--s-3);
  height: 38px; padding: 0 var(--s-3);
  border-radius: var(--r-md);
  font-size: var(--text-sm); font-weight: 500; color: var(--ink-600);
  transition: background-color 0.12s var(--ease), color 0.12s var(--ease);
}
.side-link:hover { background: var(--surface-3); color: var(--ink-900); }
.side-link.active { background: var(--brand-50); color: var(--brand-800); }
.side-link.active .icon { color: var(--brand-700); }
.side-link .count { margin-left: auto; font-size: var(--text-xs); background: var(--warn-50); color: var(--warn-700); border-radius: var(--r-full); padding: 0 var(--s-2); line-height: 20px; font-weight: 600; }
.side-foot { margin-top: auto; padding-top: var(--s-4); border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2); border-radius: var(--r-md); width: 100%; border: none; background: none; cursor: pointer; text-align: left; }
.user-chip:hover { background: var(--surface-3); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-100); color: var(--brand-800); display: grid; place-items: center; font-weight: 600; font-size: var(--text-sm); flex-shrink: 0; }
.user-chip .who { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.user-chip .who b { font-size: var(--text-sm); color: var(--ink-900); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who small { font-size: var(--text-xs); color: var(--ink-500); }

/* ---------- Main & Topbar ---------- */
.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  height: 60px;
  padding: 0 var(--s-8);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); color: var(--ink-500); }
.crumbs b { color: var(--ink-900); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.surface-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
}
.surface-switch a {
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-600);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.surface-switch a:hover { color: var(--ink-900); }
.surface-switch a.on {
  background: var(--surface);
  color: var(--ink-900);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.menu-btn { display: none; }

.page { padding: var(--s-8); max-width: 1280px; }
.view { display: none; }
.view.active { display: block; animation: fade 0.15s var(--ease); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s-6); margin-bottom: var(--s-6); flex-wrap: wrap; }
.page-head h1 { font-size: var(--text-2xl); margin-bottom: var(--s-1); }
.page-head p { color: var(--ink-500); font-size: var(--text-sm); }
.page-head-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); margin-bottom: var(--s-6); }
.kpi { padding: var(--s-5); }
.kpi small { display: block; font-size: var(--text-sm); color: var(--ink-500); margin-bottom: var(--s-2); }
.kpi strong { font-size: var(--text-2xl); color: var(--ink-900); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: var(--text-xs); color: var(--brand-700); font-weight: 500; margin-left: var(--s-2); }

/* Toolbar / filters */
.toolbar { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; margin-bottom: var(--s-6); }
.toolbar .select, .toolbar .input { width: auto; min-width: 180px; }
.toolbar .spacer { flex: 1; }

/* Generic layout */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-6); }
.stack { display: flex; flex-direction: column; gap: var(--s-6); }
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s-6); align-items: start; }

.panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: var(--text-base); font-weight: 600; letter-spacing: -0.01em; }
.panel-head p { font-size: var(--text-sm); color: var(--ink-500); margin-top: 2px; }
.panel-body { padding: var(--s-5) var(--s-6); }
.empty { padding: var(--s-10); text-align: center; color: var(--ink-500); font-size: var(--text-sm); }

/* ---------- Marketplace ---------- */
.venue-card { overflow: hidden; }
.venue-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); padding: var(--s-5) var(--s-6); }
.venue-head h2 { font-size: var(--text-lg); font-weight: 600; margin-bottom: var(--s-1); }
.venue-meta { display: flex; align-items: center; gap: var(--s-3); font-size: var(--text-sm); color: var(--ink-500); flex-wrap: wrap; }
.venue-meta span { display: inline-flex; align-items: center; gap: var(--s-1); }
.court-row { display: grid; grid-template-columns: 220px 1fr; gap: var(--s-4); align-items: center; padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); }
.court-name { font-size: var(--text-sm); font-weight: 600; color: var(--ink-900); }
.court-sub { font-size: var(--text-xs); color: var(--ink-500); display: flex; align-items: center; gap: var(--s-1); margin-top: 2px; }
.slots { display: grid; grid-template-columns: repeat(7, minmax(72px, 1fr)); gap: var(--s-2); }
.slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 52px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface);
  cursor: pointer; font-variant-numeric: tabular-nums;
  transition: border-color 0.12s var(--ease), background-color 0.12s var(--ease);
}
.slot b { font-size: var(--text-sm); font-weight: 600; color: var(--ink-900); }
.slot small { font-size: var(--text-xs); color: var(--ink-500); }
.slot:hover:not(:disabled) { border-color: var(--brand-600); background: var(--brand-50); }
.slot:focus-visible { outline: none; box-shadow: var(--ring); }
.slot:disabled { background: var(--surface-3); border-color: transparent; cursor: not-allowed; }
.slot:disabled b, .slot:disabled small { color: var(--ink-400); }
.legend { display: flex; gap: var(--s-5); font-size: var(--text-xs); color: var(--ink-500); }
.legend span { display: inline-flex; align-items: center; gap: var(--s-2); }
.legend i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line-strong); background: var(--surface); }
.legend i.off { background: var(--surface-3); border-color: transparent; }

/* ---------- Open play ---------- */
.session-card { display: flex; flex-direction: column; }
.session-body { padding: var(--s-5) var(--s-6); flex: 1; }
.session-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s-3); }
.session-card h3 { font-size: var(--text-base); margin-bottom: var(--s-3); }
.meta-list { display: flex; flex-direction: column; gap: var(--s-2); font-size: var(--text-sm); color: var(--ink-600); margin-bottom: var(--s-5); }
.meta-list li { display: flex; align-items: center; gap: var(--s-2); }
.meta-list .icon { color: var(--ink-400); }
.capacity-head { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--ink-500); margin-bottom: var(--s-2); }
.capacity-head b { color: var(--ink-900); font-weight: 600; }
.session-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); }
.price { font-size: var(--text-lg); font-weight: 700; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.price small { font-size: var(--text-xs); font-weight: 400; color: var(--ink-500); }
.eligibility { display: inline-flex; align-items: center; gap: var(--s-1); font-size: var(--text-xs); }
.eligibility.ok { color: var(--brand-700); }
.eligibility.no { color: var(--warn-700); }
.person { display: flex; align-items: center; gap: var(--s-3); }
.person .avatar { width: 30px; height: 30px; font-size: var(--text-xs); }
.person b { font-weight: 500; color: var(--ink-900); display: block; line-height: 1.3; }
.person small { font-size: var(--text-xs); color: var(--ink-500); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--text-xs); color: var(--ink-600); }
.row-actions { display: flex; gap: var(--s-1); justify-content: flex-end; }

/* ---------- Live queue ---------- */
.court-live { overflow: hidden; }
.court-live-head { display: flex; justify-content: space-between; align-items: center; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.court-live-head h3 { font-size: var(--text-base); }
.court-graphic { padding: var(--s-5); background: #0f766e; background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%); position: relative; }
.court-graphic::before { content: ''; position: absolute; left: var(--s-5); right: var(--s-5); top: 50%; height: 2px; background: rgba(255,255,255,0.85); }
.team {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: rgba(255,255,255,0.96);
  border-radius: var(--r-md);
}
.team + .team { margin-top: var(--s-10); }
.team-names { font-size: var(--text-sm); color: var(--ink-900); font-weight: 600; }
.team-names small { display: block; font-size: var(--text-xs); color: var(--ink-500); font-weight: 400; }
.score { display: flex; align-items: center; gap: var(--s-1); }
.score button { width: 30px; height: 30px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; display: grid; place-items: center; color: var(--ink-600); }
.score button:hover { background: var(--surface-3); color: var(--ink-900); }
.score output { width: 40px; text-align: center; font-size: var(--text-2xl); font-weight: 700; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.court-live-foot { padding: var(--s-4) var(--s-5); display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }

.queue-list { display: flex; flex-direction: column; }
.queue-item { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-6); border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.queue-item:last-child { border-bottom: none; }
.queue-pos { width: 24px; font-weight: 600; color: var(--ink-400); font-variant-numeric: tabular-nums; }
.queue-item.next .queue-pos { color: var(--brand-700); }
.queue-item .grow { flex: 1; min-width: 0; }
.queue-item .games { font-size: var(--text-xs); color: var(--ink-500); }
.log-item { padding: var(--s-3) var(--s-6); border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.log-item:last-child { border-bottom: none; }
.log-item small { display: block; color: var(--ink-500); font-size: var(--text-xs); }
.log-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }

/* ---------- Tournaments ---------- */
.bracket { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-6); align-items: center; }
.bracket-col { display: flex; flex-direction: column; gap: var(--s-6); }
.bracket-col-title { font-size: var(--text-xs); font-weight: 600; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.05em; }
.match { overflow: hidden; }
.match-head { display: flex; justify-content: space-between; align-items: center; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); font-size: var(--text-xs); color: var(--ink-500); }
.match-team { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); }
.match-team + .match-team { border-top: 1px solid var(--line); }
.match-team .seed { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: var(--r-sm); background: var(--surface-3); font-size: var(--text-xs); color: var(--ink-600); margin-right: var(--s-2); font-weight: 600; }
.match-team .tn { font-size: var(--text-sm); font-weight: 500; color: var(--ink-900); }
.match-team .tr { font-size: var(--text-xs); color: var(--ink-500); margin-left: 30px; }
.match-team .pts { font-size: var(--text-xl); font-weight: 700; color: var(--ink-400); font-variant-numeric: tabular-nums; }
.match-team.win .pts, .match-team.lead .pts { color: var(--ink-900); }
.match-team.serving .tn::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--highlight); border: 1px solid #a3e635; margin-left: var(--s-2); vertical-align: middle; }
.match-team.lose .tn { color: var(--ink-500); }
.ref-panel { padding: var(--s-4); background: var(--surface-2); border-top: 1px solid var(--line); }
.ref-call { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s-3); font-size: var(--text-sm); }
.ref-call strong { font-size: var(--text-xl); color: var(--ink-900); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.ref-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s-2); }

/* ---------- Admin ---------- */
.tree { font-size: var(--text-sm); }
.tree-node { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.tree-node .grow { flex: 1; }
.tree-children { margin-left: var(--s-6); padding-left: var(--s-5); border-left: 1px dashed var(--line-strong); display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .court-row { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 100; left: 0; top: 0; width: 264px; transform: translateX(-100%); transition: transform 0.2s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .split, .grid-2, .bracket { grid-template-columns: 1fr; }
  .topbar, .page { padding-left: var(--s-4); padding-right: var(--s-4); }
}
@media (max-width: 640px) {
  .grid-3, .kpis { grid-template-columns: 1fr; }
  .slots { grid-template-columns: repeat(4, 1fr); }
  .topbar .hide-sm { display: none; }
}
