/* MKSKM Ledger Pro v2.4 — hand-written dark theme. No external resources.
   System font stack only; 'Noto Sans Myanmar' is named so a locally
   installed copy is used, but nothing is fetched remotely. */
:root {
  --bg: #080c14;
  --bg-2: #0c121e;
  --panel: #0f172a;
  --panel-2: #111827;
  --card: #0f172acc;
  --border: #1e293b;
  --border-strong: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --emerald-soft: rgba(16, 185, 129, 0.15);
  --rose: #fb7185;
  --amber: #fbbf24;
  --sky: #38bdf8;
  --purple: #c084fc;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Myanmar", "Myanmar Text", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.mono, input[type="date"], input[type="time"], input[type="number"], select, td.num, .num {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
a { color: var(--emerald); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; color: var(--text); }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--emerald); outline-offset: 1px; }
select option { background: var(--panel); color: var(--text); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--panel); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.bold { font-weight: 700; }
.right { text-align: right; }
.center { text-align: center; }

/* ---------- Header ---------- */
header.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(12, 18, 30, 0.95);
  border-bottom: 1px solid rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(8px);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 14px 16px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #10b981, #0f766e);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; border: 1px solid rgba(52, 211, 153, 0.4);
}
.brand h1 { margin: 0; font-size: 17px; letter-spacing: -0.02em; color: #fff; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.version-tag {
  display: inline-block; padding: 2px 8px; margin-left: 8px; vertical-align: middle;
  font-size: 11px; font-weight: 600; border-radius: 999px;
  background: var(--emerald-soft); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3);
}
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.role-badge {
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.role-admin { background: rgba(251, 191, 36, 0.15); color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.35); }
.role-staff { background: rgba(56, 189, 248, 0.15); color: var(--sky); border: 1px solid rgba(56, 189, 248, 0.35); }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: #151e2e; color: var(--text); font-size: 12px; font-weight: 600;
}
.btn:hover { background: #1e293b; }
.btn-primary { background: var(--emerald-dark); border-color: var(--emerald-dark); color: #fff; }
.btn-primary:hover { background: var(--emerald); }
.btn-danger { background: rgba(244, 63, 94, 0.12); border-color: rgba(244, 63, 94, 0.4); color: var(--rose); }
.btn-danger:hover { background: rgba(244, 63, 94, 0.22); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 9px; font-size: 11px; border-radius: 8px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  padding: 6px 8px; border-radius: 8px; border: none; background: transparent;
  color: var(--text-dim); font-size: 14px; line-height: 1;
}
.icon-btn:hover { background: #1e293b; color: #fff; }
.icon-btn.danger:hover { color: var(--rose); }

/* ---------- Layout ---------- */
main { max-width: 1440px; margin: 0 auto; padding: 24px 16px 48px; width: 100%; }
.stack > * + * { margin-top: 24px; }
section.card, .card {
  background: rgba(15, 23, 42, 0.9); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 15px; color: #fff; }
.card .sub { margin: 0; font-size: 12px; color: var(--text-dim); }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 768px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .kpi-grid { grid-template-columns: repeat(6, 1fr); } }
.kpi { background: rgba(15, 23, 42, 0.9); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.kpi-label { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.kpi-label .tag { padding: 2px 6px; border-radius: 6px; background: #1e293b; color: var(--text-dim); font-size: 10px; }
.kpi-value { font-size: 20px; font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; color: #f8fafc; }
.kpi-sub { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.kpi-green { border-color: rgba(16, 185, 129, 0.35); }
.kpi-green .kpi-label { color: #34d399; }
.kpi-green .kpi-value { color: #34d399; }
.kpi-red { border-color: rgba(244, 63, 94, 0.35); }
.kpi-red .kpi-label { color: var(--rose); }
.kpi-red .kpi-value { color: var(--rose); }
.kpi-amber .kpi-label { color: var(--amber); }
.kpi-amber .kpi-value { color: var(--amber); }
.kpi-sky .kpi-label { color: var(--sky); }
.kpi-sky .kpi-value { color: var(--sky); }
.kpi-highlight { background: linear-gradient(135deg, rgba(6, 78, 59, 0.6), #0f172a); border-color: rgba(16, 185, 129, 0.4); }

/* Wallet grid */
.wallet-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 10px; }
@media (min-width: 640px) { .wallet-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .wallet-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1280px) { .wallet-grid { grid-template-columns: repeat(7, 1fr); } }
.wallet { background: rgba(15, 23, 42, 0.9); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.wallet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.wallet-head strong { font-size: 12px; color: var(--text); }
.wallet-acc { padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border-strong); font-size: 10px; font-family: ui-monospace, Menlo, monospace; color: var(--text-dim); }
.wallet-bal { font-size: 15px; font-weight: 700; font-family: ui-monospace, Menlo, monospace; margin-bottom: 8px; color: #fff; }
.wallet-bal span { font-size: 10px; color: var(--text-faint); font-weight: 400; }
.wallet-io { display: flex; justify-content: space-between; font-size: 10px; font-family: ui-monospace, Menlo, monospace; border-top: 1px solid rgba(30, 41, 59, 0.8); padding-top: 6px; }
.in { color: #34d399; } .out { color: var(--rose); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.section-head h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 0; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 16px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .form-grid { grid-template-columns: repeat(6, 1fr); } .span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } }
label.field-label { display: block; font-size: 11px; font-weight: 500; color: var(--text-dim); margin-bottom: 4px; }
input[type="text"], input[type="date"], input[type="time"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 12px;
  background: #020617; border: 1px solid rgba(51, 65, 85, 0.8); font-size: 12px;
}
input:focus, select:focus { border-color: var(--emerald); outline: none; }
input.amount { border-color: rgba(16, 185, 129, 0.55); font-weight: 700; }
.inline-row { display: flex; gap: 4px; }
.inline-row input { flex: 1; min-width: 0; }
.form-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.form-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--emerald); display: inline-block; margin-right: 6px; }

/* ---------- Tabs ---------- */
.tab-bar { display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.tab-btn {
  padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 600;
  background: var(--panel); color: var(--text-dim); border: 1px solid var(--border);
}
.tab-btn:hover { color: #fff; }
.tab-btn.active { background: var(--emerald-dark); color: #fff; border-color: var(--emerald-dark); }
.tab-panel { margin-top: 16px; }
.tab-panel > * + * { margin-top: 16px; }

/* ---------- Filters ---------- */
.filter-bar {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  background: rgba(15, 23, 42, 0.9); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
}
@media (min-width: 640px) { .filter-bar { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .filter-bar { grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr; } }
.filter-bar .wide { grid-column: span 1; }
@media (min-width: 1024px) { .filter-bar .wide { grid-column: span 1; } }
.date-range { display: flex; gap: 6px; align-items: center; }
.date-range span { color: var(--text-faint); font-size: 11px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead th {
  padding: 12px 14px; background: rgba(2, 6, 23, 0.9); border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim);
  white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid rgba(30, 41, 59, 0.7); font-size: 12px; vertical-align: top; }
tbody tr:hover { background: rgba(30, 41, 59, 0.4); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
.player-id { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: #6ee7b7; }
.note-line { font-size: 11px; color: var(--text-faint); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { padding: 40px 16px; text-align: center; color: var(--text-faint); }
.empty-state p { margin: 6px 0 16px; }
.pagination {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px; background: rgba(2, 6, 23, 0.6); border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim);
}
.pagination .controls { display: flex; align-items: center; gap: 8px; }
.pagination select { width: auto; padding: 4px 8px; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border-strong);
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge-deposit { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.35); }
.badge-withdraw { background: rgba(244, 63, 94, 0.12); color: var(--rose); border-color: rgba(244, 63, 94, 0.35); }
.badge-transfer { background: rgba(192, 132, 252, 0.12); color: var(--purple); border-color: rgba(192, 132, 252, 0.35); }
.badge-topup { background: rgba(56, 189, 248, 0.12); color: var(--sky); border-color: rgba(56, 189, 248, 0.35); }
.badge-extra-income { background: rgba(45, 212, 191, 0.12); color: #5eead4; border-color: rgba(45, 212, 191, 0.35); }
.badge-extra-outcome { background: rgba(251, 146, 60, 0.12); color: #fdba74; border-color: rgba(251, 146, 60, 0.35); }
.badge-balance { background: rgba(100, 116, 139, 0.25); color: var(--text); border-color: var(--border-strong); }
.bank-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border-strong); font-family: ui-monospace, Menlo, monospace; font-size: 11px; font-weight: 600; background: #1e293b; color: var(--text); white-space: nowrap; }
.bank-kpay { background: rgba(56, 189, 248, 0.12); color: #7dd3fc; border-color: rgba(56, 189, 248, 0.35); }
.bank-wave8030 { background: rgba(251, 191, 36, 0.12); color: #fcd34d; border-color: rgba(251, 191, 36, 0.35); }
.bank-wave1111 { background: rgba(192, 132, 252, 0.12); color: #d8b4fe; border-color: rgba(192, 132, 252, 0.35); }
.status-ok { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.35); }
.status-diff { background: rgba(251, 191, 36, 0.12); color: #fcd34d; border-color: rgba(251, 191, 36, 0.35); }

/* ---------- Auth ---------- */
.auth-wrap { max-width: 440px; margin: 80px auto 0; padding: 0 16px; }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.auth-card h1 { margin: 0 0 4px; font-size: 20px; color: #fff; }
.auth-card p { margin: 0 0 20px; font-size: 13px; color: var(--text-dim); }
.auth-card form > * + * { margin-top: 14px; }
.auth-error { background: rgba(244, 63, 94, 0.12); border: 1px solid rgba(244, 63, 94, 0.4); color: var(--rose); border-radius: 10px; padding: 10px 12px; font-size: 12px; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(2, 6, 23, 0.8);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius);
  max-width: 560px; width: 100%; padding: 20px; max-height: 90vh; overflow-y: auto;
}
.modal.wide { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 16px; color: #fff; }
.modal-head p { margin: 4px 0 0; font-size: 12px; color: var(--text-dim); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 16px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 12px; border-bottom: 1px solid rgba(30, 41, 59, 0.5); }
.kv:last-child { border-bottom: none; }
.kv span:first-child { color: var(--text-dim); }
.kv span:last-child { font-family: ui-monospace, Menlo, monospace; font-weight: 600; }
.preview-box { background: #020617; border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 12px; }
.preview-box h4 { margin: 0 0 8px; font-size: 12px; color: var(--text-dim); }
.invalid-row { color: var(--rose); }

/* ---------- Admin ---------- */
.admin-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1024px) { .admin-grid { grid-template-columns: 1fr 1fr; } }
.admin-grid .full { grid-column: 1 / -1; }
.admin-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.admin-row > div { flex: 1; min-width: 140px; }
.user-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid rgba(30, 41, 59, 0.6); font-size: 12px; }
.user-row:last-child { border-bottom: none; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 100;
  padding: 12px 16px; border-radius: 12px; background: #1e293b; border: 1px solid var(--border-strong);
  font-size: 12px; font-weight: 600; color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: translateY(80px); opacity: 0; transition: transform 0.3s, opacity 0.3s; pointer-events: none;
  max-width: min(90vw, 420px);
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.error { border-color: rgba(244, 63, 94, 0.5); }
#toast.success { border-color: rgba(16, 185, 129, 0.5); }

.loading { padding: 40px; text-align: center; color: var(--text-dim); font-size: 13px; }
.settlement-note { background: rgba(16, 185, 129, 0.08); border: 1px solid rgba(16, 185, 129, 0.3); border-radius: 12px; padding: 12px; font-size: 12px; }

/* ---------- New tabs: daily summary totals footer, agent fee editor ---------- */
tfoot td {
  padding: 10px 14px; border-top: 2px solid var(--border-strong);
  background: rgba(2, 6, 23, 0.6); font-weight: 700; font-size: 12px;
}
tfoot td.num { text-align: right; font-family: ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
.fee-pct-input { width: 76px; padding: 4px 8px; text-align: right; }
