/* ═══════════════════════════════════════════
   Ranks Tracker — Onesty
   Light mode — Onesty brand colors
   ═══════════════════════════════════════════ */

:root {
    --bg: #f7fcfc;
    --bg-secondary: #ffffff;
    --card: #ffffff;
    --card-hover: #f0f7f7;
    --border: #e2efef;
    --border-light: #d0e4e4;
    --text: #171c1c;
    --text-secondary: #0a8282;
    --text-muted: #6b7272;
    --primary: #0a8282;
    --primary-hover: #0a3232;
    --primary-light: rgba(10, 130, 130, 0.08);
    --primary-glow: rgba(10, 130, 130, 0.2);
    --success: #059669;
    --success-light: rgba(5, 150, 105, 0.08);
    --danger: #dc2626;
    --danger-light: rgba(220, 38, 38, 0.08);
    --warning: #d97706;
    --warning-light: rgba(217, 119, 6, 0.08);
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.content { padding: 24px; flex: 1; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
}

.sidebar-logo i { font-size: 18px; color: var(--primary); }

.sidebar-section { padding: 16px 0 4px; }

.sidebar-section-title {
    padding: 0 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.sidebar-nav { list-style: none; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    border-left: 2px solid transparent;
}

.sidebar-nav a:hover { background: var(--bg); color: var(--text); }

.sidebar-nav a.active {
    color: var(--primary);
    background: var(--primary-light);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-nav a i { width: 18px; text-align: center; font-size: 13px; }

.sidebar-bottom {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-user { display: flex; align-items: center; gap: 10px; }

.sidebar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 12px;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-weight: 600; font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

/* ── Topbar ── */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-site-selector { display: flex; align-items: center; gap: 8px; }

.topbar-site-selector select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    background: var(--card);
    color: var(--text);
    cursor: pointer;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 4px 8px; font-size: 11.5px; }

.btn-icon {
    width: 32px; height: 32px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.btn-icon:hover { background: var(--bg); color: var(--primary); }

.btn-icon .badge {
    position: absolute; top: -4px; right: -4px;
    width: 16px; height: 16px;
    background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

/* ── Cards ── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title { font-size: 13px; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }

/* ── Stat Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-value { font-size: 26px; font-weight: 800; line-height: 1; margin-bottom: 4px; color: var(--text); }

.stat-change { font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }
.stat-change.neutral { color: var(--text-muted); }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--bg);
}

tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

tbody tr:hover { background: var(--primary-light); }
tbody tr:last-child td { border-bottom: none; }

/* ── Position badges ── */
.pos {
    display: inline-flex;
    align-items: center; justify-content: center;
    min-width: 30px;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12.5px;
}

.pos-top1 { background: #f0fdf4; color: #16A34A; }
.pos-top3 { background: #f0fdf4; color: #22C55E; }
.pos-top5 { background: #fefce8; color: #EAB308; }
.pos-top10 { background: #fefce8; color: #EAB308; }
.pos-top30 { background: #fff7ed; color: #F97316; }
.pos-out { background: #fef2f2; color: #DC2626; }

.pos-change { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 600; margin-left: 6px; }
.pos-change.up { color: var(--success); }
.pos-change.down { color: var(--danger); }
.pos-change.stable { color: var(--text-muted); }

/* ── Tags ── */
.tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 11px; font-weight: 600;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.tag-color { width: 7px; height: 7px; border-radius: 50%; }
.tags-list { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Device badge ── */
.device-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); }

/* ── Filters bar ── */
.filters-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.search-input { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-input i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 12px; }

.search-input input {
    width: 100%;
    padding: 7px 12px 7px 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    background: var(--card);
    color: var(--text);
    transition: border-color 0.15s;
}

.search-input input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.filter-select {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    background: var(--card);
    color: var(--text);
    cursor: pointer;
}

.filter-select:focus { outline: none; border-color: var(--primary); }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }

/* ── Chart container ── */
.chart-container { position: relative; height: 280px; width: 100%; }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center; justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    width: 480px; max-width: 90vw; max-height: 85vh;
    overflow-y: auto;
}

.modal-header { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 16px; color: var(--text-muted); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ── Form ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px; }

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea { min-height: 80px; resize: vertical; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }

.toast {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    box-shadow: var(--shadow-md);
    display: flex; align-items: center; gap: 10px;
    font-size: 12.5px;
    min-width: 260px;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }
.toast.warning { border-left: 3px solid var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Notifications dropdown ── */
.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px); right: 0;
    width: 360px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 200;
    display: none;
}

.notif-dropdown.active { display: block; }

.notif-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 700; font-size: 12.5px;
}

.notif-list { max-height: 320px; overflow-y: auto; }

.notif-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; gap: 10px;
    font-size: 12.5px;
    transition: background 0.1s;
    cursor: default;
}

.notif-item:hover { background: var(--bg); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--primary-light); }

.notif-icon {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 12px;
}

.notif-icon.up { background: var(--success-light); color: var(--success); }
.notif-icon.down { background: var(--danger-light); color: var(--danger); }
.notif-icon.info { background: var(--primary-light); color: var(--primary); }

.notif-text { flex: 1; }
.notif-text strong { font-weight: 600; color: var(--primary); }
.notif-time { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 13px; margin-bottom: 16px; }

/* ── Misc ── */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 11.5px; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 20px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.inline-flex { display: inline-flex; align-items: center; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
