/* The account pages (/account and its four sub-tabs, plus /cashier).
 *
 * These rules used to be a <style> block that public/js/pages/account.js
 * injected into <head> the first time the account page rendered. That had a
 * latent bug: several families here (.hist-*, .txn-*, .chat-msg,
 * .btn-secondary) are used by OTHER pages too, so those pages rendered
 * unstyled for anyone who had not visited /account yet in this SPA session.
 * As a real stylesheet they apply from first paint, which is what the markup
 * always assumed.
 *
 * The .stat-grid / .stat-card / .stat-label / .stat-value / .stat-unit family
 * is NOT repeated here. It is already in main.css, character for character,
 * and the injected copy was a duplicate.
 *
 * Everything below is written against the theme tokens (--bg-secondary,
 * --border, --text-muted, --accent, --accent-text, --win, --loss) and never a
 * literal colour, because the site ships three themes (neon, black, white)
 * and a hardcoded hex breaks two of them.
 */

#account-page { max-width: 900px; margin: 0 auto; padding: 24px; }
@media (max-width: 480px) {
  #account-page { padding: 12px; }
}

/* ---- Identity card ------------------------------------------------------
 * The header of the page: who you are, rather than a heading that says
 * "Account" above a page already labelled Account.
 *
 * The tile is a monogram, not an avatar. There is no avatar column on the
 * users table and adding image upload is a different piece of work; the first
 * letter of the player name costs nothing and fills the same slot.
 */
.dash-id { display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin: 0 0 10px; }
.dash-id-mono { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--accent-text); font-size: 24px; font-weight: 800;
  text-transform: uppercase; line-height: 1; }
.dash-id-who { flex: 1 1 220px; min-width: 0; }
.dash-id-name { font-size: 17px; font-weight: 800; color: var(--text-primary);
  margin: 0 0 3px; overflow-wrap: anywhere; }
.dash-id-sub { font-size: 12px; color: var(--text-muted); margin: 0;
  line-height: 1.5; }
.dash-tag { display: inline-block; font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px; vertical-align: middle;
  white-space: nowrap; margin-left: 6px; }
.dash-tag--admin { color: var(--accent-text); border-color: var(--accent); }
.dash-tag--unverified { color: var(--loss); }

/* ---- Stat tiles ---------------------------------------------------------
 * A WRAPPING FLEX ROW, deliberately not a grid with a fixed track count.
 * .stat-grid in main.css is repeat(3, 1fr), and a fixed track count is how a
 * conditionally rendered tile ends up alone on an implicit second row and
 * visibly grows the box. flex-wrap cannot fall into that: tiles are
 * flex: 1 1 130px, so they share the row when they fit and wrap when they do
 * not, whatever the count.
 */
.dash-stat-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.dash-stat { flex: 1 1 130px; min-width: 0; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; }
/* --text-secondary, NOT --text-muted. Muted is the token main.css uses for
   .stat-label, and on the panel background it measures 2.53:1 under
   theme-black and 2.31:1 under theme-white -- both well under the 4.5:1 a
   10px uppercase label needs. Secondary measures 7.85 and 9.37. */
.dash-stat-label { display: block; color: var(--text-secondary); font-size: 10px;
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.dash-stat-value { display: block; color: var(--text-primary); font-size: 18px;
  font-weight: 800; font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere; line-height: 1.2; }
.dash-stat-value.pos { color: var(--win); }
.dash-stat-value.neg { color: var(--loss); }
@media (max-width: 560px) {
  .dash-stat { flex: 1 1 100%; }
}

/* A section header that is a row: a title on the left, one control on the
   right. Replaces a repeated inline flex in the support tab. */
.dash-head-row { display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* Table column headings, shared by the referral list. Was five identical
   inline style attributes. */
.dash-th { text-align: left; padding: 6px 8px; color: var(--text-muted);
  font-weight: 600; font-size: 10px; text-transform: uppercase;
  letter-spacing: .6px; }
.dash-th--right { text-align: right; }
.dash-td--right { text-align: right; }
.dash-td--muted { color: var(--text-muted); }
.dash-td--win { color: var(--win); }
.dash-table-wrap { margin-top: 16px; overflow-x: auto; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 12px; }

/* ---- Page and sub-page navigation --------------------------------------- */
.acct-nav { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.acct-navlink { flex: 1; color: var(--text-secondary); padding: 10px 4px; cursor: pointer; font-size: 13px; font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; text-align: center; min-width: 0; text-decoration: none; }
.acct-navlink:hover { color: var(--text-primary); text-decoration: none; }
.acct-navlink.active { color: var(--accent-text); border-bottom-color: var(--accent); }
@media (max-width: 480px) {
  .acct-navlink { font-size: 11px; padding: 9px 2px; }
}
.acct-page-head { font-size: 15px; font-weight: 800; color: var(--text-primary); margin: 34px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.acct-panel { display: none; }
.acct-panel.active { display: block; }

/* The sub-tab strip sits under the identity card and the stat row, so its top
   margin is small: the cards above it already separate it from the page nav. */
.acct-subnav { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--border); }
.acct-subtab {
  padding: 9px 16px; font-size: 13px; font-weight: 700; color: var(--text-muted);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap;
}
.acct-subtab:hover { color: var(--text-primary); text-decoration: none; }
.acct-subtab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
@media (max-width: 480px) { .acct-subtab { padding: 9px 10px; font-size: 12px; } }
.acct-sub { display: none; }
.acct-sub.active { display: block; }

/* ---- Panels -------------------------------------------------------------
 * One density for every panel on the page. The old padding was 20px with a
 * 10px radius, which made three stacked sections taller than a laptop screen.
 */
.acct-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; align-items: start; }
@media (max-width: 640px) { .acct-grid-2 { grid-template-columns: 1fr; } }
.acct-section { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 13px 15px; margin: 0 0 10px; }
/* Inside a grid the gap already does the separating; a bottom margin as well
   would double the space between rows of panels. */
.acct-grid-2 > .acct-section { margin-bottom: 0; }
.acct-section-title { color: var(--accent-text); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 9px; }

/* A label/value pair as a row with a hairline under it, rather than a stacked
   pair. Three of these read as a table of facts instead of six loose lines.
   It wraps rather than squashing, so a long email keeps its own line on a
   phone. */
.acct-field { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; justify-content: space-between; padding: 7px 0; margin: 0; border-bottom: 1px solid var(--border); }
.acct-field:last-child { border-bottom: none; padding-bottom: 0; }
.acct-label { color: var(--text-muted); font-size: 12px; }
.acct-value { color: var(--text-primary); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; text-align: right; }

.theme-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-btn { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-secondary); padding: 6px 16px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.theme-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.ref-box { background: var(--bg-tertiary); border: 1px solid var(--accent); border-radius: 8px; padding: 14px; }
.ref-code { color: var(--accent-text); font-size: 16px; font-weight: 800; letter-spacing: 2px; margin-bottom: 6px; }
.ref-desc { color: var(--text-secondary); font-size: 11px; margin-bottom: 10px; line-height: 1.5; }
.ref-stats { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--text-secondary); }
.btn-secondary { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-primary); padding: 8px 16px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.btn-secondary:hover { border-color: var(--accent); }

/* ---- Cashier ------------------------------------------------------------ */
/* The balance is the reason the page exists, so it gets the room. */
.cash-card { background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 12px; padding: 26px 24px; margin-bottom: 16px; text-align: center; }
.cash-card-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 1.4px; margin-bottom: 10px; }
.cash-card-value { display: block; font-size: 40px; font-weight: 800;
  color: var(--accent-text); line-height: 1.1; letter-spacing: -.5px; }
