/* re:forma dashboard — brand palette: Graphite/Surface/Lime + Sora/Inter.
   Lime (#B9F227) is ACTION/ACCENT only. Calm-coach tone. */
:root {
  --graphite: #0B0F14;
  --surface: #151A21;
  --surface-2: #1C232C;
  --line: #232c37;
  --lime: #B9F227;
  --white: #FFFFFF;
  --soft: #88909F;
  --success: #7FD957;
  --danger: #F2675A;
  --neutral: #88909F;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--graphite);
  color: var(--white);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand, .login-logo, .stat-value { font-family: 'Sora', sans-serif; }
.hidden { display: none !important; }
.accent { color: var(--lime); }
button { font-family: inherit; cursor: pointer; }

/* ===== Login ===== */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #16202a 0%, var(--graphite) 60%);
}
.login-card {
  width: 340px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 32px 28px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 30px; font-weight: 800; text-align: center; }
.login-sub { color: var(--soft); text-align: center; margin-bottom: 8px; }
.login-card input {
  background: var(--graphite); border: 1px solid var(--line); color: var(--white);
  padding: 12px 14px; border-radius: 10px; font-size: 15px;
}
.login-card input:focus { outline: none; border-color: var(--lime); }
.login-error { color: var(--danger); font-size: 13px; min-height: 16px; text-align: center; }
.btn-primary {
  background: var(--lime); color: #0a0d11; border: none; padding: 12px; border-radius: 10px;
  font-weight: 700; font-size: 15px; transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ===== App shell ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 24px; font-weight: 800; margin-bottom: 28px; padding-left: 8px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; background: none; border: none; color: var(--soft);
  padding: 12px 12px; border-radius: 10px; font-size: 14px; text-align: left; width: 100%;
  transition: background .15s, color .15s;
}
.nav-item .ico { font-size: 16px; }
.nav-item:hover { background: var(--surface-2); color: var(--white); }
.nav-item.active { background: var(--surface-2); color: var(--white); box-shadow: inset 3px 0 0 var(--lime); }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.user-box { color: var(--soft); font-size: 13px; padding-left: 8px; }
.btn-ghost { background: none; border: 1px solid var(--line); color: var(--soft); padding: 9px; border-radius: 9px; }
.btn-ghost:hover { border-color: var(--danger); color: var(--danger); }

.main { flex: 1; padding: 22px 28px 60px; max-width: 1400px; }

