@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700;800;900&display=swap');

:root {
    --purple: #6C5CE7;
    --purple-dark: #5849BE;
    --purple-soft: rgba(108, 92, 231, 0.08);
    --purple-soft2: rgba(108, 92, 231, 0.15);
    --sidebar-bg: #1A1A2E;
    --sidebar-active: #252542;
    --bg: #F2F3F7;
    --white: #FFFFFF;
    --card: #FFFFFF;
    --text: #2D3436;
    --text2: #6B7280;
    --text3: #9CA3AF;
    --border: #E5E7EB;
    --green: #00B894;
    --green-soft: rgba(0, 184, 148, 0.1);
    --red: #FF6B6B;
    --red-soft: rgba(255, 107, 107, 0.1);
    --orange: #FDCB6E;
    --orange-soft: rgba(253, 203, 110, 0.12);
    --blue: #74B9FF;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Rubik', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    min-height: 100vh;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}
.sidebar-brand {
    padding: 28px 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand h1 {
    font-size: 20px;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand h1 img { width: 28px; height: 28px; }
.sidebar-brand span {
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    font-weight: 500;
    display: block;
    margin-top: 4px;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
}
.sidebar-link:hover {
    color: rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.05);
}
.sidebar-link.active {
    color: white;
    background: var(--purple);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.35);
}
.sidebar-link .sl-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.sidebar-link .sl-badge {
    margin-left: auto;
    background: var(--red);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 8px;
    min-width: 20px;
    text-align: center;
}
.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-user-avatar {
    width: 38px; height: 38px;
    background: var(--purple);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.sidebar-user-name { color: white; font-size: 13px; font-weight: 700; }
.sidebar-user-role { color: rgba(255,255,255,0.4); font-size: 11px; font-weight: 500; }

/* Mobile hamburger */
.mobile-header {
    display: none;
    position: fixed; top: 0; left: 0; right: 0;
    height: 60px;
    background: var(--sidebar-bg);
    z-index: 101;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}
.hamburger {
    width: 40px; height: 40px;
    background: none; border: none;
    color: white; font-size: 22px;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
}
.mobile-header h1 {
    color: white; font-size: 16px; font-weight: 800;
}
.sidebar-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
    padding: 32px;
}
.page-header {
    margin-bottom: 28px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}
.page-title { font-size: 28px; font-weight: 800; }
.page-subtitle { font-size: 14px; color: var(--text2); font-weight: 500; margin-top: 2px; }

/* =============================================
   KPI CARDS
   ============================================= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.kpi-card.kpi-purple::after { background: var(--purple); }
.kpi-card.kpi-green::after { background: var(--green); }
.kpi-card.kpi-red::after { background: var(--red); }
.kpi-card.kpi-orange::after { background: var(--orange); }
.kpi-card.kpi-blue::after { background: var(--blue); }

.kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.kpi-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.kpi-purple .kpi-icon { background: var(--purple-soft); }
.kpi-green .kpi-icon { background: var(--green-soft); }
.kpi-red .kpi-icon { background: var(--red-soft); }
.kpi-orange .kpi-icon { background: var(--orange-soft); }
.kpi-blue .kpi-icon { background: rgba(116,185,255,0.12); }

.kpi-change {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 8px;
}
.kpi-change.up { background: var(--green-soft); color: var(--green); }
.kpi-change.down { background: var(--red-soft); color: var(--red); }

.kpi-value { font-size: 30px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.kpi-label { font-size: 12px; color: var(--text2); font-weight: 600; }

/* =============================================
   CARDS & PANELS
   ============================================= */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}
.card-title {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title .ct-icon { font-size: 18px; }

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.two-col > .card {
    align-self: stretch;
}

/* =============================================
   FILTERS
   ============================================= */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-chip {
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: var(--bg);
    color: var(--text2);
    font-family: 'Rubik', sans-serif;
    transition: all 0.15s;
}
.filter-chip.active {
    background: var(--purple);
    color: white;
    box-shadow: 0 3px 10px rgba(108,92,231,0.25);
}
.filter-chip:hover:not(.active) {
    background: #E2E3E9;
}

.filter-select {
    padding: 8px 14px;
    border-radius: 12px;
    border: 2px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Rubik', sans-serif;
    background: white;
    color: var(--text);
    cursor: pointer;
    outline: none;
}
.filter-select:focus {
    border-color: var(--purple);
}

/* =============================================
   LIVE FEED
   ============================================= */
.feed-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 6px;
    transition: background 0.15s;
    cursor: default;
    animation: feedIn 0.4s ease both;
}
.feed-item:hover { background: var(--bg); }

.feed-item.negative {
    background: var(--red-soft);
    border-left: 3px solid var(--red);
}
.feed-item.negative:hover {
    background: rgba(255, 107, 107, 0.15);
}

@keyframes feedIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.feed-avatar {
    font-size: 22px;
    width: 40px; height: 40px;
    background: var(--bg);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.feed-info { flex: 1; min-width: 0; }
.feed-name { font-size: 14px; font-weight: 700; }
.feed-meta { font-size: 12px; color: var(--text3); font-weight: 500; }
.feed-points {
    font-size: 18px;
    font-weight: 800;
    flex-shrink: 0;
}
.feed-points.plus { color: var(--green); }
.feed-points.minus { color: var(--red); }
.feed-time {
    font-size: 11px;
    color: var(--text3);
    font-weight: 600;
    flex-shrink: 0;
    min-width: 45px;
    text-align: right;
}

.live-dot {
    width: 8px; height: 8px;
    background: var(--green);
    border-radius: 50%;
    display: inline-block;
    animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(0,184,148,0.4); }
    50% { box-shadow: 0 0 0 5px rgba(0,184,148,0); }
}

