:root {
    --bg: #0b1220;
    --panel: #111b2f;
    --panel-2: #162541;
    --line: #2c436e;
    --text: #e8f0ff;
    --muted: #9fb3d4;
    --brand: #36b3a8;
    --brand-2: #1d7a72;
    --warn: #f59e0b;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(900px 400px at 100% 0, rgba(54, 179, 168, 0.18), transparent 60%),
        radial-gradient(700px 380px at 0 20%, rgba(59, 130, 246, 0.16), transparent 60%),
        var(--bg);
}

.labs-shell {
    width: min(1600px, 98vw);
    margin: 0 auto;
}

.labs-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(167, 187, 213, 0.18);
    background: rgba(11, 18, 32, 0.8);
}

.labs-header .labs-shell {
    padding: 14px 0 12px;
    display: grid;
    gap: 12px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.labs-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.labs-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: rgba(13, 23, 41, 0.72);
    border-radius: 12px;
    padding: 8px 10px;
    color: var(--muted);
    font-size: .9rem;
}

.labs-lang-switch a {
    text-decoration: none;
    color: var(--text);
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 700;
}

.labs-lang-switch a.active {
    color: #bdf8f2;
    border-color: rgba(54, 179, 168, .65);
    background: rgba(8, 34, 38, .58);
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo-mark {
    width: 46px; height: 46px; border-radius: 12px;
    background: linear-gradient(135deg, var(--brand), #3bc7bb);
    display: grid; place-items: center; color: #06211e; font-size: 22px;
}
.brand-name { font-weight: 800; font-size: 1.1rem; }
.brand-sub { color: var(--muted); font-size: .9rem; }

.back-link {
    color: var(--text); text-decoration: none; border: 1px solid var(--line);
    padding: 10px 14px; border-radius: 12px; background: rgba(22, 37, 65, 0.8);
    transition: .25s ease;
}

.back-link:hover {
    border-color: rgba(189, 248, 242, 0.6);
    box-shadow: 0 8px 24px rgba(8, 16, 33, 0.45);
}

.labs-top-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.labs-top-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: var(--muted);
    border: 1px solid var(--line);
    background: rgba(13, 23, 41, 0.72);
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 700;
    transition: .25s ease;
}

.labs-top-link:hover {
    color: var(--text);
    transform: translateY(-1px);
    border-color: rgba(159, 179, 212, .45);
}

.labs-top-link.active {
    color: #bdf8f2;
    border-color: rgba(54, 179, 168, .65);
    box-shadow: 0 0 0 1px rgba(54, 179, 168, .35);
    background: rgba(8, 34, 38, .58);
}

.labs-main {
    flex: 1 0 auto;
    padding: 24px 0 36px;
}

.labs-footer {
    border-top: 1px solid rgba(167, 187, 213, 0.2);
    margin-top: 14px;
}
.labs-footer .labs-shell {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: .9rem;
}

.hero-card, .card {
    background: linear-gradient(160deg, var(--panel), var(--panel-2));
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.25);
}

.hero-card { padding: 24px; margin-bottom: 18px; }
.hero-card h1 { margin: 0 0 8px; font-size: 1.7rem; }
.hero-card p { margin: 0; color: var(--muted); }
.hero-stats {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.hero-stat {
    border: 1px solid rgba(159, 179, 212, .26);
    background: rgba(9, 20, 37, .72);
    border-radius: 12px;
    padding: 10px 12px;
    display: grid;
    gap: 3px;
}

.hero-stat strong {
    font-size: 1.05rem;
    color: #d8faff;
}

.hero-stat span {
    color: var(--muted);
    font-size: .88rem;
}

.meta-row { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 10px; border-radius: 999px; font-size: .875rem;
    border: 1px solid transparent; background: rgba(54, 179, 168, .18); color: #bdf8f2;
}
.badge.ghost { background: rgba(159, 179, 212, .12); color: var(--muted); border-color: rgba(159, 179, 212, .2); }

.grid-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.vendor-filter {
    padding: 10px;
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.vf-btn {
    border: 1px solid var(--line);
    background: rgba(16, 29, 52, 0.9);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 14px;
    font-weight: 700;
    cursor: pointer;
}

.vf-btn.active {
    border-color: var(--brand);
    box-shadow: 0 0 0 1px rgba(54, 179, 168, 0.35);
    color: #bdf8f2;
}

.exam-card { padding: 16px; }
.exam-card {
    position: relative;
    overflow: hidden;
    transition: .25s ease;
}
.exam-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(54, 179, 168, .08), transparent 38%);
    opacity: 0;
    transition: .25s ease;
    pointer-events: none;
}
.exam-card:hover {
    transform: translateY(-4px);
    border-color: rgba(54, 179, 168, .35);
    box-shadow: 0 20px 36px rgba(0, 0, 0, .28);
}
.exam-card:hover::before { opacity: 1; }
.exam-card h3 { margin: 8px 0; }
.exam-card p { margin: 0 0 12px; color: var(--muted); min-height: 40px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-primary, .btn-secondary {
    text-decoration: none; border-radius: 10px; padding: 10px 14px; font-weight: 700; border: 1px solid transparent;
}
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #072723; }
.btn-secondary { background: transparent; border-color: var(--line); color: var(--text); }

.labs-layout { display: block; }

.lab-stage { padding: 14px; }
.lab-stage h3 { margin: 0 0 10px; }

.labs-strip {
    padding: 12px;
    margin-bottom: 12px;
}

.labs-strip h3 {
    margin: 0 0 10px;
}

.labs-strip-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow: visible;
    padding-bottom: 0;
}

