:root {
    --bg: #0b1220;
    --panel: #111a2e;
    --panel2: #0f172a;
    --card: rgba(255, 255, 255, 0.06);
    --stroke: rgba(255, 255, 255, 0.10);
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.65);
    --muted2: rgba(255, 255, 255, 0.45);

    --brand: #7c3aed;
    --brand2: #22c55e;

    --shadow: 0 18px 45px rgba(0, 0, 0, 0.40);
    --radius: 12px;
    --radius2: 15px;

    --gap: 14px;
    --max: 1200px;

    --topbar-h: 72px;
    --topbar-h-compact: 62px;

    --player-sticky-h: 72px
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    padding-top: var(--topbar-current-h);
    transition: padding-top .28s cubic-bezier(.2, .8, .2, 1);
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
    background:
            radial-gradient(1200px 600px at 30% -10%, rgba(124, 58, 237, 0.35), transparent),
            radial-gradient(900px 600px at 90% 0%, rgba(34, 197, 94, 0.20), transparent),
            var(--bg);
    color: var(--text);

    /* variável “viva” para o sticky do player no mobile */
    --topbar-current-h: var(--topbar-h);

    overflow-y: auto;
    overflow-x: hidden;
}

body.topbar--compact{
    --topbar-current-h: var(--topbar-h-compact);
}

.topbar{
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;

    display: grid;
    grid-template-columns: 1fr minmax(280px, 520px) 1fr;
    grid-template-areas: "left center right"; /* ✅ FALTAVA */
    gap: var(--gap);
    align-items: center;

    height: var(--topbar-current-h);

    /* padding compatível com a altura (não pode ser maior que a height) */
    padding: 10px 16px;

    background: rgba(9, 13, 23, 0.65);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--stroke);

    transition:
            height .28s cubic-bezier(.2,.8,.2,1),
            padding .28s cubic-bezier(.2,.8,.2,1),
            box-shadow .28s cubic-bezier(.2,.8,.2,1);
    will-change: height, padding;
}

/* ✅ agora grid-area faz sentido */
.topbar__left  { grid-area: left;  min-width: 0; }
.topbar__center{ grid-area: center; min-width: 0; }
.topbar__right { grid-area: right; min-width: 0; }

/* ===== Compact (DESKTOP) ===== */
body.topbar--compact .topbar{
    /* padding MENOR (senão estoura a height) */
    padding: 6px 10px;
    box-shadow: 0 10px 26px rgba(0,0,0,0.28);

    /* remove “vazio” lateral mantendo 3 colunas */
    grid-template-columns: 0 1fr 0;
    grid-template-areas: "left center right";
    gap: 0;
}

/* anima sumiço + evita “invadir” o centro quando colunas viram 0 */
.topbar__left,
.topbar__right{
    transition: opacity .22s ease, transform .22s ease, max-width .28s cubic-bezier(.2,.8,.2,1);
    will-change: opacity, transform, max-width;
}

body.topbar--compact .topbar__left,
body.topbar--compact .topbar__right{
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    max-width: 0;          /* ✅ impede empilhar/overlap */
    overflow: hidden;      /* ✅ */
}

/* Center ganha espaço suavemente */
.topbar__center{
    transition: transform .28s cubic-bezier(.2,.8,.2,1), width .28s cubic-bezier(.2,.8,.2,1);
    will-change: transform, width;
}

body.topbar--compact .topbar__center{
    width: 100%;
    transform: translateY(-1px);
}

/* Course picker ocupa o centro */
body.topbar--compact .course-picker{
    width: 100%;
    max-width: 100%;
}

/* Por padrão (desktop): não aparece */
.sticky-mask{
    display: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand__logo {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.95), rgba(34, 197, 94, 0.75));
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.20);
    font-weight: 800;
}

.brand__name {
    font-weight: 800;
    letter-spacing: 0.2px;
}

.userbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.userbar__name {
    padding: 8px 10px;
    border: 1px solid var(--stroke);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    font-size: 12px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn {
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border-radius: 999px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 650;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn--primary {
    border: 0;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.95), rgba(124, 58, 237, 0.65));
    box-shadow: 0 14px 40px rgba(124, 58, 237, 0.25);
}

