:root {
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --secondary: #764ba2;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --bg: #f0f2f8;
    --card: #ffffff;
    --text: #2d3436;
    --text-muted: #636e72;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(102, 126, 234, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 16px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.2rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.nav {
    display: flex;
    gap: 8px;
    flex: 1;
}

.nav a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: background 0.2s;
}

.nav a:hover,
.nav a.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0 !important;
    flex-shrink: 0;
}

.nav-icon svg {
    display: block;
}

.site-footer .footer-portal-link {
  margin-top: 10px;
}

.site-footer .footer-portal-link a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.site-footer .footer-portal-link a:hover {
  text-decoration: underline;
}

.header-stats {
    display: flex;
    gap: 16px;
    font-size: 0.9rem;
    opacity: 0.9;
}

main.container {
    padding-top: 32px;
    padding-bottom: 48px;
}

/* Hero */
.hero {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 32px;
    align-items: center;
    margin-bottom: 40px;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.hero-sub {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.hero-stats {
    display: flex;
    gap: 16px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px 24px;
    text-align: center;
    box-shadow: var(--shadow);
    min-width: 120px;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Progress */
.progress-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 40px;
    box-shadow: var(--shadow);
}

.progress-section h2 {
    margin-bottom: 16px;
}

.progress-bar-wrap {
    background: #e9ecef;
    border-radius: 999px;
    height: 16px;
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
}

.progress-text {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Calendar grid */
.calendar-section h2 {
    margin-bottom: 8px;
}

.section-desc {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.day-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.day-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
}

.day-card:hover:not(.locked) {
    transform: translateY(-2px);
}

.day-card.today {
    border-color: var(--primary);
}

.day-card.locked {
    opacity: 0.55;
}

.day-card.completed.score-excellent {
    border-color: var(--success);
}

.day-card.needs-retry {
    border-color: var(--warning);
    background: #fffbf0;
}

.day-card.needs-retry .retry-score {
    color: #e65100;
    font-weight: 700;
}

.btn-retry {
    background: var(--warning) !important;
}

.badge-require {
    background: #fce4ec;
    color: #c2185b;
}

.badge-retry {
    background: #fff3e0;
    color: #e65100;
}

.hero-done {
    background: rgba(255, 255, 255, 0.15);
    padding: 16px 20px;
    border-radius: var(--radius);
    color: white;
}

.hero-done p {
    margin: 4px 0;
}

.hero-next {
    opacity: 0.95;
}

.results-header.score-perfect {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.perfect-label {
    font-size: 1.4rem;
}

.result-message p {
    margin: 6px 0;
}

.next-day-hint {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Màn hình kết quả kiểu flyers-practice */
.result-screen {
    max-width: 480px;
    margin: 0 auto 24px;
    text-align: center;
}

.result-card {
    padding: 28px 22px 24px;
    border-radius: 18px;
    background: linear-gradient(180deg, #fafbff 0%, #fff 100%);
    border: 2px solid #c7d2fe;
}

.result-screen h3 {
    margin: 0 0 12px;
    font-size: 1.4rem;
    font-weight: 800;
}

.result-emoji {
    font-size: 2.75rem;
    line-height: 1;
    margin-bottom: 8px;
}

.result-scores {
    margin: 0 auto;
    padding: 16px 18px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    text-align: center;
}

.result-score-total {
    margin: 0;
    font-size: 1.1rem;
}

.result-score-total strong {
    font-weight: 900;
    color: var(--primary);
}

.result-screen.is-success .result-card {
    border-color: #86efac;
    background: linear-gradient(180deg, #f0fdf4 0%, #fff 100%);
    box-shadow: 0 4px 24px rgba(34, 197, 94, 0.12);
}

.result-screen.is-success h3 {
    color: #15803d;
}

.result-screen.is-success .result-score-total strong {
    color: #15803d;
}

.result-success-lead {
    margin: 8px 0 0;
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.5;
    color: #15803d;
}

.result-success-actions {
    margin-top: 20px;
}

.result-screen.is-fail .result-card {
    border-color: #fecaca;
    background: linear-gradient(180deg, #fff5f5 0%, #fff 100%);
    box-shadow: 0 4px 24px rgba(248, 113, 113, 0.12);
}

.result-screen.is-fail h3 {
    color: #b91c1c;
}

.result-fail-actions {
    margin-top: 20px;
}

.result-fail-hint {
    margin: 10px 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #64748b;
}

.result-retry-link {
    display: inline-block;
    font-size: 1.1rem;
    font-weight: 800;
    color: #2563eb;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.result-retry-link:hover {
    color: #1d4ed8;
}

.result-details-link {
    display: block;
    margin: 14px auto 0;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: underline;
    cursor: pointer;
}

.result-details-panel {
    margin-top: 14px;
    text-align: left;
    max-height: 280px;
    overflow-y: auto;
}

.result-details-panel.hidden {
    display: none;
}

.result-wrong-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.result-wrong-list li {
    padding: 12px 0;
    border-bottom: 1px solid #fee2e2;
}

.result-wrong-list li:last-child {
    border-bottom: none;
}

.result-wrong-q {
    margin: 0 0 6px;
    font-size: 0.92rem;
}

.result-wrong-ans {
    margin: 0 0 4px;
    font-size: 0.88rem;
    color: #b91c1c;
}

.result-wrong-correct {
    margin: 0;
    font-size: 0.88rem;
    color: #15803d;
}

.report-table tr.needs-retry td:nth-child(4),
.report-table tr.needs-retry td:nth-child(5) {
    color: #e65100;
    font-weight: 600;
}

.day-card.completed.score-good {
    border-color: #3498db;
}

.day-card.completed.score-ok {
    border-color: var(--warning);
}

.day-card.completed.score-low {
    border-color: var(--danger);
}

.day-number {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
}

.day-title {
    font-weight: 600;
    margin: 8px 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.day-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.day-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.day-score {
    font-weight: 700;
    margin-bottom: 8px;
}

.day-link {
    color: var(--primary);
    font-size: 0.85rem;
}

.locked-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-block;
    background: #eef1ff;
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-book {
    background: #fff3e0;
    color: #e65100;
}

.badge-count {
    background: #e8f5e9;
    color: var(--success);
}

.badge-done {
    background: #fce4ec;
    color: #c2185b;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s, transform 0.1s;
    background: #e9ecef;
    color: var(--text);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover {
    opacity: 0.92;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.05rem;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    background: var(--primary);
    color: white;
}

/* Practice */
.practice-header {
    margin-bottom: 32px;
}

.breadcrumb {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

.practice-header h1 {
    font-size: 1.6rem;
    margin-bottom: 12px;
}

.practice-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.question-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.question-num {
    font-weight: 700;
    color: var(--primary);
}

.question-topic {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #f8f9fa;
    padding: 4px 10px;
    border-radius: 999px;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.answer-input {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1.1rem;
    transition: border-color 0.2s;
}

.answer-input:focus {
    outline: none;
    border-color: var(--primary);
}

.hint {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.submit-bar {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    text-align: center;
    margin-top: 24px;
}

.submit-note {
    color: var(--text-muted);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.alert-info {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.alert-success {
    background: #e8f5e9;
    border-left: 4px solid var(--success);
}

.alert-warning {
    background: #fff8e1;
    border-left: 4px solid var(--warning);
}

.alert-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

/* Results */
.results-page {
    max-width: 700px;
    margin: 0 auto;
}

.results-header {
    text-align: center;
    padding: 40px 24px;
    border-radius: var(--radius);
    margin-bottom: 32px;
    color: white;
}

.results-header.score-excellent {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.results-header.score-good {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.results-header.score-ok {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.results-header.score-low {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.results-day {
    opacity: 0.85;
    font-size: 0.9rem;
}

.results-score-big {
    margin: 16px 0;
}

.score-num {
    font-size: 3.5rem;
    font-weight: 800;
    display: block;
}

.score-pct {
    font-size: 1.5rem;
    opacity: 0.9;
}

.score-label {
    font-size: 1.3rem;
    font-weight: 600;
}

.results-time {
    margin-top: 12px;
    opacity: 0.85;
    font-size: 0.9rem;
}

.result-item {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid #dee2e6;
}

.result-item.correct {
    border-left-color: var(--success);
}

.result-item.wrong {
    border-left-color: var(--danger);
}

.result-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 8px;
}

.result-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.correct .result-icon {
    background: #e8f5e9;
    color: var(--success);
}

.wrong .result-icon {
    background: #fce4ec;
    color: var(--danger);
}

.result-answers {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
    margin-top: 8px;
}

.correct-ans {
    color: var(--success);
}

.results-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 32px;
}

/* Report table */
.report-page h1 {
    margin-bottom: 8px;
}

.report-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin: 24px 0 32px;
}

.report-table-wrap {
    overflow-x: auto;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.report-table th,
.report-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.report-table th {
    background: #f8f9fa;
    font-weight: 600;
}

.report-table tr.score-excellent td:nth-child(4) {
    color: var(--success);
    font-weight: 600;
}

.report-table tr.score-low td:nth-child(4) {
    color: var(--danger);
}

.report-actions {
    margin-top: 24px;
}

/* Footer */
.site-footer {
    background: var(--card);
    border-top: 1px solid #eee;
    padding: 20px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

code {
    background: #f1f3f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .hero {
        grid-template-columns: 1fr;
    }

    .hero-stats {
        flex-wrap: wrap;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav {
        width: 100%;
    }
}
