:root {
    --bg: #0b1020;
    --bg2: #121a33;
    --card: #161f3d;
    --bd: #26315a;
    --tx: #e8ecff;
    --mu: #93a0cc;
    --pr: #7c5cff;
    --bl: #3b82f6;
    --ok: #22c55e;
    --wr: #f59e0b;
    --er: #ef4444;
    --r: 14px;
    --sh: 0 6px 24px rgba(0, 0, 0, .3);
    --s: 16px
}

[data-theme=light] {
    --bg: #f3f5fc;
    --bg2: #fff;
    --card: #fff;
    --bd: #dde2f3;
    --tx: #18203d;
    --mu: #5d6a93;
    --sh: 0 4px 16px rgba(30, 40, 90, .1)
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--tx);
    font: 15px/1.5 Inter, sans-serif
}

h1,
h2,
h3 {
    margin: 0 0 var(--s)
}

.cur {
    font-family: Caveat, cursive;
    font-size: 1.6em
}

.mu {
    color: var(--mu)
}

.sm {
    font-size: .85em
}

.app {
    display: flex;
    min-height: 100vh
}

.side {
    width: 260px;
    background: var(--bg2);
    border-right: 1px solid var(--bd);
    padding: 20px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform .25s cubic-bezier(0.4, 0, 0.2, 1);
}

.side::-webkit-scrollbar {
    width: 4px;
}

.side::-webkit-scrollbar-thumb {
    background: var(--bd);
    border-radius: 4px;
}

.side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

[data-theme=light] .side-head {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

.logo-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-family: Caveat, cursive;
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--pr);
    margin: 0;
    line-height: 1;
    letter-spacing: 0.5px;
    text-shadow: 0 0 20px rgba(124, 92, 255, 0.3);
}

.side-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(124, 92, 255, 0.16);
    color: var(--pr);
    border: 1px solid rgba(124, 92, 255, 0.3);
}

.side-close {
    display: none;
    background: var(--bd);
    border: 0;
    color: var(--tx);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
}

.side-close:hover {
    background: var(--er);
    color: #fff;
    transform: rotate(90deg);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 7px;
    flex: 1;
}

.nav button {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--mu);
    padding: 11px 14px;
    border-radius: 12px;
    cursor: pointer;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    text-align: left;
    transition: all .18s ease;
    position: relative;
}

.nav button:hover {
    background: rgba(124, 92, 255, 0.12);
    color: var(--tx);
    border-color: rgba(124, 92, 255, 0.22);
    transform: translateX(4px);
}

.nav button.on {
    background: linear-gradient(135deg, var(--pr), var(--bl));
    color: #fff;
    font-weight: 600;
    border-color: transparent;
    box-shadow: 0 4px 16px rgba(124, 92, 255, 0.35);
    transform: none;
}

.nav button.on:hover {
    transform: none;
    filter: brightness(1.08);
}

.nav button i {
    width: 20px;
    font-size: 1rem;
    text-align: center;
    opacity: 0.85;
    transition: transform .18s ease, opacity .18s ease;
}

.nav button:hover i {
    opacity: 1;
    transform: scale(1.1);
}

.nav button.on i {
    opacity: 1;
}

.side-footer {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

[data-theme=light] .side-footer {
    border-top-color: rgba(0, 0, 0, 0.06);
}

.side-goal-card {
    background: rgba(124, 92, 255, 0.08);
    border: 1px solid rgba(124, 92, 255, 0.2);
    border-radius: 12px;
    padding: 12px;
}

.side-goal-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    margin-bottom: 6px;
}

.side-goal-role {
    font-size: 0.75rem;
    color: var(--mu);
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 38;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.side-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.main {
    flex: 1;
    padding: 24px;
    min-width: 0
}

.top {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px
}

.menu {
    display: none
}

.row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center
}

/* --- Grid System --- */
.grid {
    display: grid;
    gap: var(--s);
}

.grid-12 {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
}

.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