.btn--ghost { background: transparent; }

.icon-btn {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
}

.icon-btn-menu {
    background: transparent;
}

.icon-btn svg { fill: rgba(255, 255, 255, 0.85); }

/* Course picker */
.course-picker {
    position: relative;
    width: 100%;
}

.course-picker__button {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
}

.course-picker__label {
    max-width: 92%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.course-picker__panel {
    position: absolute;
    left: 0;
    right: 0;
    top: 52px;
    background: rgba(17, 26, 46, 0.92);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.course-picker__search {
    padding: 10px;
    border-bottom: 1px solid var(--stroke);
}

.course-picker__search input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    outline: none;
}

.course-picker__list {
    max-height: 320px;
    overflow: auto;
}

.course-option {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.course-option:hover { background: rgba(255, 255, 255, 0.06); }

.course-option__title { font-weight: 750; }

.course-option__meta {
    color: var(--muted2);
    font-size: 12px;
    margin-top: 2px;
}

.layout {
    margin: 10px auto 22px;
    padding: 0 60px;
    display: grid;
    grid-template-columns: 1fr 1.55fr;
    gap: var(--gap);
    align-items: start;
    height: calc(95vh - 60px);
    overflow: hidden;
}

.panel {
    border: 1px solid var(--stroke);
    border-radius: var(--radius2);
    background: linear-gradient(180deg, rgba(17, 26, 46, 0.72), rgba(15, 23, 42, 0.72));
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 520px;
    height: 100%;
}

.panel__header {
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--stroke);
}

.panel__header--player {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.panel__title { font-weight: 850; font-size: 14px; }

.panel__subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.panel--left{
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0; /* importante para scroll interno */
}

.now-playing {
    display: flex;
    align-items: center;
    gap: 10px;
}

.now-playing__badge {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    display: grid;
    place-items: center;
}

.now-playing__title { font-weight: 800; font-size: 14px; }

.now-playing__subtitle {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.player-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player{
    flex: 0 0 auto;
}

/* Speed picker */
.speed-picker{ position: relative; display: inline-flex; align-items: center; }

.speed-picker__button{
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    background: linear-gradient(180deg, rgba(17, 26, 46, 0.72), rgba(15, 23, 42, 0.72));
    box-shadow: var(--shadow);
    color: rgba(255,255,255,.92);
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    font-weight: 850;
}

.speed-picker__prefix{ color: var(--muted); font-weight: 800; font-size: 12px; }
.speed-picker__label{ font-weight: 900; }
.speed-picker__chevron{ color: rgba(255,255,255,.70); margin-left: 2px; }

.speed-picker__button:hover{
    border-color: rgba(255,255,255,.22);
    filter: brightness(1.06);
}

.speed-picker__button:focus{
    outline: none;
    border-color: rgba(99,102,241,.55);
    box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}

.speed-picker__panel{
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 160px;
    z-index: 30;
    border: 1px solid var(--stroke);
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(17, 26, 46, 0.96), rgba(15, 23, 42, 0.96));
    box-shadow: var(--shadow);
}

.speed-picker__list{
    padding: 6px;
    display: grid;
    gap: 6px;
}

.speed-option{
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    padding: 10px 10px;
    border-radius: 12px;
    cursor: pointer;
    color: rgba(255,255,255,.92);
    font-weight: 850;
    font-size: 12px;
    text-align: left;
}

.speed-option:hover{
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.18);
}

.speed-option[aria-selected="true"]{
    border-color: rgba(99,102,241,.55);
    background: rgba(99,102,241,.12);
}

.speed-option:focus{
    outline: none;
    box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}

/* Accordion */
.accordion {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.accordion__item {
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius);
    overflow: hidden;
}

.accordion__header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.accordion__title {
    font-weight: 800;
    font-size: 13px;
    text-align: left;
}

.accordion__right {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
}

.accordion__chev { opacity: 0.85; }

.accordion__content { padding: 8px 10px 10px; }

.list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.item__left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.item__icon {
    width: 31px;
    height: 34px;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-weight: 800;
}

.item__texts { min-width: 0; }

.item__title {
    font-weight: 700;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.item__meta {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted2);
}

.item__right {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.pill {
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border-radius: 999px;
    padding: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pill--ok {
    border: 0;
    background: rgba(34, 197, 94, 0.18);
    color: rgba(255, 255, 255, 0.92);
}

.player video{
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    max-height: clamp(180px, 50vh, 450px);
    display: block;
    border-radius: 10px;
    border: 1px solid var(--stroke);
}

.player__hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted2);
}

.notes{
    flex: 0 0 auto;
    min-height: 0;     /* essencial */
    display: flex;
    flex-direction: column;
}

.notes__title { font-weight: 850; font-size: 13px; }

.notes__subtitle {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.notes textarea {
    flex: 1 1 auto;
    margin-top: 10px;
    width: 100%;
    min-height: 120px;
    resize: none;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 10px 12px;
    outline: none;
    height: auto;
    overflow: auto;
}

/* Skeleton */
.skeleton {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skeleton__line {
    height: 14px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.05));
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite linear;
}

.module-section {
    margin: 10px 0 6px;
    padding: 0 10px;
    color: var(--muted);
    font-weight: 800;
    font-size: 12px;
    letter-spacing: .04em;
    opacity: .9;
}
.module-section--first { margin-top: 0; }

/* ===== Mobile tabs (default hidden) ===== */
.mobile-tabs {
    display: none;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--stroke);
    background: rgba(15, 23, 42, 0.35);
}

