:root {
  --charcoal: #1F262B;
  --slate: #2C353B;
  --green: #8DC63F;
  --green-deep: #2F5207;
  --green-link: #4A7A10;
  --bg: #F2F4F5;
  --line: #D5DADD;
  --line-soft: #E4E8EA;
  --field: #6B777E;
  --muted: #4B565D;
  --danger: #7A1C12;
  --font: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--charcoal); background: var(--bg); }
a { color: var(--green-link); }
a:hover { color: var(--green-deep); }
h1, h2 { margin: 0; font-weight: 600; }
button, input { font-family: inherit; }
:focus-visible { outline: 3px solid var(--charcoal); outline-offset: 2px; }
.sidebar :focus-visible, .auth-brand :focus-visible { outline-color: #fff; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 24px; border: 0; background: var(--green); color: var(--charcoal); font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: #7DB32F; color: var(--charcoal); }
.btn:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-quiet { min-height: 44px; border: 0; background: none; padding: 0; color: var(--green-link); font-size: 14px; text-decoration: underline; cursor: pointer; }
.btn-quiet:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label, .check label { font-size: 14px; font-weight: 500; }
.field input[type="text"], .field input[type="tel"], .field input[type="password"] { height: 48px; border: 1px solid var(--field); padding: 0 14px; font-size: 16px; background: #fff; min-width: 0; }
.phone-group { display: flex; height: 48px; border: 1px solid var(--field); background: #fff; }
.phone-group:focus-within { outline: 3px solid var(--charcoal); outline-offset: 2px; }
.phone-group .prefix { display: flex; align-items: center; padding: 0 14px; background: var(--bg); border-right: 1px solid var(--field); font-family: var(--mono); font-size: 15px; }
.phone-group input { flex: 1; min-width: 0; border: 0; padding: 0 14px; font-size: 16px; outline: none; background: transparent; }
.check { display: flex; align-items: flex-start; gap: 10px; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.msg { min-height: 20px; font-size: 14px; font-weight: 500; }
.msg.error { color: var(--danger); }
.hint { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* Login page */
.auth-page { display: flex; flex-wrap: wrap; min-height: 100vh; background: #fff; }
.auth-brand { flex: 1 1 440px; min-width: 0; background: var(--charcoal); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 48px; }
.auth-brand .brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 20px; letter-spacing: 0.02em; }
.auth-brand .kicker { font-family: var(--mono); font-size: 13px; letter-spacing: 0.12em; color: var(--green); }
.auth-brand h1 { font-size: 44px; line-height: 1.15; margin: 20px 0; max-width: 460px; }
.auth-brand p { margin: 0; font-size: 17px; line-height: 1.55; color: #C5CDD2; max-width: 460px; }
.auth-brand .legal { font-size: 13px; color: #9AA5AC; }
.auth-panel { flex: 1 1 440px; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 48px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); padding: 40px; display: flex; flex-direction: column; gap: 24px; }
.auth-card h2 { font-size: 26px; }
.auth-card[hidden], .step[hidden] { display: none; }
.step { display: flex; flex-direction: column; gap: 24px; }
.otp { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.otp input { height: 52px; min-width: 0; border: 1px solid var(--field); text-align: center; font-family: var(--mono); font-size: 22px; background: #fff; }
.row-between { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }

/* App shell */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar { flex: 0 0 248px; background: var(--charcoal); color: #fff; padding: 24px 12px; display: flex; flex-direction: column; gap: 32px; }
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 0 4px; font-weight: 600; font-size: 17px; }
.sidebar .nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; color: #C5CDD2; text-decoration: none; font-size: 15px; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; }
a.nav-link:hover, button.nav-link:hover { background: var(--slate); color: #fff; }
.nav-link[aria-current="page"] { background: var(--slate); color: var(--green); font-weight: 600; }
.nav-link.disabled { color: #9AA5AC; cursor: default; }
.signout { margin-top: auto; }
.main { flex: 999 1 560px; min-width: 0; padding: 32px 40px; display: flex; flex-direction: column; gap: 28px; }
.page-head h1 { font-size: 30px; }
.page-head p { margin: 4px 0 0; font-size: 15px; }
.card { background: #fff; border: 1px solid var(--line); padding: 24px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card h2 { font-size: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.kpi .label { font-size: 13px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.kpi .value { font-family: var(--mono); font-size: 26px; font-weight: 500; overflow-wrap: anywhere; }
.kpi.profit .value { color: var(--green-deep); }
.kpi.dark { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }
.kpi.dark .label { color: #9AA5AC; }
.kpi.dark .value { color: var(--green); }
.two-col { display: flex; flex-wrap: wrap; gap: 16px; }
.two-col > .wide { flex: 2 1 460px; }
.two-col > .narrow { flex: 1 1 280px; }
.chart { height: 240px; border: 1px dashed #9AA5AC; display: flex; align-items: stretch; gap: 14px; padding: 16px; }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar { width: 100%; background: var(--line); min-height: 2px; }
.bar.latest { background: var(--green); }
.bar-val { font-family: var(--mono); font-size: 12px; }
.bar-label { font-size: 12px; color: var(--muted); }
.pending-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px; }
.pending-row:last-child { border-bottom: 0; }
.chip { font-size: 12px; font-weight: 600; padding: 4px 10px; background: #FFF1C2; color: #5C4400; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 15px; }
th { text-align: left; background: var(--bg); padding: 10px 12px; font-weight: 600; }
td { padding: 12px; border-bottom: 1px solid var(--line-soft); }
th.num, td.num { text-align: right; font-family: var(--mono); }
td.profit { color: var(--green-deep); }
.banner { padding: 14px 16px; border: 1px solid var(--danger); background: #F6D6D2; color: var(--danger); font-size: 15px; font-weight: 500; }
.welcome-card { border-color: var(--charcoal); }

@media (max-width: 900px) {
  .sidebar { flex: 1 1 100%; padding: 16px; gap: 12px; }
  .sidebar .nav { flex-direction: row; flex-wrap: wrap; }
  .signout { margin-top: 0; width: auto; }
  .main { padding: 24px 16px; }
  .auth-brand { padding: 32px 24px; gap: 24px; }
  .auth-brand h1 { font-size: 32px; }
  .auth-card { padding: 28px 20px; }
}


/* Added for payments and payouts pages */
[hidden] { display: none !important; }
.head-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn-outline { background: #fff; border: 1px solid var(--charcoal); }
.btn-outline:hover { background: var(--bg); }
.field input[type="date"], .field input[type="file"] { height: 48px; border: 1px solid var(--field); padding: 0 14px; font-size: 16px; background: #fff; min-width: 0; }
.field input[type="file"] { padding: 10px 14px; height: auto; min-height: 48px; }
.form { display: flex; flex-direction: column; gap: 18px; }
.msg.ok { color: var(--green-deep); }
.chip.pending, .chip.requested { background: #FFF1C2; color: #5C4400; }
.chip.verified, .chip.approved { background: #DCEBC4; color: var(--green-deep); }
.chip.paid { background: var(--charcoal); color: var(--green); }
.chip.rejected { background: #F6D6D2; color: var(--danger); }
.reason { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }
details summary { cursor: pointer; color: var(--green-link); font-size: 14px; min-height: 24px; }
.shot { display: block; max-width: 100%; max-height: 420px; margin-top: 10px; border: 1px solid var(--line); }
.review { border: 1px solid var(--charcoal); padding: 16px; display: flex; flex-direction: column; gap: 14px; font-size: 15px; }
.review .actions { display: flex; flex-wrap: wrap; gap: 12px; }
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Added for ledger and support pages */
.chip.open { background: var(--line-soft); color: var(--slate); }
.chip.in_progress { background: #FFF1C2; color: #5C4400; }
.chip.resolved { background: #DCEBC4; color: var(--green-deep); }
.field select { height: 48px; border: 1px solid var(--field); padding: 0 12px; font-size: 16px; background: #fff; min-width: 0; }
.field textarea { border: 1px solid var(--field); padding: 12px 14px; font-size: 16px; font-family: inherit; min-height: 120px; resize: vertical; background: #fff; width: 100%; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { min-width: 180px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.pager .btn { min-height: 44px; padding: 0 16px; font-size: 14px; }
.link-btn { min-height: 44px; border: 0; background: none; padding: 0; color: var(--green-link); font-size: 15px; text-align: left; text-decoration: underline; cursor: pointer; }
.thread { display: flex; flex-direction: column; gap: 12px; }
.bubble { border: 1px solid var(--line); padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; }
.bubble.admin { background: #F2F8E8; border-color: #C9E0A3; }
.bubble-head { font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }

/* Added for account page and OTP dialog */
.notice { padding: 14px 16px; border: 1px solid var(--charcoal); background: #fff; font-size: 15px; }
.btn-danger { background: #fff; border: 2px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: #F6D6D2; color: var(--danger); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: 15px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.dialog { width: calc(100% - 32px); max-width: 420px; border: 1px solid var(--charcoal); padding: 28px; background: #fff; color: var(--charcoal); }
.dialog::backdrop { background: rgba(31, 38, 43, 0.6); }
.dialog h2 { font-size: 22px; }

/* Admin page */
#app.admin { display: block; }
.admin-bar { background: var(--charcoal); color: #fff; padding: 12px 24px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.admin-bar .brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 17px; }
.admin-bar a, .admin-bar button { color: #C5CDD2; background: none; border: 0; font-size: 15px; min-height: 44px; padding: 0 12px; cursor: pointer; text-decoration: none; }
.admin-bar a:hover, .admin-bar button:hover { color: #fff; text-decoration: underline; }
.admin-bar :focus-visible { outline-color: #fff; }
.admin .main { max-width: 1100px; margin: 0 auto; width: 100%; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { min-height: 44px; padding: 0 16px; border: 0; border-bottom: 3px solid transparent; background: none; font-size: 15px; cursor: pointer; color: var(--charcoal); }
.tab[aria-selected="true"] { border-bottom-color: var(--green); font-weight: 600; }
.item { border: 1px solid var(--line); background: #fff; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.item-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: baseline; }
.item-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.btn-sm { min-height: 44px; padding: 0 16px; font-size: 15px; }
.field-inline { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.field-inline label { font-size: 14px; font-weight: 500; }
.field-inline input, .field-inline select { height: 44px; border: 1px solid var(--field); padding: 0 12px; font-size: 15px; background: #fff; min-width: 0; }
.num-input { width: 140px; text-align: right; font-family: var(--mono); height: 44px; border: 1px solid var(--field); padding: 0 12px; font-size: 15px; background: #fff; }

/* Equity curve */
.range { display: flex; flex-wrap: wrap; gap: 8px; }
.range button { min-height: 44px; padding: 0 16px; border: 1px solid var(--field); background: #fff; font-size: 14px; cursor: pointer; }
.range button[aria-pressed="true"] { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }
.curve { position: relative; width: 100%; }
.curve svg { display: block; width: 100%; }
.tip { position: absolute; pointer-events: none; background: var(--charcoal); color: #fff; padding: 10px 12px; font-size: 13px; line-height: 1.5; min-width: 190px; z-index: 2; }
.tip strong { display: block; margin-bottom: 4px; }
.tip span { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); }
.legend { display: flex; flex-wrap: wrap; gap: 20px; font-size: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.dark .sub { color: #9AA5AC; }

.tip i { font-style: normal; }

.item textarea { border: 1px solid var(--field); padding: 12px 14px; font-size: 15px; font-family: var(--mono); width: 100%; background: var(--bg); resize: vertical; }