.g3 {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.g2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* --- KPI Grid --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

/* --- Cards --- */
.card {
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    padding: 18px;
    box-shadow: var(--sh);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.card:hover {
    border-color: rgba(124, 92, 255, 0.25);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme=light] .card-head {
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

.card-head-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-head-title h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-head-title i {
    font-size: 1rem;
}

/* --- KPI Card --- */
.kpi {
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.kpi:hover {
    transform: translateY(-2px);
    border-color: rgba(124, 92, 255, 0.45);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.kpi-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    background: rgba(124, 92, 255, 0.15);
    color: var(--pr);
}

.kpi-label {
    font-size: 0.82rem;
    color: var(--mu);
    font-weight: 500;
}

.kpi b {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--tx);
    line-height: 1.2;
}

/* --- Quote Banner --- */
.quote-banner {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.09) 0%, rgba(59, 130, 246, 0.05) 100%), var(--card);
    border: 1px solid rgba(124, 92, 255, 0.22);
    border-radius: var(--r);
    padding: 14px 20px;
    margin: 16px 0 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--sh);
}

.quote-banner .fa-quote-left {
    color: var(--pr);
    font-size: 1.3rem;
    opacity: 0.75;
    flex-shrink: 0;
}

.quote-banner .cur {
    font-size: 1.45rem;
    line-height: 1.25;
    color: var(--tx);
}

/* --- Buttons --- */
.btn {
    background: linear-gradient(135deg, var(--pr), #6345ec);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    transition: filter .15s ease, transform .15s ease;
}

.btn:hover {
    filter: brightness(1.12);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn.s {
    background: var(--bd);
    color: var(--tx);
}

.btn.s:hover {
    background: #33406f;
}

.btn.d {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn.sm {
    padding: 5px 9px;
    font-size: 0.85rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0 !important;
    border-radius: 7px;
}

/* --- Forms & Inputs --- */
input,
select,
textarea {
    background: var(--bg);
    color: var(--tx);
    border: 1px solid var(--bd);
    border-radius: 10px;
    padding: 8px 11px;
    font: inherit;
    max-width: 100%;
    transition: border-color .15s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--pr);
}

label {
    display: block;
    font-size: .85em;
    color: var(--mu);
    margin: 8px 0 3px;
}

textarea {
    width: 100%;
    min-height: 60px;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: .75em;
    font-weight: 600;
    background: var(--bd);
    color: var(--tx);
}

.badge.Completed {
    background: rgba(34, 197, 94, 0.16);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge.Missed,
.badge.High {
    background: rgba(239, 68, 68, 0.16);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge.Medium {
    background: rgba(245, 158, 11, 0.16);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge.Low {
    background: rgba(59, 130, 246, 0.16);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge.Pending {
    background: rgba(148, 163, 184, 0.14);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.badge.sample {
    background: rgba(124, 92, 255, 0.14);
    color: #a78bfa;
    border: 1px solid rgba(124, 92, 255, 0.25);
}

/* --- Progress Bar --- */
.bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 9px;
    overflow: hidden;
}

[data-theme=light] .bar {
    background: rgba(0, 0, 0, 0.06);
}

.bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--pr), var(--bl));
    border-radius: 9px;
    transition: width .3s ease;
}

/* --- Tasks & Checklist --- */
.task-list-scroll {
    max-height: 480px;
    overflow-y: auto;
    padding-right: 4px;
    margin-top: 10px;
}

.task {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border: 1px solid var(--bd);
    background: var(--bg2);
    border-radius: 12px;
    margin-bottom: 8px;
    border-left: 4px solid var(--c);
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.task:hover {
    border-color: rgba(124, 92, 255, 0.35);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.task-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.task-check {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--ok);
    flex-shrink: 0;
}

.task .tt {
    flex: 1;
    min-width: 0;
}

.task-title-line {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.task-title-line b {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--tx);
    word-break: break-word;
}

.task.Completed .task-title-line b {
    text-decoration: line-through;
    opacity: .6;
}

.task-meta-line {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--mu);
}

.task-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.task-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.task-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

/* --- Subject Progress --- */
.sub-progress-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 4px;
}

.sub-progress-item {
    padding: 10px 12px;
    background: var(--bg2);
    border: 1px solid var(--bd);
    border-radius: 12px;
    transition: border-color .15s ease, transform .15s ease;
}

.sub-progress-item:hover {
    border-color: rgba(124, 92, 255, 0.35);
    transform: translateY(-1px);
}

.sub-prog-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 10px;
}

.sub-prog-name {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sub-icon-box {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sub-name-text {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sub-prog-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.sub-pct-badge {
    font-weight: 700;
    font-size: 0.85rem;
}

.sub-bar {
    height: 6px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.06);
}

[data-theme=light] .sub-bar {
    background: rgba(0, 0, 0, 0.06);
}

.sub-bar i {
    border-radius: 99px;
}

/* --- Dashboard Side Stack --- */
.dash-sections-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 4px;
}

.dash-sub-sec {
    background: var(--bg2);
    border: 1px solid var(--bd);
    border-radius: 12px;
    padding: 12px 14px;
}

.dash-sub-sec h4 {
    margin: 0 0 10px;
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--tx);
}

.mini-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.86rem;
}

