:root {
  --bg: #0f1320; --bg2: #161c2e; --panel: #1c2438; --panel2: #232c44;
  --line: #2c3650; --text: #e8ecf6; --muted: #94a0bd; --muted2: #6c7896;
  --brand: #4f7cff; --brand2: #23c4c9; --good: #36d399; --warn: #fbbd23; --bad: #f87272;
  --radius: 12px; --shadow: 0 6px 24px rgba(0,0,0,.28);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.num { font-family: var(--mono); text-align: right; white-space: nowrap; }

/* Buttons */
.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); padding: 8px 14px; border-radius: 9px; font-weight: 600; transition: .15s; }
.btn:hover { border-color: var(--brand); transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--brand), #6b5cff); border: none; color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.good { background: var(--good); color: #06301f; border: none; }
.btn.danger { color: var(--bad); border-color: #4a2a35; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(900px 500px at 70% -10%, #1d2742, var(--bg)); }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 36px; width: 360px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea { width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text); padding: 10px 12px; border-radius: 9px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 6px; }

/* App shell */
.shell { display: grid; grid-template-columns: 230px 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
.topbar { grid-column: 1 / 3; display: flex; align-items: center; gap: 14px; padding: 0 18px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -.02em; font-size: 16px; }
.brand .dot { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--brand), var(--brand2)); display: inline-block; }
.topbar .spacer { flex: 1; }
.pill { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; color: var(--text); }
.lang-toggle { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang-toggle button { background: var(--panel); border: none; color: var(--muted); padding: 6px 11px; font-weight: 700; font-size: 12px; }
.lang-toggle button.active { background: var(--brand); color: #fff; }

.sidebar { background: var(--bg2); border-right: 1px solid var(--line); padding: 12px 10px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel2); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.nav-item .badge { margin-left: auto; background: var(--warn); color: #3a2a00; border-radius: 20px; font-size: 11px; padding: 1px 7px; font-weight: 800; }
.nav-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted2); margin: 16px 12px 6px; }

.main { overflow-y: auto; padding: 22px 26px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 21px; }
.page-head .spacer { flex: 1; }

/* Cards / panels */
.grid { display: grid; gap: 14px; }
.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.stat { display: flex; justify-content: space-between; padding: 4px 0; color: var(--muted); }
.stat b { color: var(--text); font-family: var(--mono); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.tag.good { background: rgba(54,211,153,.16); color: var(--good); }
.tag.bad { background: rgba(248,114,114,.16); color: var(--bad); }
.tag.warn { background: rgba(251,189,35,.16); color: var(--warn); }
.tag.info { background: rgba(79,124,255,.16); color: var(--brand); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--bg2); z-index: 1; }
tr:hover td { background: var(--panel); }
.tbl-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 200px); }
td select { background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 7px; padding: 5px 7px; max-width: 230px; }
td.amt-in { color: var(--good); }
td.amt-out { color: var(--bad); }
.tb-total td { font-weight: 800; border-top: 2px solid var(--brand); background: var(--panel2); }

/* Dropzone */
.dropzone { border: 2px dashed var(--line); border-radius: 16px; padding: 44px; text-align: center; color: var(--muted); transition: .15s; background: var(--panel); }
.dropzone.over { border-color: var(--brand); background: var(--panel2); color: var(--text); }
.dropzone .big { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 6px; }

/* Toast + modal */
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--brand); padding: 11px 15px; border-radius: 9px; box-shadow: var(--shadow); max-width: 360px; animation: slidein .2s; }
.toast.good { border-left-color: var(--good); } .toast.bad { border-left-color: var(--bad); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(6,9,18,.6); display: grid; place-items: center; z-index: 40; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: 540px; max-width: 92vw; max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.right { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.help { background: var(--panel2); border-left: 3px solid var(--brand2); padding: 10px 13px; border-radius: 8px; color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: sp .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 50px; }
