:root {
    --green:       #152240;
    --green-light: #4a7ab5;
    --green-bg:    #eef3fa;
    --text:        #1b1b1b;
    --border:      #d0d8e4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, Arial, sans-serif;
    color: var(--text);
    background: #f3f4f6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
header {
    background: var(--green);
    color: white;
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 3px solid var(--green-light);
}
.header-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}
.header-logo-img {
    height: 48px;
    width: auto;
    /* logo has a white/transparent bg — add a subtle white bg pill */
    background: white;
    border-radius: 6px;
    padding: 4px 8px;
}
.header-tagline {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255,255,255,0.75);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* ── Layout ── */
main { flex: 1; }

.container {
    max-width: 720px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

h2 { font-size: 1.35rem; margin-bottom: 1.5rem; color: var(--green); }

/* ── Landing page ── */
.landing-hero {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
}
.landing-logo {
    height: 70px;
    width: auto;
    margin-bottom: 1.25rem;
}
.landing-title {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--green);
    margin-bottom: 0.6rem;
}
.landing-subtitle {
    font-size: 1rem;
    color: #555;
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.6;
}
.landing-card {
    margin-top: 1.5rem;
}
.landing-steps-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}
.landing-steps-list li {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}
.landing-step-num {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--green);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.landing-steps-list li div strong {
    display: block;
    font-size: 0.95rem;
    color: var(--green);
    margin-bottom: 0.15rem;
}
.landing-steps-list li div p {
    font-size: 0.88rem;
    color: #666;
    margin: 0;
}
.landing-lang-choice {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.landing-lang-choice .btn {
    flex: 1;
    min-width: 200px;
    text-align: center;
    text-decoration: none;
}
.ms-sso-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: #1b1b1b;
    border: 1px solid #d0d0d0;
    padding: 0.65rem 1.5rem;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    width: 100%;
    transition: background 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.ms-sso-btn:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
}

.btn-outline {
    background: white;
    color: var(--green);
    border: 2px solid var(--green);
}
.btn-outline:hover {
    background: var(--green-bg);
}

footer {
    background: #e5e7eb;
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    color: #888;
}

/* ── Progress steps ── */
.steps {
    display: flex;
    gap: 6px;
    margin-bottom: 1.75rem;
}
.step {
    flex: 1;
    text-align: center;
    padding: 0.45rem 0.25rem;
    border-radius: 4px;
    font-size: 0.8rem;
    background: #e5e7eb;
    color: #888;
}
.step.active { background: var(--green); color: white; font-weight: 600; }
.step.done   { background: var(--green-bg); color: var(--green); }

/* ── Forms ── */
.form-group { margin-bottom: 1.15rem; }

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
}
.required { color: #c0392b; }

input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--green-light);
    box-shadow: 0 0 0 3px rgba(64,145,108,.15);
}
textarea { resize: vertical; min-height: 110px; }

/* ── Button ── */
.btn {
    display: inline-block;
    padding: 0.65rem 2rem;
    background: var(--green);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.btn:hover:not(:disabled) { background: var(--green-light); }
.btn:disabled              { background: #aaa; cursor: not-allowed; }

/* ── Alerts ── */
.alert {
    padding: 0.9rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}
.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}
.alert-error ul { margin-left: 1.25rem; }
.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #86efac;
}

/* ── Video page ── */
.video-wrapper {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #111;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
}
.video-wrapper video,
.video-wrapper iframe,
.video-wrapper > div { width: 100%; height: 100%; border: none; }

.video-status {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1.25rem;
    background: #fefce8;
    color: #854d0e;
    border: 1px solid #fde68a;
    font-size: 0.9rem;
}
.video-status.done {
    background: #f0fdf4;
    color: #15803d;
    border-color: #86efac;
}

/* ── Questions ── */
.question { margin-bottom: 1.75rem; }
.question p { font-weight: 500; margin-bottom: 0.65rem; line-height: 1.5; }

/* ── Certificate (web preview) ── */
.certificate-box {
    border: 4px double var(--green);
    border-radius: 8px;
    padding: 2.5rem 2rem;
    text-align: center;
    background: var(--green-bg);
    margin-bottom: 1.5rem;
}
.cert-org {
    color: var(--green);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}
