/*
 * Modern dual-view dashboard styling for desktop and mobile
 * Adds glassmorphism, 3D hover, animated accents, and responsive navigation
 */

:root {
    --bg-gradient: radial-gradient(circle at 20% 20%, rgba(123, 67, 255, 0.35), transparent 55%),
                    radial-gradient(circle at 80% 0%, rgba(0, 230, 255, 0.25), transparent 55%),
                    linear-gradient(135deg, #060b1a 0%, #101a3c 30%, #1b2b5a 60%, #21193a 100%);
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 20px 45px rgba(15, 15, 40, 0.35);
    --accent: #58e1ff;
    --accent-strong: #b97aff;
    --text-primary: #f5f7ff;
    --text-muted: rgba(245, 247, 255, 0.75);
    --success: #4ad295;
    --warning: #ffb347;
    --danger: #ff6b6b;
    --card-tilt: rotateX(4deg) rotateY(-3deg);
    --transition-quick: 180ms ease;
    --transition-slow: 420ms cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 16px;
}

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

html, body {
    min-height: 100%;
}

body {
    font-family: "Poppins", "Segoe UI", Tahoma, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, rgba(89, 97, 249, 0.2), transparent 60%),
                linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.05) 70%);
    z-index: -3;
    animation: pulseGlow 12s ease-in-out infinite;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='rgba(255,255,255,0.045)' stroke-width='1'%3E%3Cpath d='M0 10h40M0 30h40M10 0v40M30 0v40'/%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.6;
    z-index: -4;
    mix-blend-mode: overlay;
    animation: gridDrift 28s linear infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 0.95; }
}

@keyframes gridDrift {
    0% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(-30px, -20px, 0); }
    100% { transform: translate3d(0, 0, 0); }
}

.bg-shapes {
    position: fixed;
    inset: 0;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
}

.shape {
    position: absolute;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0));
    filter: blur(0.2px);
    opacity: 0.6;
    border-radius: 40% 60% 55% 45% / 55% 35% 65% 45%;
    animation: float 12s ease-in-out infinite;
}

.shape:nth-child(1) { width: 280px; height: 280px; top: 10%; left: -6%; animation-delay: 0s; }
.shape:nth-child(2) { width: 180px; height: 180px; top: 20%; right: 5%; animation-delay: 2.2s; }
.shape:nth-child(3) { width: 240px; height: 240px; bottom: -8%; left: 15%; animation-delay: 4.1s; }
.shape:nth-child(4) { width: 160px; height: 160px; top: 65%; right: 18%; animation-delay: 5.5s; }
.shape:nth-child(5) { width: 210px; height: 210px; top: 45%; left: 45%; animation-delay: 7.7s; }
.shape:nth-child(6) { width: 150px; height: 150px; bottom: 15%; right: -6%; animation-delay: 9.4s; }

@keyframes float {
    0%, 100% {
        transform: translate3d(0, 0, 0) scale(1);
    }
    50% {
        transform: translate3d(0, -22px, 30px) scale(1.08);
    }
}

main {
    width: min(1120px, 92vw);
    margin: 0 auto 60px auto;
    padding: 110px 0 40px 0;
    flex: 1;
}

h1, h2, h3 {
    font-weight: 600;
    text-shadow: 0 10px 30px rgba(10, 10, 20, 0.35);
}

h1 {
    font-size: clamp(2.1rem, 4vw, 3.1rem);
    margin-bottom: 22px;
}

h2 {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    margin-bottom: 18px;
}

h3 {
    font-size: clamp(1.3rem, 2.4vw, 1.8rem);
    margin-bottom: 14px;
}

p, li, td, th, label {
    color: var(--text-muted);
    font-size: clamp(0.94rem, 1.6vw, 1.02rem);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover, a:focus {
    color: var(--accent-strong);
}

/* Navigation */
.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(22px);
}

.app-header {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: min(1180px, 94vw);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    background: rgba(11, 15, 35, 0.35);
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 25px 50px rgba(10, 10, 35, 0.35);
    backdrop-filter: blur(18px);
    z-index: 10;
    transition: transform var(--transition-slow), background var(--transition-quick);
}

.app-header.scrolled {
    background: rgba(8, 12, 28, 0.8);
    transform: translate(-50%, -6px) scale(0.99);
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-primary);
    text-decoration: none;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-brand::before {
    content: "";
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(89, 97, 249, 0.9), rgba(185, 122, 255, 0.9));
    box-shadow: 0 10px 25px rgba(90, 100, 255, 0.4);
    filter: drop-shadow(0 0 18px rgba(89, 97, 249, 0.35));
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 14px;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid transparent;
}

