:root {
    --blue: #00414E;
    --blue-dark: #002f38;
    --blue-light: #e6eef0;
    --red: #c0392b;
    --green: #1e8e4e;
    --gray: #6b7280;
    --border: #ddd8d3;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1f2937;
    background: #f5f3f1;
    line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; color: var(--blue-dark); margin: 0.4rem 0 0.6rem; }
h2 { font-size: 1.15rem; color: var(--blue-dark); margin-top: 1.6rem; }
h3 { margin-top: 0; }
.muted { color: var(--gray); }
.small { font-size: 0.85rem; }
code { background: var(--blue-light); padding: 0 4px; border-radius: 4px; }

/* ---------- layout / sidebar ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 250px;
    background: var(--blue); color: #fff; padding: 1.2rem 0;
    overflow-y: auto; z-index: 30;
}
.sidebar .brand {
    font-weight: 700; font-size: 1.05rem; padding: 0 1.2rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.25); margin-bottom: .6rem;
}
.sidebar nav a {
    display: block; color: #dbe7f4; padding: .65rem 1.2rem; font-size: .95rem;
    border-left: 4px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,.15); border-left-color: #fff; color: #fff; font-weight: 600; }
.main { flex: 1; margin-left: 250px; padding: 1.5rem 2rem; max-width: calc(100% - 250px); }
#sidebar-toggle {
    display: none; position: fixed; top: 10px; left: 10px; z-index: 40;
    background: var(--blue); color: #fff; border: 0; border-radius: 6px;
    font-size: 1.1rem; padding: .35rem .6rem; cursor: pointer;
}
.sidebar-overlay { display: none; }

/* ---------- buttons / badges / cards ---------- */
.btn {
    display: inline-block; border: 1px solid var(--border); background: #fff; color: #1f2937;
    border-radius: 6px; padding: .5rem 1rem; font-size: .95rem; cursor: pointer;
}
.btn:hover { background: #f0f4f8; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #a5301f; }
.btn-small { padding: .3rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn.flagged { background: #fff3cd; border-color: #e0b84c; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge-pass { background: #e2f5e9; color: var(--green); }
.badge-fail { background: #fbe4e1; color: var(--red); }
.badge-neutral { background: #e5eaf0; color: #4b5563; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1rem 0; }
.card {
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    padding: 1.1rem; text-align: center; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card-num { font-size: 1.8rem; font-weight: 700; color: var(--blue); }
.card-label { color: var(--gray); font-size: .85rem; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: .6rem; }
.table th, .table td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .92rem; }
.table th { background: var(--blue-light); color: var(--blue-dark); }
.table tr:last-child td { border-bottom: 0; }
.row-correct td { background: #f4fbf6; }
.row-wrong td { background: #fdf6f5; }

.empty-state {
    background: #fff; border: 1px dashed var(--border); border-radius: 10px;
    padding: 2rem; text-align: center; color: var(--gray); margin-top: 1rem;
}

/* ---------- login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--blue-light); }
.login-card {
    background: #fff; border-radius: 12px; box-shadow: 0 4px 18px rgba(0,0,0,.08);
    padding: 2rem; width: 100%; max-width: 360px;
}
.login-card h1 { text-align: center; margin-top: 0; }
.login-card label { display: block; margin: .8rem 0 .25rem; font-size: .9rem; font-weight: 600; }
.login-card input { width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; }
.login-card .btn { margin-top: 1.2rem; }
.alert { padding: .6rem .8rem; border-radius: 6px; margin: .8rem 0; font-size: .9rem; }
.alert-error { background: #fbe4e1; color: var(--red); }

/* ---------- tests list ---------- */
.test-list { display: flex; flex-direction: column; gap: .7rem; margin-top: 1rem; }
.test-row {
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    padding: .9rem 1.1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.test-actions { display: flex; gap: .5rem; align-items: center; }
.inline-form { display: inline; margin: 0; }

/* ---------- score report (result.php) ---------- */
.report-head {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.report-head h1 { font-size: 1.4rem; margin: .4rem 0 1rem; }
.report-actions { display: flex; gap: .5rem; align-items: center; }
.report-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
    background: #fff; color: var(--blue); cursor: pointer; font-size: 1rem; text-decoration: none;
}
.report-icon:hover { background: var(--blue-light); }

.report-card {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    display: flex; gap: 2rem; padding: 1.6rem; flex-wrap: wrap;
}
.report-left { min-width: 220px; }
.report-score { font-size: 1.7rem; color: var(--blue); }
.report-score strong { font-weight: 800; }
.report-verdict { font-size: 1.25rem; font-weight: 800; margin: .3rem 0 .8rem; }
.report-verdict.pass { color: var(--green); }
.report-verdict.fail { color: var(--red); }
.report-meta { color: #4b5563; font-size: .95rem; margin-top: .2rem; }
.report-right { flex: 1; min-width: 300px; display: flex; align-items: center; }

.scale-wrap { width: 100%; padding-top: 2.2rem; }
.scale-bar { position: relative; display: flex; height: 14px; border-radius: 999px; overflow: hidden; }
.scale-seg { height: 100%; }
.scale-below { background: #e5e7eb; }
.scale-passzone { background: #cfe9d8; }
.scale-fill {
    position: absolute; left: 0; top: 0; bottom: 0; background: var(--green);
    border-radius: 999px 0 0 999px;
}
.scale-fill.fail { background: var(--red); }
.scale-marker {
    position: absolute; top: -4px; bottom: -4px; width: 2px; background: #9ca3af;
}
.scale-bubble {
    position: absolute; top: .4rem; transform: translateX(-50%);
    background: #fff; border-radius: 8px; padding: .15rem .6rem;
    font-weight: 800; color: var(--green); box-shadow: 0 1px 5px rgba(0,0,0,.18);
    font-size: .95rem;
}
.scale-bubble.fail { color: var(--red); }
.scale-wrap { position: relative; }
.scale-bubble::after {
    content: ''; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: #fff; border-bottom: 0;
}
.scale-labels { display: flex; align-items: flex-start; margin-top: .45rem; font-size: .8rem; color: var(--gray); }
.scale-lbl-below { text-align: center; }
.scale-lbl-pass { text-align: center; color: var(--green); font-weight: 600; }

.skills-card, .breakdown-card {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 1.2rem 1.4rem; margin-top: 1.2rem;
}
.skills-card h2, .breakdown-card h2 { margin-top: 0; }
.skills-list { list-style: none; margin: 0; padding: 0; }
.skills-list li {
    display: flex; justify-content: space-between; gap: 1rem;
    padding: .55rem 0; border-bottom: 1px solid #eee9e4;
}
.skills-list li:last-child { border-bottom: 0; }
.skills-topic { font-weight: 600; }
.skills-count { color: var(--red); font-size: .9rem; }
.skills-perfect { color: var(--green); font-weight: 600; margin: 0; }
.breakdown-card .table { border: 0; }
.mark { font-weight: 800; font-size: 1rem; }
.mark-ok { color: var(--green); }
.mark-no { color: var(--red); }

/* ---------- my test history (tests.php?view=results) ---------- */
.history-table { margin-top: 1.2rem; }
.status-pass { color: var(--green); font-weight: 700; }
.status-fail { color: var(--red); font-weight: 700; }
.status-progress { color: #92600a; font-weight: 700; }
.history-score {
    font-weight: 800; color: var(--blue); display: inline-flex; align-items: center; gap: .3rem;
}
.history-score .rosette { color: #f2a93b; }
.history-resume { font-weight: 700; }

/* ---------- exam ---------- */
.exam-page .main { max-width: none; }
.exam-topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
    background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: .7rem 1rem;
}
.timer { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--blue-dark); }
.timer-low { color: var(--red); }
.exam-body { display: flex; gap: 1.2rem; margin-top: 1rem; align-items: flex-start; }
.exam-main-col { flex: 1; min-width: 0; }
.exam-split { display: flex; gap: 1.2rem; }
.stimulus-pane, .question-pane {
    background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem;
}
.stimulus-pane { flex: 1; min-width: 0; max-height: 60vh; overflow-y: auto; }
.question-pane { flex: 1; min-width: 0; }
.stimulus-pane[style*="none"] + .question-pane { flex: 1 1 100%; }
.q-text { font-size: 1.05rem; margin: .4rem 0 1rem; }
.q-options { display: flex; flex-direction: column; gap: .5rem; }
.opt {
    display: block; border: 1px solid var(--border); border-radius: 8px; padding: .55rem .8rem; cursor: pointer;
}
.opt:hover { background: var(--blue-light); }
.q-fill, .q-select { width: 100%; max-width: 420px; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; }
.exam-controls { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
.exam-controls .btn-danger { margin-left: auto; }
.exam-nav-col { width: 210px; flex-shrink: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.qnav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; }
.qnav-cell {
    border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: .35rem 0;
    cursor: pointer; font-size: .85rem;
}
.qnav-cell.answered { background: var(--blue); color: #fff; border-color: var(--blue); }
.qnav-cell.flagged { box-shadow: inset 0 -3px 0 #e0a800; }
.qnav-cell.current { outline: 2px solid var(--blue-dark); }
.legend { margin-top: .8rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.dot-answered { background: var(--blue); }
.dot-flagged { background: #e0a800; }

/* ---------- modal ---------- */
.modal-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50;
    align-items: center; justify-content: center;
}
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 1.5rem; max-width: 420px; width: 90%; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

/* ---------- home portal (GED "My Scores") ---------- */
.hero {
    background: var(--blue); color: #fff;
    margin: -1.5rem -2rem 2rem; padding: 2.5rem 2rem 2rem;
}
.hero h1 { color: #fff; font-size: 2rem; margin: 0 0 .3rem; }
.hero-sub { color: #cfe0e4; margin: 0 0 1rem; font-size: 1.05rem; }
.hero-stats { font-size: .92rem; color: #cfe0e4; }
.hero-stats strong { color: #fff; }
.hero-dot { margin: 0 .5rem; }

.highest-scores h2, .recent h2 { font-size: 1.35rem; }
.highest-scores > .muted { margin-top: -.2rem; }

.score-cards {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.1rem; margin: 1.2rem 0 1.4rem;
}
.score-card {
    background: var(--pastel, #eef2f6); border-radius: 12px; overflow: hidden;
    border: 1px solid var(--border);
    display: flex; flex-direction: column;
}
.score-card-head {
    background: var(--blue); color: #fff; padding: .8rem 1rem;
    display: flex; align-items: center; gap: .6rem;
}
.score-card-head .medal { color: #f2c94c; flex-shrink: 0; }
.score-card-kicker { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: #cfe0e4; }
.score-card-name { font-weight: 700; font-size: 1.02rem; line-height: 1.2; }
.score-card-body { padding: 1.3rem 1rem 1.1rem; text-align: center; flex: 1; display: flex; flex-direction: column; align-items: center; }
.score-circle {
    width: 96px; height: 96px; border-radius: 50%; background: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.9rem; font-weight: 800; color: var(--blue-dark);
    box-shadow: 0 1px 4px rgba(0,0,0,.10); margin-bottom: .8rem;
}
.score-status { font-size: .92rem; color: #4b5563; margin-bottom: .6rem; }
.score-status.passed { color: var(--green); font-weight: 700; }
.score-report { font-size: .88rem; font-weight: 600; margin-top: auto; }

.cta-empty { text-align: center; margin: .4rem 0 1rem; }
.center { text-align: center; margin: .6rem 0 2rem; }
.btn-outline-teal {
    background: transparent; border: 2px solid var(--blue); color: var(--blue);
    border-radius: 999px; padding: .55rem 1.6rem; font-weight: 700;
}
.btn-outline-teal:hover { background: var(--blue); color: #fff; text-decoration: none; }

@media (max-width: 1100px) { .score-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
    .hero { margin: -3.2rem -1rem 1.5rem; padding: 4rem 1rem 1.6rem; }
    .score-cards { grid-template-columns: 1fr; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }
    #sidebar-toggle { display: block; }
    .main { margin-left: 0; max-width: 100%; padding: 3.2rem 1rem 1.5rem; }
    .exam-body { flex-direction: column; }
    .exam-nav-col { width: 100%; }
    .qnav-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
    .exam-split { flex-direction: column; }
    .stimulus-pane { max-height: none; }
    .table { display: block; overflow-x: auto; }
}