.lab-item {
    display: flex;
    position: relative;
    direction: ltr;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--line);
    background: rgba(16, 29, 52, 0.8);
    border-radius: 10px;
    padding: 9px 12px;
    margin-bottom: 0;
    min-width: 180px;
    max-width: 320px;
    white-space: nowrap;
    flex: 1 1 260px;
}
.lab-item.active {
    border-color: var(--brand);
    box-shadow: 0 0 0 1px rgba(54, 179, 168, 0.35);
}
.lab-item:hover {
    border-color: rgba(159, 179, 212, .48);
}
.lab-item.locked {
    position: relative;
    border-style: dashed;
    opacity: .92;
}
.lab-lock-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 0;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: .875rem;
    color: #ffd9a8;
    background: rgba(245, 158, 11, .2);
    border: 1px solid rgba(245, 158, 11, .4);
}
.lab-seq {
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #052c27;
    background: rgba(54, 179, 168, .92);
    border: 1px solid rgba(189, 248, 242, .58);
}

.lab-name {
    font-weight: 700;
    color: #a6f1ea;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: left;
}
.lab-new-badge {
    position: absolute;
    top: -10px;
    right: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .875rem;
    font-weight: 800;
    color: #ffffff !important;
    background: #dc2626 !important;
    border: 1px solid #ef4444 !important;
}

.lab-stage-header { margin-bottom: 10px; }
.lab-stage-header .muted { color: var(--muted); font-size: .92rem; }
.lab-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.lab-controls-top {
    margin-top: 10px;
}
.lab-question-box {
    margin: 10px 0 12px;
    border: 1px solid rgba(77, 191, 181, 0.38);
    background: linear-gradient(145deg, rgba(8, 18, 34, 0.96), rgba(13, 30, 52, 0.92));
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: inset 0 0 0 1px rgba(189, 248, 242, 0.08);
}
.lab-question-label {
    font-size: .875rem;
    font-weight: 800;
    color: #9ee8df;
    margin-bottom: 7px;
    letter-spacing: .2px;
}
.lab-question-text {
    color: #f1f7ff;
    line-height: 1.8;
    font-size: 1.04rem;
    font-weight: 600;
    white-space: normal;
    word-break: break-word;
    direction: ltr;
    text-align: left;
    unicode-bidi: plaintext;
}
.lab-controls-bottom {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(159, 179, 212, 0.28);
}

.lab-controls .btn-primary,
.lab-controls .btn-secondary {
    min-height: 44px;
    padding: 11px 16px;
    font-size: .96rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.lab-frame {
    width: 100%;
    min-height: 72vh;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #0a0f1a;
}

.lab-frame-wrap {
    position: relative;
}
.lab-frame-wrap.is-locked .lab-frame {
    filter: blur(7px) saturate(.5);
    pointer-events: none;
    user-select: none;
}

.lab-lock-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    border-radius: 12px;
    background: rgba(6, 11, 21, .62);
    border: 1px dashed rgba(245, 158, 11, .45);
}

.lab-lock-overlay-inner {
    width: min(460px, 100%);
    background: rgba(7, 15, 29, .96);
    border: 1px solid rgba(245, 158, 11, .42);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    display: grid;
    gap: 8px;
}
.lab-lock-overlay-inner i {
    color: #f7b955;
    font-size: 1.28rem;
}
.lab-lock-overlay-inner strong {
    font-size: 1.05rem;
}
.lab-lock-overlay-inner span {
    color: var(--muted);
    font-size: .93rem;
}

.lab-locked-inline {
    margin-bottom: 10px;
    border: 1px solid rgba(245, 158, 11, .42);
    background: rgba(45, 34, 11, .55);
    color: #ffe6c0;
    border-radius: 10px;
    padding: 9px 11px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.lab-controls .btn-primary[disabled],
.lab-controls .btn-secondary[disabled] {
    opacity: .58;
    cursor: not-allowed;
}

.result-box,
.answer-box {
    margin: 10px 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: rgba(10, 20, 36, 0.85);
    color: var(--text);
}
.result-box.pending { border-color: #3b82f6; }
.result-box.ok { border-color: #22c55e; }
.result-box.warn { border-color: #f59e0b; }
.answer-box h4 { margin: 0 0 8px; }
.answer-box ul { margin: 0; padding-right: 20px; }

.warning { border-color: rgba(245, 158, 11, .45); background: linear-gradient(160deg, #2d220b, #3b2c0b); padding: 16px; margin-bottom: 14px; }
.empty { padding: 16px; color: var(--muted); text-align: center; }

@media (max-width: 1024px) {
    .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .grid-cards { grid-template-columns: 1fr; }
    .hero-card h1 { font-size: 1.35rem; }
    .hero-stats { grid-template-columns: 1fr; }
    .lab-frame { min-height: 58vh; }
    .labs-header .labs-shell,
    .labs-footer .labs-shell { flex-direction: column; align-items: flex-start; }
    .header-top { flex-direction: column; align-items: stretch; }
    .labs-header-actions { width: 100%; flex-direction: column; align-items: stretch; }
    .labs-lang-switch { width: 100%; justify-content: center; }
    .labs-top-nav { width: 100%; }
    .labs-top-link { flex: 1 1 calc(33.333% - 8px); justify-content: center; }
    .back-link { width: 100%; text-align: center; }
    .btn-primary, .btn-secondary { width: 100%; text-align: center; }
}
