*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:         #0f1117;
    --bg2:        #181b24;
    --bg3:        #1e2130;
    --border:     rgba(255,255,255,0.07);
    --border2:    rgba(255,255,255,0.12);
    --text:       #e8eaf0;
    --text2:      #8b8fa8;
    --text3:      #555870;
    --green:      #1d9e75;
    --green-bg:   rgba(29,158,117,0.12);
    --green-text: #4ecfa4;
    --red:        #d85a30;
    --red-bg:     rgba(216,90,48,0.12);
    --red-text:   #f4896a;
    --accent:     #5b7cf6;
    --accent-bg:  rgba(91,124,246,0.12);
    --radius:     8px;
    --radius-lg:  12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1400px; margin: 0 auto; padding: 0 20px; }

/* ── Navbar ── */
.navbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
    width: 32px; height: 32px;
    background: var(--accent-bg);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.logo-text  { font-size: 16px; font-weight: 600; }
.logo-badge {
    font-size: 10px;
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid rgba(91,124,246,0.3);
    border-radius: 20px;
    padding: 2px 8px;
    font-weight: 500;
}
.live-dot {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text2);
}
.live-dot::before {
    content: '';
    width: 7px; height: 7px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

.refresh-btn {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    color: var(--text2);
    font-size: 13px;
    padding: 7px 14px;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: all .15s;
    text-decoration: none;
}
.refresh-btn:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }

/* ── Error banner ── */
.error-banner {
    background: var(--red-bg);
    border: 1px solid rgba(216,90,48,0.3);
    border-radius: var(--radius);
    color: var(--red-text);
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 13px;
}

/* ── Stats ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    padding: 20px 0 16px;
}
.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}
.stat-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 600; }
.stat-value.green { color: var(--green-text); }
.stat-value.red   { color: var(--red-text); }

/* ── Controls ── */
.controls-row {
    display: flex;
    gap: 10px; align-items: center; flex-wrap: wrap;
    margin-bottom: 14px;
}
.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 280px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); pointer-events: none; }
.search-wrap input { padding: 8px 12px 8px 34px; width: 100%; }

input[type="text"], select {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    padding: 8px 12px;
    outline: none;
    transition: border-color .15s;
}
input[type="text"]:focus, select:focus { border-color: var(--accent); }
select {
    cursor: pointer; padding-right: 28px; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8fa8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.btn-group { display: flex; gap: 4px; }
.btn {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    color: var(--text2);
    font-size: 12px;
    padding: 7px 14px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.btn:hover  { border-color: var(--accent); color: var(--text); }
.btn.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

/* ── Table ── */
.table-wrap {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; min-width: 780px; }
thead th {
    background: var(--bg3);
    padding: 11px 14px;
    font-size: 11px; font-weight: 500;
    color: var(--text3);
    text-transform: uppercase; letter-spacing: 0.06em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    cursor: pointer; user-select: none;
    transition: color .15s;
}
thead th:hover { color: var(--text2); }
thead th.sorted { color: var(--accent); }
.arr { font-size: 10px; margin-left: 4px; opacity: 0.5; }
thead th.sorted .arr { opacity: 1; }

tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody td { padding: 10px 14px; color: var(--text); white-space: nowrap; }

.coin-cell { display: flex; align-items: center; gap: 10px; }
.coin-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--bg3);
    border: 1px solid var(--border2);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; color: var(--text2);
    flex-shrink: 0;
}
.coin-sym  { font-weight: 600; font-size: 13px; }
.coin-pair { font-size: 11px; color: var(--text3); }

.pct-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 12px; font-weight: 500;
}
.pct-pos  { background: var(--green-bg); color: var(--green-text); }
.pct-neg  { background: var(--red-bg);   color: var(--red-text); }
.pct-zero { background: rgba(255,255,255,0.05); color: var(--text2); }

.col-num {
    width: 40px;
    text-align: right;
    color: var(--text3);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.align-right { text-align: right; }
.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; }

.state-row td { text-align: center; padding: 3rem; color: var(--text2); }

.table-footer {
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text3);
    border-top: 1px solid var(--border);
}

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: var(--text3);
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

/* ── Filter panel ── */
.filter-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 14px;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}
.filter-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.filter-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-num {
    width: 80px;
    padding: 6px 8px;
    font-size: 13px;
}
/* Hide number input spinners */
.filter-num::-webkit-inner-spin-button,
.filter-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.filter-num { -moz-appearance: textfield; }
.filter-unit {
    padding: 6px 8px;
    font-size: 13px;
    width: 60px;
}
.filter-sep {
    color: var(--text3);
    font-size: 13px;
}
.result-count {
    font-size: 12px;
    color: var(--text2);
    margin-left: 4px;
    align-self: center;
}

/* ── Login ── */
.logout-form { margin: 0; }
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
}
.login-logo { margin-bottom: 20px; }
.login-card .error-banner { margin: 0 0 16px; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form .filter-label { margin-top: 8px; }
.login-input { width: 100%; padding: 10px 12px; font-size: 14px; }
.login-submit { margin-top: 18px; padding: 10px; font-size: 14px; justify-content: center; }
