:root {
  --bg: #ece6d9;
  --surface: #f7f2e7;
  --surface-2: #eee7d8;
  --border: #ddd4c1;
  --text: #1c2230;
  --muted: #6b7385;
  --primary: #2f5bea;
  --primary-text: #ffffff;
  --side-bg: #1e3a8a;
  --pos: #12804a;
  --pos-bg: #e6f5ec;
  --neg: #c62f2f;
  --neg-bg: #fbeaea;
  --warn: #b25e00;
  --warn-bg: #fff3e0;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141a;
    --surface: #1a1e26;
    --side-bg: #1a1e26;
    --surface-2: #222733;
    --border: #2d3340;
    --text: #e7eaf0;
    --muted: #9aa2b3;
    --primary: #5b82ff;
    --pos: #3ecf82;
    --pos-bg: #13301f;
    --neg: #ff6b6b;
    --neg-bg: #3a1b1b;
    --warn: #ffab4a;
    --warn-bg: #3a2a14;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--primary); text-decoration: none; }

.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 10px;
  background: var(--side-bg, var(--surface));
  border-right: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); padding: 4px 10px 16px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text); font-weight: 500;
}
.nav-link:hover { background: rgba(0, 0, 0, .06); }
.nav-link.active { background: var(--primary); color: var(--primary-text); }
.nav-ico { width: 20px; text-align: center; }

