:root {
    --bg: #06111f;
    --bg-2: #091b31;
    --panel: rgba(7, 17, 31, 0.76);
    --panel-soft: rgba(9, 21, 38, 0.62);
    --ink: #edf7ff;
    --muted: #9cb6d1;
    --line: rgba(120, 189, 255, 0.18);
    --cyan: #46d7ff;
    --cyan-2: #8ef3ff;
    --lime: #73ffa5;
    --red: #ff6f91;
    --violet: #8b7cff;
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 10%, rgba(70, 215, 255, 0.22), transparent 22%),
        radial-gradient(circle at 90% 15%, rgba(139, 124, 255, 0.2), transparent 18%),
        radial-gradient(circle at 80% 80%, rgba(115, 255, 165, 0.12), transparent 20%),
        linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 52%, #040b14 100%);
    background-attachment: fixed;
}

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

.auth-shell,
.app-shell {
    min-height: 100vh;
    display: grid;
    position: relative;
}

.auth-shell {
    place-items: center;
    padding: 24px;
}

.ambient {
    position: fixed;
    width: 34vw;
    height: 34vw;
    border-radius: 50%;
    filter: blur(40px);
    pointer-events: none;
    opacity: 0.45;
}

.ambient-one {
    left: -8vw;
    top: -10vw;
    background: rgba(70, 215, 255, 0.18);
}

.ambient-two {
    right: -10vw;
    bottom: -12vw;
    background: rgba(139, 124, 255, 0.18);
}

.auth-card,
.panel,
.hero-card {
    background: var(--panel);
    border: 1px solid var(--line);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(560px, 100%);
    padding: 42px;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: -40px auto auto -30px;
    width: 220px;
    height: 220px;
    border-radius: 28px;
    background: linear-gradient(145deg, rgba(70, 215, 255, 0.2), rgba(139, 124, 255, 0));
    transform: rotate(24deg);
    pointer-events: none;
}

.auth-card h1,
.hero-card h1,
.panel h1,
.panel h2,
.panel h3,
.sidebar h2,
.stat-card strong {
    margin-top: 0;
    font-family: "Segoe UI", Inter, system-ui, sans-serif;
    letter-spacing: -0.03em;
}

.auth-card h1,
.hero-card h1 {
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1;
}

.brand-pill,
.sidebar-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(70, 215, 255, 0.12);
    border: 1px solid rgba(70, 215, 255, 0.18);
    color: var(--cyan-2);
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.stack-form {
    display: grid;
    gap: 18px;
}

.stack-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.stack-form input[type="text"],
.stack-form input[type="password"] {
    width: 100%;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 1rem;
    color: var(--ink);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.stack-form input[type="text"]:focus,
.stack-form input[type="password"]:focus {
    outline: none;
    border-color: rgba(70, 215, 255, 0.8);
    box-shadow: 0 0 0 4px rgba(70, 215, 255, 0.14);
    transform: translateY(-1px);
}

.stack-form input::placeholder {
    color: rgba(237, 247, 255, 0.42);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 14px 20px;
    border-radius: 18px;
    border: none;
    cursor: pointer;
    font-size: 0.98rem;
    font-weight: 700;
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn.primary {
    background: linear-gradient(135deg, var(--cyan) 0%, var(--violet) 100%);
    color: #03111f;
    box-shadow: 0 12px 30px rgba(70, 215, 255, 0.22);
}

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

.btn-small {
    padding: 10px 14px;
    font-size: 0.85rem;
    border-radius: 14px;
}

.app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
    width: 100%;
}

.sidebar {
    padding: 28px 18px;
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(5, 16, 29, 0.96), rgba(7, 17, 31, 0.78));
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 0;
    min-height: 100vh;
}

.content {
    padding: 32px;
    display: grid;
    gap: 28px;
    min-width: 0;
}

.hero-card {
    padding: 34px;
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 24px;
}

