:root {
  --bg: #f3f6f4;
  --card: #ffffff;
  --text: #1c2b24;
  --muted: #6b7c74;
  --line: #e2e9e5;
  --primary: #0f8a5f;
  --primary-dark: #0b6b49;
  --primary-soft: #e3f4ec;
  --accent: #d7f24a;
  --pos: #0f8a3c;
  --neg: #d63031;
  --warn: #b7791f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 40, 30, .06), 0 4px 14px rgba(16, 40, 30, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
.container { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.pos { color: var(--pos); font-weight: 600; } .neg { color: var(--neg); font-weight: 600; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 20px; background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; display: flex; gap: 8px; align-items: center; }
.ball { color: var(--accent); font-size: 1.3rem; }
.topnav { display: flex; gap: 6px; align-items: center; }
.topnav a { color: #e6fff3; padding: 6px 10px; border-radius: 8px; }
.topnav a.active, .topnav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid var(--line); }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: 2px; }
.club-card { cursor: pointer; transition: transform .12s, box-shadow .12s; display: flex; flex-direction: column; gap: 8px; }
.club-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(16,40,30,.1); }
.club-card .bal { font-size: 1.25rem; font-weight: 700; }

/* Buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent;
  background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--line); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: #fff; color: var(--neg); border-color: #f3c6c6; }
.btn.danger:hover { background: #fdecec; }
.btn.sm { padding: 4px 10px; font-size: .85rem; border-radius: 7px; }
.btn.block { width: 100%; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #cfdad4; border-radius: 9px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15,138,95,.25); border-color: var(--primary); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.field { margin-bottom: 12px; }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.money-input { text-align: right; font-variant-numeric: tabular-nums; }
.error { color: var(--neg); font-size: .9rem; margin: 8px 0; min-height: 1em; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--neg); color: #fff; font-size: .75rem; text-align: center; line-height: 20px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .75rem; background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.tag.gray { background: #eef1ef; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); font-weight: 600; background: #f8fbf9; }
tbody tr:hover { background: #fafcfb; }
tfoot td { font-weight: 700; background: #f8fbf9; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.unchecked td { opacity: .55; }
.coef-input { width: 80px; text-align: center; padding: 6px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 25, 18, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 980px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1; }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1c2b24; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; }
.toast.err { background: var(--neg); }

/* Auth */
.auth-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.auth { width: 100%; max-width: 420px; }
.auth .hero { text-align: center; margin-bottom: 18px; }
.auth .hero .ball { font-size: 2.6rem; color: var(--primary); }

/* Chat */
.chat { display: flex; flex-direction: column; height: min(70vh, 640px); padding: 0; overflow: hidden; }
.chat-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #f8fbf9; }
.msg { max-width: 72%; align-self: flex-start; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg .bubble { display: inline-block; padding: 8px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; text-align: left; }
.msg.mine .bubble { background: var(--primary); color: #fff; border-color: var(--primary); }
.msg .meta { font-size: .75rem; color: var(--muted); margin: 0 4px 2px; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.chat-form textarea { resize: none; height: 44px; }
.day-sep { text-align: center; font-size: .75rem; color: var(--muted); margin: 6px 0; }

.split-summary { display: flex; gap: 18px; flex-wrap: wrap; padding: 12px 14px; background: var(--primary-soft); border-radius: 10px; margin: 10px 0; }
.split-summary b { font-size: 1.1rem; }
.code-box { font-family: ui-monospace, Consolas, monospace; font-size: 1.4rem; letter-spacing: .2em; font-weight: 700; padding: 6px 12px; background: #f1f7f3; border: 1px dashed var(--primary); border-radius: 8px; color: var(--primary-dark); }
.empty { text-align: center; padding: 30px; color: var(--muted); }
.info-list { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.info-list dt { color: var(--muted); } .info-list dd { margin: 0; }

@media (max-width: 640px) {
  .topbar { padding: 10px 12px; }
  .topnav a[data-nav="home"] { display: none; }
  .msg { max-width: 88%; }
  .info-list { grid-template-columns: 110px 1fr; }
  th, td { padding: 8px 6px; }
  .hide-sm { display: none; }
}