.mobile-tabs__tab {
    flex: 1;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.86);
    font-weight: 750;
    cursor: pointer;
}

.mobile-tabs__tab.is-active {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.18);
}

/* Mobile notes box */
.notes--mobile textarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.9);
    padding: 12px;
    outline: none;
}

.player__actions{
    margin-top: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.player__actions,
.notes__actions{
    flex: 0 0 auto;
}

#btnPlayerWatched[disabled]{
    opacity: .55;
    cursor: not-allowed;
}

/* =========================
   Mobile
   ========================= */
@media (max-width: 980px) {
    :root{
        --topbar-h: 112px;          /* ✅ topbar em 2 linhas */
        --topbar-h-compact: 68px;   /* ✅ compact */
    }

    body{
        background:
                radial-gradient(900px 700px at 50% 20%, rgba(124, 58, 237, 0.22), transparent 60%),
                radial-gradient(900px 700px at 50% 70%, rgba(34, 197, 94, 0.14), transparent 60%),
                var(--bg);
        background-attachment: scroll;
    }

    .layout {
        margin-top: 0;
        grid-template-columns: 1fr;
        grid-template-areas: "right" "left";
        height: auto;
        overflow: visible;
        row-gap: 12px;
        padding: 10px;
    }

    /* header do painel some no mobile */
    .panel--left .panel__header { display: none; }

    .panel--right {
        position: sticky;
        top: calc(var(--topbar-current-h) + 10px);
        background: linear-gradient(180deg, rgba(17, 26, 46, 0.98), rgba(15, 23, 42, 0.98));
        isolation: isolate;
        z-index: 40;
        border-bottom: 1px solid var(--stroke);
    }

    .panel--right .panel__body { background: transparent; }

    .panel--left { grid-area: left; }

    .panel--left .panel__body {
        overflow: visible;
    }

    .mobile-tabs { display: flex; }

    .panel--right .notes { display: none; }

    .player video {
        width: 100%;
        aspect-ratio: 16 / 9;
        height: auto;
        display: block;
        background: #000;
    }

    .topbar {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
          "left right"
          "center center";
        height: var(--topbar-current-h); /* ✅ mantém fixo */
    }

    body.topbar--compact .topbar{
        grid-template-columns: 1fr;
        grid-template-areas: "center";
        height: var(--topbar-current-h); /* ✅ mantém fixo */
    }

    .topbar__left  { grid-area: left; }
    .topbar__center{ grid-area: center; }
    .topbar__right { grid-area: right; }

    /* compact no mobile: só o center (sem desaparecer por completo) */
    body.topbar--compact .topbar{
        grid-template-columns: 0 1fr 0;
        grid-template-areas: "left center right";
        height: var(--topbar-current-h);
    }

    .panel { min-height: unset; }

    .sticky-mask{
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        height: calc(var(--topbar-current-h) + var(--player-sticky-h, 0px) + 12px);
        background: rgba(9, 13, 23, 0.92);
        backdrop-filter: blur(14px);
        z-index: 44;
        pointer-events: none;
        box-shadow: 0 14px 30px rgba(0,0,0,0.35);
        opacity: 0;
        transform: translateY(-6px);
        visibility: hidden;
        transition:
                opacity .22s ease,
                transform .22s ease,
                visibility 0s linear .22s;
    }

    .sticky-mask::after{
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: -18px;
        height: 18px;
        background: linear-gradient(to bottom, rgba(9,13,23,0.85), rgba(9,13,23,0));
    }

    body.topbar--compact .sticky-mask{
        opacity: 1;
        transform: translateY(0);
        visibility: visible;

        transition:
                opacity .22s ease,
                transform .22s ease,
                visibility 0s linear 0s;
    }

    .panel--right{
        z-index: 45;
        isolation: isolate;
    }

    .topbar{
        z-index: 50;
    }

    .module-section{
        font-size: 12px;
    }
}

