:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #1c2128;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-dark: #1f6feb;
    --success: #3fb950;
    --danger: #f85149;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ── Navbar ─────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

/* ── Buttons ─────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.85;
}

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    border-radius: 14px;
}

/* ── Page layout helpers ─────────────────── */
.page-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 64px);
    padding: 2rem;
}

/* ── Home ────────────────────────────────── */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6rem 2rem 4rem;
}

.hero h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: 1.25rem;
}

.hero h1 .accent {
    color: var(--accent);
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 480px;
    line-height: 1.6;
    margin-bottom: 2.5rem;
}

.features {
    display: flex;
    gap: 1.25rem;
    justify-content: center;
    padding: 0 2rem 4rem;
    flex-wrap: wrap;
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.75rem 1.5rem;
    width: 210px;
    text-align: center;
    transition: border-color 0.2s;
}

.feature-card:hover {
    border-color: var(--accent);
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(88, 166, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.feature-icon svg {
    color: var(--accent);
}

.feature-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.feature-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ── Login ───────────────────────────────── */
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow);
}

.login-logo {
    width: 56px;
    height: 56px;
    background: rgba(88, 166, 255, 0.1);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.login-logo svg {
    color: var(--accent);
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-card .subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    background: #fff;
    color: #1f1f1f;
    border-radius: var(--radius);
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: box-shadow 0.2s, opacity 0.2s;
    font-family: inherit;
}

.google-btn:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    opacity: 0.95;
}

/* ── User Page ───────────────────────────── */
.user-layout {
    max-width: 640px;
    margin: 0 auto;
    padding: 2rem;
}

.user-profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.user-profile-header {
    background: linear-gradient(135deg, #1f6feb 0%, #0d1117 100%);
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-avatar-lg {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.user-avatar-placeholder {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(88, 166, 255, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.user-profile-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.user-profile-header .role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    padding: 0.2rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
}

.info-list {
    padding: 0 1.5rem;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-secondary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.15rem;
}

.info-value {
    font-size: 0.9rem;
    font-weight: 500;
}

.quick-links {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.quick-links h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.quick-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: background 0.15s;
}

.quick-link:hover {
    background: var(--bg-secondary);
}

.quick-link svg {
    color: var(--text-secondary);
}

/* ── Admin / Control Hub ─────────────────── */
.admin-layout {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

.admin-title {
    font-size: 1.4rem;
    font-weight: 700;
}

.admin-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

.summary-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.summary-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1.25rem;
    flex: 1;
    min-width: 140px;
}

.summary-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
}

.summary-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.summary-value.on { color: var(--success); }
.summary-value.off { color: var(--text-secondary); }

/* ── Device Cards ────────────────────────── */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.device-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.device-card.active {
    border-color: var(--success);
    box-shadow: 0 0 0 1px rgba(63, 185, 80, 0.15);
}

.device-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.device-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.25s, border-color 0.25s;
}

.device-card.active .device-icon-wrap {
    background: rgba(63, 185, 80, 0.1);
    border-color: rgba(63, 185, 80, 0.3);
    color: var(--success);
}

.device-icon-wrap svg {
    color: var(--text-secondary);
    transition: color 0.25s;
}

.device-card.active .device-icon-wrap svg {
    color: var(--success);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-pill.off {
    background: rgba(139, 148, 158, 0.12);
    color: var(--text-secondary);
}

.status-pill.on {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-dot.on {
    box-shadow: 0 0 5px currentColor;
}

.device-name {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.device-location {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.device-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ── Toggle Switch ───────────────────────── */
.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: 28px;
    transition: background 0.25s;
}

.toggle-thumb {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    top: 4px;
    left: 4px;
    transition: transform 0.25s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.toggle-switch input:checked ~ .toggle-track {
    background: var(--success);
}

.toggle-switch input:checked ~ .toggle-thumb {
    transform: translateX(24px);
}

/* ── Toast ───────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.875rem 1.25rem;
    box-shadow: var(--shadow);
    font-size: 0.875rem;
    transform: translateY(80px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 200;
    max-width: 280px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }

/* ── Footer ──────────────────────────────── */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-color);
}