/* SDM Suno Admin Panel & Site Analytics - Responsive Dark Studio */
:root {
    --ad-bg: #070A12;
    --ad-sidebar: #0B101D;
    --ad-card: #0F1524;
    --ad-card-2: #121A2C;
    --ad-border: rgba(255, 255, 255, 0.08);
    --ad-border-strong: rgba(255, 255, 255, 0.14);
    --ad-text: #F8FAFC;
    --ad-muted: #8E9BB0;
    --ad-dim: #64748B;
    --ad-purple: #7C3AED;
    --ad-purple-soft: rgba(124, 58, 237, 0.16);
    --ad-green: #10B981;
    --ad-green-soft: rgba(16, 185, 129, 0.15);
    --ad-blue: #3B82F6;
    --ad-amber: #F59E0B;
    --ad-red: #E11D48;
    --ad-red-soft: rgba(225, 29, 72, 0.14);
}

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

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--ad-bg);
    color: var(--ad-text);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, sans-serif;
    line-height: 1.48;
    overflow-x: hidden;
}

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

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 256px minmax(0, 1fr);
}

/* Sidebar */
.admin-sidebar {
    background: var(--ad-sidebar);
    border-right: 1px solid var(--ad-border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sb-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 8px;
}

.sb-brand img {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    border: 1px solid rgba(255,255,255,0.16);
}

.sb-brand-name {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.sb-brand-sub {
    font-size: 0.72rem;
    color: var(--ad-muted);
}

.sb-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.sb-section-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--ad-dim);
    padding: 8px 10px 4px;
    text-transform: uppercase;
}

.sb-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 11px;
    color: var(--ad-muted);
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.16s ease;
}

.sb-link:hover {
    color: var(--ad-text);
    background: rgba(255,255,255,0.04);
}

.sb-link.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.28), rgba(124, 58, 237, 0.12));
    border-color: rgba(124, 58, 237, 0.45);
}

.sb-link-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sb-online-pill {
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--ad-green-soft);
    color: #34D399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.sb-footer {
    border-top: 1px solid var(--ad-border);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sb-user-box {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--ad-border);
}

.sb-user-name {
    font-size: 0.84rem;
    font-weight: 700;
}

.sb-user-email {
    font-size: 0.73rem;
    color: var(--ad-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main Column */
.admin-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--ad-sidebar);
    border-bottom: 1px solid var(--ad-border);
    position: sticky;
    top: 0;
    z-index: 40;
}

.mobile-menu-btn {
    height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--ad-border-strong);
    background: rgba(255,255,255,0.04);
    color: var(--ad-text);
    font-weight: 700;
    cursor: pointer;
}

.admin-content {
    padding: 26px 28px 42px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* Page Headers */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 22px;
}

.page-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    margin: 0;
    font-size: 1.48rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-sub {
    margin: 4px 0 0;
    font-size: 0.86rem;
    color: var(--ad-muted);
}

.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.14);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #34D399;
    font-size: 0.76rem;
    font-weight: 700;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10B981;
    animation: adminPulse 1.6s infinite;
}