@keyframes shimmer {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

[hidden] { display: none !important; }

/* ===== App menu ===== */
.appmenu{
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.appmenu__hamburger svg{
    display: none; /* mobile only */
}

.appmenu__panel{
    position: absolute;
    top: calc(100% + 10px);
    min-width: 180px;
    z-index: 80;

    border: 1px solid var(--stroke);
    border-radius: 14px;
    background: rgba(17, 26, 46, 0.96);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.appmenu__item{
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: var(--text);
    padding: 12px 12px;
    cursor: pointer;
    font-weight: 750;
}
.appmenu__item:hover { background: rgba(255,255,255,0.06); }

@media (max-width: 980px) {
    .appmenu__hamburger svg { display: grid; }
    .appmenu__hamburger label { display: none; }

    .icon-btn-menu {
        width: 40px;
        height: 40px;
        display: grid;
        place-items: center;
        border-radius: 999px;
        border: 1px solid var(--stroke);
        background: rgba(255, 255, 255, 0.04);
        cursor: pointer;
        padding: 0;
    }
}

/* ===== Admin view ===== */
.course{
    max-width: var(--max);
    margin: 14px auto 22px;
    padding: calc(var(--topbar-current-h) + 14px) 60px 22px; /* topbar fixed */
}

@media (max-width: 980px){
    .course{ padding: 15px 14px 22px; }
}

.course__header{
    margin-bottom: 12px;
}

.course__title{
    margin: 0;
    font-weight: 900;
    letter-spacing: .2px;
}

.course__subtitle{
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.course__panel{
    border: 1px solid var(--stroke);
    border-radius: var(--radius2);
    background: linear-gradient(180deg, rgba(17, 26, 46, 0.72), rgba(15, 23, 42, 0.72));
    box-shadow: var(--shadow);
    overflow: hidden;
    padding: 14px;
    margin-top: 12px;
}

.course-form__grid {
    display: grid;
    grid-template-columns: 0.55fr 1fr auto; /* Nome | Link | Toggle */
    align-items: end;
    gap: 10px;
}

@media (max-width: 980px) {
    .course-form__grid{ grid-template-columns: 1fr; }
}

.field{
    display: grid;
    gap: 6px;
}

.field__label{
    font-size: 12px;
    color: var(--muted);
    font-weight: 800;
}

.field__hint{
    font-size: 12px;
    color: var(--muted2);
}

.field input, .field select{
    width: 100%;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    outline: none;
}

.field--inline{
    display: flex;
    align-items: center;
    gap: 10px;
}

.field--inline .field__label{
    margin: 0;
    white-space: nowrap;
}

.course-form__actions{
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.course-form__msg{
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
}

/* ===== Table ===== */
.tablebar{
    display:flex;
    align-items:center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.tablebar__title{
    font-weight: 900;
}

.tablebar__meta{
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.tablewrap{
    overflow: auto;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
}

.table{
    width: 100%;
    border-collapse: collapse;
    min-width: 720px; /* permite scroll horizontal no mobile */
}

.table th, .table td{
    padding: 12px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: left;
    font-size: 13px;
}

.table thead th{
    position: sticky;
    top: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    z-index: 2;
}

.thbtn{
    border: 0;
    background: transparent;
    color: var(--text);
    font-weight: 900;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.thbtn::after{
    content: "";
    opacity: 0.5;
    font-weight: 900;
}

.thbtn[data-dir="asc"]::after{ content: "▲"; opacity: 0.7; }

.thbtn[data-dir="desc"]::after{ content: "▼"; opacity: 0.7; }

.table__actions{
    width: 170px;
}

.row-actions{
    display: flex;
    gap: 8px;
}

.pager{
    display:flex;
    justify-content: flex-end;
    align-items:center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.pager__btn{
    border: 1px solid var(--stroke);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    border-radius: 999px;
    padding: 8px 10px;
    cursor: pointer;
    font-weight: 800;
    font-size: 12px;
}

.pager__btn:disabled{ opacity: .5; cursor: not-allowed; }

.pager__info{
    color: var(--muted);
    font-size: 12px;
    margin-right: 8px;
}

/* ===== Toggle pill ON/OFF ===== */
.toggle--pill{
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 10px 0;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

/* esconde o checkbox real */
.toggle--pill input{
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle--pill .toggle__track{
    width: 44px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
    position: relative;
    transition: border-color .16s ease, background .16s ease, filter .16s ease;
}

.toggle--pill .toggle__knob{
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: rgba(255,255,255,0.92);
    position: absolute;
    top: 50%;
    left: 3px;
    transform: translateY(-50%);
    transition: left .18s ease, transform .18s ease;
    box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}

.toggle--pill .toggle__text{
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}

.toggle--pill .toggle__label{
    font-weight: 850;
    font-size: 12px;
    color: rgba(255,255,255,.86);
}

.toggle--pill .toggle__state{
    font-weight: 950;
    font-size: 12px;
    color: rgba(255,255,255,.70);
    letter-spacing: .04em;
}

/* Hover */
.toggle--pill:hover{
    border-color: rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.04);
}
.toggle--pill:hover .toggle__track{
    border-color: rgba(255,255,255,0.22);
    filter: brightness(1.05);
}

/* Focus (acessível) */
.toggle--pill input:focus-visible + .toggle__track{
    box-shadow: 0 0 0 3px rgba(99,102,241,.18);
    border-color: rgba(99,102,241,.55);
}

/* ON */
.toggle--pill input:checked + .toggle__track{
    border-color: rgba(99,102,241,.55);
    background: rgba(99,102,241,.18);
}
.toggle--pill input:checked + .toggle__track .toggle__knob{
    left: 23px; /* track(44) - knob(18) - padding(3) = 23 */
}
.toggle--pill input:checked ~ .toggle__text .toggle__state{
    color: rgba(255,255,255,.92);
}

/* troca texto OFF/ON sem JS */
.toggle--pill .toggle__state::before{
    content: attr(data-off);
}
.toggle--pill input:checked ~ .toggle__text .toggle__state::before{
    content: attr(data-on);
}

/* Mobile: ocupa 100% e centraliza */
@media (max-width: 740px){
    .toggle--pill{
        width: 100%;
    }
}

/* ===== Badge SIM/NAO (Categoria) ===== */
.badge{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .02em;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.86);
}

.badge::before{
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.35);
}

/* SIM (verde) */
.badge--yes{
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.14);
    color: rgba(255,255,255,0.92);
}
.badge--yes::before{
    background: rgba(34, 197, 94, 0.95);
}

/* NAO (vermelho) */
.badge--no{
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.14);
    color: rgba(255,255,255,0.92);
}
.badge--no::before{
    background: rgba(239, 68, 68, 0.95);
}

/* ===== Toast / Popup ===== */
.toast-host{
    position: fixed;
    z-index: 9999;
    right: 16px;
    top: 16px;
    bottom: auto;
    display: grid;
    gap: 10px;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

@media (max-width: 980px){
    .toast-host{
        left: 12px;
        right: 12px;
        bottom: 12px;
        top: auto;
        width: auto;
    }
}

.toast{
    pointer-events: auto;
    position: relative;
    overflow: hidden;

    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: start;

    padding: 12px 12px 12px;
    border-radius: var(--radius2);
    border: 1px solid var(--stroke);

    background: linear-gradient(180deg, rgba(17, 26, 46, 0.92), rgba(15, 23, 42, 0.92));
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
}

.toast__bar{
    position: absolute;
    left: 0;
    top: 0;
    height: 3px;
    width: 100%;
    opacity: .9;
    background: linear-gradient(90deg, rgba(124,58,237,.95), rgba(34,197,94,.85));
    transform-origin: left center;
    transform: scaleX(1);
}

.toast__icon{
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: grid;
    place-items: center;

    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.86);
    font-weight: 900;
}

.toast__content{
    min-width: 0;
}

.toast__title{
    font-weight: 900;
    font-size: 13px;
    line-height: 1.2;
}

.toast__msg{
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    word-break: break-word;
}

.toast__close{
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.84);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.toast__close:hover{
    border-color: rgba(255,255,255,0.20);
    background: rgba(255,255,255,0.06);
}

/* Tipos */
.toast--success .toast__icon{ background: rgba(34,197,94,0.14); border-color: rgba(34,197,94,0.25); }
.toast--error   .toast__icon{ background: rgba(239,68,68,0.14); border-color: rgba(239,68,68,0.25); }
.toast--info    .toast__icon{ background: rgba(124,58,237,0.14); border-color: rgba(124,58,237,0.25); }

/* Animations */
.toast{
    animation: toastIn .22s cubic-bezier(.2,.8,.2,1) both;
}

.toast.is-leaving{
    animation: toastOut .16s ease both;
}

@keyframes toastIn{
    from{ opacity: 0; transform: translateY(10px) scale(.98); }
    to{ opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut{
    from{ opacity: 1; transform: translateY(0) scale(1); }
    to{ opacity: 0; transform: translateY(6px) scale(.98); }
}

/* Barra de tempo (10s) */
.toast[data-life="10000"] .toast__bar{
    animation: toastLife 10s linear forwards;
}

@keyframes toastLife{
    from{ transform: scaleX(1); }
    to{ transform: scaleX(0); }
}

.notes__actions{
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@media (max-width: 980px){
    .notes__actions{
        justify-content: stretch;
    }
    .notes__actions .btn{
        width: 100%;
    }
}

.panel--right { min-height: 0; }

/* =========================================================
   PANEL BODY (default) - mantém scroll e scrollbar custom
   ========================================================= */

.panel__body{
    padding: 12px 12px 14px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;

    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.22) rgba(255,255,255,0.06);
}

/* Chrome/Edge/Safari */
.panel__body::-webkit-scrollbar{ width: 10px; }
.panel__body::-webkit-scrollbar-track{
    background: rgba(255,255,255,0.06);
    border-radius: 999px;
}
.panel__body::-webkit-scrollbar-thumb{
    background: rgba(255,255,255,0.22);
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,0);
    background-clip: padding-box;
}
.panel__body::-webkit-scrollbar-thumb:hover{
    background: rgba(255,255,255,0.32);
    background-clip: padding-box;
}


/* =========================================================
   PLAYER BODY (right panel) - NÃO repete display/gap, só ajusta scroll
   A regra é: .panel__body--player herda de .panel__body e só sobrescreve o necessário
   ========================================================= */

.panel__body--player{
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    flex: 1 1 auto;
    overflow: auto;
    -webkit-overflow-scrolling: touch;

    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.22) rgba(255,255,255,0.06);
}

/* Chrome/Edge/Safari */
.panel__body--player::-webkit-scrollbar{ width: 10px; }
.panel__body--player::-webkit-scrollbar-track{
    background: rgba(255,255,255,0.06);
    border-radius: 999px;
}
.panel__body--player::-webkit-scrollbar-thumb{
    background: rgba(255,255,255,0.22);
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,0);
    background-clip: padding-box;
}
.panel__body--player::-webkit-scrollbar-thumb:hover{
    background: rgba(255,255,255,0.32);
    background-clip: padding-box;
}

.panel--right{ display:flex; flex-direction:column; }