/* Three equal buttons. Deposit, Transfer and Withdraw are three things a
   player might want, not a primary with two alternatives, so they share a
   treatment and split the width evenly. */
.cash-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cash-actions .btn { padding: 13px 10px; font-size: 14px; font-weight: 700; }
@media (max-width: 420px) { .cash-actions { grid-template-columns: 1fr; } }

/* ---- Shared: history and transaction lists, messages, chat --------------
 * Used by the cashier, /stats and the chat widget, which is why these live in
 * a stylesheet now rather than in a block injected by the account page.
 */
.hist-header { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; padding: 8px 12px; color: var(--text-muted); font-size: 10px; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.hist-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; padding: 8px 12px; font-size: 13px; border-bottom: 1px solid var(--border); }
.hist-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px; border-top: 1px solid var(--border); font-size: 12px; }
.hist-page-info { color: var(--text-muted); flex: 1; min-width: 140px; }
.hist-page-controls { display: flex; align-items: center; gap: 8px; }
.hist-page-btn { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-primary); padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.hist-page-btn:hover:not(:disabled) { border-color: var(--accent); }
.hist-page-btn:disabled { opacity: 0.35; cursor: default; }
.hist-page-num { color: var(--text-secondary); font-size: 12px; }
.hist-per-page { display: flex; align-items: center; gap: 4px; color: var(--text-muted); font-size: 11px; }
.hist-pp-btn { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-secondary); padding: 3px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.hist-pp-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.acct-msg { min-height: 20px; font-size: 12px; margin-top: 10px; }
.acct-msg.error { color: var(--loss); }
.acct-msg.success { color: var(--win); }
.txn-header { display: grid; grid-template-columns: 1.5fr 2fr 1fr 1.2fr; gap: 8px; padding: 8px 12px; color: var(--text-muted); font-size: 10px; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.txn-row { display: grid; grid-template-columns: 1.5fr 2fr 1fr 1.2fr; gap: 8px; padding: 10px 12px; font-size: 12px; border-bottom: 1px solid var(--border); align-items: center; }
.txn-type { color: var(--text-primary); font-weight: 600; }
.txn-note { color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-amt { font-weight: 700; text-align: right; }
.txn-date { color: var(--text-muted); font-size: 10px; text-align: right; }
@media (max-width: 560px) {
  .hist-header, .hist-row { padding: 8px 6px; gap: 4px; }
  .hist-row { font-size: 12px; }
  .hist-header { font-size: 9px; }
  .txn-header { display: none; }
  .txn-row {
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    padding: 10px 8px;
  }
  .txn-row .txn-type { grid-area: 1 / 1; }
  .txn-row .txn-amt  { grid-area: 1 / 2; }
  .txn-row .txn-note { grid-area: 2 / 1; font-size: 11px; }
  .txn-row .txn-date { grid-area: 2 / 2; }
}
.chat-msg { font-size:12px; padding:2px 0; line-height:1.5; word-break:break-word; }
.chat-msg .msg-time { color:var(--text-muted); font-size:10px; margin-right:4px; }
.chat-msg .msg-name { font-weight:600; margin-right:4px; }
.chat-msg.system { color:var(--text-muted); font-style:italic; }