.hero-card::after {
    content: "";
    position: absolute;
    inset: 14px 14px auto auto;
    width: 180px;
    height: 180px;
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(115, 255, 165, 0.1), rgba(70, 215, 255, 0));
    transform: rotate(22deg);
}

.panel {
    padding: 28px;
}

.dataset-grid,
.checkbox-grid,
.auth-meta {
    display: grid;
    gap: 14px;
}

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

.checkbox-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.checkbox-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.dataset-card,
.check-card {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 16px;
}

.dataset-card {
    display: grid;
    gap: 6px;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.dataset-card:hover {
    transform: translateY(-2px);
    border-color: rgba(70, 215, 255, 0.34);
    background: rgba(255, 255, 255, 0.08);
}

.check-card {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-card input {
    accent-color: var(--cyan);
}

.alert {
    padding: 14px 16px;
    border-radius: 18px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.alert.error {
    background: rgba(255, 111, 145, 0.12);
    color: #ffd6df;
    border-color: rgba(255, 111, 145, 0.24);
}

.alert.success {
    background: rgba(115, 255, 165, 0.12);
    color: #d8ffe7;
    border-color: rgba(115, 255, 165, 0.2);
}

.upload-dropzone {
    padding: 26px;
    border: 1px dashed rgba(70, 215, 255, 0.38);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03));
    display: grid;
    gap: 10px;
    color: var(--ink);
}

.upload-dropzone small,
.dataset-card span,
.dataset-card small,
.panel p,
.sidebar p,
.auth-meta span {
    color: var(--muted);
}

.upload-dropzone input[type="file"] {
    margin-top: 12px;
    color: var(--muted);
    width: 100%;
}

.preview-table-wrap,
.table-wrap {
    overflow-x: auto;
    border-radius: 24px;
    border: 1px solid var(--line);
}

.preview-table,
.attendance-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.04);
    table-layout: auto;
}

.preview-table th,
.preview-table td,
.attendance-table th,
.attendance-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: normal;
    word-break: break-word;
    max-width: 220px;
}

.cell-display {
    min-height: 1.25rem;
    white-space: normal;
    word-break: break-word;
}

.cell-input {
    width: 100%;
    min-width: 120px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
}

.cell-input:focus {
    outline: none;
    border-color: rgba(70, 215, 255, 0.8);
    box-shadow: 0 0 0 3px rgba(70, 215, 255, 0.14);
}

.row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.attendance-table th {
    position: sticky;
    top: 0;
    background: rgba(8, 19, 35, 0.96);
    z-index: 1;
}

.status-toggle {
    display: inline-flex;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.status-btn {
    border: none;
    border-radius: 999px;
    padding: 9px 14px;
    cursor: pointer;
    background: transparent;
    color: var(--muted);
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.status-btn.active.present {
    background: rgba(115, 255, 165, 0.14);
    color: var(--lime);
}

.status-btn.active.absent {
    background: rgba(255, 111, 145, 0.14);
    color: var(--red);
}

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

.save-indicator {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    min-width: 120px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.save-indicator.saving {
    background: rgba(70, 215, 255, 0.12);
    color: var(--cyan-2);
}

.save-indicator.saved {
    background: rgba(115, 255, 165, 0.12);
    color: var(--lime);
}

.save-indicator.error {
    background: rgba(255, 111, 145, 0.12);
    color: var(--red);
}

.export-box {
    margin: 20px 0 28px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    border-radius: 22px;
}

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

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--line);
        min-height: auto;
        position: static;
    }

    .panel-header,
    .auth-meta {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 14px;
    }

    .auth-card,
    .panel,
    .hero-card {
        border-radius: 24px;
    }

    .auth-card {
        padding: 28px;
    }

    .panel {
        padding: 18px;
    }

    .preview-table th,
    .preview-table td,
    .attendance-table th,
    .attendance-table td {
        padding: 10px 8px;
        max-width: 160px;
        font-size: 0.9rem;
    }

    .btn,
    .btn-small {
        width: 100%;
    }

    .row-actions,
    .status-toggle {
        min-width: 130px;
    }
}