/* =============================================
   TABLES
   ============================================= */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.data-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    border-bottom: 2px solid var(--border);
}
.data-table td {
    padding: 14px;
    font-size: 14px;
    font-weight: 500;
    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(--bg); }
.data-table .td-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}
.td-avatar {
    font-size: 20px;
    width: 36px; height: 36px;
    background: var(--bg);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

/* Tags / Badges */
.tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
}
.tag-purple { background: var(--purple-soft); color: var(--purple); }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-blue { background: rgba(116,185,255,0.12); color: #3D8BFD; }
.tag-gray { background: var(--bg); color: var(--text2); }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Rubik', sans-serif;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-primary {
    background: var(--purple);
    color: white;
    box-shadow: 0 4px 12px rgba(108,92,231,0.25);
}
.btn-primary:hover { background: var(--purple-dark); }
.btn-ghost {
    background: var(--bg);
    color: var(--text);
}
.btn-ghost:hover { background: #E2E3E9; }
.btn-danger {
    background: var(--red-soft);
    color: var(--red);
}
.btn-danger:hover { background: rgba(255,107,107,0.2); }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
}

/* =============================================
   SCHEDULE GRID
   ============================================= */
.schedule-grid {
    display: grid;
    grid-template-columns: 80px repeat(5, 1fr);
    gap: 2px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.sg-header {
    background: var(--sidebar-bg);
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 12px 8px;
    text-align: center;
}
.sg-time {
    background: #F8F9FB;
    font-size: 12px;
    font-weight: 700;
    color: var(--text2);
    padding: 16px 8px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sg-cell {
    background: white;
    padding: 10px 8px;
    min-height: 70px;
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
}
.sg-cell:hover { background: var(--purple-soft); }
.sg-cell-content {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}
.sg-cell-teacher {
    font-size: 10px;
    color: var(--text3);
    margin-top: 3px;
}
.sg-cell-empty {
    font-size: 11px;
    color: var(--text3);
    text-align: center;
    padding-top: 20px;
}

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
    padding: 20px;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-box {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}
.modal-overlay.active .modal-box { transform: translateY(0); }
.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 20px; }

.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid var(--border);
    font-size: 14px;
    font-weight: 500;
    font-family: 'Rubik', sans-serif;
    outline: none;
    transition: border 0.15s;
}
.form-input:focus { border-color: var(--purple); }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}
.form-actions .btn { flex: 1; justify-content: center; padding: 14px; }

/* =============================================
   STAFF CARD
   ============================================= */
.staff-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 16px;
    align-items: flex-start;
    transition: box-shadow 0.15s;
    cursor: pointer;
}
.staff-card:hover { box-shadow: var(--shadow-lg); }
.staff-avatar {
    font-size: 32px;
    width: 56px; height: 56px;
    background: var(--purple-soft);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.staff-info { flex: 1; min-width: 0; }
.staff-name { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.staff-subject { font-size: 13px; color: var(--text2); font-weight: 500; }
.staff-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.staff-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
    .staff-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .mobile-header { display: flex; }
    .main {
        margin-left: 0;
        padding: 76px 16px 20px;
    }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .kpi-card { padding: 14px; }
    .kpi-value { font-size: 22px; }
    .page-title { font-size: 22px; }
    .schedule-grid { grid-template-columns: 60px repeat(5, 1fr); }
    .card { padding: 16px; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi-value { font-size: 20px; }
    .filter-bar { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .schedule-grid {
        grid-template-columns: 50px repeat(5, 1fr);
        font-size: 11px;
    }
}

/* =============================================
   EXPANDED TABLE FOR CLASSES
   ============================================= */
.class-expand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background 0.15s;
}
.class-expand-header:hover { background: var(--bg); }
.class-expand-header .ceh-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.class-expand-header .ceh-name {
    font-size: 18px;
    font-weight: 800;
}
.class-expand-header .ceh-meta {
    font-size: 13px;
    color: var(--text2);
    font-weight: 500;
}
.class-expand-header .ceh-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.class-expand-header .ceh-arrow {
    font-size: 16px;
    transition: transform 0.2s;
    color: var(--text3);
}
.class-expand-header.open .ceh-arrow {
    transform: rotate(180deg);
}
.class-expand-body {
    display: none;
    padding: 0 20px 20px;
}
.class-expand-body.open { display: block; }

/* Student row in table */
.student-row-avatar {
    display: flex;
    align-items: center;
    gap: 10px;
}
.student-row-emoji {
    font-size: 20px;
    width: 34px; height: 34px;
    background: var(--bg);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

/* Mini bar for subject performance */
.mini-bar {
    display: flex;
    align-items: center;
    gap: 6px;
}
.mini-bar-track {
    width: 50px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.mini-bar-fill {
    height: 100%;
    border-radius: 3px;
}

/* Tabs inside cards */
.card-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 12px;
    padding: 4px;
}
.card-tab {
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text2);
    font-family: 'Rubik', sans-serif;
    transition: all 0.15s;
}
.card-tab.active {
    background: white;
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Edit form grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 500px) {
    .form-grid { grid-template-columns: 1fr; }
}

/* Checkbox list style */
.check-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.check-item {
    padding: 8px 14px;
    border-radius: 10px;
    border: 2px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Rubik', sans-serif;
    transition: all 0.15s;
    user-select: none;
}
.check-item.checked {
    border-color: var(--purple);
    background: var(--purple-soft);
    color: var(--purple);
}

/* =============================================
   ФОТО-АВАТАРИ
   ============================================= */
.avatar-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
}