:root {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;

    --bg: #0d1120;
    --surface: #171c2d;
    --text: #f3f5ff;
    --muted: #a7aec4;
    --primary: #8074ff;
    --line: #2a3044;
    --soft: #252a48;
}

.light {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #111827;
    --muted: #4b5563;
    --primary: #5b4ee0;
    --line: #d7dce5;
    --soft: #e9ecff;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
}

body {
    transition: background .2s, color .2s;
}

.app {
    min-height: 100vh;
    background: var(--bg);
    padding: 28px 18px 48px;
}

.wrap {
    max-width: 1050px;
    margin: auto;
}

/* HEADER */

.brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.logo {
    font-size: 22px;
    font-weight: 850;
}

.actions {
    display: flex;
    align-items: center;
    gap: 9px;
}

/* THEME */

.theme {
    width: 58px;
    height: 30px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 999px;
    cursor: pointer;
    position: relative;
}

.theme::before {
    content: "☀️";
    position: absolute;
    left: 4px;
    top: 4px;
    font-size: 12px;
}

.theme::after {
    content: "🌙";
    position: absolute;
    right: 4px;
    top: 4px;
    font-size: 12px;
}

.theme span {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    left: 2px;
    top: 2px;
    transition: .2s;
}

.theme.dark span {
    left: 30px;
}

/* HERO */

.hero {
    background: linear-gradient(135deg, #211b4d, #17324d);
    border-radius: 28px;
    padding: 34px 24px;
    color: white;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0,0,0,.38);
    cursor: pointer;
}

.hero h1 {
    margin: 0;
    font-size: clamp(27px,5vw,46px);
}

.hero p {
    margin: 9px 0 0;
    opacity: .9;
}

.countdown {
    margin: 28px auto 0;
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 12px;
    max-width: 760px;
}

.unit {
    background: rgba(255,255,255,.09);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 18px;
    padding: 18px 8px;
    transition: .2s;
}

.unit:hover {
    transform: translateY(-3px);
}

.num {
    font-size: clamp(30px,6vw,52px);
    font-weight: 900;
}

.lab {
    margin-top: 7px;
    font-size: 12px;
    opacity: .85;
    text-transform: uppercase;
}

.hint {
    margin-top: 17px;
    font-size: 13px;
}

/* SCHEDULE */

.schedule {
    display: none;
    margin-top: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18);
}

.schedule.open {
    display: block;
}

.schedule h2 {
    margin: 0 0 14px;
}

.row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr .8fr;
    gap: 10px;
    align-items: center;
    padding: 14px 4px;
    border-top: 1px solid var(--line);
}

.row:first-of-type {
    border-top: 0;
}

.subject {
    font-weight: 800;
}

.pill {
    display: inline-block;
    background: var(--soft);
    color: var(--primary);
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
}

.close {
    margin-top: 15px;
    border: 1px solid var(--line);
    background: var(--soft);
    color: var(--text);
    padding: 9px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
}

.close:hover {
    background: var(--primary);
    color: white;
}

/* MENU */

.menu {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 12px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 19px;
    min-height: 110px;
    cursor: pointer;
    transition: .2s;
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.icon {
    font-size: 25px;
}

.card b {
    display: block;
    margin-top: 8px;
}

.card span {
    font-size: 12px;
    color: var(--muted);
    display: block;
    margin-top: 4px;
}

/* TOOLS */

.tools {
    display: none;
    margin-top: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 20px;
}

.tools.open {
    display: block;
}

.tools h2 {
    margin: 0 0 14px;
}

/* SCORE */

.scoretabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding: 5px;
    background: var(--soft);
    border-radius: 14px;
}

.scoretab {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 800;
}

.scoretab.active {
    background: var(--surface);
    color: var(--primary);
}

/* INPUT */

.toolgrid {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 10px;
}

.toolbox {
    background: var(--soft);
    border-radius: 14px;
    padding: 13px;
    margin-bottom: 10px;
}

