/* ---------- Layout ---------- */
.pm-main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
@media (max-width: 600px) { .pm-main { padding: 16px 16px 48px; } }
.pm-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.pm-page-head h1 { font-size: 24px; font-weight: 800; margin: 0; }
.pm-page-head p { margin: 4px 0 0; color: var(--pm-muted); font-size: 14px; }
.pm-breadcrumb { font-size: 13px; color: var(--pm-muted); margin-bottom: 6px; }
.pm-breadcrumb a { color: var(--pm-muted); text-decoration: none; }
.pm-breadcrumb a:hover { color: var(--pm-primary); }

.pm-card { background: var(--pm-card); border: 1px solid var(--pm-border); border-radius: var(--pm-radius); padding: 20px; }
.pm-card + .pm-card { margin-top: 16px; }
.pm-card h2 { font-size: 17px; font-weight: 700; margin: 0 0 14px; }
.pm-grid { display: grid; gap: 16px; }
.pm-grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.pm-grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.pm-stat { background: #fff; border: 1px solid var(--pm-border); border-radius: var(--pm-radius); padding: 18px 20px; }
.pm-stat span { color: var(--pm-muted); font-size: 13px; font-weight: 600; }
.pm-stat b { display: block; font-size: 28px; font-weight: 800; margin-top: 4px; }

.btn { font-weight: 600; border-radius: 10px; font-size: 14px; }
.btn-primary { background: var(--pm-primary); border-color: var(--pm-primary); }
.btn-primary:hover { background: var(--pm-primary-dark); border-color: var(--pm-primary-dark); }
.btn-sm { font-size: 13px; border-radius: 8px; }
.form-control, .form-select { border-radius: 10px; font-size: 14px; }
.form-label { font-size: 13px; font-weight: 600; margin-bottom: 4px; }

.pm-flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; font-size: 14px; }
.pm-flash-ok { background: #dcfce7; color: #166534; }
.pm-flash-err { background: #fee2e2; color: #991b1b; white-space: pre-line; }

/* ---------- Tables (cuộn ngang an toàn trên điện thoại) ---------- */
.pm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--pm-border); border-radius: 12px; background: #fff; }
.pm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pm-table th { background: #f8fafc; color: var(--pm-muted); font-size: 13px; font-weight: 700; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--pm-border); white-space: nowrap; }
.pm-table td { padding: 10px 12px; border-bottom: 1px solid var(--pm-border); vertical-align: middle; }
.pm-table tr:last-child td { border-bottom: 0; }
.pm-table tr:hover td { background: #fafbff; }
.pm-table .num { text-align: center; white-space: nowrap; }
.pm-table .actions { white-space: nowrap; text-align: right; }
.pm-matrix td.num, .pm-matrix th.num { min-width: 74px; }
.pm-sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }
th.pm-sticky-col { background: #f8fafc; }

.pm-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--pm-bg); color: var(--pm-muted); white-space: nowrap; }
.pm-badge-ok { background: #dcfce7; color: #166534; }
.pm-badge-warn { background: #fef3c7; color: #92400e; }
.pm-badge-bad { background: #fee2e2; color: #991b1b; }
.pm-badge-primary { background: var(--pm-primary-soft); color: var(--pm-primary); }

.pm-score { font-weight: 700; padding: 3px 8px; border-radius: 8px; font-size: 13px; display: inline-block; text-decoration: none; }
.pm-score-hi { background: #dcfce7; color: #166534; }
.pm-score-mid { background: #fef3c7; color: #92400e; }
.pm-score-lo { background: #fee2e2; color: #991b1b; }
.pm-muted { color: var(--pm-muted); }

/* ---------- Tabs ---------- */
.pm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--pm-border); margin-bottom: 16px; overflow-x: auto; }
.pm-tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--pm-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.pm-tabs button.active { color: var(--pm-primary); border-bottom-color: var(--pm-primary); }

/* ---------- Modal ---------- */
.pm-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.pm-modal[hidden] { display: none; }
.pm-modal-box { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.pm-modal-box.wide { max-width: 640px; }
.pm-modal-box h3 { font-size: 18px; font-weight: 700; margin: 0 0 14px; }
.pm-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Login ---------- */
.pm-login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.pm-login-art { background: linear-gradient(150deg, #13294b 0%, #1f3d6e 70%, #2b528f 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.pm-login-art h1 { font-size: 40px; font-weight: 800; line-height: 1.15; margin: 0 0 14px; }
.pm-login-art p { font-size: 16px; opacity: .9; max-width: 440px; }
.pm-login-pi { position: absolute; right: -40px; bottom: -80px; font-size: 420px; font-family: Georgia, serif; opacity: .12; line-height: 1; }
.pm-login-chips { display: flex; flex-wrap: wrap; gap: 8px; position: relative; }
.pm-login-chips span { background: rgba(255,255,255,.16); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; }
.pm-login-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: #fff; }
.pm-login-form form { width: 100%; max-width: 360px; }
.pm-login-form h2 { font-weight: 800; font-size: 24px; margin-bottom: 4px; }
@media (max-width: 860px) {
  .pm-login { grid-template-columns: 1fr; }
  .pm-login-art { padding: 32px 20px; min-height: 0; }
  .pm-login-art h1 { font-size: 28px; }
  .pm-login-pi { font-size: 220px; bottom: -40px; }
}

/* ---------- Student home ---------- */
.pm-hero { background: linear-gradient(120deg, #13294b 0%, #1f3d6e 75%, #e8501e 160%); color: #fff; border-radius: 20px; padding: 26px 28px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.pm-hero h1 { font-size: 26px; font-weight: 800; margin: 0 0 4px; }
.pm-hero p { margin: 0; opacity: .9; }
.pm-hero-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.pm-hero-stats div { background: rgba(255,255,255,.16); border-radius: 14px; padding: 10px 16px; min-width: 100px; }
@media (max-width: 600px) {
  .pm-hero { padding: 20px; }
  .pm-hero-stats { width: 100%; flex-wrap: nowrap; gap: 8px; }
  .pm-hero-stats div { flex: 1; min-width: 0; padding: 8px 10px; }
}
.pm-hero-stats b { display: block; font-size: 22px; }
.pm-hero-stats span { font-size: 13px; opacity: .9; }
.pm-section-title { font-size: 18px; font-weight: 800; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }

.pm-topic { background: #fff; border: 1px solid var(--pm-border); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 10px; transition: transform .15s, box-shadow .15s; }
.pm-topic:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(19,41,75,.12); }
.pm-topic-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--pm-primary-soft); display: grid; place-items: center; font-size: 24px; }
.pm-topic h3 { font-size: 16px; font-weight: 700; margin: 0; }
.pm-topic p { font-size: 13px; color: var(--pm-muted); margin: 0; }
.pm-topic-next { font-size: 13px; color: var(--pm-muted); margin-top: 6px; min-height: 19px; }
.pm-topic-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.pm-topic-actions form { margin: 0; }
.pm-topic-actions .btn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 6px; padding-right: 6px; }
.pm-btn-review { background: var(--pm-navy-soft); border: 1px solid #d3dceb; color: var(--pm-navy); }
.pm-btn-review:hover:not(:disabled) { background: var(--pm-navy); color: #fff; border-color: var(--pm-navy); }
.pm-btn-review:disabled { background: #f2f4f7; border-color: var(--pm-border); color: #98a2b3; }
.pm-topic-next b { color: var(--pm-primary-dark); }
.pm-progress { height: 8px; background: #eef0f6; border-radius: 999px; overflow: hidden; }
.pm-progress > div { height: 100%; background: linear-gradient(90deg, #f07a4b, #e8501e); }

.pm-exam-row { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--pm-border); border-radius: 14px; padding: 14px 16px; }
.pm-exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; }
@media (max-width: 400px) { .pm-exam-grid { grid-template-columns: 1fr; } }
.pm-round { margin-bottom: 6px; }
.pm-round-title { list-style: none; cursor: pointer; font-size: 16px; font-weight: 700; color: var(--pm-navy); margin: 14px 0 10px; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 4px; border-radius: 10px; user-select: none; }
.pm-round-title::-webkit-details-marker { display: none; }
.pm-round-title:hover { background: var(--pm-navy-soft); }
.pm-round-count { font-size: 13px; font-weight: 500; color: var(--pm-muted); }
.pm-round-chevron { margin-left: auto; font-size: 20px; line-height: 1; transition: transform .2s; transform: rotate(-90deg); color: var(--pm-muted); }
.pm-round[open] .pm-round-chevron { transform: none; }
.pm-title-short { display: none; }
.pm-exam-num { width: 44px; height: 44px; border-radius: 12px; background: var(--pm-navy-soft); color: var(--pm-navy); display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.pm-exam-info { flex: 1; min-width: 0; }
.pm-exam-info b { display: block; font-size: 15px; }
.pm-exam-info small { color: var(--pm-muted); }
.pm-resume { background: #fffbeb; border: 1px solid #fde68a; border-radius: 14px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pm-resume + .pm-resume { margin-top: 10px; }

/* ---------- Result ---------- */
.pm-result-hero { text-align: center; padding: 32px 20px; }
.pm-result-ring { width: 160px; height: 160px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center; }
.pm-result-ring > div { width: 128px; height: 128px; border-radius: 50%; background: #fff; display: grid; place-items: center; }
.pm-result-ring b { font-size: 34px; font-weight: 800; line-height: 1; }
.pm-result-ring small { display: block; color: var(--pm-muted); }

/* ---------- Print slips ---------- */
.pm-slips { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pm-slip { border: 2px dashed #f3a684; border-radius: 14px; padding: 14px 16px; background: #fff; break-inside: avoid; }
.pm-slip h4 { font-size: 16px; font-weight: 800; margin: 0 0 6px; }
.pm-slip div { font-size: 14px; }
.pm-slip code { font-size: 16px; font-weight: 700; color: var(--pm-primary-dark); background: var(--pm-primary-soft); padding: 1px 6px; border-radius: 6px; }
@media print {
  .pm-nav, .pm-noprint, .pm-flash { display: none !important; }
  body { background: #fff; }
  .pm-main { padding: 0; max-width: none; }
  .pm-slips { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Bảng xếp hạng ---------- */
.pm-rank-card { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--pm-border); border-left: 4px solid var(--pm-primary); border-radius: 14px; padding: 14px 16px; margin: -8px 0 20px; text-decoration: none; color: var(--pm-text); transition: box-shadow .15s; }
.pm-rank-card:hover { color: var(--pm-text); box-shadow: 0 8px 22px rgba(19,41,75,.10); }
.pm-rank-card-badge { width: 46px; height: 46px; border-radius: 12px; background: #fff4e5; display: grid; place-items: center; font-size: 24px; flex-shrink: 0; }
.pm-rank-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pm-rank-card-body small { color: var(--pm-muted); font-weight: 600; }
.pm-rank-card-body b { font-size: 16px; }
.pm-rank-card-body span { font-size: 14px; color: var(--pm-muted); }
.pm-rank-card-body span b { font-size: 14px; color: var(--pm-primary-dark); }
.pm-rank-card-go { font-weight: 700; color: var(--pm-primary); white-space: nowrap; font-size: 14px; }

.pm-board-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.pm-board-head h2 small { font-size: 13px; font-weight: 500; }
.pm-seg { display: inline-flex; background: var(--pm-bg); border: 1px solid var(--pm-border); border-radius: 10px; padding: 3px; }
.pm-seg a { padding: 6px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--pm-muted); text-decoration: none; min-height: 36px; display: inline-flex; align-items: center; }
.pm-seg a.active { background: #fff; color: var(--pm-navy); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.pm-podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 10px; max-width: 460px; margin: 4px auto 18px; text-align: center; }
.pm-podium-slot.empty { visibility: hidden; }
.pm-podium-medal { font-size: 30px; line-height: 1; }
.pm-podium-name { font-weight: 700; font-size: 14px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-podium-score { font-size: 13px; color: var(--pm-muted); margin-bottom: 6px; }
.pm-podium-bar { border-radius: 12px 12px 0 0; color: #fff; font-weight: 800; font-size: 20px; display: grid; place-items: center; }
.pm-podium-slot.r1 .pm-podium-bar { height: 92px; background: linear-gradient(180deg, #f5b301, #e09400); }
.pm-podium-slot.r2 .pm-podium-bar { height: 70px; background: linear-gradient(180deg, #9aa7bd, #7b889f); }
.pm-podium-slot.r3 .pm-podium-bar { height: 54px; background: linear-gradient(180deg, #e3925a, #c46f35); }
.pm-podium-slot.me .pm-podium-name { color: var(--pm-primary); }

.pm-rank-list { list-style: none; padding: 0; margin: 0; }
.pm-rank-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; min-height: 44px; }
.pm-rank-list li + li { border-top: 1px solid var(--pm-border); }
.pm-rank-list li.me { background: var(--pm-primary-soft); border-top-color: transparent; }
.pm-rank-list li.me + li { border-top-color: transparent; }
.pm-rank-list li.zero { color: var(--pm-muted); }
.pm-rank-no { width: 32px; text-align: center; font-weight: 800; color: var(--pm-navy); font-size: 15px; flex-shrink: 0; }
.pm-rank-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-rank-name em { font-style: normal; color: var(--pm-primary); font-weight: 700; }
.pm-rank-val { font-size: 14px; color: var(--pm-muted); white-space: nowrap; }
.pm-rank-val b { color: var(--pm-text); }

.pm-board-picker { max-width: 420px; }
.pm-exam-rank { margin-left: 6px; font-weight: 700; color: #b45309; text-decoration: none; white-space: nowrap; }
.pm-lb-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--pm-navy-soft); border: 1px solid #d3dceb; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; flex-wrap: wrap; }
.pm-lb-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }

@media (max-width: 640px) {
  .pm-rank-card { flex-wrap: wrap; }
  .pm-rank-card-go { width: 100%; text-align: right; }
  .pm-lb-grid { grid-template-columns: 1fr; }
  .pm-lb-switch .btn { width: 100%; }
}