.nav-links a:hover,
.nav-links a:focus,
.nav-links a.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.nav-toggle {
    display: none;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(8, 12, 28, 0.6);
    color: var(--text-primary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.nav-toggle:hover,
.nav-toggle:focus {
    background: rgba(8, 12, 28, 0.85);
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 999px;
    position: relative;
    transition: transform var(--transition-quick), opacity var(--transition-quick);
}

.nav-toggle span::before,
.nav-toggle span::after {
    content: "";
    position: absolute;
    left: 0;
}

.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }

.nav-toggle[aria-expanded="true"] span {
    background: transparent;
}

.nav-toggle[aria-expanded="true"] span::before {
    transform: translateY(6px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span::after {
    transform: translateY(-6px) rotate(-45deg);
}

/* Cards & surfaces */
.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 22px;
    padding: clamp(24px, 4vw, 32px);
    margin-bottom: 26px;
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(24px);
    position: relative;
    overflow: hidden;
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

.card h2, .card h3 {
    margin-bottom: 12px;
}

.card ul,
.card ol {
    list-style: none;
    display: grid;
    gap: 10px;
    padding-left: 0;
}

.card li {
    background: rgba(15, 20, 40, 0.55);
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.card li strong {
    color: var(--text-primary);
}

.card li.birthday-privacy {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.birthday-privacy-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.birthday-privacy-status {
    font-weight: 600;
    color: var(--text-primary);
}

#birthdayPrivacyToggle {
    padding: 10px 20px;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
}

.small-print {
    font-size: 0.85rem;
}

.card details {
    background: rgba(15, 20, 40, 0.4);
    border-radius: 16px;
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
}

.card details[open] {
    background: rgba(15, 20, 40, 0.6);
}

.card summary {
    list-style: none;
    font-weight: 600;
    font-size: 1.05rem;
}

.card summary::-webkit-details-marker {
    display: none;
}

.card summary::after {
    content: "➜";
    float: right;
}

.card details[open] summary::after {
    transform: rotate(90deg);
}

.dashboard-grid {
    display: grid;
    gap: 28px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    align-items: start;
}

.dashboard-grid .card {
    margin-bottom: 0;
}

.motivational-card {
    position: relative;
    overflow: hidden;
}

.motivational-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(88, 225, 255, 0.18), transparent 55%);
    pointer-events: none;
    opacity: 0.8;
}

.motivational-quote {
    position: relative;
    display: grid;
    gap: 16px;
    z-index: 1;
}

.motivational-quote .quote-text {
    font-size: 1.05rem;
    font-style: italic;
    color: var(--text-primary);
}

.motivational-quote .quote-author {
    text-align: right;
    font-weight: 600;
    color: var(--text-muted);
}

/* Games hub */
.games-layout {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.games-hero {
    display: grid;
    gap: 18px;
}

.games-hero .current-game {
    background: rgba(15, 22, 45, 0.6);
    border-radius: 18px;
    padding: 18px 22px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
}

.current-game-copy {
    display: grid;
    gap: 6px;
    flex: 1 1 240px;
}

.current-game-button {
    flex: 0 0 auto;
    min-width: 180px;
}

.games-browser {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.browser-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
    flex-wrap: wrap;
}

.browser-title {
    margin-bottom: 4px;
}

.browser-subtitle {
    color: rgba(245, 247, 255, 0.7);
}

.toggle-game-browser {
    flex: 0 0 auto;
    min-width: 160px;
}

.games-browser.is-collapsed .games-grid {
    display: none;
}

.games-grid {
    display: grid;
    gap: 22px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.game-tile {
    background: rgba(15, 20, 45, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 18px 35px rgba(10, 10, 35, 0.28);
    backdrop-filter: blur(16px);
    cursor: pointer;
    transition: transform var(--transition-slow), border-color var(--transition-quick), box-shadow var(--transition-slow);
    outline: none;
    display: grid;
    gap: 12px;
}

.game-tile:hover,
.game-tile:focus-visible {
    transform: translateY(-6px) scale(1.01);
    border-color: rgba(88, 225, 255, 0.8);
    box-shadow: 0 26px 48px rgba(20, 20, 55, 0.35);
}

.game-tile.active {
    border-color: var(--accent);
    box-shadow: 0 28px 60px rgba(88, 225, 255, 0.38);
}

.game-meta {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.65);
}

.games-main {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    gap: 28px;
    align-items: start;
}

.game-panel {
    min-height: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 18px;
}

.game-panel--active {
    align-items: stretch;
    justify-content: flex-start;
    text-align: left;
    gap: 20px;
}

.game-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 18px;
}

.game-tag {
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    display: inline-block;
}

.game-instruction {
    font-size: 0.95rem;
    color: rgba(245, 247, 255, 0.75);
}

.game-reference {
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(88, 225, 255, 0.15);
    border: 1px solid rgba(88, 225, 255, 0.3);
    color: var(--accent);
    white-space: nowrap;
}

.game-question {
    font-size: clamp(1.25rem, 2.4vw, 1.9rem);
    margin-bottom: 20px;
}

.game-options {
    display: grid;
    gap: 14px;
}

.game-option {
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(10, 15, 35, 0.6);
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: transform var(--transition-quick), border-color var(--transition-quick), background var(--transition-quick);
}

.game-option:hover,
.game-option:focus-visible {
    transform: translateY(-2px);
    border-color: var(--accent);
    background: rgba(88, 225, 255, 0.2);
}

.game-option.is-disabled {
    opacity: 0.6;
    cursor: default;
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.input-group input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(9, 12, 28, 0.75);
    color: var(--text-primary);
}

.pill {
    padding: 12px 22px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, rgba(88, 225, 255, 0.9), rgba(185, 122, 255, 0.9));
    color: #050914;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: transform var(--transition-quick), box-shadow var(--transition-quick);
}

.pill:hover,
.pill:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(88, 225, 255, 0.35);
}

.pill--ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
}

