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

:root {
    --bg-primary: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-card-hover: #242424;
    --bg-header: #141414;
    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --accent: #4fc3f7;
    --status-ok: #4caf50;
    --status-down: #f44336;
    --status-checking: #ff9800;
    --status-locked: #ff9800;
    --border: #2a2a2a;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 0;
}

/* ── Header bar ─────────────────────────────────────────────── */

.header-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.header-left h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-left .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ── Auth badge ─────────────────────────────────────────────── */

.auth-badge {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: default;
}

.auth-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--status-checking);
    transition: background 0.3s;
}

.auth-dot.ok {
    background: var(--status-ok);
    box-shadow: 0 0 6px var(--status-ok);
}

.auth-dot.no {
    background: var(--status-down);
    box-shadow: 0 0 6px var(--status-down);
}

.auth-dot.checking {
    background: var(--status-checking);
    box-shadow: 0 0 6px var(--status-checking);
    animation: pulse-check 1.5s ease-in-out infinite;
}

@keyframes pulse-check {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Auth button ────────────────────────────────────────────── */

.auth-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.auth-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

/* ── Main spacing ───────────────────────────────────────────── */

main {
    padding: 2rem;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    max-width: 1100px;
    margin: 0 auto;
}

.service-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    position: relative;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.service-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.service-card .icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(79, 195, 247, 0.08);
}

.service-card .name {
    font-weight: 600;
    font-size: 1.05rem;
}

.service-card .desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.service-card .status-dot {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--status-checking);
    transition: background 0.3s;
}

.service-card .status-dot.ok {
    background: var(--status-ok);
    box-shadow: 0 0 6px var(--status-ok);
}

.service-card .status-dot.down {
    background: var(--status-down);
    box-shadow: 0 0 6px var(--status-down);
}

.service-card .tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #222;
    color: var(--text-primary);
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
    border: 1px solid var(--border);
}

.service-card:hover .tooltip {
    display: block;
}

/* ── Locked / protected tiles ───────────────────────────────── */

.service-card.card-locked {
    border-color: var(--status-locked);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--status-locked) 30%, transparent);
}

.service-card.card-locked::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    background: rgba(255, 152, 0, 0.06);
    pointer-events: none;
    z-index: 1;
}

.service-card .protected-warning {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: var(--status-locked);
    font-weight: 500;
    position: relative;
    z-index: 2;
}

.status-bar {
    max-width: 1100px;
    margin: 1.5rem auto 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

#refresh-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.2s;
}

#refresh-btn:hover {
    background: var(--bg-card-hover);
}

@media (max-width: 600px) {
    .header-bar {
        padding: 0.6rem 1rem;
    }
    .header-left h1 {
        font-size: 1.1rem;
    }
    .auth-label {
        display: none;
    }
    main {
        padding: 1rem;
    }
    .services-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}
