:root {
    --bg: #070b14;
    --surface: rgba(18, 24, 38, 0.85);
    --surface-solid: #121826;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f1f5f9;
    --muted: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #22c55e;
    --danger: #ef4444;
    --shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
    --radius: 16px;
}

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

body {
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 10% 0%, rgba(99, 102, 241, 0.18), transparent 55%),
        radial-gradient(ellipse 60% 50% at 90% 10%, rgba(14, 165, 233, 0.12), transparent 50%),
        radial-gradient(ellipse 50% 40% at 50% 100%, rgba(168, 85, 247, 0.08), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.page {
    position: relative;
    z-index: 1;
}

/* ── Login ── */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-header {
    padding: 36px 32px 28px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.12) 0%, transparent 100%);
}

.login-logo {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: grid;
    place-items: center;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.login-logo svg {
    width: 26px;
    height: 26px;
    fill: #fff;
}

.login-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-header p {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 6px;
}

.login-form {
    padding: 28px 32px 32px;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(7, 11, 20, 0.6);
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.alert-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.88rem;
    margin-bottom: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #fff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 0.85rem;
    padding: 10px 16px;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* ── Dashboard ── */

.dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 20px 48px;
}

.topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.topbar-icon svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

.topbar h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.topbar p {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 2px;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: 0.08;
    transform: translate(30%, -30%);
}

.kpi-card:nth-child(1)::after { background: #6366f1; }
.kpi-card:nth-child(2)::after { background: #22c55e; }
.kpi-card:nth-child(3)::after { background: #0ea5e9; }

.kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-top: 6px;
    line-height: 1.1;
}

.kpi-card:nth-child(1) .kpi-value { color: #a5b4fc; }
.kpi-card:nth-child(2) .kpi-value { color: #86efac; }
.kpi-card:nth-child(3) .kpi-value { color: #7dd3fc; }

.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 16px;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.project-card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.project-card:hover {
    border-color: rgba(255, 255, 255, 0.14);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.project-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.project-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.project-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 12px currentColor;
}

.project-info h2 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.project-rank {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 20px;
    flex-shrink: 0;
}

.project-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-hover);
    text-decoration: none;
    margin-bottom: 16px;
}

.project-link:hover {
    text-decoration: underline;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}

.stat-box {
    background: rgba(7, 11, 20, 0.5);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.stat-box .num {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.stat-box .lbl {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

.share-bar-wrap {
    margin-bottom: 16px;
}

.share-bar-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.share-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 99px;
    overflow: hidden;
}

.share-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.6s ease;
}

.chart-label {
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 8px;
}

.bars {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 64px;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.bar {
    width: 100%;
    max-width: 32px;
    border-radius: 6px 6px 2px 2px;
    min-height: 3px;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.bar-col:hover .bar {
    opacity: 1;
}

.bar-val {
    font-size: 0.62rem;
    color: var(--muted);
    font-weight: 600;
}

.bar-label {
    font-size: 0.6rem;
    color: #64748b;
}

.footer-note {
    margin-top: 32px;
    text-align: center;
    font-size: 0.78rem;
    color: #64748b;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 10px;
}

.user-badge strong {
    color: var(--text);
}

.btn-config {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.35);
    font-size: 0.85rem;
    padding: 10px 16px;
}

.btn-config:hover {
    background: rgba(99, 102, 241, 0.25);
    color: #c7d2fe;
}

.dashboard-narrow {
    max-width: 860px;
}

.alert-success {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.alert-error-block {
    margin-bottom: 20px;
}

.topbar-icon-config {
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
}

.config-card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}

.config-card h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.config-desc {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.config-desc code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.config-form .field {
    margin-bottom: 20px;
}

.config-form .field input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(7, 11, 20, 0.6);
    color: var(--text);
    font-size: 0.95rem;
    font-family: ui-monospace, monospace;
}

.config-form .field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.field-hint {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 6px;
}

.config-meta {
    margin-top: 20px;
    font-size: 0.78rem;
    color: #64748b;
}

.config-side {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.config-side h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 14px;
}

.project-tags {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.project-tags li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 500;
}

.tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.config-side-note {
    margin-top: 18px;
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .config-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

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

    .stats-row {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }
}
