/* =====================================================================
   Market Panel — glass UI
   ===================================================================== */
:root {
    --bg:        #070a16;
    --bg-2:      #0b1020;
    --glass:     rgba(21, 27, 51, 0.55);
    --glass-2:   rgba(30, 38, 68, 0.45);
    --stroke:    rgba(148, 163, 220, 0.16);
    --stroke-2:  rgba(148, 163, 220, 0.28);
    --text:      #e6ebff;
    --muted:     #8e99c4;
    --primary:   #7c5cff;
    --primary-2: #a78bfa;
    --success:   #23d18b;
    --danger:    #ff5f7a;
    --warn:      #ffb545;
    --radius:    18px;
    --radius-sm: 12px;
    --shadow:    0 24px 60px -20px rgba(0, 0, 0, 0.75);
    --font:      "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono:      "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

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

h1, h2, h3, h4 { margin: 0 0 .6rem; font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: 1.5rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .92rem; margin-top: 1.1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
p  { margin: 0 0 .7rem; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.hidden { display: none !important; }
code, .mono { font-family: var(--mono); font-size: .86em; }

/* ---------------------------------------------------------- background */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; background:
    radial-gradient(1200px 700px at 12% -10%, #15204a 0%, transparent 60%),
    radial-gradient(900px 600px at 95% 5%, #2a1550 0%, transparent 55%),
    linear-gradient(180deg, #080b18 0%, #060810 100%); }
.aurora span {
    position: absolute; border-radius: 50%; filter: blur(90px); opacity: .42;
    animation: drift 24s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) { width: 480px; height: 480px; left: -80px; top: 8%;  background: #5b3df5; }
.aurora span:nth-child(2) { width: 420px; height: 420px; right: -60px; top: 32%; background: #1f6feb; animation-delay: -8s; }
.aurora span:nth-child(3) { width: 520px; height: 520px; left: 35%; bottom: -220px; background: #9333ea; animation-delay: -15s; }
@keyframes drift {
    from { transform: translate3d(0,0,0) scale(1); }
    to   { transform: translate3d(40px,-30px,0) scale(1.12); }
}

/* -------------------------------------------------------------- glass */
.glass {
    background: var(--glass);
    border: 1px solid var(--stroke);
    backdrop-filter: blur(22px) saturate(130%);
    -webkit-backdrop-filter: blur(22px) saturate(130%);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

/* --------------------------------------------------------------- auth */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card { width: min(420px, 100%); padding: 34px 30px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head h1 { margin: .4rem 0 .2rem; }
.auth-foot { margin: 18px 0 0; text-align: center; font-size: .78rem; }
.logo {
    display: inline-grid; place-items: center; width: 56px; height: 56px; font-size: 26px;
    border-radius: 16px; background: linear-gradient(145deg, rgba(124,92,255,.35), rgba(124,92,255,.08));
    border: 1px solid var(--stroke-2);
}

/* -------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 262px 1fr; gap: 20px; padding: 20px; min-height: 100vh; }

.sidebar { position: sticky; top: 20px; height: calc(100vh - 40px); padding: 20px 16px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 18px; }
.brand .logo { width: 42px; height: 42px; font-size: 20px; border-radius: 13px; }
.brand strong { display: block; font-size: 1.05rem; }
.brand small { display: block; font-size: .72rem; }

.nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
    background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
    color: var(--muted); font: inherit; font-size: .91rem; text-align: left; cursor: pointer;
    transition: .18s ease;
}
.nav-item span { font-size: 1rem; width: 20px; text-align: center; }
.nav-item:hover { background: var(--glass-2); color: var(--text); }
.nav-item.active {
    background: linear-gradient(100deg, rgba(124,92,255,.26), rgba(124,92,255,.06));
    border-color: rgba(124,92,255,.45); color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.nav-item .badge {
    margin-left: auto; font-style: normal; font-size: .72rem; padding: 1px 7px;
    border-radius: 999px; background: var(--danger); color: #fff; display: none;
}
.nav-item .badge.on { display: inline-block; }

.sidebar-foot { padding-top: 14px; border-top: 1px solid var(--stroke); }
.who { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.who strong { display: block; font-size: .9rem; }
.who small { display: block; font-size: .72rem; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--glass-2); border: 1px solid var(--stroke); }

/* --------------------------------------------------------------- main */
.main { min-width: 0; display: flex; flex-direction: column; gap: 18px; padding-bottom: 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 22px; }
.topbar h1 { margin: 0; }
.topbar p { margin: 0; font-size: .84rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.pill {
    font-size: .76rem; padding: 5px 11px; border-radius: 999px;
    background: var(--glass-2); border: 1px solid var(--stroke); color: var(--muted);
    white-space: nowrap;
}
.pill.on  { color: #c9ffe8; border-color: rgba(35,209,139,.45); background: rgba(35,209,139,.14); }
.pill.off { color: #ffd0d8; border-color: rgba(255,95,122,.45); background: rgba(255,95,122,.14); }

.view { display: none; flex-direction: column; gap: 18px; }
.view.active { display: flex; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* -------------------------------------------------------------- cards */
.card { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h3 { margin: 0; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid.gap { gap: 14px; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(188px, 1fr)); }
.span2 { grid-column: 1 / -1; }

.stat {
    padding: 16px 18px; border-radius: var(--radius-sm);
    background: var(--glass); border: 1px solid var(--stroke); backdrop-filter: blur(16px);
    position: relative; overflow: hidden;
}
.stat::after {
    content: ''; position: absolute; inset: auto -30% -70% auto; width: 160px; height: 160px;
    background: radial-gradient(circle, rgba(124,92,255,.22), transparent 70%);
}
.stat b { display: block; font-size: 1.6rem; font-weight: 680; letter-spacing: -0.02em; }
.stat small { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; }
.stat i { font-style: normal; font-size: .76rem; color: var(--muted); }
.stat.good b { color: #7ef0bd; }
.stat.warn b { color: var(--warn); }

/* --------------------------------------------------------------- rows */
.row { display: flex; align-items: center; gap: 10px; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* -------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .82rem; color: var(--muted); }
.field.compact { max-width: 240px; }
input, select, textarea {
    width: 100%; padding: 10px 13px; font: inherit; font-size: .92rem; color: var(--text);
    background: rgba(10, 14, 30, 0.6); border: 1px solid var(--stroke);
    border-radius: var(--radius-sm); outline: none; transition: .16s ease;
}
input[type="file"] { padding: 7px 10px; color: var(--muted); }
textarea { resize: vertical; font-family: var(--mono); font-size: .86rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
    border-color: rgba(124,92,255,.7);
    box-shadow: 0 0 0 3px rgba(124,92,255,.16);
    background: rgba(12, 17, 36, 0.8);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input::placeholder, textarea::placeholder { color: #5d6894; }

.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: .88rem; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle span {
    width: 40px; height: 22px; border-radius: 999px; background: rgba(10,14,30,.8);
    border: 1px solid var(--stroke); position: relative; transition: .2s ease; flex: none;
}
.toggle span::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    border-radius: 50%; background: var(--muted); transition: .2s ease;
}
.toggle input:checked + span { background: rgba(124,92,255,.35); border-color: rgba(124,92,255,.7); }
.toggle input:checked + span::after { left: 20px; background: #fff; }

/* ------------------------------------------------------------ buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 10px 16px; font: inherit; font-size: .89rem; font-weight: 550;
    border-radius: var(--radius-sm); border: 1px solid var(--stroke-2);
    background: var(--glass-2); color: var(--text); cursor: pointer;
    transition: .16s ease; white-space: nowrap; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(167,139,250,.6); }
.btn:active { transform: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, #7c5cff, #5b3df5); border-color: transparent; color: #fff;
    box-shadow: 0 10px 26px -12px rgba(124,92,255,.9); }
.btn.success { background: linear-gradient(135deg, #22c98a, #15a06c); border-color: transparent; color: #04140d; }
.btn.danger  { background: rgba(255,95,122,.14); border-color: rgba(255,95,122,.45); color: #ffc4ce; }
.btn.danger:hover { background: rgba(255,95,122,.22); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.tiny { padding: 5px 10px; font-size: .78rem; border-radius: 9px; }

/* ------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 4px -6px 0; padding: 0 6px; }
.table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.table th {
    text-align: left; padding: 9px 10px; font-size: .74rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
    border-bottom: 1px solid var(--stroke); white-space: nowrap;
}
.table td { padding: 11px 10px; border-bottom: 1px solid rgba(148,163,220,.08); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: .14s ease; }
.table tbody tr:hover { background: rgba(124,92,255,.07); }
.table td input, .table td select { padding: 7px 10px; font-size: .85rem; }
.table .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.table .nowrap { white-space: nowrap; }

.tag {
    display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem;
    border: 1px solid var(--stroke-2); background: var(--glass-2); color: var(--muted); white-space: nowrap;
}
.tag.ok      { color: #9bf3cf; border-color: rgba(35,209,139,.4);  background: rgba(35,209,139,.12); }
.tag.bad     { color: #ffc0cd; border-color: rgba(255,95,122,.4);  background: rgba(255,95,122,.12); }
.tag.wait    { color: #ffd79a; border-color: rgba(255,181,69,.4);  background: rgba(255,181,69,.12); }
.tag.info    { color: #bfd4ff; border-color: rgba(96,165,250,.4);  background: rgba(96,165,250,.12); }

/* ---------------------------------------------------------- key/value */
.kv { display: grid; gap: 7px; margin: 6px 0 14px; font-size: .87rem; }
.kv div { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 6px; border-bottom: 1px dashed rgba(148,163,220,.12); }
.kv div:last-child { border-bottom: none; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; word-break: break-all; }

/* --------------------------------------------------------------- list */
.list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.list-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    background: var(--glass-2); border: 1px solid var(--stroke); cursor: pointer; transition: .16s ease;
}
.list-item:hover { border-color: rgba(167,139,250,.5); transform: translateX(2px); }
.list-item.selected { border-color: rgba(124,92,255,.8); background: rgba(124,92,255,.14); }
.list-item strong { font-size: .92rem; display: block; }
.list-item small { color: var(--muted); font-size: .78rem; }

/* --------------------------------------------------------------- logs */
.loglist { display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow-y: auto; font-size: .84rem; }
.logrow { display: grid; grid-template-columns: 150px 170px 1fr; gap: 12px; padding: 8px 12px;
    border-radius: 10px; background: rgba(10,14,30,.4); border: 1px solid rgba(148,163,220,.08); }
.logrow time { color: var(--muted); font-family: var(--mono); font-size: .78rem; }
.logrow b { font-weight: 600; font-size: .8rem; }
.logrow span { color: #c6cdeb; word-break: break-word; }
.logrow.error { border-color: rgba(255,95,122,.35); background: rgba(255,95,122,.08); }
.logrow.error b { color: #ffb3c0; }
.logrow.warn  { border-color: rgba(255,181,69,.3); background: rgba(255,181,69,.07); }
.logrow.warn b { color: #ffd79a; }

/* -------------------------------------------------------------- pager */
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pager button { padding: 6px 12px; font-size: .82rem; border-radius: 9px; border: 1px solid var(--stroke); background: var(--glass-2); color: var(--muted); cursor: pointer; }
.pager button.active { background: rgba(124,92,255,.25); border-color: rgba(124,92,255,.6); color: #fff; }
.pager span { color: var(--muted); font-size: .82rem; }

/* ------------------------------------------------------------- alerts */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: .86rem; border: 1px solid var(--stroke-2); }
.alert.error { background: rgba(255,95,122,.12); border-color: rgba(255,95,122,.45); color: #ffc8d2; }
.alert.ok    { background: rgba(35,209,139,.12); border-color: rgba(35,209,139,.45); color: #a8f5d6; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; font-size: .88rem; }
.checklist li { display: flex; align-items: center; gap: 10px; }
.checklist li::before { content: '•'; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 6px; background: var(--glass-2); border: 1px solid var(--stroke); font-size: .8rem; }
.checklist li.ok::before { content: '✓'; color: #7ef0bd; border-color: rgba(35,209,139,.45); }
.checklist li.bad::before { content: '!'; color: #ffb3c0; border-color: rgba(255,95,122,.45); }

details.bulk { margin: 14px 0 4px; padding: 12px 14px; border-radius: var(--radius-sm);
    background: rgba(10,14,30,.4); border: 1px solid var(--stroke); }
details.bulk summary { cursor: pointer; color: var(--muted); font-size: .86rem; }
details.bulk textarea { margin: 12px 0 10px; }

.secret { display: block; padding: 11px 14px; border-radius: var(--radius-sm); background: rgba(10,14,30,.7);
    border: 1px solid var(--stroke); font-family: var(--mono); font-size: .9rem; word-break: break-all; }

/* ------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast {
    min-width: 240px; max-width: 360px; padding: 12px 16px; border-radius: var(--radius-sm);
    background: rgba(18,24,46,.92); border: 1px solid var(--stroke-2); color: var(--text);
    box-shadow: var(--shadow); font-size: .87rem; backdrop-filter: blur(14px);
    animation: slidein .22s ease;
}
.toast.ok    { border-color: rgba(35,209,139,.6); }
.toast.error { border-color: rgba(255,95,122,.6); }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* -------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
    background: rgba(4,6,14,.72); backdrop-filter: blur(6px); }
.modal-card { width: min(640px, 100%); max-height: 86vh; overflow-y: auto; padding: 22px 24px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1000px) {
    .shell { grid-template-columns: 1fr; padding: 14px; }
    .sidebar { position: static; height: auto; }
    .nav { flex-direction: row; overflow-x: auto; }
    .nav-item { white-space: nowrap; }
    .logrow { grid-template-columns: 1fr; gap: 4px; }
}
