* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    width: 100%;
    min-height: 100%;
    background: #020817;
    color: #f8fafc;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
}

.app-container {
    position: relative;
    width: min(100%, 1080px);
    min-height: 760px;
    background: radial-gradient(circle at top, rgba(34, 211, 238, 0.26), transparent 28%), #020817;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(2, 6, 23, 0.42), inset 0 1px 0 rgba(255,255,255,0.12);
}

.landing-screen {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 28px;
    background: radial-gradient(circle at top right, #082f49 0%, #0f172a 56%, #020817 100%);
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.landing-screen:not(.active) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.landing-content {
    width: min(100%, 440px);
    margin: 0 auto;
    text-align: center;
}

.title {
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    line-height: 1.04;
    font-weight: 900;
    letter-spacing: -0.06em;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #f8fafc 0%, #7dd3fc 36%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #67e8f9;
    margin-bottom: 10px;
}

.stat-label {
    color: #cbd5e1;
    font-size: 1rem;
    line-height: 1.5;
}

.input-card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 12px;
    text-align: left;
    box-shadow: 0 20px 35px rgba(2, 6, 23, 0.28);
}

.input-card h3 {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 5px;
}

.input-desc {
    color: #94a3b8;
    font-size: 0.78rem;
    line-height: 1.45;
    margin-bottom: 14px;
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
    min-width: 0;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 10px 12px;
    color: #f8fafc;
    font-size: 0.85rem;
    outline: none;
}

.input-group input::placeholder {
    color: rgba(148, 163, 184, 0.18);
    opacity: 1;
}

.input-group input:focus {
    border-color: rgba(125, 211, 252, 0.9);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.action-btn-sm {
    appearance: none;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
    color: white;
    font-weight: 800;
    font-size: 0.85rem;
    padding: 0 16px;
    cursor: pointer;
}

.divider {
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.7);
    margin: 12px 0;
}

.file-btn {
    display: block;
    width: 100%;
    border-radius: 12px;
    text-align: center;
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    color: #052e16;
    font-weight: 800;
    padding: 12px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

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

.file-name {
    display: block;
    margin-top: 8px;
    color: #64748b;
    font-size: 0.72rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.demo-btn {
    position: absolute;
    right: 24px;
    bottom: 18px;
    background: transparent;
    border: none;
    color: rgba(148, 163, 184, 0.16);
    cursor: pointer;
    font-size: 0.68rem;
    transition: color 0.2s ease;
}

.demo-btn:hover {
    color: rgba(148, 163, 184, 0.42);
}

.heatmap-screen {
    width: 100%;
    min-height: 760px;
    display: flex;
    flex-direction: column;
    padding: 24px clamp(16px, 3vw, 28px) 28px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.8), rgba(2, 6, 23, 0.96));
}

.heatmap-screen[hidden] {
    display: none;
}

.heatmap-header {
    text-align: center;
    margin-bottom: 14px;
}

.heatmap-header h1 {
    font-size: clamp(2rem, 5vw, 3.1rem);
    line-height: 1.08;
    font-weight: 900;
    letter-spacing: -0.06em;
    background: linear-gradient(135deg, #ffffff 0%, #a5f3fc 40%, #c4b5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#heatmapSummaryText {
    margin-top: 8px;
    color: #cbd5e1;
    font-size: 0.96rem;
}

.ghost-btn {
    margin-top: 18px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.32);
    background: rgba(15, 23, 42, 0.35);
    color: #e2e8f0;
    font-weight: 700;
    cursor: pointer;
}

.tick-scope-toggle {
    display: flex;
    justify-content: center;
    width: fit-content;
    margin: 0 auto 10px;
    padding: 3px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.5);
}

.tick-scope-toggle legend {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.tick-scope-option {
    position: relative;
    cursor: pointer;
}

.tick-scope-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tick-scope-option span {
    display: block;
    border-radius: 999px;
    padding: 7px 13px;
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.tick-scope-option input:checked + span {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.28), rgba(167, 139, 250, 0.28));
    color: #f8fafc;
    box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.5), inset 0 1px 0 rgba(255,255,255,0.16);
}