[data-theme=light] .mini-row {
    border-bottom-color: rgba(0, 0, 0, 0.04);
}

.mini-row:last-child {
    border-bottom: none;
}

.mini-row-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Chart Wrap --- */
.chart-wrap {
    position: relative;
    height: 270px;
    width: 100%;
}

.chart-wrap canvas {
    max-height: 270px;
    width: 100% !important;
    height: 100% !important;
}

.empty {
    text-align: center;
    color: var(--mu);
    padding: 24px
}

.cal {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px
}

.dow {
    text-align: center;
    color: var(--mu);
    font-size: .8em
}

.cell {
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 6px 2px;
    color: #fff;
    cursor: pointer;
    font: inherit;
    min-height: 46px;
    background: var(--bd)
}

.cell i {
    display: block;
    font-size: .7em
}

.cell.done {
    background: #16a34a
}

.cell.partial {
    background: #2563eb
}

.cell.missed {
    background: #dc2626
}

.cell.rest,
.cell.none {
    background: #475069
}

.cell.holiday {
    background: #ea7a0c
}

.cell.future {
    background: #7c3aed
}

.cell.tod {
    border-color: #fff
}

.cell.sel {
    outline: 3px solid var(--wr)
}

.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 12px
}

.modal {
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: var(--r);
    padding: 20px;
    width: 560px;
    max-width: 100%;
    max-height: 90vh;
    overflow: auto
}

#toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 99;
    display: grid;
    gap: 8px
}

.toast {
    background: var(--card);
    border: 1px solid var(--bd);
    border-left: 4px solid var(--ok);
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: var(--sh)
}

.toast.err {
    border-left-color: var(--er)
}

.toast.warn {
    border-left-color: var(--wr)
}

.drop {
    border: 2px dashed var(--bd);
    border-radius: var(--r);
    padding: 30px;
    text-align: center
}

.drop.over {
    border-color: var(--pr)
}

.login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 20% 10%, #2b1f6b, var(--bg))
}

.login .card {
    width: 380px;
    max-width: 94vw
}

.err-t {
    color: var(--er);
    font-size: .85em;
    min-height: 1.2em
}

canvas {
    max-height: 270px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

td,
th {
    padding: 8px 10px;
    border-bottom: 1px solid var(--bd);
    text-align: left;
}

@media(max-width: 1024px) {
    .col-6,
    .col-8,
    .col-4 {
        grid-column: span 12;
    }
}

@media(max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media(max-width: 800px) {
    .side {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        width: 270px;
        transform: translateX(-100%);
        box-shadow: 4px 0 28px rgba(0, 0, 0, 0.6);
        z-index: 40;
    }

    .side.open {
        transform: translateX(0);
    }

    .side-close {
        display: inline-flex;
    }

    .side-backdrop {
        display: block;
    }

    .menu {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .main {
        padding: 14px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media(max-width: 640px) {
    .task {
        flex-wrap: wrap;
        gap: 8px;
    }

    .task-right {
        width: 100%;
        justify-content: space-between;
        padding-left: 30px;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }
}