.game-result {
    display: grid;
    gap: 16px;
    text-align: left;
}

.game-result.is-correct {
    border-left: 4px solid var(--success);
    padding-left: 18px;
}

.game-result.is-wrong {
    border-left: 4px solid var(--danger);
    padding-left: 18px;
}

.game-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.game-placeholder {
    color: rgba(245, 247, 255, 0.7);
}

.game-error {
    color: var(--danger);
    text-align: center;
}

.game-status {
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 0.9rem;
    width: fit-content;
}

.game-status--success {
    background: rgba(74, 210, 149, 0.25);
    border: 1px solid rgba(74, 210, 149, 0.45);
}

.game-status--warning {
    background: rgba(255, 179, 71, 0.25);
    border: 1px solid rgba(255, 179, 71, 0.45);
}

.game-status--error {
    background: rgba(255, 107, 107, 0.25);
    border: 1px solid rgba(255, 107, 107, 0.45);
}

.game-status--info {
    background: rgba(88, 225, 255, 0.25);
    border: 1px solid rgba(88, 225, 255, 0.4);
}

.spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.8);
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.player-card {
    display: grid;
    gap: 16px;
    text-align: left;
}

.player-name {
    font-size: 1.2rem;
    font-weight: 600;
}

.player-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
}

.stat-label {
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(245, 247, 255, 0.65);
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.leaderboard-card {
    display: grid;
    gap: 14px;
}

.leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(12, 18, 36, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.leaderboard-row.is-self {
    border-color: rgba(74, 210, 149, 0.7);
    box-shadow: 0 0 0 1px rgba(74, 210, 149, 0.4);
}

.hangman-word {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.hangman-guesses {
    font-size: 0.9rem;
    color: rgba(245, 247, 255, 0.7);
}

.story-ordering {
    display: grid;
    gap: 18px;
}

@media (min-width: 720px) {
    .story-ordering {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

.story-subheading {
    font-size: 1rem;
    margin: 0 0 8px;
    color: rgba(245, 247, 255, 0.85);
}

.story-options-list,
.story-sequence-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.story-option,
.story-sequence-item {
    width: 100%;
    background: rgba(12, 18, 38, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.story-option {
    cursor: pointer;
    text-align: left;
    color: inherit;
}

.story-option:disabled {
    cursor: default;
    opacity: 0.65;
}

.story-option.is-selected {
    border-color: rgba(74, 210, 149, 0.6);
    box-shadow: 0 0 0 1px rgba(74, 210, 149, 0.3);
}

.story-option-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(74, 210, 149, 0.2);
    color: rgba(74, 210, 149, 0.9);
    font-weight: 600;
    flex-shrink: 0;
}

.story-option-text,
.story-sequence-text {
    flex: 1;
}

.story-sequence-item {
    position: relative;
}

.story-sequence-position {
    font-weight: 600;
    color: rgba(245, 247, 255, 0.7);
}

.story-remove {
    margin-left: auto;
    background: transparent;
    border: none;
    color: rgba(245, 247, 255, 0.6);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.story-remove:hover,
.story-remove:focus-visible {
    color: rgba(245, 247, 255, 0.85);
}

.story-clear {
    margin-top: 12px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 960px) {
    .games-main {
        grid-template-columns: 1fr;
    }

    .game-sidebar {
        display: grid;
        gap: 20px;
    }
}

@media (max-width: 720px) {
    .games-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    .current-game-button,
    .toggle-game-browser {
        width: 100%;
        min-width: 0;
    }

    .game-option {
        font-size: 0.95rem;
    }

    .input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group input {
        width: 100%;
    }

    .pill {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 600px) {
    button,
    .button,
    .pill {
        padding: 10px 18px;
        font-size: 0.9rem;
        letter-spacing: 0.04em;
    }

    .actions {
        gap: 10px;
    }

    .actions button,
    .actions .button {
        flex: 1 1 100%;
        width: 100%;
    }
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    background: rgba(12, 16, 35, 0.65);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 12px;
}

.table-responsive table {
    min-width: 540px;
    margin-top: 0;
}

thead {
    background: linear-gradient(135deg, rgba(89, 97, 249, 0.6), rgba(185, 122, 255, 0.45));
}

thead th {
    color: var(--text-primary);
}

th, td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-weight: 500;
}

td a {
    color: var(--accent);
    font-weight: 600;
}

tr:last-child td {
    border-bottom: none;
}

.absentee-list {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.absentee-card {
    background: rgba(12, 16, 35, 0.65);
    border-radius: 18px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.absentee-card-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.absentee-name {
    font-weight: 600;
    color: var(--text-primary);
}

.absentee-email {
    word-break: break-word;
}

.absentee-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.absentee-no-email {
    display: inline-block;
}

@media (min-width: 720px) {
    .absentee-list {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }

    .absentee-card-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: baseline;
    }
}

/* Forms */
form {
    display: grid;
    gap: 16px;
}

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

form .form-field label {
    font-weight: 500;
    color: var(--text-primary);
}

input,
textarea,
select {
    width: 100%;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(12, 16, 35, 0.7);
    color: var(--text-primary);
    font-size: 1rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: border-color var(--transition-quick), transform var(--transition-quick), box-shadow var(--transition-quick);
}

input::placeholder,
textarea::placeholder {
    color: rgba(245, 247, 255, 0.45);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: rgba(88, 225, 255, 0.75);
    transform: translateY(-1px);
    box-shadow: 0 0 0 3px rgba(88, 225, 255, 0.15);
}

textarea {
    min-height: 140px;
    resize: vertical;
}

/* Buttons */
button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(89, 97, 249, 0.85), rgba(88, 225, 255, 0.85));
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    box-shadow: 0 18px 35px rgba(89, 97, 249, 0.35);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    filter: grayscale(0.4);
    box-shadow: none;
}

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

.actions button,
.actions .button {
    flex: 1 1 240px;
}

.attendance-request-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.attendance-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 18px;
}

.attendance-settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}

.attendance-status {
    padding: 12px 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 22, 45, 0.55);
    font-weight: 600;
}

.profile-card {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.profile-message {
    padding: 12px 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 22, 45, 0.6);
    font-weight: 500;
}

.profile-message.success {
    border-color: rgba(74, 210, 149, 0.45);
    background: rgba(74, 210, 149, 0.18);
    color: #bff4d8;
}

.profile-message.error {
    border-color: rgba(255, 107, 107, 0.45);
    background: rgba(255, 107, 107, 0.18);
    color: #ffd4d4;
}

.profile-form .form-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.profile-form .form-actions {
    display: flex;
    justify-content: flex-end;
}

.profile-form .form-actions button {
    width: auto;
    min-width: 180px;
}

.profile-extra {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.profile-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 22, 45, 0.45);
}

.profile-meta-row span {
    font-weight: 600;
    color: var(--text-primary);
}

.profile-extra .birthday-privacy {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 22, 45, 0.45);
}

.profile-extra .birthday-privacy-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.attendance-status.success {
    background: rgba(74, 210, 149, 0.18);
    color: #c3f8de;
}

.attendance-status.pending {
    background: rgba(255, 179, 71, 0.16);
    color: #ffe3c1;
}

.attendance-status.denied {
    background: rgba(255, 107, 107, 0.18);
    color: #ffd3d3;
}

.request-attendance-form {
    display: flex;
    justify-content: flex-start;
}

.request-attendance-form button {
    width: fit-content;
}

.attendance-request-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.attendance-request-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

.attendance-request-item .requester {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.request-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.request-actions form {
    margin: 0;
}

.present-message {
    margin-top: 80px;
    text-align: center;
    font-size: clamp(2.1rem, 5vw, 3rem);
    font-weight: 700;
    background: linear-gradient(120deg, #58e1ff 0%, #b97aff 50%, #58e1ff 100%);
    background-size: 240% 240%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: colorWave 4s ease infinite;
}

@keyframes colorWave {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.status-pill {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-pill.success {
    background: rgba(74, 210, 149, 0.2);
    color: #c3f8de;
}

.status-pill.warning {
    background: rgba(255, 179, 71, 0.18);
    color: #ffe3c1;
}

.status-pill.danger {
    background: rgba(255, 107, 107, 0.18);
    color: #ffd3d3;
}

.alert {
    padding: 14px 18px;
    border-radius: 14px;
    margin-bottom: 18px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(8, 16, 40, 0.55);
    box-shadow: 0 18px 30px rgba(9, 12, 32, 0.35);
    color: var(--text-primary);
}

.alert.success {
    border-left: 4px solid var(--success);
}

.alert.error {
    border-left: 4px solid var(--danger);
}

.alert.warning {
    border-left: 4px solid var(--warning);
}

.alert.info {
    border-left: 4px solid var(--accent);
}

/* Utility */
.text-center { text-align: center; }
.muted { color: var(--text-muted); }

/* Landing page */
.landing-page {
    display: flex;
    flex-direction: column;
    gap: 64px;
    padding-top: 140px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 48px;
    padding: clamp(32px, 6vw, 64px);
    border-radius: 32px;
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(89, 97, 249, 0.35), transparent 60%),
                radial-gradient(circle at 80% 80%, rgba(88, 225, 255, 0.25), transparent 65%);
    opacity: 0.6;
    pointer-events: none;
    z-index: -1;
}

.hero-copy {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.eyebrow {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.4em;
    color: rgba(255, 255, 255, 0.7);
}

.lead {
    font-size: clamp(1rem, 2vw, 1.2rem);
    max-width: 42ch;
}

.cta-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.button-outline {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: none;
}

.button-outline:hover,
.button-outline:focus {
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 35px rgba(255, 255, 255, 0.2);
}

.signup-note {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.75);
}

.hero-highlights {
    list-style: none;
    display: grid;
    gap: 26px;
}

.hero-highlights li {
    background: rgba(11, 15, 35, 0.55);
    padding: 22px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 15px 30px rgba(10, 10, 30, 0.35);
}

.feature-showcase {
    display: flex;
    flex-direction: column;
    gap: 36px;
}

.section-heading {
    max-width: 620px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feature-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.feature-card {
    padding: 28px;
    border-radius: 24px;
    min-height: 220px;
    position: relative;
    overflow: hidden;
}

.feature-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(88, 225, 255, 0.25), transparent 65%);
    opacity: 0.8;
    pointer-events: none;
}

.feature-card h3 {
    margin-bottom: 12px;
}

.feature-card p {
    position: relative;
    z-index: 1;
}

.announcement-section {
    padding: clamp(32px, 5vw, 56px);
    border-radius: 32px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.announcement-list {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.announcement-card {
    background: rgba(11, 15, 35, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 15px 30px rgba(10, 10, 40, 0.35);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.announcement-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.announcement-card-header h3 {
    margin: 0;
}

.announcement-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.announcement-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.82);
}

.status-active {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
}

.status-expired {
    background: rgba(231, 76, 60, 0.22);
    color: #e74c3c;
}

.announcement-meta {
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

.signup-card {
    padding: clamp(32px, 5vw, 54px);
    border-radius: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    text-align: left;
}

.signup-card p {
    max-width: 58ch;
}

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

    .hero-highlights {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 720px) {
    .app-header {
        padding: 16px 22px;
    }

    .landing-page {
        padding-top: 120px;
        gap: 48px;
    }

    .feature-card,
    .announcement-card {
        padding: 20px;
    }
}

.admin-announcement-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin: 18px 0 0;
    padding: 0;
}

.admin-announcement-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-announcement-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.admin-announcement-dates {
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
}

.admin-announcement-form,
.admin-announcement-delete {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.admin-announcement-form input[type="text"] {
    flex: 1 1 240px;
}

/* Responsive layouts */
@media (max-width: 1024px) {
    main {
        padding-top: 96px;
    }

    .app-header {
        top: 18px;
    }
}

@media (max-width: 768px) {
    :root {
        font-size: 15px;
        --card-tilt: rotateX(0deg) rotateY(0deg);
    }

    .app-header {
        padding: 14px 20px;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .nav-links {
        position: fixed;
        inset: 86px 0 auto 0;
        margin: 0 auto;
        width: min(92vw, 420px);
        flex-direction: column;
        background: rgba(10, 14, 30, 0.95);
        border-radius: 18px;
        padding: 22px 20px;
        border: 1px solid rgba(255, 255, 255, 0.15);
        box-shadow: 0 25px 55px rgba(8, 10, 20, 0.45);
        transform: translateY(-30px);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-quick), transform var(--transition-quick);
    }

    .nav-links a {
        width: 100%;
        justify-content: center;
        font-size: 1rem;
    }

    .nav-links.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    main {
        width: min(94vw, 720px);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .actions {
        flex-direction: column;
    }

    .card {
        transform: none;
    }
}

@media (max-width: 480px) {
    main {
        padding-top: 82px;
        margin-bottom: 36px;
    }

    .app-header {
        width: calc(100vw - 24px);
        left: 12px;
        transform: none;
    }

    .app-header.scrolled {
        transform: none;
    }

    .nav-brand::before {
        width: 32px;
        height: 32px;
    }

    h1 {
        margin-top: 12px;
    }

    table {
        font-size: 0.92rem;
    }
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.chat-page {
    display: flex;
    flex-direction: column;
    gap: 36px;
}

.chat-hero {
    position: relative;
    overflow: hidden;
    padding: clamp(28px, 4vw, 42px);
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: linear-gradient(135deg, rgba(25, 31, 70, 0.88), rgba(72, 36, 120, 0.58));
}

.chat-hero__content {
    position: relative;
    z-index: 1;
}

.chat-hero__glow {
    position: absolute;
    inset: -40%;
    background: radial-gradient(circle at 30% 30%, rgba(88, 225, 255, 0.45), transparent 60%),
                radial-gradient(circle at 75% 30%, rgba(185, 122, 255, 0.35), transparent 65%);
    animation: auroraDrift 14s ease-in-out infinite alternate;
    z-index: 0;
    opacity: 0.7;
}

@keyframes auroraDrift {
    0% { transform: translate3d(-2%, -1%, 0) scale(1); opacity: 0.6; }
    50% { transform: translate3d(3%, 4%, 0) scale(1.05); opacity: 0.9; }
    100% { transform: translate3d(-3%, 2%, 0) scale(1.02); opacity: 0.7; }
}

.chat-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 32px;
}

.chat-tutorial {
    position: relative;
    padding: 28px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    overflow: hidden;
    transition: transform var(--transition-slow), box-shadow var(--transition-slow);
}

.chat-tutorial::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(88, 225, 255, 0.1), rgba(185, 122, 255, 0.08));
    opacity: 0.8;
    z-index: 0;
}

.chat-tutorial__header,
.chat-tutorial__body {
    position: relative;
    z-index: 1;
}

.chat-tutorial__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.chat-tutorial__toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(6, 11, 26, 0.55);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform var(--transition-quick), background var(--transition-quick);
}

.chat-tutorial__toggle:hover,
.chat-tutorial__toggle:focus {
    transform: translateY(-1px);
    background: rgba(6, 11, 26, 0.8);
}

.chat-tutorial__toggle .toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-quick);
}

.chat-tutorial__body {
    display: grid;
    gap: 26px;
    max-height: 650px;
    transition: max-height var(--transition-slow), opacity var(--transition-quick), transform var(--transition-quick);
}

.tutorial-steps {
    display: grid;
    gap: 18px;
}

.tutorial-step {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: start;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(18px);
    transform: translateY(16px);
    opacity: 0;
    animation: tutorialSlideIn 0.6s forwards;
}

.tutorial-step:nth-child(2) { animation-delay: 0.12s; }
.tutorial-step:nth-child(3) { animation-delay: 0.24s; }

@keyframes tutorialSlideIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.tutorial-step__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 1.4rem;
    background: rgba(88, 225, 255, 0.2);
    box-shadow: 0 10px 30px rgba(88, 225, 255, 0.2);
}

.tutorial-footnote {
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(12, 18, 40, 0.65);
    border: 1px dashed rgba(255, 255, 255, 0.22);
}

.chat-tutorial[data-state="collapsed"] .chat-tutorial__body {
    max-height: 0;
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
}

.chat-tutorial[data-state="collapsed"] .chat-tutorial__toggle .toggle-icon {
    transform: rotate(180deg);
}

.chat-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 26px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.chat-window {
    flex: 1;
    min-height: 360px;
    max-height: 540px;
    overflow-y: auto;
    display: grid;
    gap: 14px;
    padding-right: 4px;
}

.chat-window::-webkit-scrollbar {
    width: 8px;
}

.chat-window::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
}

