:root {
  color-scheme: dark;
  --bg: #101012;
  --sidebar: #151517;
  --panel: #1a1a1d;
  --panel-hover: #1f1f22;
  --field: #121214;
  --text: #f4f3f1;
  --muted: #aaa7a4;
  --faint: #747174;
  --line: #2d2c30;
  --accent: #9f3c46;
  --accent-hover: #b14954;
  --accent-soft: rgba(159,60,70,.15);
  --green: #65b978;
  --danger: #de7777;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; overflow-x: hidden; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
.is-hidden { display: none !important; }
.ambient { display: none; }

.brand-mark { display: grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; border-radius: 10px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 800; letter-spacing: -.06em; }

/* Login */
.login-view { display: grid; min-height: 100vh; padding: 24px; place-items: center; }
.login-card { width: min(100%,430px); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.login-brand, .sidebar-brand { display: flex; align-items: center; gap: 12px; }
.login-brand div, .sidebar-brand div { display: grid; gap: 1px; }
.login-brand b, .sidebar-brand b { font-size: 21px; font-weight: 750; }
.login-brand small, .sidebar-brand small { color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .09em; }
.login-copy { margin: 46px 0 28px; }
.login-copy > span { display: none; }
.login-copy h1 { margin: 0 0 10px; font-size: 32px; line-height: 1.15; }
.login-copy p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
#login-form { display: grid; gap: 16px; }
#login-form label { display: grid; gap: 8px; }
#login-form label > span { color: var(--muted); font-size: 14px; font-weight: 600; }
#login-form input, .search-box input { width: 100%; height: 52px; padding: 0 15px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--field); color: var(--text); transition: border-color 150ms ease; }
#login-form input:focus, .search-box input:focus { border-color: var(--accent); }
.primary-action { display: flex; min-height: 52px; padding: 0 18px; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; transition: background 150ms ease; }
.primary-action:not(:disabled):hover { background: var(--accent-hover); }
.primary-action i { font-size: 18px; font-style: normal; }
.form-error { min-height: 19px; margin: -3px 0; color: var(--danger); font-size: 13px; }
.security-note { display: flex; margin-top: 20px; align-items: center; justify-content: center; gap: 7px; color: var(--faint); font-size: 12px; }
.security-note i, .sidebar-status > i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

/* Shell */
.admin-layout { display: block; min-height: 100vh; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; display: flex; width: 240px; padding: 24px 18px; flex-direction: column; border-right: 1px solid var(--line); background: var(--sidebar); }
.sidebar nav { display: grid; margin-top: 42px; gap: 7px; }
.nav-button, .logout-button { display: flex; height: 48px; padding: 0 14px; align-items: center; gap: 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 15px; font-weight: 650; text-align: left; }
.nav-button:hover, .logout-button:hover { background: #1d1d20; color: var(--text); }
.nav-button.is-active { background: var(--accent-soft); color: #edbdc1; }
.nav-icon { position: relative; width: 18px; height: 18px; flex: 0 0 auto; border: 2px solid currentColor; border-radius: 5px; }
.nav-icon--users { border: 0; }
.nav-icon--users::before, .nav-icon--users::after { position: absolute; border: 2px solid currentColor; border-radius: 50%; content: ""; }
.nav-icon--users::before { top: 0; left: 5px; width: 6px; height: 6px; }
.nav-icon--users::after { bottom: 0; left: 2px; width: 12px; height: 7px; border-radius: 8px 8px 4px 4px; }
.sidebar-status { display: flex; margin-top: auto; padding: 14px; align-items: center; gap: 10px; color: var(--muted); }
.sidebar-status div { display: grid; gap: 2px; }
.sidebar-status b { font-size: 13px; }
.sidebar-status small { color: var(--faint); font-size: 11px; }
.logout-button { margin-top: 5px; }
.logout-button i { width: 16px; height: 16px; border: 2px solid currentColor; border-radius: 4px; }
.workspace { width: auto; min-width: 0; margin-left: 240px; padding: 30px 38px 50px; }
.workspace-header { display: flex; min-height: 64px; align-items: center; justify-content: space-between; }
.workspace-header > div > span { display: none; }
.workspace-header h1 { margin: 0; font-size: 32px; line-height: 1; }
.admin-pill { display: flex; min-width: 190px; padding: 8px 11px; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.admin-avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 8px; background: #2b2a2e; font-weight: 750; }
.admin-pill div { display: grid; gap: 2px; }
.admin-pill small { color: var(--faint); font-size: 11px; }
.admin-pill b { font-size: 14px; }
.admin-pill > i { width: 7px; height: 7px; margin-left: auto; border-radius: 50%; background: var(--green); }
.page { display: none; padding-top: 42px; }
.page.is-active { display: block; }

/* Dashboard */
.dashboard-heading, .users-toolbar { position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.dashboard-heading h2, .users-toolbar h2 { margin: 0 0 7px; font-size: 27px; }
.dashboard-heading p, .users-toolbar p { max-width: 680px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.period-button { display: flex; width: 230px; height: 56px; padding: 0 14px; flex: 0 0 auto; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); text-align: left; }
.period-button:hover { border-color: #4a484d; }
.calendar-icon { width: 19px; height: 18px; border: 2px solid var(--muted); border-radius: 4px; }
.period-button span { display: grid; min-width: 0; gap: 2px; }
.period-button small { color: var(--muted); font-size: 11px; }
.period-button b { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.period-button em { margin-left: auto; color: var(--muted); font-style: normal; }
.calendar-popover { position: absolute; z-index: 30; top: calc(100% + 10px); right: 0; width: 360px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #1b1b1e; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.calendar-popover header { display: flex; align-items: center; justify-content: space-between; }
.calendar-popover header b { font-size: 16px; }
.calendar-popover header button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--text); font-size: 21px; }
.calendar-week, .calendar-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; }
.calendar-week { margin-top: 16px; color: var(--faint); font-size: 11px; text-align: center; }
.calendar-grid { margin-top: 7px; }
.calendar-day { height: 37px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; }
.calendar-day:hover:not(:disabled) { background: #29292d; color: var(--text); }
.calendar-day.is-outside { opacity: .35; }
.calendar-day.is-today { color: #efb7bc; font-weight: 750; }
.calendar-day.is-in-range { background: var(--accent-soft); border-radius: 0; color: #e9c1c5; }
.calendar-day.is-start, .calendar-day.is-end { background: var(--accent); border-radius: 7px; color: #fff; }
.calendar-selection { display: grid; margin-top: 15px; padding: 12px; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 9px; }
.calendar-selection span { display: grid; gap: 3px; }
.calendar-selection span:last-child { text-align: right; }
.calendar-selection small { color: var(--faint); font-size: 11px; }
.calendar-selection b { font-size: 13px; }
.calendar-selection i { width: 14px; height: 1px; background: var(--line); }
.calendar-presets { display: grid; margin-top: 10px; grid-template-columns: repeat(3,1fr); gap: 6px; }
.calendar-presets button, .calendar-apply { height: 39px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; }
.calendar-apply { width: 100%; margin-top: 9px; border: 0; background: var(--accent); color: #fff; font-weight: 700; }
.profit-grid { display: grid; margin-top: 24px; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.profit-grid > *, .dashboard-lower > * { min-width: 0; }
.metric-card { position: relative; display: flex; min-height: 170px; padding: 23px; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.metric-card--primary { border-color: rgba(159,60,70,.55); }
.metric-icon { display: grid; width: 30px; height: 30px; margin-bottom: 22px; place-items: center; border-radius: 7px; background: var(--accent-soft); color: #dfa6ac; font-size: 15px; }
.metric-card > span { color: var(--muted); font-size: 15px; }
.metric-card strong { margin-top: 7px; font-size: clamp(34px,3.5vw,48px); font-weight: 720; letter-spacing: -.04em; }
.metric-card small { margin-top: auto; padding-top: 13px; color: var(--faint); font-size: 13px; }
.metric-shine { display: none; }
.dashboard-lower { display: grid; margin-top: 14px; grid-template-columns: minmax(340px,.85fr) minmax(420px,1.4fr); gap: 14px; }
.balance-panel, .trend-panel, .users-panel { padding: 23px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.balance-panel, .trend-panel { min-height: 315px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; }
.panel-heading span { display: none; }
.panel-heading h3 { margin: 0; font-size: 19px; }
.panel-heading > small { color: var(--muted); font-size: 12px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.balance-total { display: grid; margin-top: 34px; padding-bottom: 25px; border-bottom: 1px solid var(--line); gap: 6px; }
.balance-total span { color: var(--muted); font-size: 15px; }
.balance-total strong { font-size: 42px; letter-spacing: -.04em; }
.balance-total small { color: var(--faint); font-size: 13px; }
.club-stats { display: grid; margin-top: 20px; grid-template-columns: 1fr 1fr; gap: 12px; }
.club-stats > div { display: flex; min-height: 72px; padding: 12px 14px; align-items: center; border-radius: 10px; background: var(--field); }
.stat-icon { display: none; }
.club-stats span { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; }
.club-stats small { color: var(--muted); font-size: 13px; }
.club-stats b { font-size: 26px; }
.trend-panel { position: relative; }
.profit-chart { display: flex; height: 225px; padding-top: 25px; align-items: flex-end; gap: 5px; }
.chart-column { position: relative; display: flex; height: 100%; flex: 1; align-items: flex-end; }
.chart-bar { position: relative; display: block; width: 100%; min-height: 3px; border-radius: 4px 4px 1px 1px; background: var(--accent); }
.chart-bar:hover { background: var(--accent-hover); }
.chart-bar::after { position: absolute; z-index: 4; bottom: calc(100% + 7px); left: 50%; display: none; padding: 6px 8px; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 6px; background: #29292d; color: var(--text); font-size: 11px; white-space: nowrap; content: attr(data-value); }
.chart-bar:hover::after { display: block; }
.bar-level-0{height:2%}.bar-level-1{height:5%}.bar-level-2{height:10%}.bar-level-3{height:15%}.bar-level-4{height:20%}.bar-level-5{height:25%}.bar-level-6{height:30%}.bar-level-7{height:35%}.bar-level-8{height:40%}.bar-level-9{height:45%}.bar-level-10{height:50%}.bar-level-11{height:55%}.bar-level-12{height:60%}.bar-level-13{height:65%}.bar-level-14{height:70%}.bar-level-15{height:75%}.bar-level-16{height:80%}.bar-level-17{height:85%}.bar-level-18{height:90%}.bar-level-19{height:95%}.bar-level-20{height:100%}
.chart-empty { position: absolute; inset: 80px 20px 20px; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--muted); font-size: 14px; }
.chart-empty i { font-size: 25px; font-style: normal; }

/* Users */
.search-box { position: relative; width: min(100%,370px); }
.search-box input { height: 52px; padding-left: 44px; font-size: 14px; }
.search-box i::before { position: absolute; z-index: 1; top: 17px; left: 16px; width: 13px; height: 13px; border: 2px solid var(--muted); border-radius: 50%; content: ""; }
.search-box i::after { position: absolute; z-index: 1; top: 29px; left: 28px; width: 7px; height: 2px; transform: rotate(45deg); background: var(--muted); content: ""; }
.users-panel { min-height: 430px; margin-top: 24px; padding: 7px; overflow: hidden; }
.users-table-head, .user-row { display: grid; grid-template-columns: minmax(220px,1.6fr) minmax(140px,.8fr) minmax(150px,1fr) minmax(110px,.7fr) 150px; align-items: center; gap: 16px; }
.users-table-head { min-height: 50px; padding: 0 17px; color: var(--muted); font-size: 12px; font-weight: 650; }
.user-row { min-height: 86px; padding: 11px 17px; border-top: 1px solid var(--line); transition: background 140ms ease; }
.user-row:hover { background: var(--panel-hover); }
.user-identity { display: flex; min-width: 0; align-items: center; gap: 13px; }
.user-avatar { display: grid; width: 46px; height: 46px; flex: 0 0 auto; place-items: center; border-radius: 10px; background: var(--accent-soft); color: #e6b6bb; font-size: 16px; font-weight: 750; }
.user-identity div, .user-balance { display: grid; min-width: 0; gap: 4px; }
.user-identity b { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.user-identity small, .user-balance small, .user-lastseen { color: var(--muted); font-size: 13px; }
.user-balance b { font-size: 21px; }
.user-status { display: inline-flex; width: max-content; padding: 8px 10px; align-items: center; gap: 7px; border-radius: 8px; background: #242427; color: var(--muted); font-size: 12px; }
.user-status::before { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); content: ""; }
.user-status.is-online { background: rgba(101,185,120,.1); color: #98d0a4; }
.user-status.is-online::before { background: var(--green); }
.add-balance-button { height: 42px; padding: 0 13px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; }
.add-balance-button:hover { background: var(--accent-hover); }
.users-empty { display: grid; min-height: 330px; place-items: center; align-content: center; gap: 9px; }
.users-empty b { font-size: 18px; }
.users-empty small { color: var(--muted); font-size: 14px; }

/* Balance modal */
.modal { position: fixed; z-index: 80; inset: 0; display: grid; padding: 20px; place-items: center; background: rgba(0,0,0,.72); animation: modal-in 160ms ease both; }
.modal-dismiss { position: absolute; inset: 0; width: 100%; border: 0; background: transparent; }
.balance-sheet { position: relative; width: min(100%,470px); padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: #1a1a1d; box-shadow: 0 24px 60px rgba(0,0,0,.45); animation: sheet-in 180ms ease both; }
@keyframes modal-in { from { opacity: 0; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px); } }
.balance-sheet > header { display: flex; align-items: flex-start; justify-content: space-between; }
.balance-sheet header span { display: none; }
.balance-sheet h2 { margin: 0; font-size: 25px; }
.balance-sheet header button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); font-size: 20px; }
.balance-user { display: grid; margin-top: 22px; padding: 14px; grid-template-columns: 46px 1fr auto; align-items: center; gap: 12px; border-radius: 10px; background: var(--field); }
.balance-user > span { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 9px; background: var(--accent-soft); color: #e6b6bb; font-weight: 750; }
.balance-user div { display: grid; min-width: 0; gap: 3px; }
.balance-user b { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.balance-user small { color: var(--muted); font-size: 12px; }
.balance-user strong { font-size: 19px; }
.amount-field { display: flex; height: 82px; margin: 20px 0 12px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 10px; background: var(--field); }
.amount-field span { margin-right: 6px; color: var(--muted); font-size: 22px; }
.amount-field input { width: min(270px,76%); border: 0; outline: 0; background: transparent; color: var(--text); font-size: 40px; font-weight: 700; text-align: center; }
.amount-presets { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.amount-presets button { height: 42px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; }
.amount-presets button:hover { border-color: var(--accent); color: var(--text); }
.authorization-field { display: grid; margin-top: 18px; gap: 7px; }
.authorization-field > span { color: var(--muted); font-size: 14px; font-weight: 650; }
.authorization-field > div { display: grid; height: 50px; padding: 0 14px; grid-template-columns: 18px 1fr; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--field); transition: border-color 150ms ease; }
.authorization-field > div:focus-within { border-color: var(--accent); }
.authorization-field i { position: relative; width: 13px; height: 11px; border: 1.5px solid var(--muted); border-radius: 3px; }
.authorization-field i::before { position: absolute; top: -8px; left: 2px; width: 7px; height: 7px; border: 1.5px solid var(--muted); border-bottom: 0; border-radius: 6px 6px 0 0; content: ""; }
.authorization-field input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; }
.authorization-field input::placeholder { color: var(--faint); }
.authorization-field small { color: var(--faint); font-size: 12px; }
.balance-sheet .form-error { margin: 10px 0 4px; text-align: center; }
.balance-sheet .primary-action { width: 100%; margin-top: 5px; }
.toast { position: fixed; z-index: 120; right: 24px; bottom: 24px; max-width: 380px; padding: 14px 17px; transform: translateY(18px); border: 1px solid rgba(101,185,120,.3); border-radius: 10px; background: #193120; color: #c1e3c8; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast.is-error { border-color: rgba(222,119,119,.35); background: #351c1e; color: #efb5b5; }
.mobile-nav { display: none; }

@media (max-width: 1100px) {
  .sidebar { width: 210px; }
  .workspace { width: auto; margin-left: 210px; padding-inline: 24px; }
  .profit-grid { grid-template-columns: 1fr 1fr; }
  .metric-card:last-child { grid-column: 1 / -1; }
  .dashboard-lower { grid-template-columns: 1fr; }
  .users-table-head { display: none; }
  .user-row { grid-template-columns: minmax(210px,1.5fr) 1fr 150px; }
  .user-lastseen, .user-status { display: none; }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .workspace { width: 100%; margin-left: 0; padding: 21px 14px 94px; }
  .workspace-header { min-height: 54px; }
  .workspace-header h1 { font-size: 28px; }
  .admin-pill { min-width: 0; padding: 6px; border: 0; background: transparent; }
  .admin-pill div, .admin-pill > i { display: none; }
  .page { padding-top: 34px; }
  .dashboard-heading, .users-toolbar { align-items: stretch; flex-direction: column; gap: 17px; }
  .dashboard-heading h2, .users-toolbar h2 { font-size: 24px; }
  .period-button, .search-box { width: 100%; }
  .calendar-popover { top: calc(100% + 8px); right: 0; left: 0; width: 100%; }
  .profit-grid { grid-template-columns: 1fr; }
  .metric-card:last-child { grid-column: auto; }
  .metric-card { min-height: 155px; }
  .metric-card strong { font-size: 39px; }
  .dashboard-lower { grid-template-columns: minmax(0,1fr); }
  .balance-panel, .trend-panel { padding: 18px; }
  .balance-total strong { font-size: 37px; }
  .club-stats { grid-template-columns: 1fr; }
  .profit-chart { gap: 3px; }
  .users-panel { padding: 5px; }
  .user-row { grid-template-columns: 1fr auto; gap: 12px; }
  .user-balance { text-align: right; }
  .add-balance-button { grid-column: 1 / -1; width: 100%; height: 46px; }
  .mobile-nav { position: fixed; z-index: 50; right: 12px; bottom: 12px; left: 12px; display: grid; height: 66px; padding: 7px; grid-template-columns: 1fr 1fr; gap: 6px; border: 1px solid var(--line); border-radius: 14px; background: #18181b; box-shadow: 0 15px 35px rgba(0,0,0,.45); }
  .mobile-nav .nav-button { height: 50px; justify-content: center; }
  .login-view { padding: 14px; }
  .login-card { padding: 25px 20px; }
  .login-copy { margin-top: 42px; }
  .login-copy h1 { font-size: 29px; }
  .balance-sheet { padding: 21px 17px; }
  .balance-user { grid-template-columns: 42px 1fr; }
  .balance-user > span { width: 42px; height: 42px; }
  .balance-user strong { grid-column: 2; }
  .amount-presets { grid-template-columns: 1fr 1fr; }
  .toast { right: 14px; bottom: 90px; left: 14px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