.tick-scope-option input:focus-visible + span {
    outline: 2px solid #a5f3fc;
    outline-offset: 2px;
}

.grade-family-toggle {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 auto 18px;
    width: min(100%, 660px);
}

.grade-family-btn {
    appearance: none;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(15, 23, 42, 0.5);
    color: #cbd5e1;
    font-weight: 800;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: 9px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.grade-family-btn:hover,
.grade-family-btn:focus-visible {
    border-color: rgba(125, 211, 252, 0.7);
    color: #e0f2fe;
}

.grade-family-btn.active {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.28), rgba(167, 139, 250, 0.28));
    border-color: rgba(125, 211, 252, 0.8);
    color: #f8fafc;
    box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.28), inset 0 1px 0 rgba(255,255,255,0.16);
}

.heatmap-panel {
    width: 100%;
    overflow-x: auto;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 20px;
    padding: 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.heatmap-chart {
    display: grid;
    gap: 0;
    min-width: 0;
    padding: 0;
}

.heatmap-row {
    display: contents;
}

.heatmap-label,
.heatmap-year,
.heatmap-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 14px;
    height: 14px;
    border-radius: 0;
    border: none;
    padding: 0;
    text-align: center;
    font-size: 0.66rem;
    line-height: 1;
}

.heatmap-label {
    justify-content: flex-start;
    padding-left: 5px;
    color: #e2e8f0;
    font-weight: 700;
    background: rgba(15, 23, 42, 0.18);
}

.heatmap-year {
    color: #cbd5e1;
    font-weight: 800;
    background: rgba(15, 23, 42, 0.12);
    font-size: 0.58rem;
}

.heatmap-cell {
    background: rgba(148, 163, 184, 0.08);
    color: rgba(248, 250, 252, 0.8);
    font-weight: 700;
    transition: transform 0.2s ease;
}

.heatmap-cell[role="button"] {
    cursor: pointer;
}

.heatmap-cell[role="button"]:hover,
.heatmap-cell[role="button"]:focus-visible {
    transform: translateY(-1px);
    outline: 1px solid #f8fafc;
    outline-offset: -1px;
}

.heatmap-cell.empty {
    opacity: 0.4;
}

body.modal-open {
    overflow: hidden;
}

.cell-modal[hidden] {
    display: none;
}

.cell-modal {
    position: fixed;
    z-index: 10;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
}

.cell-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.76);
    backdrop-filter: blur(6px);
}

.cell-modal-dialog {
    position: relative;
    width: min(100%, 520px);
    max-height: min(74dvh, 620px);
    overflow: hidden;
    border: 1px solid rgba(125, 211, 252, 0.38);
    border-radius: 14px;
    background: #0f172a;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.56);
}

.cell-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.cell-modal-header .subtitle {
    margin-bottom: 5px;
}

.cell-modal-header h2 {
    font-size: 1.35rem;
    line-height: 1.1;
}

.cell-modal-close {
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    padding: 6px 9px;
    background: rgba(15, 23, 42, 0.55);
    color: #e2e8f0;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 800;
}

.cell-modal-list {
    max-height: calc(min(74dvh, 620px) - 106px);
    overflow-y: auto;
}

.cell-modal-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 16px;
    padding: 14px 22px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.cell-modal-item:last-child {
    border-bottom: none;
}

.cell-modal-area {
    grid-column: 1 / -1;
    margin-bottom: 4px;
    color: #67e8f9;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.cell-modal-item h3 {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 0.94rem;
    line-height: 1.25;
}

.cell-modal-grade {
    align-self: center;
    color: #f8fafc;
    font-size: 0.82rem;
    font-weight: 800;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.summary-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 16px;
    padding: 16px 18px;
}

.summary-card .label {
    color: #94a3b8;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.summary-card .value {
    font-size: clamp(1.2rem, 3vw, 2rem);
    font-weight: 900;
    letter-spacing: -0.04em;
}

@media (max-width: 640px) {
    .app-container {
        min-height: 92vh;
        border-radius: 20px;
    }

    .heatmap-screen {
        min-height: 92vh;
    }

    .heatmap-panel {
        padding-inline: 8px;
    }
}
