/* ─── Design tokens ─────────────────────────────────────────────────── */
:root {
  --bg:           #f5ede2;
  --bg-subtle:    #fdf7f0;
  --surface:      #ffffff;
  --surface-alt:  #fdf7f0;
  --ink:          #1c1a16;
  --ink-muted:    #6b5f52;
  --line:         #e4d3bf;
  --brand:        #b72b3b;
  --brand-dim:    #fce8ea;
  --brand-2:      #5a8026;
  --sidebar-w:    220px;
  --header-h:     56px;
  --radius:       12px;
  --shadow-sm:    0 1px 4px rgba(100,70,40,.10);
  --shadow-md:    0 4px 16px rgba(100,70,40,.13);
  --shadow-lg:    0 8px 32px rgba(100,70,40,.16);
  --transition:   0.18s ease;
}

/* ─── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── App shell ──────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex: 1;
  min-height: 100vh;
}

/* ─── Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: rgba(255,250,244,0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
  border: 1px solid rgba(142,109,77,.22);
  box-shadow: var(--shadow-sm);
  background: #e8e8e8;
}

.topbar-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.topbar-eyebrow {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--brand);
}

.topbar-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.topbar-spacer { flex: 1; }

.topbar-meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-meta strong { color: var(--ink); }

/* hamburger – mobile only */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--ink);
  border-radius: 8px;
}
.sidebar-toggle:hover { background: var(--bg); }
.sidebar-toggle svg { display: block; }

/* ─── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 14px 0 28px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

/* ── nav group ── */
.nav-group {
  margin: 0 8px 2px;
}

.nav-group-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  transition: background var(--transition), color var(--transition);
}

.nav-group-btn:hover { background: var(--bg-subtle); color: var(--ink); }

.nav-group.open .nav-group-btn { color: var(--ink); }

.nav-group-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.65;
}

.nav-group-chevron {
  margin-left: auto;
  width: 13px;
  height: 13px;
  transition: transform var(--transition);
  flex-shrink: 0;
  opacity: 0.45;
}

.nav-group.open .nav-group-chevron { transform: rotate(90deg); }

.nav-group-items {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}

.nav-group.open .nav-group-items {
  max-height: 360px;
}

/* inner wrapper pads the content without breaking the clip */
.nav-group-items-inner {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 6px 0;
}

/* ── nav link ── */
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px;
  padding: 6px 10px 6px 14px;
  border-radius: 7px;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-muted);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-link:hover {
  background: var(--bg-subtle);
  color: var(--ink);
}

.nav-link.active {
  background: var(--brand-dim);
  color: var(--brand);
  font-weight: 700;
}

/* top-level solo link (Dashboard) */
.nav-solo {
  margin: 0 8px 6px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-muted);
  transition: background var(--transition), color var(--transition);
}

.nav-solo:hover { background: var(--bg-subtle); color: var(--ink); }
.nav-solo.active { background: var(--brand-dim); color: var(--brand); font-weight: 700; }

.nav-solo-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.65;
}

/* ── sidebar divider ── */
.nav-divider {
  height: 1px;
  background: var(--line);
  margin: 8px 16px;
}

/* ─── Main content ───────────────────────────────────────────────────── */
.main-area {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  padding: 28px 32px 48px;
  max-width: 1200px;
  width: 100%;
}

.page-title {
  margin: 0 0 20px;
  font-size: clamp(1.3rem, 2.5vw, 1.75rem);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
}

/* ─── Footer ─────────────────────────────────────────────────────────── */
.site-footer {
  margin-left: var(--sidebar-w);
  border-top: 1px solid var(--line);
  padding: 10px 32px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--ink-muted);
  background: var(--surface);
}

/* ─── Cards ──────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 22px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px 14px;
  animation: rise 240ms ease both;
}

.clickable-card {
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}

.clickable-card:hover {
  transform: translateY(-2px);
  border-color: #c8804e;
  box-shadow: var(--shadow-md);
}

.clickable-card:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(183,43,59,.18), var(--shadow-md);
}

.card h3 {
  margin: 0 0 8px;
  color: var(--ink-muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  font-weight: 700;
}

.metric-link { color: inherit; text-decoration: none; }
.metric-link:hover { text-decoration: underline; text-decoration-color: var(--brand); text-underline-offset: 2px; }

/* ─── Meta / small text ──────────────────────────────────────────────── */
.meta { margin: 5px 0 0; color: var(--ink-muted); font-size: 0.8rem; }

.meta-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(183,43,59,.35);
  text-underline-offset: 2px;
}
.meta-link:hover { text-decoration-color: var(--brand); }