.chat-message {
    display: flex;
    justify-content: flex-start;
}

.chat-message.message--user {
    justify-content: flex-end;
}

.message__bubble {
    max-width: 85%;
    padding: 16px 18px;
    border-radius: 18px 18px 6px 18px;
    background: rgba(15, 20, 48, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 35px rgba(8, 12, 32, 0.35);
    display: grid;
    gap: 10px;
}

.message--user .message__bubble {
    border-radius: 18px 18px 18px 6px;
    background: linear-gradient(135deg, rgba(185, 122, 255, 0.9), rgba(88, 225, 255, 0.8));
    color: #0b0f20;
}

.message__text {
    font-size: 1rem;
    color: inherit;
}

.message__reference {
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
}

.message--user .message__reference {
    color: rgba(11, 15, 32, 0.75);
}

.chat-form {
    display: grid;
    gap: 12px;
}

.chat-form textarea {
    width: 100%;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(8, 12, 28, 0.55);
    color: var(--text-primary);
    resize: vertical;
    min-height: 120px;
    font-size: 1rem;
    transition: border var(--transition-quick), box-shadow var(--transition-quick);
}

.chat-form textarea:focus {
    outline: none;
    border-color: rgba(88, 225, 255, 0.65);
    box-shadow: 0 0 0 2px rgba(88, 225, 255, 0.25);
}

.placeholder-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0 4px 0;
    flex-wrap: wrap;
}