.toolbox label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.toolbox input,
.toolbox select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
}

/* BUTTON */

.toolbtn {
    margin-top: 2px;
    border: 0;
    background: var(--primary);
    color: white;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 800;
}

/* RESULT */

.result {
    margin-top: 14px;
    padding: 13px;
    border-radius: 12px;
    background: var(--soft);
    font-weight: 800;
}

/* TABLE */

.table-box {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
}

th,
td {
    padding: 8px;
    border-bottom: 1px solid var(--line);
    text-align: center;
}

th:first-child,
td:first-child {
    text-align: left;
}

table input {
    width: 90px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
}

/* CUTOFF */

.cutoff-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    table-layout: fixed;
    border: 1px solid var(--line);
}

.cutoff-table th,
.cutoff-table td {
    border-right: 1px solid var(--line);
    text-align: left;
}

.cutoff-table th {
    padding: 9px 7px;
    font-size: 11px;
    color: var(--muted);
    background: var(--soft);
    border-bottom: 1px solid var(--line);
}

.cutoff-table th:nth-child(1),
.cutoff-table td:nth-child(1) {
    width: 45px;
    text-align: left;
}

.cutoff-table th:nth-child(2),
.cutoff-table td:nth-child(2) {
    width: auto;
}

.cutoff-table th:nth-child(3),
.cutoff-table td:nth-child(3) {
    width: 34%;
}

.cutoff-table th:nth-child(4),
.cutoff-table td:nth-child(4) {
    width: 90px;
}

.cutoff-table td {
    padding: 9px 7px;
    border-top: 1px solid var(--line);
    vertical-align: middle;
    font-size: 13px;
}

.cutoff-table td:nth-child(2) {
    font-weight: 700;
}

.cutoff-table td:last-child {
    font-weight: 900;
    color: var(--primary);
}

.combo {
    color: var(--muted);
    font-size: 11px;
}

.rank {
    display: inline-grid;
    place-items: center;
    width: 21px;
    height: 21px;
    border-radius: 6px;
    background: var(--soft);
    color: var(--primary);
    font-size: 10px;
}

/* MESSAGE */

.message {
    margin-top: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px 20px;
    color: var(--muted);
    line-height: 1.6;
    text-align: center;
}

.message b {
    display: block;
    color: var(--text);
    margin-bottom: 5px;
}

/* MOBILE */

@media(max-width:700px) {

    .countdown {
        gap: 7px;
    }

    .menu {
        grid-template-columns: repeat(2,1fr);
    }

    .row {
        grid-template-columns: 1fr 1fr;
    }

    .toolgrid {
        grid-template-columns: 1fr;
    }

}

@media(max-width:420px) {

    .app {
        padding: 18px 12px 35px;
    }

    .hero {
        padding: 28px 13px;
        border-radius: 22px;
    }

    .countdown {
        grid-template-columns: repeat(2,1fr);
    }

    .menu {
        grid-template-columns: 1fr;
    }

    .row {
        font-size: 13px;
    }

    .cutoff-table {
        font-size: 11px;
    }

}
/* ===== TÌM KIẾM TRƯỜNG ===== */
.school-hint,
.cutoff-count {
    color: var(--muted);
    font-size: 13px;
    margin: 8px 0 12px;
}

#schoolSearch {
    width: 100%;
    min-width: 0;
}

.cutoff-heading {
    margin: 8px 0;
    overflow-wrap: anywhere;
}

#cutoffResult {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.cutoff-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}

.cutoff-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
    color: var(--text);
}

.cutoff-table th,
.cutoff-table td {
    padding: 12px 8px;
    border: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    overflow-wrap: anywhere;
    word-break: normal;
}

.cutoff-table th {
    background: var(--soft);
    color: var(--muted);
    font-weight: 700;
}

