/* =====================================================
   QS Global Academic Survey - Professional UI
   ===================================================== */
:root {
    --qs-orange: #f5a000;
    --qs-orange-dark: #d98c00;
    --qs-orange-soft: #fff4de;
    --navy: #1f2a44;
    --navy-2: #2c3a5c;
    --ink: #24292f;
    --muted: #6b7280;
    --line: #e4e7ec;
    --bg: #f6f7fa;
    --card: #ffffff;
    --danger: #d64545;
    --success: #1f9d61;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.55;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header {
    background: var(--navy);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand-logo {
    height: 44px;
    width: auto;
    max-width: 190px;
    display: block;
    border-radius: 6px;
    object-fit: contain;
}
@media (max-width: 640px) { .brand-logo { height: 34px; } }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; }
.brand-text small { color: #aeb8d0; font-size: 12px; }
.main-nav { display: flex; gap: 8px; }
.nav-link {
    color: #dbe1ee;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--navy-2); color: #fff; }

.page-body { padding: 28px 20px 60px; }

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    padding: 18px 0;
}
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- Intro panel ---------- */
.survey-intro {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 28px 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.survey-intro h1 { margin: 0 0 8px; font-size: 26px; }
.survey-intro p { margin: 0; color: #c3cde2; max-width: 720px; }

/* ---------- Stepper ---------- */
.stepper {
    display: flex;
    gap: 4px;
    margin-bottom: 22px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}
.step-tab {
    flex: 1;
    min-width: 150px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    border: none;
    background: transparent;
    font: inherit;
    text-align: left;
    color: var(--muted);
    transition: background .15s;
}
.step-tab:hover { background: #f1f3f8; }
.step-num {
    width: 30px; height: 30px;
    flex: 0 0 30px;
    border-radius: 50%;
    background: #e8ebf2;
    color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 13px;
    transition: all .2s;
}
.step-tab .step-label { font-size: 13px; font-weight: 600; line-height: 1.25; }
.step-tab.active { color: var(--navy); }
.step-tab.active .step-num { background: var(--qs-orange); color: #fff; }
.step-tab.done .step-num { background: var(--success); color: #fff; }

.progress-track {
    height: 6px;
    background: #e8ebf2;
    border-radius: 999px;
    margin-bottom: 26px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 20%;
    background: linear-gradient(90deg, var(--qs-orange), var(--qs-orange-dark));
    border-radius: 999px;
    transition: width .35s ease;
}

/* ---------- Cards / steps ---------- */
.step-panel { display: none; animation: fadeIn .3s ease; }
.step-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 30px;
    margin-bottom: 20px;
}
.card h2 {
    margin: 0 0 4px;
    font-size: 20px;
    color: var(--navy);
}
.card .card-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.card h3 {
    font-size: 15px;
    color: var(--navy);
    margin: 26px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--qs-orange-soft);
}
.card h3:first-of-type { margin-top: 0; }

.req::after { content: " *"; color: var(--danger); font-weight: 700; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }

/* ---------- Form controls ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; color: #333c4d; }

.field input[type="text"],
.field input[type="email"],
.field input[type="number"],
.field input[type="password"],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: 9px;
    font: inherit;
    background: #fff;
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--qs-orange);
    box-shadow: 0 0 0 3px rgba(245, 160, 0, .18);
}

/* Pills (radio groups) */
.pill-group { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pill span {
    display: inline-block;
    padding: 8px 16px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--muted);
    background: #fff;
    cursor: pointer;
    transition: all .15s;
}
.pill input:checked + span {
    background: var(--qs-orange);
    border-color: var(--qs-orange);
    color: #fff;
}
.pill input:focus-visible + span { box-shadow: 0 0 0 3px rgba(245,160,0,.3); }

/* Checkbox tiles */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.check-tile { position: relative; }
.check-tile input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.check-tile span {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1.5px solid var(--line);
    border-radius: 9px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
    transition: all .15s;
    min-height: 40px;
}
.check-tile span::before {
    content: "";
    width: 16px; height: 16px;
    flex: 0 0 16px;
    border: 2px solid #cdd3de;
    border-radius: 4px;
    background: #fff;
    transition: all .15s;
}
.check-tile input:checked + span {
    border-color: var(--qs-orange);
    background: var(--qs-orange-soft);
    font-weight: 600;
}
.check-tile input:checked + span::before {
    background: var(--qs-orange) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3E%3Cpath d='M13.5 4.5l-7 7L3 8'/%3E%3C/svg%3E") center/12px no-repeat;
    border-color: var(--qs-orange);
}
.check-tile input:disabled + span { opacity: .45; cursor: not-allowed; }

/* Broad subject cards */
.subject-card-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.subject-card { position: relative; }
.subject-card input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.subject-card .sc-body {
    display: block;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px 14px 46px;
    cursor: pointer;
    background: #fff;
    transition: all .15s;
    position: relative;
}
.subject-card .sc-body::before {
    content: "";
    position: absolute;
    left: 16px; top: 17px;
    width: 17px; height: 17px;
    border: 2px solid #cdd3de;
    border-radius: 5px;
    transition: all .15s;
}
.subject-card input:checked + .sc-body {
    border-color: var(--qs-orange);
    background: var(--qs-orange-soft);
}
.subject-card input:checked + .sc-body::before {
    background: var(--qs-orange) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3E%3Cpath d='M13.5 4.5l-7 7L3 8'/%3E%3C/svg%3E") center/12px no-repeat;
    border-color: var(--qs-orange);
}
.subject-card strong { display: block; font-size: 14.5px; color: var(--navy); }
.subject-card small { color: var(--muted); font-size: 12px; line-height: 1.45; display: block; margin-top: 3px; }

/* Region groups */
.region-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.region-group h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.region-group .check-tile { margin-bottom: 6px; }

/* Specialization follow-up blocks */
.spec-block {
    margin-top: 18px;
    padding: 4px 16px 16px;
    border-left: 4px solid var(--qs-orange);
    background: #fffdf7;
    border-radius: 0 10px 10px 0;
    animation: fadeIn .25s ease;
}

/* Search filter box */
.filter-box { margin-bottom: 12px; position: relative; }
.filter-box input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1.5px solid var(--line);
    border-radius: 9px;
    font: inherit;
}
.filter-box::before {
    content: "";
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    width: 15px; height: 15px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.4'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Counter badge */
.counter-badge {
    display: inline-block;
    background: var(--navy);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    padding: 2px 10px;
    margin-left: 8px;
    vertical-align: middle;
}
.counter-badge.limit { background: var(--danger); }

/* ---------- Tag input (institutions) ---------- */
.tag-input {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 9px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: #fff;
    cursor: text;
    transition: border-color .15s, box-shadow .15s;
}
.tag-input:focus-within {
    border-color: var(--qs-orange);
    box-shadow: 0 0 0 3px rgba(245,160,0,.18);
}
.tag-input input {
    flex: 1;
    min-width: 220px;
    border: none;
    outline: none;
    font: inherit;
    padding: 6px 4px;
    background: transparent;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--navy);
    color: #fff;
    border-radius: 999px;
    padding: 5px 8px 5px 13px;
    font-size: 13px;
    font-weight: 600;
    animation: fadeIn .2s ease;
}
.chip button {
    background: rgba(255,255,255,.22);
    color: #fff;
    border: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.chip button:hover { background: var(--danger); }
.chip.alt { background: var(--qs-orange-dark); }

/* ---------- Sliders (reputation factors) ---------- */
.factor-row {
    display: grid;
    grid-template-columns: 240px 1fr 44px;
    align-items: center;
    gap: 16px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--line);
}
.factor-row:last-child { border-bottom: none; }
.factor-row .f-name { font-size: 13.5px; font-weight: 600; color: #333c4d; }
.factor-row input[type="range"] {
    width: 100%;
    accent-color: var(--qs-orange);
    cursor: pointer;
}
.factor-row .f-value {
    text-align: center;
    background: var(--qs-orange-soft);
    border: 1px solid #f0d9a8;
    color: var(--qs-orange-dark);
    border-radius: 8px;
    font-weight: 700;
    font-size: 13.5px;
    padding: 4px 0;
}
@media (max-width: 640px) { .factor-row { grid-template-columns: 1fr; gap: 6px; } }
.scale-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 10px; }

/* ---------- Matrix table (social engagement) ---------- */
.matrix-wrap { overflow-x: auto; }
.matrix {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}
.matrix th, .matrix td {
    padding: 11px 10px;
    text-align: center;
    font-size: 12.5px;
    border-bottom: 1px solid var(--line);
}
.matrix th { color: var(--muted); font-weight: 600; }
.matrix td.statement {
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #333c4d;
    max-width: 320px;
}
.matrix tbody tr:hover { background: #fafbfd; }
.matrix input[type="radio"] {
    width: 17px; height: 17px;
    accent-color: var(--qs-orange);
    cursor: pointer;
}

/* ---------- Online learning per-discipline grid ---------- */
.online-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 26px;
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 16px;
    background: #fafbfd;
}
@media (max-width: 720px) { .online-grid { grid-template-columns: 1fr; } }
.online-row {
    display: grid;
    grid-template-columns: 1fr 86px;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    border-bottom: 1px dashed var(--line);
}
.online-row .o-name { font-size: 13px; color: #333c4d; }
.online-row input[type="number"],
.online-row input[type="text"] {
    padding: 6px 9px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
    background: #fff;
    width: 100%;
}
.online-row input:focus {
    outline: none;
    border-color: var(--qs-orange);
    box-shadow: 0 0 0 3px rgba(245,160,0,.18);
}
.online-row.other-row { grid-template-columns: 1fr 86px; }

/* ---------- Range with output ---------- */
.range-output {
    display: inline-block;
    min-width: 58px;
    text-align: center;
    background: var(--navy);
    color: #fff;
    border-radius: 8px;
    padding: 4px 10px;
    font-weight: 700;
    margin-left: 12px;
}

/* ---------- Buttons / nav ---------- */
.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font: inherit;
    font-weight: 700;
    font-size: 14.5px;
    padding: 11px 26px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.btn-primary { background: var(--qs-orange); color: #fff; box-shadow: 0 2px 6px rgba(245,160,0,.4); }
.btn-primary:hover { background: var(--qs-orange-dark); transform: translateY(-1px); }
.btn-secondary { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
.btn-secondary:hover { border-color: var(--navy); }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 2px 6px rgba(31,157,97,.4); }
.btn-success:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Alerts / validation ---------- */
.alert {
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert-danger { background: #fdecec; border-color: #f5c2c2; color: #9b2c2c; }
.alert-danger ul { margin: 6px 0 0; padding-left: 20px; }
.step-error {
    display: none;
    background: #fdecec;
    border: 1px solid #f5c2c2;
    color: #9b2c2c;
    border-radius: 9px;
    padding: 10px 14px;
    font-size: 13px;
    margin-top: 16px;
}
.step-error.show { display: block; }
.field-validation-error { color: var(--danger); font-size: 12.5px; display: block; margin-top: 4px; }
input.input-validation-error, select.input-validation-error { border-color: var(--danger) !important; }

/* ---------- Thank you ---------- */
.thanks-card {
    text-align: center;
    padding: 60px 30px;
}
.thanks-icon {
    width: 74px; height: 74px;
    margin: 0 auto 18px;
    background: #e6f7ef;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 34px;
    color: var(--success);
}
.thanks-card h1 { color: var(--navy); margin: 0 0 8px; }
.thanks-card p { color: var(--muted); max-width: 520px; margin: 0 auto 24px; }

/* ---------- Responses table ---------- */
.table-card { padding: 0; overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    background: var(--navy);
    color: #fff;
    text-align: left;
    padding: 12px 16px;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.data-table tbody tr:hover { background: #fafbfd; }
.data-table .badge {
    background: var(--qs-orange-soft);
    color: var(--qs-orange-dark);
    border-radius: 999px;
    padding: 3px 11px;
    font-weight: 700;
    font-size: 12px;
}
.link { color: var(--qs-orange-dark); font-weight: 700; text-decoration: none; }
.link:hover { text-decoration: underline; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }

/* ---------- Analytics dashboard ---------- */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.kpi-tile {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 22px;
}
.kpi-tile label {
    display: block;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 6px;
}
.kpi-value { font-size: 34px; font-weight: 700; color: var(--navy); line-height: 1.1; }

.chart-card { padding: 22px 26px; }
.chart-card h2 { font-size: 16.5px; margin-bottom: 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 360px; }
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 20px;
}
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

.range-toggle { display: flex; gap: 4px; background: #f1f3f8; border-radius: 9px; padding: 4px; }
.toggle-btn {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 7px;
    padding: 7px 14px;
    cursor: pointer;
    transition: all .15s;
}
.toggle-btn:hover { color: var(--navy); }
.toggle-btn.active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(16,24,40,.15); }

/* ---------- Table toolbar (search + export) ---------- */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: #fafbfd;
}
.search-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-form input[type="text"] {
    padding: 8px 12px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 13.5px;
    min-width: 280px;
    background: #fff;
}
.search-form input[type="text"]:focus {
    outline: none;
    border-color: var(--qs-orange);
    box-shadow: 0 0 0 3px rgba(245,160,0,.18);
}
.export-buttons { display: flex; gap: 8px; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ---------- Pagination ---------- */
.pager {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 4px 16px 18px;
}
.pager a, .pager span {
    display: inline-block;
    min-width: 38px;
    text-align: center;
    padding: 7px 12px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
    color: var(--navy);
    font-weight: 600;
    font-size: 13.5px;
    background: #fff;
    transition: all .15s;
}
.pager a:hover { border-color: var(--qs-orange); color: var(--qs-orange-dark); }
.pager .current { background: var(--qs-orange); border-color: var(--qs-orange); color: #fff; }
.pager .disabled { opacity: .45; }
.pager-info { text-align: center; color: var(--muted); font-size: 12.5px; margin: 12px 0 4px; }

/* ---------- Details page ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.detail-item { background: #fafbfd; border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; }
.detail-item label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.detail-item span { font-size: 14px; font-weight: 600; color: var(--ink); }
.chip-static {
    display: inline-block;
    background: var(--navy);
    color: #fff;
    border-radius: 999px;
    padding: 4px 13px;
    font-size: 12.5px;
    font-weight: 600;
    margin: 0 6px 6px 0;
}
.chip-static.orange { background: var(--qs-orange-dark); }
.chip-static.gray { background: #7c8598; }