/* ===== Filter bar ===== */
.filterbar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; position: sticky; top: 12px; z-index: 20;
}
.period { display: flex; gap: 6px; align-items: center; }
.chip {
  background: var(--graphite); border: 1px solid var(--line); color: var(--soft);
  padding: 7px 14px; border-radius: 20px; font-size: 13px;
}
.chip.active { background: var(--lime); color: #0a0d11; border-color: var(--lime); font-weight: 600; }
.custom-range { display: flex; align-items: center; gap: 6px; }
.custom-range input { background: var(--graphite); border: 1px solid var(--line); color: var(--white); padding: 6px 8px; border-radius: 8px; }
.btn-mini { background: var(--surface-2); border: 1px solid var(--line); color: var(--white); padding: 7px 11px; border-radius: 8px; font-size: 13px; }
.btn-mini:hover { border-color: var(--lime); }
.clubs { position: relative; }
.clubs-toggle { background: var(--graphite); border: 1px solid var(--line); color: var(--white); padding: 8px 14px; border-radius: 10px; font-size: 13px; }
.clubs-toggle b { color: var(--lime); font-weight: 600; }
.clubs-menu {
  position: absolute; top: 110%; left: 0; min-width: 260px; max-height: 320px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
  box-shadow: var(--shadow); z-index: 30;
}
.clubs-menu label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--white); }
.clubs-menu label:hover { background: var(--surface); }
.clubs-menu .menu-actions { display: flex; gap: 8px; padding: 6px 4px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.clubs-menu .menu-actions button { flex: 1; background: var(--graphite); border: 1px solid var(--line); color: var(--soft); padding: 6px; border-radius: 7px; font-size: 12px; }
.refresh { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.last-updated { color: var(--soft); font-size: 12px; }

/* ===== Cards ===== */
.block-title { font-size: 18px; font-weight: 700; margin: 28px 0 14px; }
.sub-title { font-size: 14px; color: var(--soft); margin: 22px 0 10px; font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 8px;
}
.stat-label { color: var(--soft); font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-sub { font-size: 13px; color: var(--soft); }
.stat-trend { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-flat { color: var(--neutral); }

/* ===== Charts ===== */
.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.chart-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.chart-box canvas { max-width: 100%; }
.chart-box.wide { grid-column: 1 / -1; }
.chart-box h3 { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: var(--soft); }
.chart-box canvas { max-height: 240px; }

/* ===== Renewal months ===== */
.renewal-months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.rm-cell { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.rm-cell .m { color: var(--soft); font-size: 12px; }
.rm-cell .pct { font-size: 20px; font-weight: 700; font-family: 'Sora'; margin: 4px 0; }
.rm-cell .abs { color: var(--soft); font-size: 12px; }

/* ===== Rating table ===== */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.rating-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1100px; }
.rating-table th, .rating-table td { padding: 12px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.rating-table th:first-child, .rating-table td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
.rating-table thead th { color: var(--soft); font-weight: 600; cursor: pointer; user-select: none; }
.rating-table thead th:hover { color: var(--white); }
.rating-table thead th.sorted { color: var(--lime); }
.rating-table tbody tr:hover { background: var(--surface-2); }
.rating-table .club-name { font-weight: 600; }
.cell-main { font-weight: 600; }
.cell-delta { font-size: 11px; margin-left: 6px; }

/* ===== Comparison ===== */
.comparison { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.comparison h3 { margin: 0 0 14px; font-size: 16px; }
.cmp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.cmp-row { background: var(--graphite); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.cmp-metric { color: var(--soft); font-size: 12px; margin-bottom: 8px; }
.cmp-best, .cmp-worst { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.cmp-best b { color: var(--success); }
.cmp-worst b { color: var(--danger); }

/* ===== Funnel ===== */
.funnel { display: flex; flex-direction: column; gap: 8px; max-width: 760px; margin: 0 auto 30px; }
.funnel-stage { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; position: relative; overflow: hidden; }
.funnel-bar { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(185,242,39,.16), rgba(185,242,39,.04)); border-right: 2px solid var(--lime); z-index: 0; }
.funnel-stage > * { position: relative; z-index: 1; }
.funnel-top { display: flex; justify-content: space-between; align-items: baseline; }
.funnel-name { font-weight: 600; font-size: 15px; }
.funnel-count { font-family: 'Sora'; font-size: 20px; font-weight: 700; }
.funnel-meta { display: flex; gap: 18px; color: var(--soft); font-size: 12px; margin-top: 4px; }
.funnel-meta b { color: var(--lime); font-weight: 600; }

.funnel-byclub { overflow-x: auto; }
.funnel-byclub table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 760px; }
.funnel-byclub th, .funnel-byclub td { padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--line); }
.funnel-byclub th:first-child, .funnel-byclub td:first-child { text-align: left; }
.funnel-byclub thead th { color: var(--soft); font-weight: 600; }

/* ===== Users screen ===== */
.users-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.add-user-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; }
.add-user-form input { background: var(--graphite); border: 1px solid var(--line); color: var(--white); padding: 9px 12px; border-radius: 9px; font-size: 14px; }
.add-user-form .btn-primary { padding: 9px 18px; }
.users-table-actions { display: inline-flex; gap: 6px; }
.btn-act { background: var(--surface-2); border: 1px solid var(--line); color: var(--soft); padding: 5px 10px; border-radius: 7px; font-size: 12px; }
.btn-act:hover { border-color: var(--lime); color: var(--white); }
.btn-act.danger:hover { border-color: var(--danger); color: var(--danger); }
.badge { padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.badge.on { background: rgba(127,217,87,.15); color: var(--success); }
.badge.off { background: rgba(242,103,90,.15); color: var(--danger); }

/* ===== misc ===== */
.loading { display: flex; justify-content: center; padding: 40px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--lime); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.screen { display: none; }
.screen.active { display: block; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--white);
  padding: 12px 22px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100;
}
.toast.err { border-color: var(--danger); }

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
  .renewal-months { grid-template-columns: repeat(3, 1fr); }
  .sidebar { width: 64px; }
  .nav-item span:not(.ico), .brand, .user-box { display: none; }
}