.container { width: 100%; max-width: 1400px; margin: 0 auto; padding: 20px 16px 60px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; height: auto; z-index: 5;
    flex-direction: row; align-items: center; overflow-x: auto;
    padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0 10px 0 4px; font-size: 16px; white-space: nowrap; }
  .nav-link { white-space: nowrap; padding: 7px 10px; }
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.page-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.page-head h1 { margin: 0; font-size: 22px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--neg); }
.btn.sm { padding: 3px 8px; font-size: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:hover > td { background: var(--surface-2); }
tfoot td { font-weight: 700; background: var(--surface-2); border-bottom: 0; }
tr.clickable { cursor: pointer; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.pos { background: var(--pos-bg); }
.badge.neg { background: var(--neg-bg); }
/* Balance tags: highlighted — Lena (Dr) solid red, Dena (Cr) solid green */
.badge.dr, .badge.cr {
  color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .02em;
  padding: 3px 10px; vertical-align: middle; box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.badge.dr { background: #c62f2f; }
.badge.cr { background: #12804a; }
a.btn { display: inline-block; }
.card-link { color: inherit; display: block; }
.card-link:hover { border-color: var(--primary); }

.sub-row > td { background: var(--surface-2); padding: 8px 12px 14px 40px; }
.sub-row table { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.sub-row th { background: transparent; }

.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 12px; }
.filters label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* Modal */
dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 0;
  width: min(460px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(10, 14, 22, .45); }
dialog form { padding: 18px 20px; }
dialog h2 { margin: 0 0 14px; font-size: 18px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preview {
  background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px;
  display: grid; gap: 4px; font-variant-numeric: tabular-nums;
}
.preview div { display: flex; justify-content: space-between; gap: 10px; }
.error { color: var(--neg); margin: 0 0 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.btn.warn { color: var(--warn); border-color: var(--warn); font-weight: 600; }
.btn.warn:hover { background: var(--warn-bg); }

.sheet-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
/* Agent sheet table: bigger, clearer text */
.sheet-table th { font-size: 13px; color: #4b5366; padding-top: 12px; padding-bottom: 12px; }
.sheet-table td { font-size: 15.5px; padding-top: 12px; padding-bottom: 12px; font-weight: 500; }
.sheet-table td strong { font-weight: 700; }
.sheet-table .actions-col { padding-left: 40px; border-left: 1px dashed var(--border); }
.sheet-table .actions-col .btn.sm { font-size: 13px; padding: 5px 10px; }
/* AGENT TOTAL: light yellow, dark readable text */
.sheet-table tfoot td {
  background: #fff6d5; color: #1c2230; font-size: 16.5px; font-weight: 800;
  border-top: 2px solid #f0d77a; padding-top: 14px; padding-bottom: 14px;
}
.sheet-table tfoot .pos { color: #0b6b3a; }
.sheet-table tfoot .neg { color: #b01e1e; }
.sheet-table tfoot .comm { color: #9a4d00; }
.cards-single { grid-template-columns: minmax(220px, 280px); }
@media (prefers-color-scheme: dark) {
  .sheet-table th { color: var(--muted); }
}

.date-group td { background: var(--surface-2); font-weight: 700; font-size: 13px; padding-top: 7px; padding-bottom: 7px; }
.date-group .muted { font-weight: 400; }
.sheet-main { min-width: 0; }
.history { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.history-head { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.history-empty { padding: 16px 14px; }
.history ul { list-style: none; margin: 0; padding: 0; }
.history li { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.history li:hover { background: var(--surface-2); }
.history li:last-child { border-bottom: 0; }
.history-period { font-weight: 600; font-size: 13px; }
.history-net { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

dialog.wide { width: min(760px, calc(100vw - 32px)); }
/* Settlement breakdown TOTAL row: ultra pink (#FF6FFF), dark text; darker green/red for contrast */
.lines-total td { background: #ff6fff; color: #000; border-top: 2px solid #d63fd6; }
.lines-total .pos { color: #04421f; }
.lines-total .neg { color: #6e0000; }
.lines-total .comm { color: #4a2400; }
.lines-total .muted { color: #000; }

/* Settlement breakdown popup: ~30% larger (width and text) */
dialog.wide.big { width: min(1300px, calc(100vw - 32px)); font-size: 18px; }
dialog.big h2 { font-size: 24px; }
dialog.big th { font-size: 15px; padding: 12px 14px; }
dialog.big td { font-size: 18px; padding: 12px 14px; }
dialog.big .small { font-size: 15px; }
dialog.big .settle-net { font-size: 22px; }
dialog.big .btn { font-size: 17px; padding: 9px 18px; }
dialog .panel { margin-bottom: 12px; box-shadow: none; }
.settle-net { font-size: 17px; font-weight: 700; margin: 4px 0 14px; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; cursor: pointer; }
.check input { width: auto; margin-top: 3px; }

@media (max-width: 1000px) {
  .sheet-layout { grid-template-columns: 1fr; }
  .history { position: static; max-height: none; }
}

/* ---------- journal voucher ---------- */
dialog.wide:has(.jv) { width: min(860px, calc(100vw - 32px)); }
.jv { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 4px; }
.jv-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; background: var(--surface-2); border-bottom: 2px solid var(--primary);
}
.jv-title { font-weight: 800; letter-spacing: .12em; font-size: 13px; color: var(--primary); }
.jv-no { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.jv-date { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.jv-date input { width: 170px; }
.jv-scroll { overflow-x: auto; }
.jv-table { min-width: 560px; }
.jv-table th { background: transparent; border-bottom: 1px solid var(--border); }
.jv-table td { padding: 6px 8px; border-bottom: 1px dashed var(--border); }
.jv-table tbody tr:hover > td { background: transparent; }
.jv-table select, .jv-table input { padding: 6px 8px; }
.jv-table input.num { text-align: right; font-variant-numeric: tabular-nums; }
.jv-table input:disabled { background: var(--surface-2); border-color: transparent; }
.jv-table tfoot td { border-top: 2px solid var(--text); border-bottom: 0; font-size: 15px; background: transparent; }
.jv-remove {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--neg); font-size: 18px; line-height: 1; cursor: pointer;
}
.jv-remove:hover { background: var(--neg-bg); }
.jv-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; }
.jv > .field { padding: 0 16px 14px; margin: 0; }
.jv-diff { font-weight: 700; font-size: 13px; }
.jv-diff.ok { color: var(--pos); }
.jv-diff.bad { color: var(--neg); }

/* Colourful paired voucher */
:root { --cr: #0f9d6b; --cr-bg: #e3f7ee; --dr: #d9480f; --dr-bg: #fff0e6; --jv-grad: linear-gradient(120deg, #4f46e5, #7c3aed 55%, #db2777); }
@media (prefers-color-scheme: dark) {
  :root { --cr: #3ddc97; --cr-bg: #10332a; --dr: #ff8a4c; --dr-bg: #3a2216; }
}
.jv-head { background: var(--jv-grad); color: #fff; border-bottom: 0; }
.jv-head .jv-title { color: #fff; opacity: .9; }
.jv-head .jv-no { color: #fff; font-size: 22px; }
.jv-head .jv-date { color: rgba(255, 255, 255, .85); }
.jv-head .jv-date input { border-color: transparent; }
.jv-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.15); padding: 6px 10px; border-radius: 999px; }
.jv-legend .jv-tag { margin-right: 4px; }
.jv-arrow { font-weight: 700; opacity: .8; }

.jv-tag {
  display: inline-block; min-width: 34px; text-align: center; padding: 3px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 800; letter-spacing: .03em;
}
.jv-tag.side-cr, select.jv-side.side-cr { background: var(--cr-bg); color: var(--cr); border-color: var(--cr); font-weight: 800; }
.jv-tag.side-dr, select.jv-side.side-dr { background: var(--dr-bg); color: var(--dr); border-color: var(--dr); font-weight: 800; }

.jv-pair { border-top: 8px solid transparent; }
.jv-pair-head td { padding: 10px 8px 2px !important; border-bottom: 0 !important; }
.jv-pair-no {
  font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  background: var(--jv-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.jv-pair-head .jv-remove { float: right; width: auto; height: auto; padding: 2px 8px; font-size: 12px; }
.jv-row td { border-bottom: 0 !important; }
.jv-row.side-row-cr td:first-child { box-shadow: inset 4px 0 0 var(--cr); }
.jv-row.side-row-dr td:first-child { box-shadow: inset 4px 0 0 var(--dr); }
.jv-row.side-row-cr { background: linear-gradient(90deg, var(--cr-bg), transparent 45%); }
.jv-row.side-row-dr { background: linear-gradient(90deg, var(--dr-bg), transparent 45%); }
.jv-sub { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 3px; font-size: 11.5px; }
.jv-hint { color: var(--muted); font-style: italic; }
.jv-bal { color: var(--text); }
.jv-bal .badge { font-size: 10px; }
.jv-table input.jv-off { background: transparent; border-color: transparent; }
.jv-table input[readonly] { background: var(--surface-2); color: var(--muted); }
.jv-row.side-row-cr .jv-cr:not(.jv-off), .jv-row.side-row-dr .jv-dr:not(.jv-off) { font-weight: 700; }
.jv-add { background: var(--jv-grad); color: #fff; border: 0; font-weight: 700; }
.jv-add:hover { filter: brightness(1.1); background: var(--jv-grad); }
.jv-bar { background: var(--surface-2); }
.jv-narr { padding-top: 12px !important; }

/* Journal cards: each entry as a transfer */
.jv-card { border-top: 0; }
.jv-card-head { background: var(--jv-grad); color: #fff; }
.jv-card-head .muted { color: rgba(255,255,255,.85); }
.jv-card-head .btn { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.35); }
.jv-transfers { padding: 10px 14px; display: grid; gap: 8px; }
.jv-transfer { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.jv-party-chip { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; min-width: 0; }
.jv-party-chip a, .jv-party-chip span:not(.jv-tag) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jv-party-chip.side-cr { background: var(--cr-bg); }
.jv-party-chip.side-dr { background: var(--dr-bg); }
.jv-flow { display: grid; justify-items: center; font-size: 12px; font-weight: 700; line-height: 1.1; }
.jv-flow .jv-arrow { font-size: 18px; color: var(--muted); }
.jv-card-total { text-align: right; font-size: 13px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 6px; }
.jv-card-total strong { color: var(--text); font-size: 15px; }

.jv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.jv-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden; border-top: 3px solid var(--primary);
}
.jv-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-2); }
.jv-card-head .jv-no { font-size: 15px; margin-right: 8px; }
.jv-card-actions { display: flex; gap: 6px; }
.jv-mini th { background: transparent; font-size: 11px; padding: 6px 12px; }
.jv-mini td { padding: 7px 12px; }
.jv-mini tbody tr:hover > td { background: transparent; }
.jv-mini tfoot td { background: transparent; border-top: 1px solid var(--text); font-size: 13px; }
.jv-narration { padding: 8px 14px; font-size: 13px; border-top: 1px dashed var(--border); }
.jv-card > .edit-info { margin: 0 14px 12px; }
.side { display: inline-block; min-width: 28px; text-align: center; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 6px; }
.side.dr { background: var(--warn-bg); color: var(--warn); }
.side.cr { background: var(--surface-2); color: var(--primary); }

@media (max-width: 600px) {
  .jv-list { grid-template-columns: 1fr; }
}

.comm { color: var(--warn); font-weight: 600; }
/* Agent's personal ledger: TOTAL row in hot pink (#FF4FA7), black text for contrast */
.ledger-total td { background: #ff4fa7; color: #000; border-top: 2px solid #d61f7c; font-size: 15px; }
.ledger-total .bal-lena, .ledger-total .bal-dena, .ledger-total .muted { color: #000; }
/* Agent's personal ledger: header row in metallic cyan (#37F5EB), black text */
table:has(.ledger-total) thead th { background: #37f5eb; color: #000; font-weight: 700; }
/* Darker, bolder amounts in the ledger rows */
table:has(.ledger-total) tbody td.num { color: #000; font-weight: 600; font-size: 15px; }
.ledger-total .badge { box-shadow: 0 0 0 2px rgba(255, 255, 255, .85); }

/* Journal cards: readable header + entries in sequence with their narrations */
.jv-card { border-top: 0; }
.jv-card .jv-card-head { background: var(--jv-grad); color: #fff; }
.jv-card .jv-card-head .jv-no { color: #fff; font-weight: 800; }
.jv-card .jv-card-head .muted { color: rgba(255, 255, 255, .92); font-weight: 600; }
.jv-card .jv-card-head .btn { background: #fff; color: #4338ca; border-color: #fff; font-weight: 700; }
.jv-card .jv-card-head .btn:hover { background: #eef2ff; }
.jv-entry-no { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #6d28d9; margin-top: 4px; }
.jv-party-chip { flex-direction: column; align-items: flex-start; gap: 3px; }
.jv-chip-top { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.jv-chip-narr { font-size: 12px; color: #374151; font-style: italic; white-space: normal; overflow-wrap: anywhere; }
.jv-line-narr { margin-top: 6px; padding: 6px 9px; font-size: 13px; }

/* Darker text in every popup form */
dialog .field > span { color: #1c2230; font-weight: 600; }
dialog input, dialog select, dialog textarea { color: #000; font-weight: 500; }
dialog h2 { color: #000; }
dialog .hint { color: #4b5366; }

/* Edit customer: its Win/Loss entries with Edit buttons */
.cust-entries { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 4px 0 12px; }
.cust-entries-head { font-weight: 700; font-size: 13px; padding: 8px 12px; background: var(--surface-2); color: #1c2230; }
.cust-entries th, .cust-entries td { padding: 7px 10px; font-size: 13px; }
.cust-entries td { color: #000; }

/* Edit PIN prompt */
#pin-dialog { width: min(340px, calc(100vw - 32px)); }
#pin-input { font-size: 28px; letter-spacing: .5em; text-align: center; padding: 10px; margin: 6px 0 12px; }

/* Win/Loss entry popup: 20% larger, darker text */
dialog.entry-modal { width: min(552px, calc(100vw - 32px)); font-size: 16.8px; }
dialog.entry-modal h2 { font-size: 21.6px; color: #000; }
dialog.entry-modal .field > span { font-size: 14.4px; color: #1c2230; font-weight: 600; }
dialog.entry-modal input, dialog.entry-modal select { font-size: 16.8px; padding: 9px 12px; color: #000; font-weight: 500; }
dialog.entry-modal .preview { font-size: 16.8px; color: #000; }
dialog.entry-modal .btn { font-size: 16.8px; padding: 8px 16px; }

/* E & D page */
.audit-tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.audit-tag.edit { background: #fff3e0; color: #9a4d00; }
.audit-tag.del { background: #fbeaea; color: #b01e1e; }
.audit-table td { vertical-align: top; }
.audit-details { font-size: 14px; line-height: 1.55; }

/* Login screen */
#auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
#auth[hidden], .shell[hidden] { display: none; }
.auth-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 26px 24px; box-shadow: 0 10px 30px rgba(16, 24, 40, .1);
}
.auth-brand { font-weight: 800; font-size: 20px; color: var(--primary); margin-bottom: 4px; }
.auth-card h2 { margin: 0 0 14px; font-size: 18px; }
.auth-btn { width: 100%; padding: 10px; font-weight: 600; }
.nav-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }
@media (max-width: 760px) { .nav-bottom { margin-top: 0; border-top: 0; padding-top: 0; display: flex; } }

.day-settle-head { font-size: 14px; margin: 6px 0 8px; }
.report-net td { background: #fff6d5; font-weight: 800; font-size: 15.5px; border-top: 2px solid #f0d77a; }
.report-net .muted { font-weight: 600; }
.bal-lena { color: var(--neg); font-weight: 700; }
.bal-dena { color: var(--pos); font-weight: 700; }
.card-final { border-color: var(--primary); }

.settle-link { color: var(--primary); }
.settle-link:hover { text-decoration: underline; }

.edit-info {
  margin-top: 4px; padding: 4px 8px; border-left: 3px solid var(--warn);
  background: var(--warn-bg); color: var(--text); border-radius: 4px;
  font-size: 11.5px; line-height: 1.45;
}

.hint { font-size: 12px; color: var(--muted); margin-top: 10px; }

@media (max-width: 600px) {
  .row2 { grid-template-columns: 1fr; }
  .sub-row > td { padding-left: 12px; }
  .card .value { font-size: 17px; }
}

@media print {
  .sidebar, .actions, .filters, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
  .panel, .card { box-shadow: none; }
}

/* ID / Master: 2 Way names */
.tw-master { color: #d11a1a; font-weight: 800; }
.tw-id { color: #0a8a3a; font-weight: 400; }
/* Same-width box so "ID" and the circled M line up in the 2 Way column. */
.tw-cell { display: inline-flex; align-items: center; justify-content: center; width: 28px; vertical-align: middle; }
.tw-cell .tw-m { margin-left: 0; }
.tw-m { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border: 2px solid #d11a1a; border-radius: 50%; color: #d11a1a; font-weight: 900; font-size: 11px; line-height: 1; margin-left: 6px; vertical-align: middle; }

/* ID / Master → "+ Win/Loss coins" (many IDs at once) */
dialog.bulk-modal { width: min(1300px, calc(100vw - 32px)); font-size: 16px; }
dialog.bulk-modal h2 { font-size: 21px; color: #000; }
.bulk-date { max-width: 240px; }
.bulk-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.bulk-table th { text-align: left; font-size: 13px; color: #1c2230; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.bulk-table td { padding: 4px; vertical-align: middle; }
.bulk-table input, .bulk-table select { width: 100%; font-size: 15px; padding: 7px 9px; color: #000; }
.bulk-table .b-id { min-width: 150px; font-weight: 700; }
.bulk-table .b-agent { min-width: 90px; white-space: nowrap; }
.bulk-table .b-coins { min-width: 110px; }
.bulk-table .b-rate { min-width: 80px; }
.bulk-table .b-net { min-width: 90px; white-space: nowrap; font-weight: 600; }
.bulk-table tfoot td { padding-top: 10px; }
.bulk-draft { background: #fff7e0; border: 1px solid #f0d58a; color: #6b4e00; border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bulk-table .b-rate { min-width: 70px; font-weight: 600; color: #1c2230; }
.bulk-table .b-id.b-dup { border-color: #d11a1a; background: #fdecec; color: #b01e1e; }
.bulk-table .b-res.res-won { background: #e3f7e8; border-color: #8fd3a2; color: #0a6b2e; font-weight: 700; }
.bulk-table .b-res.res-lost { background: #fde6e6; border-color: #f0a3a3; color: #a31515; font-weight: 700; }
.bulk-table .b-panel, .bulk-table .b-tw { min-width: 110px; white-space: nowrap; font-weight: 600; color: #1c2230; }
input.locked { background: #f1f3f7; color: #4a5160; cursor: not-allowed; }
.ledger-date { white-space: nowrap; color: #000; font-weight: 600; }

/* ---------- Mobile (phone) view ---------- */
#modal-body { overflow-x: auto; }
@media (max-width: 760px) {
  /* Page must never be wider than the phone; wide tables scroll inside their own box. */
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { top: 0; background: var(--side-bg, var(--surface)); }
  .container { padding: 14px 12px 40px; }
  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .page-head { align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; text-align: center; padding: 8px 10px; font-size: 14px; }
  .filters label { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .filters label input, .filters label select { width: 100%; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .cards-single { grid-template-columns: 1fr; }
  .sheet-table td, .sheet-table th { padding: 8px 10px; font-size: 14px; }
  dialog { width: calc(100vw - 16px) !important; max-width: none; }
  dialog form { padding: 14px 12px; }
  /* Bulk Win/Loss: each line becomes a small card on the phone */
  .bulk-table thead { display: none; }
  .bulk-table, .bulk-table tbody { display: block; }
  .bulk-table tr.bulk-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px 8px; padding: 10px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 10px; }
  .bulk-table tr.bulk-row td { padding: 0; min-width: 0; border: 0; }
  .bulk-table tr.bulk-row td:nth-child(1) { grid-column: 1 / 3; }
  .bulk-table tr.bulk-row td:nth-child(9) { grid-column: 3; grid-row: 1; }
  .bulk-table .b-id, .bulk-table .b-coins, .bulk-table .b-agent, .bulk-table .b-panel, .bulk-table .b-tw, .bulk-table .b-rate, .bulk-table .b-net { min-width: 0; }
  .bulk-table .b-rate, .bulk-table .b-net { text-align: left; }
  .bulk-table .b-rate:not(:empty)::before { content: "Rate "; color: var(--muted); font-weight: 400; }
  .bulk-table .b-net:not(:empty)::before { content: "Net "; color: var(--muted); font-weight: 400; }
  .bulk-table tfoot, .bulk-table tfoot tr { display: flex; justify-content: space-between; align-items: center; }
  .bulk-table tfoot td { padding: 6px 0; }
  .hint { font-size: 11.5px; }
}
/* Journal: editing an existing voucher looks different from a new one (amber theme + dashed frame) */
dialog.jv-edit-modal { border: 3px dashed #f59e0b; background: #fffbeb; }
dialog.jv-edit-modal #modal-title { color: #b45309; }
dialog.jv-edit-modal #modal-title::before { content: "✎ "; }
.jv.jv-editing { border-color: #f59e0b; }
.jv.jv-editing .jv-head { background: linear-gradient(120deg, #d97706, #f59e0b 55%, #ea580c); }
.jv.jv-editing .jv-title { letter-spacing: .12em; }
dialog.jv-edit-modal #modal-submit { background: #d97706; border-color: #d97706; }
dialog.jv-edit-modal #modal-submit:hover { background: #b45309; }
.jv-swap { margin-left: 10px; border: 1px solid #f59e0b; background: #fff7e6; color: #b45309; font-weight: 700; border-radius: 999px; padding: 2px 12px; font-size: 12px; cursor: pointer; }
.jv-swap:hover { background: #fde7c2; }
/* Filter bars (ID / Master, History, Report, Vouchers, E & D): darker, easier to read */
.filters label { color: #1c2230; font-weight: 600; font-size: 13px; }
.filters input, .filters select { color: #000; font-weight: 500; border: 1.5px solid #9aa3b2; background: #fff; }
.filters input::placeholder { color: #6b7385; }
.filters input:focus, .filters select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.filters > .btn { border: 1.5px solid #9aa3b2; color: #000; font-weight: 600; }
.filters > .muted.small { color: #1c2230; font-weight: 600; }
.bulk-table .b-coins.res-won { background: #e3f7e8; border-color: #8fd3a2; color: #0a6b2e; font-weight: 700; }
.bulk-table .b-coins.res-lost { background: #fde6e6; border-color: #f0a3a3; color: #a31515; font-weight: 700; }
.date-group .day-del { float: right; margin-top: -3px; }
.del-box { background: #fdecec; border: 1px solid #f0a3a3; color: #7a1010; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.del-box ul { margin: 6px 0 8px 18px; padding: 0; }
dialog.del-modal #modal-submit { background: #c81e1e; border-color: #c81e1e; }
dialog.del-modal #modal-submit:hover { background: #a11818; }
.date-group .day-edit { margin-right: 8px; border-color: #f59e0b; color: #b45309; background: #fff7e6; font-weight: 700; }
.edit-steps { margin: 6px 0 10px 20px; padding: 0; line-height: 1.6; }

/* Ledger: edited entries get a round colourful "H" (opens the edit history) */
.hist-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer; vertical-align: middle;
  background: linear-gradient(135deg, #7c3aed, #db2777 55%, #f59e0b); color: #fff;
  font-weight: 900; font-size: 14px; line-height: 30px; padding: 0; margin-left: 6px;
  box-shadow: 0 2px 6px rgba(124, 58, 237, .35);
}
.hist-btn:hover { filter: brightness(1.1); transform: scale(1.06); }
.date-group .edit-closed { margin-right: 8px; padding: 3px 10px; border-radius: 999px; background: #eef0f4; color: #4a5160; font-size: 12px; font-weight: 700; }
.stmt-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.stmt-head p { margin: 0; }
.stmt-pdf { background: linear-gradient(120deg, #4f46e5, #7c3aed 55%, #db2777); color: #fff !important; border: 0; font-weight: 700; }
.day-settle-head .stmt-pdf { float: right; }
/* Journal: register table (one line per voucher) */
.jr-table thead th { background: #37f5eb; color: #000; font-weight: 700; }
.jr-table .jr-no { color: #4338ca; font-weight: 800; white-space: nowrap; }
.jr-table .cr-name a, .jr-table .cr-name strong { color: #0b7a45; }
.jr-table .dr-name a, .jr-table .dr-name strong { color: #c2410c; }
.jr-table .jr-arrow { width: 18px; text-align: center; }
.jr-table .jr-extra td { background: #fafbff; }
.jr-table .jr-more { border-color: #a5b4fc; color: #4338ca; }
.jr-table tfoot .jr-total td { background: #ff4fa7; color: #000; font-weight: 800; border-top: 2px solid #d61f7c; }
.jr-table tbody.jr-voucher[hidden] { display: none; }

/* Colourful filter bars: each box gets its own accent (cycles blue → purple → teal → orange → pink). */
.filters > label { --fc: #2563eb; --fbg: #eef4ff; color: var(--fc); }
.filters > label:nth-of-type(5n+2) { --fc: #7c3aed; --fbg: #f4efff; }
.filters > label:nth-of-type(5n+3) { --fc: #0d9488; --fbg: #e9f8f5; }
.filters > label:nth-of-type(5n+4) { --fc: #ea580c; --fbg: #fff2e8; }
.filters > label:nth-of-type(5n+5) { --fc: #db2777; --fbg: #fdeef5; }
.filters > label input, .filters > label select {
  background: var(--fbg); border: 1.5px solid var(--fc); border-left-width: 4px;
  color: #1c2230; font-weight: 600;
}
.filters > label input:focus, .filters > label select:focus {
  background: #fff; border-color: var(--fc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fc) 22%, transparent);
}
.filters > .btn {
  background: linear-gradient(135deg, #ef4444, #db2777); color: #fff; border: 0; font-weight: 700;
  box-shadow: 0 2px 6px rgba(219, 39, 119, .3);
}
.filters > .btn:hover { filter: brightness(1.08); background: linear-gradient(135deg, #ef4444, #db2777); }
.filters > .muted.small {
  background: #1c2230; color: #fff; padding: 4px 12px; border-radius: 999px; font-weight: 700;
}

/* Row under the cursor: light blue with a blue strip on the left. */
tbody tr:hover > td { background: #dce8ff; }
tbody tr:hover > td:first-child { box-shadow: inset 4px 0 0 #2f5bea; }
@media (prefers-color-scheme: dark) {
  tbody tr:hover > td { background: #1f2d4d; }
}

/* Colourful summary boxes: each gets its own colour (blue → purple → teal → orange → pink). */
.cards > .card { --cc: #2563eb; --cbg1: #e8f0ff; --cbg2: #f5f8ff;
  background: linear-gradient(135deg, var(--cbg1), var(--cbg2));
  border: 1px solid color-mix(in srgb, var(--cc) 30%, transparent); border-top: 4px solid var(--cc);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--cc) 14%, transparent);
}
.cards > .card:nth-child(5n+2) { --cc: #7c3aed; --cbg1: #f1eaff; --cbg2: #faf7ff; }
.cards > .card:nth-child(5n+3) { --cc: #0d9488; --cbg1: #e2f6f2; --cbg2: #f5fcfa; }
.cards > .card:nth-child(5n+4) { --cc: #ea580c; --cbg1: #ffeedf; --cbg2: #fffaf5; }
.cards > .card:nth-child(5n+5) { --cc: #db2777; --cbg1: #fde8f2; --cbg2: #fff7fb; }
.cards > .card .label { color: var(--cc); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: 11.5px; }
.cards > .card .value { font-size: 24px; font-weight: 800; color: #1c2230; }
@media (prefers-color-scheme: dark) {
  .cards > .card { background: var(--surface); }
  .cards > .card .value { color: var(--text); }
}
.cards > .card-link:hover { transform: translateY(-2px); box-shadow: 0 8px 20px color-mix(in srgb, var(--cc) 25%, transparent); }
.cards > .card { transition: transform .15s, box-shadow .15s; }

/* Summary boxes: dark, rich colours with white text. */
.cards > .card { --cd1: #1e3a8a; --cd2: #2563eb;
  background: linear-gradient(135deg, var(--cd1), var(--cd2)); border: 0;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--cd1) 35%, transparent);
}
.cards > .card:nth-child(5n+2) { --cd1: #4c1d95; --cd2: #7c3aed; }
.cards > .card:nth-child(5n+3) { --cd1: #115e59; --cd2: #0d9488; }
.cards > .card:nth-child(5n+4) { --cd1: #9a3412; --cd2: #ea580c; }
.cards > .card:nth-child(5n+5) { --cd1: #9d174d; --cd2: #db2777; }
.cards > .card .label { color: rgba(255, 255, 255, .8); }
.cards > .card .value, .cards > .card .value .muted { color: #fff; }
.cards > .card .value .pos { color: #86efac; }
.cards > .card .value .neg { color: #fca5a5; }
.cards > .card-link:hover { box-shadow: 0 10px 22px color-mix(in srgb, var(--cd1) 45%, transparent); }
@media (prefers-color-scheme: dark) {
  .cards > .card { background: linear-gradient(135deg, var(--cd1), var(--cd2)); }
  .cards > .card .value { color: #fff; }
}

/* Settle & Clear (All): green. */
#settle-all { color: #fff; border-color: #14532d; background: #166534; font-weight: 700; }
#settle-all:hover { background: #14532d; }

/* + Win/Loss coins: dark red. */
#bulk-wl { color: #fff; border-color: #7f1d1d; background: #991b1b; font-weight: 700; }
#bulk-wl:hover { background: #7f1d1d; }

/* Sidebar "Master" group (Master ID Panel + 2 Way). */
.nav-group > summary { list-style: none; cursor: pointer; user-select: none; font-weight: 600; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-caret { margin-left: auto; font-size: 12px; transition: transform .15s; }
.nav-group:not([open]) .nav-caret { transform: rotate(-90deg); }
.nav-group .nav-sub { margin-left: 14px; padding-left: 12px; border-left: 2px solid rgba(0, 0, 0, .12); border-radius: 0 8px 8px 0; font-size: 13.5px; }
.nav-group .nav-sub.active { border-left-color: var(--primary); }
/* A folder inside a folder (Incoming → Results): its pages sit one step further in. */
.nav-group .nav-sub { white-space: nowrap; }
.nav-subgroup .nav-sub { margin-left: 24px; padding-left: 8px; font-size: 13px; }
.nav-subgroup > summary.nav-sub { margin-left: 14px; padding-left: 12px; font-size: 13.5px; }@media (max-width: 760px) {
  .nav-group { display: flex; align-items: center; }
  .nav-group .nav-sub { margin-left: 0; border-left: 0; border-radius: 8px; }
  .nav-caret { display: none; }
}

/* Dark summary boxes: all text pure white so it reads clearly on every colour. */
.cards > .card .label { color: #fff; opacity: .92; }
.cards > .card .value,
.cards > .card .value span[class] { color: #fff; font-weight: 800; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }

/* Agent History: TOTAL line in orange, white text. */
.hist-total td { background: #ea580c; color: #fff; font-weight: 800; font-size: 18px; letter-spacing: .02em; padding-top: 14px; padding-bottom: 14px; border-top: 2px solid #c2410c; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.hist-total td span[class] { color: #fff; font-weight: 800; }

/* Settlement Report: Net Profit / Loss line in orange, same as the Agent History total. */
tr.report-net > td, tbody tr.report-net:hover > td { background: #ea580c; color: #fff; font-weight: 800; font-size: 18px; letter-spacing: .02em; padding-top: 14px; padding-bottom: 14px; border-top: 2px solid #c2410c; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
tr.report-net > td span[class] { color: #fff; font-weight: 800; }
tr.report-net > td .muted { opacity: .85; font-weight: 600; }
tbody tr.report-net:hover > td:first-child { box-shadow: none; }

/* Settlement Report: colourful header, date rows and day buttons. */
.report-table thead tr { background: linear-gradient(90deg, #4338ca, #7c3aed 60%, #a21caf); }
.report-table thead th { background: transparent; color: #fff; font-size: 14px; font-weight: 800; letter-spacing: .03em; }
.date-group td, tbody tr.date-group:hover > td { background: linear-gradient(90deg, #dbeafe, #e0f2fe 60%, #f0f9ff); color: #1e3a8a; font-size: 14px; }
tbody tr.date-group > td:first-child, tbody tr.date-group:hover > td:first-child { box-shadow: inset 5px 0 0 #2563eb; }
.date-group .muted { color: #1d4ed8; opacity: .85; }
.date-group .day-edit { background: #f59e0b; border-color: #d97706; color: #fff; }
.date-group .day-edit:hover { background: #d97706; }
.date-group .btn.danger.day-del { background: #dc2626; border-color: #b91c1c; color: #fff; font-weight: 700; }
.date-group .btn.danger.day-del:hover { background: #b91c1c; }

/* PDF buttons: keep the gradient on hover (the plain .btn:hover was turning them pale). */
.btn.stmt-pdf:hover { background: linear-gradient(120deg, #4338ca, #6d28d9 55%, #be185d); color: #fff; box-shadow: 0 4px 12px rgba(124, 58, 237, .4); transform: translateY(-1px); }
.btn.stmt-pdf { transition: transform .15s, box-shadow .15s; }

/* Space between the balance amount and its Dr · Lena / Cr · Dena tag. */
.badge.dr, .badge.cr { margin-left: 10px; }

/* Blue sidebar: matching divider lines. */
.sidebar { border-right-color: #172554; }
.nav-bottom { border-top-color: rgba(255, 255, 255, .18); }
.nav-group .nav-sub { border-left-color: rgba(255, 255, 255, .25); }
@media (prefers-color-scheme: dark) {
  .sidebar { border-right-color: var(--border); }
  .nav-bottom { border-top-color: var(--border); }
}
/* Blue sidebar: white text, gold active item. */
.sidebar .brand { color: #fff; }
.sidebar .nav-link { color: #e6edfc; font-weight: 600; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.sidebar .nav-link.active { background: #e0b04a; color: #1f1400; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.nav-group .nav-sub.active { border-left-color: #e0b04a; }
@media (prefers-color-scheme: dark) {
  .sidebar .brand, .sidebar .nav-link { color: var(--text); }
}

/* Ledger: the line under each entry (e.g. "Paid to RAJU MASTER · Cucu/raju babu") in orange. */
.ledger-note { color: #ea580c; font-size: 15.5px; font-weight: 800; margin-top: 2px; }
.ledger-note .ledger-party { color: #000; font-weight: 400; font-size: 13.5px; }

/* Journal narration is always CAPITALS. */
.jv-line-narr { text-transform: uppercase; }

/* Journal form: Cr line all green, Dr line all red (row, party, narration and amount boxes). */
.jv-row.side-row-cr { background: #cdeedd; }
.jv-row.side-row-dr { background: #f8d4d4; }
.jv-row.side-row-cr td:first-child { box-shadow: inset 5px 0 0 #15803d; }
.jv-row.side-row-dr td:first-child { box-shadow: inset 5px 0 0 #b91c1c; }
.jv-row.side-row-cr .jv-party, .jv-row.side-row-cr .jv-line-narr, .jv-row.side-row-cr .jv-amt {
  background: #e6f7ee; border: 1.5px solid #4ca876; color: #14532d; font-weight: 700;
}
.jv-row.side-row-dr .jv-party, .jv-row.side-row-dr .jv-line-narr, .jv-row.side-row-dr .jv-amt {
  background: #fdeaea; border: 1.5px solid #d46a6a; color: #7f1d1d; font-weight: 700;
}
.jv-row.side-row-cr .jv-amt[readonly], .jv-row.side-row-dr .jv-amt[readonly] { opacity: .9; }
.jv-row.side-row-cr .jv-hint { color: #166534; }
.jv-row.side-row-dr .jv-hint { color: #991b1b; }
.jv-row.side-row-cr .jv-party-name { color: #14532d; }
.jv-row.side-row-dr .jv-party-name { color: #7f1d1d; }
@media (prefers-color-scheme: dark) {
  .jv-row.side-row-cr { background: #12392a; }
  .jv-row.side-row-dr { background: #3d1a1a; }
  .jv-row.side-row-cr .jv-party, .jv-row.side-row-cr .jv-line-narr, .jv-row.side-row-cr .jv-amt { background: #0f2e22; color: #bbf7d0; }
  .jv-row.side-row-dr .jv-party, .jv-row.side-row-dr .jv-line-narr, .jv-row.side-row-dr .jv-amt { background: #2e1414; color: #fecaca; }
}
/* "Amount" label beside the journal amount box. */
.jv-amt-label { display: block; font-size: 13px; font-weight: 800; letter-spacing: .03em; white-space: nowrap; }
.jv-amt-label-cr { text-align: right; color: #15803d; }
.jv-amt-label-dr { text-align: left; color: #b91c1c; }
/* Journal → New voucher: Quick grid (each row = one transfer) */
dialog.jg-modal { width: min(1200px, calc(100vw - 32px)); font-size: 15px; }
.jg-top { display: flex; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.jg-date { max-width: 220px; margin: 0; }
.jg-table { width: 100%; border-collapse: collapse; }
.jg-table thead th { background: #37f5eb; color: #000; font-weight: 700; padding: 7px 6px; text-align: left; font-size: 13px; }
.jg-table thead th.num { text-align: right; }
.jg-table td { padding: 4px; vertical-align: middle; }
.jg-table input { width: 100%; font-size: 15px; padding: 7px 9px; color: #000; font-weight: 600; }
.jg-table .jg-from, .jg-table .jg-to { min-width: 170px; font-weight: 700; }
.jg-table .jg-amt { min-width: 120px; text-align: right; font-weight: 800; }
.jg-table .jg-narr { min-width: 150px; }
.jg-table .jg-arrow { width: 22px; text-align: center; color: #7c3aed; font-weight: 800; font-size: 18px; }
.jg-table input.jg-cr { background: #e3f7ee; border-color: #7fcfa6; color: #0b6b3c; }
.jg-table input.jg-dr { background: #fff0e6; border-color: #f3b38a; color: #b23d0c; }
.jg-table input.jg-bad { background: #fdecec; border-color: #d11a1a; color: #b01e1e; }
.jg-table tr.jg-info td { padding: 0 6px 6px; font-size: 12px; color: #4a5160; }
.jg-table tr.jg-info[hidden] { display: none; }
.jg-table tfoot td { padding-top: 10px; }

/* Quick journal grid: From (Cr) green, To (Dr) red, Amount blue — header and boxes. Narration unchanged. */
.jg-table thead th:nth-child(1) { background: #15803d; color: #fff; }
.jg-table thead th:nth-child(3) { background: #b91c1c; color: #fff; }
.jg-table thead th:nth-child(4) { background: #1d4ed8; color: #fff; }
.jg-table input.jg-from { background: #dcfce7; border: 1.5px solid #16a34a; color: #14532d; }
.jg-table input.jg-to { background: #fee2e2; border: 1.5px solid #dc2626; color: #7f1d1d; }
.jg-table input.jg-amt { background: #dbeafe; border: 1.5px solid #2563eb; color: #1e3a8a; }
.jg-table input.jg-from:focus { box-shadow: 0 0 0 3px rgba(22, 163, 74, .25); outline: none; }
.jg-table input.jg-to:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .25); outline: none; }
.jg-table input.jg-amt:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, .25); outline: none; }
/* A party name that doesn't match anyone still shows the warning look. */
.jg-table input.jg-from.jg-bad, .jg-table input.jg-to.jg-bad { background: #fff7ed; border: 2px dashed #ea580c; color: #9a3412; }

/* Journal grid: party picker dropdown under From / To. */
.jg-pick {
  position: fixed; z-index: 1000; max-height: 260px; overflow-y: auto;
  background: #fff; border: 1.5px solid #94a3b8; border-radius: 8px; box-shadow: 0 10px 24px rgba(15, 23, 42, .22);
  padding: 4px 0; font-size: 14.5px;
}
.jg-pick[hidden] { display: none; }
.jg-pick-item { padding: 7px 12px; cursor: pointer; font-weight: 700; color: #1c2230; }
.jg-pick-item:hover { background: #eef2ff; }
.jg-pick-item.on { background: #2563eb; color: #fff; }
.jg-pick-none { padding: 8px 12px; color: #b91c1c; font-weight: 700; }
.jg-table input.jg-shake { animation: jg-shake .3s; border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220, 38, 38, .3) !important; }
@keyframes jg-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@media (prefers-color-scheme: dark) {
  .jg-pick { background: var(--surface); border-color: var(--border); }
  .jg-pick-item { color: var(--text); }
  .jg-pick-item:hover { background: var(--surface-2); }
}
/* ID / Master → Import Excel */
#import-wl { color: #fff; border-color: #0e7490; background: #0891b2; font-weight: 700; }
#import-wl:hover { background: #0e7490; }
.imp-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.imp-chip { background: #eef0f4; border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 13px; color: #374151; }
.imp-chip.ok { background: #e3f7e8; color: #0a6b2e; }
.imp-chip.warn { background: #fff4e0; color: #9a4d00; }
.imp-missing { background: #fff4e0; border: 1px solid #f3c27a; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; color: #6b3b00; }
.imp-missing .bulk-table { margin-top: 6px; }
.imp-res { font-weight: 800; padding: 2px 8px; border-radius: 6px; font-size: 12.5px; }
.imp-res.won { background: #e3f7e8; color: #0a6b2e; }
.imp-res.lost { background: #fde6e6; color: #a31515; }
.imp-now { color: #9a4d00; font-weight: 800; background: #fff4e0; padding: 1px 6px; border-radius: 6px; }
.imp-coins { font-weight: 800; }
.imp-coins.won { color: #0a6b2e; }
.imp-coins.lost { color: #c81e1e; }
/* Import popup: numbers in the middle of their column (headers too). */
.imp-table th.num, .imp-table td.num, .imp-table th:nth-child(5), .imp-table td:nth-child(5) { text-align: center; }
.imp-table tfoot td:first-child { text-align: right; }
#import-wl.has-pending { box-shadow: 0 0 0 3px #fca5a5; }
.pend-badge { display: inline-block; margin-left: 6px; background: #dc2626; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 800; animation: pend-pulse 1.4s ease-in-out infinite; }
@keyframes pend-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
/* Required box left empty: red outline until filled. */
#modal .need-fill { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220, 38, 38, .2) !important; background: #fff5f5; }
.imp-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.imp-file { background: #eef2ff; color: #3730a3; border-radius: 6px; padding: 3px 10px; font-size: 12.5px; font-weight: 700; }
.imp-file.bad { background: #fde6e6; color: #a31515; }
.imp-chip.bad { background: #fde6e6; color: #a31515; }
.imp-conflict { background: #fde6e6; border: 2px solid #dc2626; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; color: #7a1010; }
.imp-conflict .bulk-table { margin-top: 6px; }
#clear-wl { color: #fff; border-color: #475569; background: #64748b; font-weight: 700; }
#clear-wl:hover { background: #475569; }
.tot-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 800; color: #fff; background: #374151; }
.tot-tag.dr { background: #b91c1c; }
.tot-tag.cr { background: #15803d; }
.imp-choose { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 6px 0 4px; }
.imp-pick { border: 0; border-radius: 12px; padding: 22px 10px; font-size: 20px; font-weight: 800; color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.imp-pick span { font-size: 12.5px; font-weight: 600; opacity: .9; }
.imp-pick.pdf { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.imp-pick.xls { background: linear-gradient(135deg, #16a34a, #15803d); }
.imp-pick:hover { filter: brightness(1.08); transform: translateY(-1px); }
.imp-pick.both { grid-column: 1 / -1; background: linear-gradient(135deg, #4f46e5, #7c3aed 55%, #db2777); font-size: 17px; padding: 16px 10px; }
/* Ledger page totals: whole Dr line light red, whole Cr line light green, dark text. */
.ledger-total tr.tot-dr-row td { background: #fca5a5; color: #7f1d1d; border-top-color: #f87171; }
.ledger-total tr.tot-cr-row td { background: #86efac; color: #14532d; border-top-color: #4ade80; }
.ledger-total tr.tot-dr-row .tot-tag, .ledger-total tr.tot-cr-row .tot-tag { background: #fff; }
.ledger-total tr.tot-dr-row .tot-tag { background: #b91c1c; color: #fff; }
.ledger-total tr.tot-cr-row .tot-tag { background: #15803d; color: #fff; }
/* WhatsApp buttons */
.btn.wa-btn { background: #25d366; border-color: #1ebe57; color: #fff; font-weight: 700; }
.btn.wa-btn:hover { background: #1ebe57; }
.btn.wa-btn:disabled { background: #a7e8bf; border-color: #a7e8bf; }
.wa-mini { margin-left: 8px; border: 0; background: #25d366; color: #fff; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-size: 14px; vertical-align: middle; }
.wa-mini:hover { background: #1ebe57; }
.wa-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.wa-list { max-height: 55vh; overflow: auto; }
.wa-list tr.wa-sent td { background: #e3f7e8; }
.wa-list tr.wa-nophone td, .wa-list tr.wa-skip td { opacity: .5; }

/* Incoming → Playground → Add Bets */
.bet-box { padding: 14px 16px; margin-bottom: 14px; }
.bet-match { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.bet-match .field { margin: 0; min-width: 170px; }
.bet-vs { font-weight: 800; color: var(--muted); padding-bottom: 10px; }
.bet-entry { width: 100%; border-collapse: collapse; }
.bet-entry th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 6px 4px; }
.bet-entry td { padding: 0 6px; vertical-align: middle; }
.bet-entry select, .bet-entry input { width: 100%; min-width: 90px; }
.bet-entry td:last-child { width: 1%; }
.bet-lk { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.bet-lk.l { background: #dcfce7; color: #166534; }
.bet-lk.k { background: #fee2e2; color: #991b1b; }
@media (max-width: 760px) {
  .bet-entry thead { display: none; }
  .bet-entry tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .bet-entry td { padding: 0; }
  .bet-entry td:last-child { width: auto; grid-column: 1 / -1; }
  .bet-entry td:last-child .btn { width: 100%; }
}

/* Create Match: sessions */
.sess-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.sess-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-bottom: 12px; }
.sess-row { display: flex; gap: 6px; align-items: center; }
.sess-row input { flex: 1; min-width: 0; }
.sess-chip { display: inline-block; margin: 2px 4px 2px 0; padding: 2px 8px; border-radius: 999px; background: #e0e7ff; color: #3730a3; font-size: 12px; font-weight: 700; white-space: nowrap; }
.bet-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 12px; }
.bet-teams { font-size: 18px; }
.bet-head .bet-vs { padding: 0 4px; }

/* Add Bets list: compact */
.bet-list-wrap { overflow-x: auto; }
.bet-lk.s { background: #e0e7ff; color: #3730a3; }
.bet-entry select:disabled { opacity: .45; cursor: not-allowed; }
.bet-list { width: auto; min-width: 0; }
.bet-list th, .bet-list td { padding: 7px 14px; white-space: nowrap; }
/* Add Bets: Book total of each team, top right of the page */
.book-top { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; }
.book-top-label { align-self: center; font-weight: 700; color: var(--muted); }
.book-top-team { display: flex; flex-direction: column; align-items: center; min-width: 130px; padding: 8px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
.book-top-team > span { font-size: 12px; font-weight: 700; letter-spacing: .03em; color: var(--muted); }
.book-top-team strong { font-size: 20px; }
.bet-yn { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.bet-yn.y { background: #dcfce7; color: #166534; }
.bet-yn.n { background: #fee2e2; color: #991b1b; }
/* Add Bets: bets list on the left, Session Book in the space on the right */
.bet-split { display: flex; gap: 14px; align-items: flex-start; }
.bet-split > .panel:first-child { flex: 1 1 auto; min-width: 0; overflow-x: auto; }
.bet-split .bet-list { width: 100%; }
.sbook-panel { flex: 0 0 300px; padding: 12px 14px; }
@media (max-width: 900px) {
  .bet-split { flex-direction: column; align-items: stretch; }
  .bet-split > .panel:first-child { max-width: 100%; }
  .sbook-panel { flex-basis: auto; }
}
.sbook-title { font-weight: 700; margin-bottom: 8px; }
.sbook-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.sbook { width: 100%; }
.sbook td, .sbook th { padding: 6px 12px; }
.sbook td:first-child { font-weight: 600; }
.sbook-line { color: #3730a3; }
.sbook tr.sbook-best td { background: rgba(22, 163, 74, .10); }
.sbook tr.sbook-worst td { background: rgba(220, 38, 38, .10); }
/* Add Bets: the Book total sits in the centre of the heading line */
.page-head.bets-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.bets-head .book-top { justify-self: center; }
@media (max-width: 760px) {
  .page-head.bets-head { grid-template-columns: 1fr; }
  .bets-head .book-top { justify-self: start; }
}
.bet-head kbd { display: inline-block; padding: 0 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font: 600 12px/18px inherit; }
/* Add Bets: Match bet line and Session bet line */
.bet-line-title { font-size: 12.5px; font-weight: 800; letter-spacing: .03em; color: #166534; margin: 2px 6px 4px; }
.bet-line-title.sess { color: #3730a3; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.bet-entry.sess thead th { background: rgba(99, 102, 241, .08); }

/* Super Master panel */
#super[hidden], #view-banner[hidden] { display: none; }
.sm-wrap { max-width: 1200px; margin: 0 auto; padding: 22px 16px; }
.sm-table td, .sm-table th { white-space: nowrap; }
.sm-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.sm-badge.ok { background: #dcfce7; color: #166534; }
.sm-badge.bad { background: #fee2e2; color: #991b1b; }
.sm-badge.warn { background: #fef3c7; color: #92400e; }
/* Super Master viewing an ID: read-only strip on top */
#view-banner { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; background: #fef3c7; color: #78350f; border-bottom: 2px solid #f59e0b; font-size: 14px; }
body.read-only #edit-pin, body.read-only #change-password, body.read-only #create-super { display: none; }
/* .nav-link sets display, so the hidden attribute needs its own rule */
.nav-link[hidden] { display: none !important; }
/* ID / Master: ID Name, Agent and Master ID Panel take only the width they need */
.ids-table th:nth-child(2), .ids-table td:nth-child(2),
.ids-table th:nth-child(3), .ids-table td:nth-child(3),
.ids-table th:nth-child(4), .ids-table td:nth-child(4) { width: 1%; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
/* ID / Master: small colourful "E" (Edit Win/Loss) button; the space saved goes to CR */
.e-btn { width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer; font: 800 14px/30px inherit; color: #fff;
  background: linear-gradient(135deg, #f97316, #db2777 55%, #7c3aed); box-shadow: 0 2px 6px rgba(124, 58, 237, .35); transition: transform .12s, box-shadow .12s; }
.e-btn:hover { transform: scale(1.12); box-shadow: 0 3px 10px rgba(219, 39, 119, .45); }
.e-btn:disabled { opacity: .5; }
.ids-table th:last-child, .ids-table td:last-child { width: 1%; padding-left: 6px; padding-right: 10px; text-align: center; }
.ids-table th:nth-child(8), .ids-table td:nth-child(8) { min-width: 120px; white-space: nowrap; }

/* No explaining / help lines anywhere in the app (user's rule). Anything marked .hint is never shown. */
.hint { display: none !important; }
/* ID / Master: CR column centred, with a light tint down the whole column */
.ids-table th:nth-child(8), .ids-table tbody td:nth-child(8) { text-align: center; background: rgba(14, 165, 233, .10); }
.ids-table tbody tr:hover td:nth-child(8) { background: rgba(14, 165, 233, .16); }
/* Settlement Report: Master ID Panel share rows and the Net Profit after panels (shown only) */
.report-table tr.report-panel td { background: rgba(14, 165, 233, .08); font-size: 14px; font-weight: 600; }
.report-table tr.report-final td { background: #15803d; color: #fff; font-weight: 800; font-size: 16px; }
.report-table tr.report-final td .muted { color: rgba(255, 255, 255, .8); }
.report-table tr.report-final td .pos, .report-table tr.report-final td .neg { color: #fff; }
/* Settlement Report: clear gap between one date and the next */
.report-table tr.report-gap td, .report-table tbody tr.report-gap:hover td { height: 22px; padding: 0; background: var(--bg); border: 0; box-shadow: none; }
.report-table tbody:last-of-type tr.report-gap { display: none; }
