:root {
  --bg: #0f1420;
  --surface: #171e2e;
  --surface-2: #1e2740;
  --line: #2a3350;
  --text: #e8edf7;
  --muted: #97a3bd;
  --brand: #5b8cff;
  --pos: #35c98a;
  --neg: #ff6b7d;
  --warn: #ffb648;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1c2a4d 0, transparent 60%), var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .8rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand a { font-weight: 800; font-size: 1.2rem; color: var(--text); letter-spacing: -.5px; }
.brand span { color: var(--brand); font-weight: 600; }
.topbar nav { display: flex; gap: .3rem; margin-left: .5rem; }
.topbar nav a { padding: .45rem .8rem; border-radius: 9px; color: var(--muted); font-weight: 500; }
.topbar nav a:hover { background: var(--surface-2); color: var(--text); }
.topbar nav a.active { color: var(--text); background: var(--surface-2); }
.btn-nav { background: var(--brand) !important; color: #fff !important; }
.who { margin-left: auto; display: flex; align-items: center; gap: .55rem; }
.who-name { font-size: .9rem; }
.logout { color: var(--muted); font-size: .82rem; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand);
  display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: .9rem;
}

.wrap { max-width: 980px; margin: 0 auto; padding: 1.5rem; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.hero p { margin: .3rem 0 0; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1.2rem; box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* balances */
.balances { display: flex; flex-direction: column; gap: .6rem; }
.bal-row { display: flex; align-items: center; gap: .7rem; padding: .55rem .2rem; border-bottom: 1px dashed var(--line); }
.bal-row:last-child { border-bottom: none; }
.bal-name { font-weight: 600; }
.bal-amt { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }
.tag { font-size: .7rem; padding: .12rem .5rem; border-radius: 20px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.tag.credit { background: rgba(53,201,138,.15); color: var(--pos); }
.tag.debit { background: rgba(255,107,125,.15); color: var(--neg); }
.tag.zero { background: var(--surface-2); color: var(--muted); }

/* transfers */
.transfers { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-direction: column; gap: .5rem; }
.transfers li { display: flex; align-items: center; gap: .5rem; background: var(--surface-2); padding: .6rem .8rem; border-radius: 10px; flex-wrap: wrap; }
.t-from { font-weight: 600; }
.t-arrow { color: var(--muted); font-size: .85rem; }
.t-to { font-weight: 600; color: var(--brand); }
.t-amt { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.inline-settle { margin: 0; }
.empty { color: var(--muted); padding: .5rem 0; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
.tbl td { padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.mv { font-variant-numeric: tabular-nums; font-size: .84rem; }
.meta-line { display: flex; gap: .5rem; flex-wrap: wrap; color: var(--muted); font-size: .78rem; margin-top: .25rem; }
.meta-line span { background: var(--surface-2); padding: .05rem .45rem; border-radius: 6px; }

.chip { font-size: .72rem; font-weight: 600; padding: .18rem .55rem; border-radius: 20px; white-space: nowrap; }
.chip-DIRECT_SALE { background: rgba(91,140,255,.18); color: #9db9ff; }
.chip-JOINT_DEAL { background: rgba(53,201,138,.16); color: #6be0ae; }
.chip-PAYMENT { background: rgba(255,182,72,.16); color: var(--warn); }
.chip-ADJUSTMENT { background: var(--surface-2); color: var(--muted); }
.chip-STOCK_PURCHASE { background: rgba(53,201,138,.16); color: #6be0ae; }
.chip-STOCK_SALE { background: rgba(91,140,255,.18); color: #9db9ff; }
.chip-SUPPLIER_PAYMENT { background: rgba(255,182,72,.16); color: var(--warn); }
.field-label { font-size: .82rem; color: var(--muted); font-weight: 600; }

/* forms */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; color: var(--muted); font-weight: 600; }
input, select { background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: .55rem .65rem; border-radius: 9px; font-size: .95rem; font-family: inherit; }
input:focus, select:focus { outline: none; border-color: var(--brand); }
.row { display: flex; gap: .9rem; flex-wrap: wrap; margin-bottom: 1rem; }
.row > label { flex: 1; min-width: 130px; }
.row > label.grow { flex: 2; }
fieldset { border: none; padding: 0; margin: 0 0 1rem; }
.hint { font-size: .83rem; color: var(--muted); background: var(--surface-2); padding: .5rem .7rem; border-radius: 9px; border-left: 3px solid var(--brand); }

.type-tabs { display: flex; gap: .5rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.type-tab { position: relative; }
.type-tab input { position: absolute; opacity: 0; }
.type-tab span { display: block; padding: .55rem 1rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: .88rem; color: var(--muted); }
.type-tab input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }

.split-tbl { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.split-tbl th { font-size: .75rem; color: var(--muted); text-align: left; padding: .3rem .4rem; font-weight: 600; }
.split-tbl td { padding: .3rem .4rem; }
.split-tbl td:first-child { font-weight: 600; color: var(--text); font-size: .9rem; white-space: nowrap; }
.split-tbl input { width: 100%; }

.actions { display: flex; gap: .7rem; align-items: center; margin-top: .5rem; }
.btn-primary { background: var(--brand); color: #fff; border: none; padding: .65rem 1.3rem; border-radius: 10px; font-weight: 700; font-size: .95rem; cursor: pointer; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { color: var(--muted); padding: .65rem 1rem; }
.btn-mini { background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: .72rem; padding: .25rem .55rem; border-radius: 7px; cursor: pointer; }
.btn-mini:hover { color: var(--text); border-color: var(--brand); }
.btn-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .95rem; padding: .2rem .4rem; border-radius: 6px; }
.btn-del:hover { color: var(--neg); background: rgba(255,107,125,.1); }
.btn-edit { color: var(--muted); font-size: .95rem; padding: .2rem .4rem; border-radius: 6px; text-decoration: none; }
.btn-edit:hover { color: var(--brand); background: var(--surface-2); }
.inline-settle { display: inline; margin: 0; }
.avatar.sm { width: 24px; height: 24px; font-size: .78rem; vertical-align: middle; margin-right: .3rem; }
.bal-tbl td, .bal-tbl th { padding: .6rem .6rem; }
.bal-tbl .tag { margin-left: .4rem; }
.link { font-size: .85rem; }

/* import / dropzone */
.import-box { border: 1px dashed var(--line); }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 1.6rem; text-align: center; cursor: pointer; transition: .15s; background: var(--bg); }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--surface-2); }
.dropzone p { margin: .2rem 0; }
.extract-status { margin-top: .8rem; font-size: .9rem; min-height: 1.2rem; }
.extract-status.loading { color: var(--brand); }
.extract-status.ok { color: var(--pos); }
.extract-status.warn { color: var(--warn); }

.alert { background: rgba(255,107,125,.12); border: 1px solid var(--neg); color: #ffb0ba; padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; }

/* stock accounts */
.link-row { background: var(--surface-2); padding: .8rem; border-radius: 10px; }
.acct-info { font-size: .85rem; margin: -.3rem 0 .9rem; min-height: 1rem; color: var(--muted); }
.chip-buy { background: rgba(53,201,138,.16); color: #6be0ae; }
.chip-sell { background: rgba(91,140,255,.18); color: #9db9ff; }
.profit-badge { display: flex; flex-direction: column; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .6rem 1rem; }
.profit-badge > span:last-child { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.acct-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.acct-head h2 { font-size: 1.05rem; }
.acct-stats { display: flex; gap: 1.4rem; }
.stat { display: flex; flex-direction: column; align-items: flex-end; }
.stat strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.warn-line { background: rgba(255,182,72,.12); border-left: 3px solid var(--warn); color: #ffcf85; padding: .5rem .7rem; border-radius: 8px; font-size: .85rem; margin: .3rem 0 .8rem; }
input[readonly] { opacity: .75; cursor: not-allowed; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 2.2rem; width: min(380px, 92vw); box-shadow: var(--shadow); }
.login-brand { font-size: 1.8rem; font-weight: 800; text-align: center; }
.login-brand span { color: var(--brand); }
.login-sub { text-align: center; color: var(--muted); font-size: .85rem; margin: .2rem 0 1.5rem; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; }
.login-card .btn-primary { margin-top: .5rem; }

/* password rules checklist */
.pw-rules { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .25rem; }
.pw-rules li { font-size: .82rem; color: var(--muted); }
.pw-rules li.ok { color: var(--pos); }
.pw-rules .mark { display: inline-block; width: 1.1rem; font-weight: 700; }
.pw-match { font-size: .82rem; margin: 0; min-height: 1rem; }
.pw-match.ok { color: var(--pos); }
.pw-match.bad { color: var(--neg); }