.certificate-box h3 { font-size: 1.75rem; color: var(--text); margin-bottom: 0.25rem; }
.cert-subtitle  { font-size: 0.85rem; letter-spacing: 2px; text-transform: uppercase; color: #666; margin-bottom: 1.75rem; }
.cert-certifies { font-size: 0.9rem; color: #666; margin-bottom: 0.5rem; }
.cert-name      { font-size: 1.6rem; font-weight: 700; color: var(--green);
                  border-bottom: 2px solid var(--green); display: inline-block;
                  padding: 0 1.5rem 0.4rem; margin-bottom: 1rem; }
.cert-detail    { font-size: 0.9rem; color: #444; margin-bottom: 0.3rem; }
.cert-description { font-size: 0.85rem; color: #555; margin: 1rem auto; max-width: 420px; line-height: 1.6; }
.cert-footer {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #b7dfc9;
    padding-top: 0.9rem;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #555;
}
.cert-id { font-family: monospace; color: #888; }

/* ── Responsive ── */
@media (max-width: 520px) {
    .steps { flex-direction: column; }
    .card  { padding: 1.25rem; }
    .certificate-box { padding: 1.5rem 1rem; }
    .cert-footer { flex-direction: column; gap: 0.5rem; text-align: left; }
}

/* ── Admin panel ── */
.admin-container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.admin-nav {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    margin-left: auto;
}
.admin-nav a {
    color: rgba(255,255,255,.8);
    text-decoration: none;
    font-size: 0.9rem;
}
.admin-nav a:hover { color: white; }
.admin-nav a.active { color: white; font-weight: 600; }

/* Logout as a subtle link-style button */
.btn-link {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.btn-link:hover { color: white; }

/* Summary stat cards */
.stat-grid {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.stat-card {
    flex: 1;
    min-width: 120px;
    background: white;
    border-radius: 6px;
    padding: 1rem 1.25rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.stat-num   { font-size: 2rem; font-weight: 700; color: var(--green); line-height: 1; }
.stat-label { font-size: 0.8rem; color: #666; margin-top: 0.3rem; }

/* Data tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.data-table th {
    background: var(--green);
    color: white;
    padding: 0.6rem 0.8rem;
    text-align: left;
    font-weight: 500;
    white-space: nowrap;
}
.data-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td     { background: var(--green-bg); }
.data-table .nowrap         { white-space: nowrap; }

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 3px;
    font-size: 0.73rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-yes { background: #d1fae5; color: #065f46; }
.badge-no  { background: #fee2e2; color: #991b1b; }
.badge-na  { background: #f3f4f6; color: #6b7280; }

/* Small action links */
.link-btn {
    display: inline-block;
    padding: 0.28rem 0.7rem;
    background: var(--green);
    color: white;
    border-radius: 3px;
    font-size: 0.8rem;
    text-decoration: none;
    white-space: nowrap;
}
.link-btn:hover            { background: var(--green-light); }
.link-btn.secondary        { background: #6b7280; }
.link-btn.secondary:hover  { background: #4b5563; }

/* Detail page layout */
.detail-section { margin-bottom: 1.5rem; }
.detail-section h3 {
    font-size: 1rem;
    color: var(--green);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
    margin-bottom: 0.9rem;
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem 1.5rem;
}
.detail-field label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #888;
    font-weight: 600;
    display: block;
    margin-bottom: 0.15rem;
}
.detail-field p { margin: 0; font-size: 0.95rem; word-break: break-word; }

/* Answer blocks */
.answer-block {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}
.answer-block p.question-text {
    font-weight: 500;
    font-size: 0.9rem;
    color: #444;
    margin-bottom: 0.4rem;
}
.answer-block p.answer-text {
    font-size: 0.92rem;
    color: var(--text);
    white-space: pre-wrap;
}

/* ── Language toggle ── */
.lang-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    justify-content: flex-end;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}
.lang-toggle a {
    color: #888;
    text-decoration: none;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}
.lang-toggle a.active,
.lang-toggle a:hover {
    color: var(--green);
    font-weight: 600;
}
.lang-toggle span { color: #ccc; }

/* ── Quiz (multiple choice) ── */
.quiz-question {
    margin-bottom: 1.75rem;
}
.quiz-question-text {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.quiz-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    cursor: pointer;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fafafa;
    transition: border-color 0.15s, background 0.15s;
    font-size: 0.92rem;
    line-height: 1.4;
}
.quiz-option:hover {
    border-color: var(--green-light);
    background: var(--green-bg);
}
.quiz-option input[type="radio"] {
    margin-top: 0.15rem;
    accent-color: var(--green);
    flex-shrink: 0;
}
.quiz-option input[type="radio"]:checked + span {
    font-weight: 500;
}

/* Quiz feedback states */
.quiz-question-correct { opacity: 0.85; }
.quiz-question-wrong   { }

.quiz-option-correct {
    border-color: #16a34a;
    background: #f0fdf4;
}
.quiz-option-wrong {
    border-color: #dc2626;
    background: #fef2f2;
}
.quiz-option-correct input[type="radio"] { accent-color: #16a34a; }
.quiz-option-wrong   input[type="radio"] { accent-color: #dc2626; }

.quiz-badge-correct {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #16a34a;
}
.quiz-badge-wrong {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #dc2626;
}

@media (max-width: 768px) {
    .stat-grid { gap: 0.5rem; }
    .data-table { font-size: 0.8rem; }
    .data-table th,
    .data-table td { padding: 0.45rem 0.5rem; }
}

/* ── Welcome image ── */
.landing-welcome-img {
    margin: 0 0 1.5rem;
    border-radius: 8px;
    overflow: hidden;
    max-height: 260px;
}
.landing-welcome-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Foreman link ── */
.landing-foreman-link {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: left;
}
.landing-foreman-link a {
    font-size: 0.9rem;
    color: var(--green-light);
    text-decoration: none;
    font-weight: 500;
}
.landing-foreman-link a:hover {
    text-decoration: underline;
}

/* ── Sign-off page ── */
.signoff-declaration {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.7;
    color: #444;
}
.signoff-details {
    background: var(--green-bg);
    border: 1px solid #c0d0e8;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    font-size: 0.95rem;
}
.signoff-details p { margin: 0.2rem 0; }
.signoff-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.5;
}
.signoff-checkbox input[type="checkbox"] {
    margin-top: 0.2rem;
    accent-color: var(--green);
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

/* ── Sign-Off Sheet ── */
.signoff-card { max-width: 680px; }

.signoff-card .form-group { margin-bottom: 1.4rem; }
.signoff-card .form-group.has-error input,
.signoff-card .form-group.has-error select { border-color: #dc2626; }
.field-error {
    font-size: 0.82rem;
    color: #dc2626;
    margin-top: 0.25rem;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.4rem;
}
.checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.92rem;
    line-height: 1.4;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fafafa;
    transition: border-color 0.15s, background 0.15s;
}
.checkbox-option:hover { border-color: var(--green-light); background: var(--green-bg); }
.checkbox-option input[type="checkbox"] {
    margin-top: 0.15rem;
    accent-color: var(--green);
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.signoff-agreements { margin-top: 1.5rem; }
.signoff-agreements.has-error .signoff-agreement-block {
    border-left-color: #dc2626;
}
.signoff-agreement-block {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-left: 3px solid var(--green);
    border-radius: 6px;
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
}
.agreement-body {
    font-size: 0.88rem;
    color: #444;
    line-height: 1.65;
    margin-bottom: 0.75rem;
}
.agreement-check {
    border: none;
    padding: 0;
    background: transparent;
    font-weight: 600;
}
.agreement-check:hover { background: transparent; border-color: transparent; }

/* ── Foreman tip box ── */
.foreman-tip-box {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding: 1rem 1.2rem;
    background: #fffbea;
    border: 1px solid #f0c030;
    border-left: 4px solid #e6a800;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #5a4000;
    line-height: 1.6;
}
.foreman-tip-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 0.05rem;
    color: #e6a800;
}
.foreman-tip-content a {
    color: #8b5e00;
    font-weight: 600;
    text-decoration: underline;
}
.foreman-tip-content a:hover { color: #5a3d00; }