.placeholder-toolbar-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.button-ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition-quick), border-color var(--transition-quick), transform var(--transition-quick);
}

.button-ghost:hover,
.button-ghost:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.45);
    transform: translateY(-1px);
}

.chat-form__actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.chat-send {
    padding: 12px 28px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, rgba(88, 225, 255, 0.9), rgba(185, 122, 255, 0.9));
    color: #061021;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform var(--transition-quick), box-shadow var(--transition-quick);
    box-shadow: 0 15px 35px rgba(88, 225, 255, 0.35);
}

.chat-send:hover,
.chat-send:focus {
    transform: translateY(-1px);
    box-shadow: 0 18px 40px rgba(88, 225, 255, 0.45);
}

.chat-send:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.chat-status {
    min-height: 1.5rem;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.7);
}

.chat-status.error {
    color: var(--danger);
}

@media (max-width: 980px) {
    .chat-layout {
        grid-template-columns: 1fr;
    }

    .chat-tutorial,
    .chat-panel {
        padding: 24px;
    }

    .message__bubble {
        max-width: 100%;
    }
}

@media (max-width: 640px) {
    .chat-hero {
        padding: 24px;
    }

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

    .chat-form textarea {
        min-height: 140px;
    }
}


/* CRM chat workspace */
.crm-main {
    width: min(1200px, 96vw);
    margin: 0 auto 60px auto;
    padding: 110px 0 40px 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.crm-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.crm-heading h1 {
    margin-bottom: 6px;
}

.crm-sidebar-toggle,
.crm-sidebar-close {
    padding: 10px 18px;
    background: rgba(6, 14, 32, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(10, 10, 35, 0.32);
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 0.95rem;
}

.crm-sidebar-close {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 1.2rem;
}

.crm-sidebar-toggle-icon {
    width: 18px;
    height: 2px;
    background: currentColor;
    position: relative;
    display: inline-block;
    margin-right: 10px;
}

.crm-sidebar-toggle-icon::before,
.crm-sidebar-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    background: currentColor;
    transition: transform var(--transition-quick);
}

.crm-sidebar-toggle-icon::before { transform: translateY(-6px); }
.crm-sidebar-toggle-icon::after { transform: translateY(6px); }

.crm-alert {
    padding: 16px 22px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(6, 12, 28, 0.55);
    box-shadow: 0 18px 36px rgba(10, 10, 35, 0.38);
}

.crm-alert-success { border-color: rgba(74, 210, 149, 0.5); color: var(--success); }
.crm-alert-warning { border-color: rgba(255, 179, 71, 0.45); color: var(--warning); }
.crm-alert-error { border-color: rgba(255, 107, 107, 0.45); color: var(--danger); }

.crm-shell {
    position: relative;
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 24px;
    min-height: 540px;
}

.crm-sidebar {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 28px;
    border-radius: 28px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.crm-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.crm-contact-search {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.crm-search-field {
    display: flex;
    gap: 12px;
}

.crm-search-field input[type="search"] {
    flex: 1 1 auto;
    padding: 12px 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(6, 16, 36, 0.6);
    color: var(--text-primary);
}

.crm-contact-scroll {
    overflow: auto;
    max-height: 620px;
    padding-right: 6px;
}

.crm-contact-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.crm-contact a {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: rgba(6, 14, 32, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    box-shadow: 0 12px 28px rgba(10, 10, 35, 0.32);
    transition: transform var(--transition-quick), box-shadow var(--transition-quick);
}

.crm-contact.is-active a {
    background: linear-gradient(135deg, rgba(88, 225, 255, 0.18), rgba(89, 97, 249, 0.18));
    border-color: rgba(88, 225, 255, 0.45);
    transform: translateY(-2px);
}

.crm-contact a:hover,
.crm-contact a:focus {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(10, 10, 35, 0.45);
}

.crm-contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(89, 97, 249, 0.7), rgba(88, 225, 255, 0.7));
    color: var(--text-primary);
    text-transform: uppercase;
}

.crm-contact-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.crm-contact-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.crm-contact-name {
    font-weight: 600;
    font-size: 1.05rem;
}

.crm-contact-time {
    font-size: 0.8rem;
    color: rgba(245, 247, 255, 0.65);
}

.crm-contact-email,
.crm-contact-snippet {
    font-size: 0.9rem;
    color: rgba(245, 247, 255, 0.7);
    display: block;
}

.crm-contact.is-empty .crm-contact-snippet {
    font-style: italic;
    color: rgba(245, 247, 255, 0.55);
}

.crm-empty-list,
.crm-empty-state,
.crm-empty-thread {
    display: grid;
    place-items: center;
    text-align: center;
    padding: 60px 20px;
    gap: 12px;
}

.crm-overlay {
    position: absolute;
    inset: 0;
    border-radius: 32px;
    background: rgba(4, 8, 20, 0.65);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-quick);
}

.crm-conversation {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 28px;
    border-radius: 32px;
}

.crm-conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.crm-conversation-email a {
    color: var(--accent);
}

.crm-conversation-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.crm-thread {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-height: 420px;
    overflow: auto;
    padding-right: 6px;
}

.crm-thread-item {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
    border-radius: 24px;
    background: rgba(6, 16, 36, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 36px rgba(10, 10, 35, 0.38);
}

.crm-thread-title {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    align-items: baseline;
}

.crm-thread-subject {
    font-size: 1.05rem;
    font-weight: 600;
}

.crm-thread-time {
    font-size: 0.85rem;
    color: rgba(245, 247, 255, 0.7);
}

.crm-thread-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.crm-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(6, 14, 32, 0.5);
}

.crm-tag-bulk { color: rgba(88, 225, 255, 0.95); border-color: rgba(88, 225, 255, 0.35); }
.crm-tag-group { color: rgba(185, 122, 255, 0.95); border-color: rgba(185, 122, 255, 0.35); }
.crm-tag-direct { color: rgba(245, 247, 255, 0.75); }
.crm-tag-status-sent { color: var(--success); border-color: rgba(74, 210, 149, 0.4); }
.crm-tag-status-failed { color: var(--danger); border-color: rgba(255, 107, 107, 0.4); }
.crm-tag-status-partial { color: var(--warning); border-color: rgba(255, 179, 71, 0.4); }
.crm-tag-status-pending { color: rgba(245, 247, 255, 0.75); }
.crm-tag-status-skipped,
.crm-tag-status-no-recipients { color: rgba(245, 247, 255, 0.6); }
.crm-tag-status-opened { color: rgba(88, 225, 255, 0.95); border-color: rgba(88, 225, 255, 0.35); }

.crm-thread-body p {
    white-space: pre-wrap;
    line-height: 1.7;
    color: var(--text-primary);
}

.crm-thread-recipients {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.9rem;
}

.crm-thread-recipients-label {
    font-weight: 600;
    color: rgba(245, 247, 255, 0.75);
}

.crm-thread-recipients ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
}