@keyframes adminPulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.btn {
    height: 40px;
    padding: 0 15px;
    border-radius: 10px;
    border: 1px solid var(--ad-border-strong);
    background: var(--ad-card-2);
    color: var(--ad-text);
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.btn:hover { background: #1A243B; }

.btn-primary {
    background: var(--ad-purple);
    border-color: var(--ad-purple);
    color: #fff;
}

.btn-primary:hover { background: #6D28D9; }

.btn-danger {
    background: var(--ad-red-soft);
    border-color: rgba(225, 29, 72, 0.42);
    color: #FDA4AF;
}

.btn-danger:hover {
    background: rgba(225, 29, 72, 0.25);
}

/* Alerts */
.flash-alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-size: 0.86rem;
    font-weight: 600;
    background: var(--ad-green-soft);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #6EE7B7;
}

.flash-error {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-size: 0.86rem;
    font-weight: 600;
    background: var(--ad-red-soft);
    border: 1px solid rgba(225, 29, 72, 0.35);
    color: #FDA4AF;
}

/* 4-card & 5-card Metric Rows (Analytics & Dashboard) */
.metrics-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.metrics-grid-5 {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.metric-card {
    background: var(--ad-card);
    border: 1px solid var(--ad-border);
    border-radius: 16px;
    padding: 18px 20px;
    position: relative;
}

.metric-card.is-live {
    border-color: rgba(16, 185, 129, 0.42);
    background: radial-gradient(circle at 20% 20%, rgba(16, 185, 129, 0.14), var(--ad-card) 72%);
    box-shadow: 0 12px 30px -14px rgba(16, 185, 129, 0.35);
}

.metric-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.metric-label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--ad-muted);
    text-transform: uppercase;
}

.metric-card.is-live .metric-label { color: #34D399; }

.metric-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border: 1px solid var(--ad-border);
    background: rgba(255,255,255,0.04);
}

.metric-icon.green { background: rgba(16,185,129,0.14); border-color: rgba(16,185,129,0.3); color: #34D399; }
.metric-icon.blue  { background: rgba(59,130,246,0.14); border-color: rgba(59,130,246,0.3); color: #60A5FA; }
.metric-icon.purple{ background: rgba(124,58,237,0.16); border-color: rgba(124,58,237,0.34); color: #C4B5FD; }
.metric-icon.amber { background: rgba(245,158,11,0.14); border-color: rgba(245,158,11,0.3); color: #FBBF24; }

.metric-value-line {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 2rem;
    font-weight: 850;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.metric-unit {
    font-size: 0.82rem;
    color: var(--ad-muted);
    font-weight: 600;
}

.metric-card.is-live .metric-unit { color: #34D399; }

.metric-sub {
    font-size: 0.77rem;
    color: var(--ad-dim);
}

.metric-sub strong { color: #60A5FA; }
.metric-sub.purple strong { color: #C4B5FD; }
.metric-sub.amber strong { color: #FBBF24; }

/* Device & Country Strip */
.summary-strip {
    background: var(--ad-card);
    border: 1px solid var(--ad-border);
    border-radius: 14px;
    padding: 13px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    font-size: 0.82rem;
}

.strip-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    color: var(--ad-muted);
}

.strip-item strong { color: var(--ad-text); }

.country-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 8px;
    background: var(--ad-card-2);
    border: 1px solid var(--ad-border);
    color: var(--ad-text);
    font-size: 0.76rem;
    font-weight: 700;
}

/* Filter Toolbar */
.filter-bar {
    background: var(--ad-card);
    border: 1px solid var(--ad-border);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.filter-tabs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-tab {
    height: 34px;
    padding: 0 12px;
    border-radius: 9px;
    border: 1px solid var(--ad-border);
    background: transparent;
    color: var(--ad-muted);
    font-size: 0.8rem;
    font-weight: 650;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.filter-tab:hover {
    color: var(--ad-text);
    background: rgba(255,255,255,0.04);
}

.filter-tab.active {
    background: var(--ad-purple);
    border-color: var(--ad-purple);
    color: #fff;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 340px;
    min-width: 220px;
}

.search-input {
    flex: 1;
    height: 36px;
    border-radius: 9px;
    border: 1px solid var(--ad-border-strong);
    background: var(--ad-bg);
    color: var(--ad-text);
    padding: 0 12px;
    font-size: 0.82rem;
    outline: none;
}

.search-input:focus { border-color: var(--ad-purple); }

/* Data Table Card */
.table-card {
    background: var(--ad-card);
    border: 1px solid var(--ad-border);
    border-radius: 16px;
    overflow: hidden;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.data-table th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ad-dim);
    padding: 13px 16px;
    border-bottom: 1px solid var(--ad-border);
    background: rgba(255,255,255,0.02);
    white-space: nowrap;
}

.data-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--ad-border);
    font-size: 0.83rem;
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-badge.online {
    background: var(--ad-green-soft);
    color: #34D399;
    border: 1px solid rgba(16,185,129,0.35);
}

.status-badge.offline {
    background: rgba(255,255,255,0.05);
    color: var(--ad-muted);
    border: 1px solid var(--ad-border);
}

.device-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.28);
    color: #93C5FD;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

/* Forms (Profile & Login) */
.panel-card {
    background: var(--ad-card);
    border: 1px solid var(--ad-border);
    border-radius: 16px;
    padding: 22px 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field.full { grid-column: 1 / -1; }

.form-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ad-muted);
}

.form-input {
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--ad-border-strong);
    background: var(--ad-bg);
    color: var(--ad-text);
    padding: 0 14px;
    font-size: 0.9rem;
    outline: none;
}

.form-input:focus {
    border-color: var(--ad-purple);
    box-shadow: 0 0 0 3px var(--ad-purple-soft);
}

.field-error {
    color: #FB7185;
    font-size: 0.76rem;
    font-weight: 600;
}

/* Login Page */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 20% 20%, rgba(124, 58, 237, 0.18), transparent 45%), var(--ad-bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--ad-card);
    border: 1px solid var(--ad-border-strong);
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}

/* Responsive Breakpoints */
@media (max-width: 1280px) {
    .metrics-grid-5 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1120px) {
    .metrics-grid-4,
    .metrics-grid-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-topbar {
        display: flex;
    }

    .admin-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 70;
        transition: left 0.22s ease;
    }

    .admin-sidebar.open {
        left: 0;
        box-shadow: 20px 0 50px rgba(0,0,0,0.75);
    }

    .admin-content {
        padding: 18px 14px 32px;
    }
}

@media (max-width: 580px) {
    .metrics-grid-4,
    .metrics-grid-5 {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}
