/* Цагаан суурьтай, шилэн (glass) загвар */
:root {
  --bg: #eef1f7; --card: rgba(255,255,255,.72); --solid: #ffffff; --text: #16202e; --muted: #64748b;
  --line: rgba(255,255,255,.85); --edge: rgba(148,163,184,.28);
  --accent: #2563eb; --accent-soft: rgba(37,99,235,.10); --danger: #dc2626; --ok: #16a34a;
  --side: rgba(255,255,255,.70); --side-text: #334155;
  --shadow: 0 10px 30px rgba(15,23,42,.08), 0 2px 6px rgba(15,23,42,.04);
  --blur: saturate(1.6) blur(18px);
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vw 60vw at 8% 0%, rgba(99,102,241,.38), transparent 60%),
    radial-gradient(50vw 50vw at 95% 10%, rgba(236,72,153,.28), transparent 60%),
    radial-gradient(60vw 60vw at 70% 95%, rgba(34,197,94,.26), transparent 60%),
    radial-gradient(40vw 40vw at 20% 90%, rgba(251,146,60,.28), transparent 60%); }
[hidden] { display: none !important; }
a { color: var(--accent); }
input, select, button, textarea { font: inherit; color: inherit; }
input, select, textarea { background: rgba(255,255,255,.75); border: 1px solid var(--edge); border-radius: 9px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
button { cursor: pointer; border: 1px solid var(--edge); background: rgba(255,255,255,.8); border-radius: 9px; padding: 7px 13px;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); transition: transform .08s, box-shadow .15s; }
button:hover { box-shadow: var(--shadow); }
button:active { transform: translateY(1px); }
button.primary { background: linear-gradient(135deg, #3b82f6, #2563eb); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 6px 18px rgba(37,99,235,.35); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: inherit; text-decoration: underline; padding: 0; backdrop-filter: none; }
button.icon { border: 0; background: none; font-size: 20px; padding: 4px 8px; backdrop-filter: none; }
.muted { color: var(--muted); } .error { color: var(--danger); min-height: 1em; } .ok { color: var(--ok); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); }

#auth { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px 120px; background: #050505; color: #fff; overflow: hidden; font-family: Poppins, system-ui, sans-serif; }
#auth .auth-bg { position: absolute; inset: 0; background: url(login-bg2.png) center 35%/cover no-repeat; opacity: .85;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 38%, #000 35%, transparent 80%); mask-image: radial-gradient(ellipse 70% 60% at 50% 38%, #000 35%, transparent 80%); }
#auth .auth-wrap { position: relative; z-index: 2; display: grid; justify-items: center; gap: 14px; width: 100%; max-width: 560px; }
#auth .pill { font-size: 12px; padding: 6px 14px; border-radius: 999px; background: #ffffff14; border: 1px solid #ffffff33; backdrop-filter: blur(8px); }
#auth .hero { margin: 0 0 -34px; font-size: clamp(40px, 8vw, 72px); font-weight: 700; letter-spacing: -0.04em; line-height: 1; text-align: center;
  background: linear-gradient(180deg, #fff 55%, #ffffff66); -webkit-background-clip: text; background-clip: text; color: transparent; position: relative; z-index: 1; }
.auth-card { width: 100%; display: grid; gap: 12px; padding: 44px 36px 32px; text-align: center; position: relative; z-index: 2;
  background: #ffffff0f; backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border: 1px solid #ffffff2e; border-radius: 26px; box-shadow: inset 0 1px 0 #ffffff26, 0 30px 80px #000a; color: #fff; }
.auth-card h2 { margin: 0; font-weight: 400; font-size: 26px; }
.auth-card .muted { color: #ffffffa6; margin: 0 0 6px; font-size: 13px; }
.auth-card label { color: #ffffff99; text-align: left; font-size: 12px; padding-left: 14px; }
.auth-card input { background: #0000004d; border: 1px solid #ffffff26; color: #fff; border-radius: 999px; padding: 11px 18px; }
.auth-card input:focus { outline: none; border-color: #ff8a3d; box-shadow: 0 0 0 3px #ff8a3d33; }
.auth-card button.primary { justify-self: center; background: #fff; color: #111; border: 0; border-radius: 999px; font-weight: 600; padding: 11px 34px; margin-top: 6px; box-shadow: 0 8px 30px #ffffff26; }
.auth-card button.primary:hover { background: #ffe8d6; }
.auth-card .error { color: #ffb4a0; margin: 0; }
#auth .auth-foot { font-size: 12px; color: #ffffff80; margin: 8px 0 0; }
#auth .giant { position: absolute; left: 50%; bottom: -0.22em; transform: translateX(-50%); z-index: 1; white-space: nowrap; pointer-events: none;
  font-size: clamp(90px, 22vw, 300px); font-weight: 600; letter-spacing: -0.04em; line-height: 1; color: transparent;
  -webkit-text-stroke: 1px #ffffff22; background: linear-gradient(180deg, #ffffff14, transparent 80%); -webkit-background-clip: text; background-clip: text; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); font-size: 14px; }

#app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
#side { background: var(--side); color: var(--side-text); padding: 16px 12px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-right: 1px solid var(--line); }
#side .brand { font-weight: 700; font-size: 17px; color: var(--text); padding: 2px 8px; letter-spacing: -.02em; }
#side select { background: rgba(255,255,255,.75); color: var(--text); border-color: var(--edge); }
#nav { display: grid; gap: 2px; }
#nav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; opacity: .55; margin: 10px 8px 2px; }
#nav a { color: var(--side-text); text-decoration: none; padding: 7px 10px; border-radius: 6px; }
#nav a:hover { background: rgba(255,255,255,.75); }
#nav a.active { background: linear-gradient(135deg, rgba(59,130,246,.16), rgba(99,102,241,.12)); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px rgba(37,99,235,.18); }
.me { margin-top: auto; display: flex; justify-content: space-between; gap: 8px; padding: 10px 8px; font-size: 13px; border-top: 1px solid var(--edge); }
main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.top h2 { margin: 0; font-size: 19px; flex: 1; letter-spacing: -.02em; }
.period { display: flex; align-items: center; gap: 6px; }
#menuBtn { display: none; }
#view { padding: 22px; display: grid; gap: 18px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .grow { flex: 1; }
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--edge); text-align: left; white-space: nowrap; }
th { background: rgba(255,255,255,.82); backdrop-filter: var(--blur); font-weight: 600; position: sticky; top: 0; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
td.n, th.n { text-align: right; }
td.wrap { white-space: normal; min-width: 200px; }
tr.l0 td { font-weight: 700; background: var(--accent-soft); }
tr.l1 td { font-weight: 600; }
tr.l2 td:nth-child(2) { padding-left: 28px; color: var(--muted); }
tr.total td { font-weight: 700; border-top: 2px solid var(--text); }
tbody tr:hover { background: rgba(255,255,255,.6); }
tr.click { cursor: pointer; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat .v { font-size: 23px; letter-spacing: -.02em; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; overflow-x: auto; }
.bars .m { display: grid; justify-items: center; gap: 4px; font-size: 11px; color: var(--muted); min-width: 44px; }
.bars .pair { display: flex; align-items: flex-end; gap: 3px; height: 150px; }
.bars .b { width: 14px; border-radius: 3px 3px 0 0; }
.b.rev { background: linear-gradient(180deg,#60a5fa,#2563eb); } .b.exp { background: linear-gradient(180deg,#fbbf24,#f59e0b); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }

dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; background: rgba(255,255,255,.88); color: var(--text); width: min(640px, calc(100vw - 32px));
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: 0 30px 70px rgba(15,23,42,.25); }
dialog::backdrop { background: rgba(15,23,42,.35); backdrop-filter: blur(3px); }
#dlgForm { padding: 18px; display: grid; gap: 12px; }
#dlgForm h3 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(22,32,46,.92); color: #fff; backdrop-filter: blur(8px); padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); border: 1px solid rgba(37,99,235,.18); }
.warn { border-left: 4px solid #f59e0b; }

@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; }
  #side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  #side.open { transform: none; }
  #menuBtn { display: block; }
  #view { padding: 16px; }
  .top { padding: 10px 16px; }
  .grid2 { grid-template-columns: 1fr; }
}

.refs { display: grid; gap: 14px; }
.ref { padding: 14px 16px; border: 1px solid var(--edge); border-radius: 13px; display: grid; gap: 6px; background: rgba(255,255,255,.55); }
.ref-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ref-act { margin-left: auto; display: flex; gap: 10px; font-size: 12px; }
.ref a { font-size: 12px; word-break: break-all; }
.ref textarea, #dlgForm textarea { resize: vertical; }

.subbar { padding: 11px 22px; font-size: 13px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.7); backdrop-filter: var(--blur); }
.subbar.warnbar { background: rgba(245,158,11,.18); border-bottom-color: rgba(245,158,11,.4); }
.subbar.danger { background: rgba(220,38,38,.15); border-bottom-color: rgba(220,38,38,.35); }

/* Ачаалж байгааг харуулах нимгэн зураас */
body.loading::after { content: ""; position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 99;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: load 1s linear infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