.crm-thread-error {
    color: var(--danger);
    font-size: 0.9rem;
}

.crm-thread-metric {
    font-size: 0.85rem;
}

.crm-composer {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.crm-composer-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.crm-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crm-field input,
.crm-field textarea {
    background: rgba(6, 14, 32, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 18px;
    padding: 14px 18px;
    color: var(--text-primary);
}

.crm-no-email-warning {
    color: rgba(255, 179, 71, 0.9);
    font-size: 0.92rem;
}

.crm-composer-actions {
    display: flex;
    justify-content: flex-end;
}

.crm-composer-actions button[disabled] {
    opacity: 0.5;
}

@media (max-width: 1180px) {
    .crm-shell {
        grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    }
}

@media (max-width: 960px) {
    .crm-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .crm-sidebar {
        position: absolute;
        inset: 0 auto 0 0;
        width: min(320px, 85vw);
        max-width: 85vw;
        transform: translateX(-120%);
        transition: transform var(--transition-slow), opacity var(--transition-slow);
        z-index: 10;
    }

    .crm-shell.crm-shell--sidebar-open .crm-sidebar {
        transform: translateX(0);
    }

    .crm-shell.crm-shell--sidebar-open .crm-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .crm-thread {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .crm-heading {
        align-items: flex-start;
    }

    .crm-conversation {
        padding: 22px;
    }

    .crm-contact a {
        grid-template-columns: 1fr;
    }

    .crm-contact-avatar {
        justify-self: flex-start;
    }
}