.cutoff-table th:nth-child(1),
.cutoff-table td:nth-child(1) {
    width: 38px;
    text-align: center;
    white-space: nowrap;
}

.cutoff-table th:nth-child(2),
.cutoff-table td:nth-child(2) {
    width: 38%;
}

.cutoff-table th:nth-child(4),
.cutoff-table td:nth-child(4) {
    width: 58px;
    text-align: center;
    white-space: nowrap;
}

.cutoff-table .rank-cell {
    color: var(--primary);
    font-weight: 800;
}

.cutoff-table .combo-cell {
    color: var(--muted);
    font-weight: 600;
}

.cutoff-table .score-cell {
    color: var(--primary);
    font-weight: 850;
}

.cutoff-empty {
    padding: 12px;
    color: var(--muted);
}

@media (max-width: 600px) {
    .app {
        padding-left: 12px;
        padding-right: 12px;
    }

    .tools {
        padding: 14px;
        min-width: 0;
    }

    .cutoff-table {
        font-size: 12px;
    }

    .cutoff-table th,
    .cutoff-table td {
        padding: 10px 5px;
    }

    .cutoff-table th:nth-child(1),
    .cutoff-table td:nth-child(1) {
        width: 30px;
    }

    .cutoff-table th:nth-child(2),
    .cutoff-table td:nth-child(2) {
        width: 38%;
    }

    .cutoff-table th:nth-child(4),
    .cutoff-table td:nth-child(4) {
        width: 52px;
    }
}

/* Gợi ý trường nằm ngay dưới ô tìm kiếm */
.school-search-box {
    position: relative;
    min-width: 0;
}

.school-suggestions {
    position: absolute;
    top: calc(100% - 36px);
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 240px;
    overflow-y: auto;
    background: #202338;
    border: 1px solid #393e59;
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .35);
}

.school-suggestions[hidden] {
    display: none;
}

.school-suggestion {
    display: block;
    width: 100%;
    padding: 13px 15px;
    border: 0;
    border-bottom: 1px solid #343850;
    background: transparent;
    color: #f4f5ff;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.school-suggestion:last-child {
    border-bottom: 0;
}

.school-suggestion:hover,
.school-suggestion:focus {
    background: #343052;
    outline: none;
}

.school-suggestion small {
    display: block;
    margin-top: 4px;
    color: #a5a9c0;
    font-size: 12px;
}

.school-no-result {
    padding: 13px 15px;
    color: #a5a9c0;
    font-size: 13px;
}
/* Danh ngôn truyền cảm hứng */
.inspiration {
    margin: 12px auto 18px;
    max-width: 750px;
    text-align: center;
}

.quote-text {
    font-size: clamp(14px, 2vw, 18px);
    font-weight: 600;
    line-height: 1.7;
    transition: opacity .35s ease, transform .35s ease;
}

.quote-author {
    margin-top: 5px;
    font-size: 12px;
    opacity: .7;
    transition: opacity .35s ease;
}

.inspiration.changing .quote-text,
.inspiration.changing .quote-author {
    opacity: 0;
    transform: translateY(5px);
}

.quote-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
}

.quote-dot {
    width: 6px;
    height: 6px;
    padding: 0;
    border: 0;
    border-radius: 20px;
    background: #cbd5e1;
    cursor: pointer;
    transition: width .3s ease, background .3s ease;
}

.quote-dot.active {
    width: 20px;
    background: #64748b;
}

/* Fix danh ngôn trên điện thoại */
.inspiration {
    display: block !important;
    width: 100%;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 12px auto 18px;
    padding: 0 10px;
    box-sizing: border-box;
    text-align: center;
}

.quote-text {
    display: block !important;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.quote-author {
    display: block !important;
    margin-top: 8px;
}

.quote-dots {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
    margin-top: 12px;
}

.quote-dot {
    flex: 0 0 6px;
    min-width: 6px;
    min-height: 6px;
}

.quote-dot.active {
    flex-basis: 20px;
}