.meta-list { margin: 5px 0 0; padding-left: 18px; color: var(--ink-muted); font-size: 0.8rem; }
.meta-list li { margin: 2px 0; }

/* ─── Menu grid (landing pages) ─────────────────────────────────────── */
.menu-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: 18px 0 4px;
}

.menu-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 18px 16px;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.menu-card h2 { margin: 0 0 6px; font-size: 1rem; color: #6d111d; }
.menu-card p  { margin: 0; color: var(--ink-muted); font-size: 0.86rem; }

.menu-card:hover {
  transform: translateY(-2px);
  border-color: #c67647;
  box-shadow: var(--shadow-md);
}

/* ─── Tables ─────────────────────────────────────────────────────────── */
.table-section { margin-top: 22px; }
.table-section h2 { margin: 0 0 10px; font-size: 1.05rem; }
.table-controls { margin: 0 0 10px; }

.table-controls button,
.intake-form button,
.inline-form button {
  border: 1px solid #ba6f40;
  border-radius: 8px;
  background: linear-gradient(145deg, #ffe8d4, #fff8ef);
  color: #5c2f14;
  font-weight: 700;
  font-family: inherit;
  font-size: 0.84rem;
  padding: 7px 13px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.table-controls button:hover,
.intake-form button:hover,
.inline-form button:hover {
  transform: translateY(-1px);
  border-color: #a4532a;
  box-shadow: 0 6px 14px rgba(113,86,52,.15);
}

.fee-cols-hidden .fee-col { display: none; }

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

table { width: 100%; border-collapse: collapse; min-width: 780px; }

.hio-history-table { min-width: 0; }
.hio-history-table .hio-tournament-col {
  white-space: normal;
  width: 50ch; max-width: 50ch; min-width: 30ch;
  overflow-wrap: anywhere; word-break: break-word;
}

th, td {
  border-bottom: 1px solid #ecdecf;
  padding: 9px 12px;
  font-size: 0.855rem;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

td.notes-col {
  white-space: normal;
  width: 280px; min-width: 240px; max-width: 360px;
  overflow-wrap: anywhere; word-break: break-word;
}

td.txid-col {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

th {
  position: sticky; top: 0; z-index: 1;
  background: linear-gradient(0deg, #f5e9da, #fdf7f0);
  color: var(--ink-muted);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 800;
}

th .th-sort { color: inherit; text-decoration: none; display: inline-block; width: 100%; }
th .th-sort:hover { text-decoration: underline; }

tbody tr:nth-child(even) { background: #fdfaf6; }
tbody tr:hover { background: #fff5ea; }

tbody tr.venmo-unmatched,
tbody tr.venmo-unmatched:nth-child(even) { background: #fff1f1; }
tbody tr.venmo-unmatched:hover { background: #ffe4e4; }

.clickable-row { cursor: pointer; }
.clickable-row:hover  { background: #ffeedc !important; box-shadow: inset 3px 0 0 #cb7444; }
.clickable-row:focus  { outline: none; background: #ffe9d1 !important; box-shadow: inset 3px 0 0 #c55f2a; }

.row-link { color: inherit; text-decoration: none; font-weight: 700; }
.clickable-row:hover .row-link,
.clickable-row:focus .row-link { text-decoration: underline; text-decoration-color: var(--brand); text-underline-offset: 2px; }

.selected-row { background: #fff2e2 !important; }

/* ─── Numbers & status ───────────────────────────────────────────────── */
.num { font-variant-numeric: tabular-nums; }
.negative     { color: #a21228; font-weight: 700; }
.num.positive { color: #236617; font-weight: 700; }
.diff-pass    { color: #236617; font-weight: 800; }
.diff-fail    { color: #a21228; font-weight: 800; }
.mono         { font-family: "Courier New", monospace; }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.pill.open, .pill.waiting    { color: #385e06; background: #e8f4d4; }
.pill.processed, .pill.added { color: #1e4f8b; background: #deecff; }
.pill.invited  { color: #7e5a00; background: #fff0c4; }
.pill.removed  { color: #7a1124; background: #fde2e8; }
.pill.pass, .pill.yes { color: #1e5a12; background: #def6cc; }
.pill.fail, .pill.no  { color: #8a1024; background: #ffdbe3; }
.pill.pending  { color: #5f4d22; background: #f8e8bf; }

.ok-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 999px;
  background: #49a22a;
  box-shadow: 0 0 0 2px #dff2d7 inset;
}

/* ─── Progress bar ───────────────────────────────────────────────────── */
.flow-track { width: 130px; height: 9px; border-radius: 999px; background: #ece5db; border: 1px solid #d8c8b5; overflow: hidden; }
.flow-bar { display: block; height: 100%; }
.flow-bar.positive { background: linear-gradient(90deg, #bfe8a8, #4b9a35); }
.flow-bar.negative { background: linear-gradient(90deg, #f7b8c2, #b01f3a); }
.flow-bar.neutral  { background: #d8d0c2; }

/* ─── Forms ──────────────────────────────────────────────────────────── */
.intake-panel { margin-bottom: 12px; }

.intake-form {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.intake-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 700;
}

.intake-form .check-label {
  flex-direction: row;
  align-items: center;
  min-width: auto;
  gap: 6px;
  padding-bottom: 8px;
}

.intake-form select,
.intake-form input[type="file"],
.intake-form input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 7px 10px;
  color: var(--ink);
  font-size: 0.86rem;
  font-family: inherit;
}

.intake-alert { margin: 8px 0 0; border-radius: 8px; padding: 8px 12px; font-size: 0.83rem; font-weight: 700; }
.intake-alert.success { border: 1px solid #a5cc6a; background: #ecf9d8; color: #27530f; }
.intake-alert.error   { border: 1px solid #e9a5b2; background: #ffe6eb; color: #7a1124; }

.inline-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.inline-form input[type="text"],
.inline-form select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
}

.member-jump {
  margin-top: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 10px;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
}

/* ─── Players grid ───────────────────────────────────────────────────── */
.next-players-grid {
  margin: 8px 0 0; padding: 0; list-style: none;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px 10px;
}
.next-players-grid li { margin: 0; color: var(--ink-muted); font-size: 0.9rem; line-height: 1.25; }
.player-link { color: inherit; text-decoration: none; }
.player-link:hover { text-decoration: underline; text-decoration-color: var(--brand); text-underline-offset: 2px; }

@media (max-width: 1100px) { .next-players-grid { grid-template-columns: repeat(4, minmax(0,1fr)); } }
@media (max-width: 760px)  { .next-players-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }

/* ─── Legacy table ───────────────────────────────────────────────────── */
.legacy-group-head  { border-left: 3px solid #c4a98b !important; border-right: 3px solid #c4a98b !important; text-align: center !important; font-size: 1rem; font-weight: 800; letter-spacing: 0.08em; }
.legacy-group-start { border-left: 3px solid #c4a98b !important; }
.legacy-group-end   { border-right: 3px solid #c4a98b !important; }

/* ─── Empty state ────────────────────────────────────────────────────── */
.empty-state {
  border: 1px dashed #c9a17a;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px 24px;
}
.empty-state h2 { margin: 0 0 8px; }
.empty-state p  { margin: 0; color: var(--ink-muted); }

/* ─── Prose / workflow docs ──────────────────────────────────────────── */
.prose-doc { line-height: 1.7; color: var(--ink); max-width: 860px; }
.prose-doc h1 { font-size: 1.5rem; margin: 1.4rem 0 0.5rem; color: var(--brand); }
.prose-doc h2 { font-size: 1.2rem; margin: 1.4rem 0 0.4rem; color: var(--brand); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.prose-doc h3 { font-size: 1rem; margin: 1rem 0 0.3rem; font-weight: 700; }
.prose-doc h4, .prose-doc h5, .prose-doc h6 { font-size: 0.95rem; margin: 0.8rem 0 0.2rem; }
.prose-doc p  { margin: 0.4rem 0 0.8rem; }
.prose-doc ul, .prose-doc ol { padding-left: 1.4rem; margin: 0.3rem 0 0.8rem; }
.prose-doc li { margin-bottom: 0.25rem; }
.prose-doc code { background: var(--bg-subtle); padding: 1px 5px; border-radius: 4px; font-size: 0.88em; }
.prose-doc hr  { border: none; border-top: 1px solid var(--line); margin: 1.4rem 0; }
.prose-doc strong { font-weight: 700; }
.prose-doc a { color: var(--brand); }
.prose-doc .table-wrap { margin: 0.8rem 0; }
.prose-doc table { min-width: 0; font-size: 0.9rem; }

/* ─── Animations ─────────────────────────────────────────────────────── */
@keyframes rise {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 60;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.25);
    z-index: 55;
  }
  .sidebar-overlay.open { display: block; }

  .main-area   { margin-left: 0; }
  .site-footer { margin-left: 0; }
  .page-content { padding: 20px 18px 40px; }
}

@media (max-width: 640px) {
  .page-content { padding: 16px 14px 36px; }
  .site-footer  { padding: 10px 14px; flex-direction: column; gap: 4px; }
}
