@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
    --bg:         #F6FAF6;
    --surface:    #FFFFFF;
    --surface2:   #F0F7F0;
    --border:     #DFF0DF;
    --text:       #1A2E1A;
    --muted:      #5A7A5A;
    --primary:    #4CAF50;
    --primary-dk: #388E3C;
    --primary-lt: #E8F5E9;
    --blue:       #42A5F5;
    --blue-lt:    #E3F2FD;
    --green:      #4CAF50;
    --green-lt:   #E8F5E9;
    --amber:      #FFA726;
    --amber-lt:   #FFF3E0;
    --red:        #EF5350;
    --red-lt:     #FFEBEE;
    --purple:     #7E57C2;
    --purple-lt:  #EDE7F6;
    --sidebar-w:  220px;
    --radius-sm:  8px;
    --radius:     12px;
    --radius-lg:  16px;
    --shadow-sm:  0 1px 2px rgba(0,0,0,.04);
    --shadow:     0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
    --shadow-lg:  0 4px 24px rgba(0,0,0,.08);
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dk); text-decoration: none; transition: opacity .15s; }
a:hover { opacity: .75; }

/* ── LAYOUT ─────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid var(--border);
}
.logo-text { font-size: 16px; font-weight: 700; letter-spacing: -.3px; color: var(--primary-dk); }

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-weight: 500;
    font-size: 13.5px;
    transition: all .12s;
    cursor: pointer;
}
.nav-item:hover { background: var(--surface2); color: var(--text); opacity: 1; }
.nav-item.active { background: var(--primary-lt); color: var(--primary-dk); font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; height: 20px; text-align: center; }

.sidebar-bottom {
    padding: 14px;
    border-top: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; gap: 10px; padding: 8px 4px; margin-bottom: 8px; }
.user-avatar {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), #66BB6A);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 13px; }
.logout-btn {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: none; border: none;
    color: var(--muted); font-size: 13px; font-weight: 500;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer; transition: .12s; text-decoration: none;
}
.logout-btn:hover { background: var(--red-lt); color: var(--red); opacity: 1; }

/* ── MAIN ───────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 28px 32px;
    max-width: calc(100vw - var(--sidebar-w));
}

/* ── PAGE HEADER ────────────────────────────────────── */
.page-header {
    display: flex; align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.page-sub   { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ── STAT CARDS ─────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-label-top { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.stat-icon-wrap {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.icon-blue   { background: var(--blue-lt); }
.icon-green  { background: var(--green-lt); }
.icon-amber  { background: var(--amber-lt); }
.icon-purple { background: var(--purple-lt); }
.stat-value  { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.stat-change { font-size: 12px; font-weight: 500; margin-top: 4px; color: var(--primary); }

/* ── SECTION CARD ───────────────────────────────────── */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 18px;
}
.section-header {
    display: flex; align-items: center;
    justify-content: space-between; margin-bottom: 18px;
}
.section-header h2 { font-size: 15px; font-weight: 600; letter-spacing: -.2px; }

/* ── LESSON LIST ────────────────────────────────────── */
.lesson-list { display: flex; flex-direction: column; }
.lesson-row {
    display: flex; align-items: center; gap: 14px;
    padding: 11px 12px; border-radius: var(--radius-sm); transition: background .1s;
}
.lesson-row:hover { background: var(--surface2); }
.lesson-date-block { min-width: 80px; }
.lesson-date { font-weight: 600; font-size: 13px; }
.lesson-time { color: var(--muted); font-size: 12px; font-family: 'DM Mono', monospace; }
.lesson-info { flex: 1; }
.lesson-student { font-weight: 600; font-size: 13.5px; }
.lesson-subject { color: var(--muted); font-size: 12px; margin-top: 1px; }
.lesson-amount { min-width: 130px; text-align: right; }

/* ── STUDENTS TABLE ─────────────────────────────────── */
.students-table { width: 100%; border-collapse: collapse; }
.students-table th {
    text-align: left; font-size: 12px; font-weight: 600;
    color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
    padding: 0 12px 12px; border-bottom: 1px solid var(--border);
}
.students-table td {
    padding: 14px 12px; border-bottom: 1px solid var(--border);
    font-size: 13.5px; vertical-align: middle;
}
.students-table tr:last-child td { border-bottom: none; }
.students-table tr:hover td { background: var(--surface2); }
.students-table a { color: var(--text); font-weight: 600; }
.students-table a:hover { color: var(--primary-dk); opacity: 1; }

.student-cell { display: flex; align-items: center; gap: 12px; }
.student-avatar-sm {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.av-blue   { background: linear-gradient(135deg,#42A5F5,#1E88E5); }
.av-green  { background: linear-gradient(135deg,#4CAF50,#388E3C); }
.av-amber  { background: linear-gradient(135deg,#FFA726,#F57C00); }
.av-purple { background: linear-gradient(135deg,#7E57C2,#5E35B1); }
.av-red    { background: linear-gradient(135deg,#EF5350,#E53935); }
.av-teal   { background: linear-gradient(135deg,#26C6DA,#00ACC1); }

.student-name-wrap .name  { font-weight: 600; font-size: 13.5px; }
.student-name-wrap .email { font-size: 12px; color: var(--muted); margin-top: 1px; }
.contact-cell { font-size: 12.5px; color: var(--muted); }
.contact-cell div { display: flex; align-items: center; gap: 5px; }

/* ── STUDENT CARDS ──────────────────────────────────── */
.students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.student-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    display: flex; align-items: center; gap: 14px;
    transition: box-shadow .15s, transform .15s;
    color: var(--text); box-shadow: var(--shadow-sm);
}
.student-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); opacity: 1; }
.student-avatar-lg {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.student-info-card { flex: 1; min-width: 0; }
.student-name-card { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.student-sub-card  { color: var(--muted); font-size: 12px; margin-top: 2px; }
.price-pill {
    background: var(--primary-lt); color: var(--primary-dk);
    font-size: 11px; font-weight: 600; padding: 3px 8px;
    border-radius: 20px; white-space: nowrap;
}

/* ── SEARCH ─────────────────────────────────────────── */
.search-wrap { margin-bottom: 18px; }
.search-wrap form { display: flex; gap: 10px; flex-wrap: wrap; }
.search-input {
    flex: 1; min-width: 200px;
    padding: 9px 14px 9px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px; font-family: 'DM Sans', sans-serif;
    color: var(--text);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%235A7A5A' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") 12px center no-repeat;
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(76,175,80,.1); }

/* ── DETAIL LAYOUT ──────────────────────────────────── */
.detail-layout { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.student-big-avatar {
    width: 64px; height: 64px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-weight: 700; color: #fff; margin: 0 auto 14px;
}
.info-list { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.info-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--bg);
}
.info-key { color: var(--muted); font-weight: 500; }
.notes-block {
    background: var(--surface2); border-radius: var(--radius-sm);
    padding: 12px; margin-top: 14px; font-size: 13px; color: var(--muted);
}

/* ── FORM ───────────────────────────────────────────── */
.form-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow-sm); max-width: 680px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .2px; }

input, select, textarea {
    padding: 9px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 13.5px;
    font-family: 'DM Sans', sans-serif; color: var(--text);
    background: var(--surface); outline: none;
    transition: border-color .15s, box-shadow .15s; width: 100%;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(76,175,80,.12);
}
textarea { resize: vertical; }

.form-check { justify-content: flex-end; padding-top: 18px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; font-weight: 500; }
.checkbox-label input { width: auto; }

/* ── BUTTONS ────────────────────────────────────────── */
.btn-primary {
    background: var(--primary); color: #fff; border: none;
    padding: 9px 18px; border-radius: var(--radius-sm);
    font-size: 13.5px; font-weight: 600; font-family: 'DM Sans', sans-serif;
    cursor: pointer; transition: all .15s;
    display: inline-flex; align-items: center; gap: 6px; letter-spacing: -.1px;
}
.btn-primary:hover { background: var(--primary-dk); box-shadow: 0 4px 12px rgba(76,175,80,.3); color: #fff; opacity: 1; }

.btn-secondary {
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); padding: 8px 16px;
    border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
    font-family: 'DM Sans', sans-serif; cursor: pointer; transition: .15s;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary-dk); background: var(--primary-lt); opacity: 1; }

.btn-ghost {
    background: transparent; color: var(--muted); border: none;
    padding: 8px 14px; border-radius: var(--radius-sm);
    font-size: 13.5px; font-weight: 500; cursor: pointer; transition: .15s;
    display: inline-flex; align-items: center; gap: 6px;
    font-family: 'DM Sans', sans-serif;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); opacity: 1; }

.btn-danger {
    background: var(--red-lt); color: var(--red); border: none;
    padding: 9px 18px; border-radius: var(--radius-sm);
    font-size: 13.5px; font-weight: 600; font-family: 'DM Sans', sans-serif;
    cursor: pointer; transition: .15s;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-full { width: 100%; justify-content: center; }
.btn-link { background: none; border: none; cursor: pointer; font-family: 'DM Sans', sans-serif; padding: 0; }

/* ── BADGES ─────────────────────────────────────────── */
.badge {
    padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 4px;
}
.badge-green  { background: var(--green-lt);  color: #2E7D32; }
.badge-amber  { background: var(--amber-lt);  color: #E65100; }
.badge-red    { background: var(--red-lt);    color: #C62828; }
.badge-blue   { background: var(--blue-lt);   color: #1565C0; }
.badge-gray   { background: var(--surface2);  color: var(--muted); }

/* ── FLASH ──────────────────────────────────────────── */
.flash-container, .flash-container-auth { margin-bottom: 18px; }
.flash {
    padding: 11px 16px; border-radius: var(--radius-sm);
    font-weight: 500; font-size: 13.5px; margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px;
}
.flash-success { background: var(--green-lt); color: #2E7D32; border: 1px solid #A5D6A7; }
.flash-error   { background: var(--red-lt);   color: #C62828; border: 1px solid #EF9A9A; }

/* ── EMPTY STATE ────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-icon  { font-size: 40px; margin-bottom: 10px; }
.empty-state p { margin-bottom: 14px; font-size: 14px; }

/* ── AUTH ───────────────────────────────────────────── */
.auth-layout {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    background: var(--bg); padding: 20px; position: relative; overflow: hidden;
}
.auth-layout::before {
    content: ''; position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(76,175,80,.08) 0%, transparent 70%);
    top: -100px; right: -100px; pointer-events: none;
}
.auth-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 36px; width: 100%;
    max-width: 400px; box-shadow: var(--shadow-lg); position: relative; z-index: 1;
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.logo-icon-big { font-size: 40px; display: block; margin-bottom: 10px; }
.auth-title    { font-size: 22px; font-weight: 700; letter-spacing: -.4px; }
.auth-subtitle { color: var(--muted); font-size: 13px; margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-link { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }

/* ── SETTINGS ───────────────────────────────────────── */
.tg-steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.tg-step  { display: flex; align-items: center; gap: 14px; font-size: 13.5px; }
.step-num {
    width: 28px; height: 28px; background: var(--primary);
    color: #fff; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.btn-telegram {
    display: inline-flex; align-items: center; gap: 8px;
    background: #0088cc; color: #fff; padding: 10px 22px;
    border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; transition: .15s;
}
.btn-telegram:hover { background: #0077b5; color: #fff; opacity: 1; }
.commands-list { display: flex; flex-direction: column; gap: 8px; }
.command-row {
    display: flex; align-items: center; gap: 14px;
    padding: 9px 12px; background: var(--surface2);
    border-radius: var(--radius-sm); font-size: 13px;
}
code {
    background: var(--border); padding: 2px 7px; border-radius: 4px;
    font-size: 12px; font-family: 'DM Mono', monospace;
    min-width: 70px; display: inline-block;
}

/* ── ANIMATIONS ─────────────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.stat-card, .section-card, .student-card, .form-card { animation: fadeUp .25s ease both; }
.stat-card:nth-child(1) { animation-delay: .03s; }
.stat-card:nth-child(2) { animation-delay: .06s; }
.stat-card:nth-child(3) { animation-delay: .09s; }
.stat-card:nth-child(4) { animation-delay: .12s; }

/* ── MOBILE ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        width: 100%; height: 60px;
        top: auto; bottom: 0; left: 0; right: 0;
        flex-direction: row;
        border-right: none; border-top: 1px solid var(--border);
        z-index: 200;
    }
    .sidebar-logo { display: none; }
    .sidebar-bottom { display: none; }
    .sidebar-nav {
        flex-direction: row; padding: 0; gap: 0; width: 100%;
        justify-content: space-around; align-items: center; height: 60px;
    }
    .nav-item {
        flex-direction: column; gap: 3px; padding: 6px 8px;
        font-size: 10px; border-radius: 8px; flex: 1;
        justify-content: center; align-items: center; min-width: 0;
    }
    .nav-item span:last-child { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60px; }
    .nav-icon { width: 20px; height: 20px; }
    .main-content { margin-left: 0; padding: 16px 14px 80px; max-width: 100vw; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
    .page-title { font-size: 18px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
    .stat-value { font-size: 22px; }
    div[style*="grid-template-columns:1.6fr 1fr"] { display: flex !important; flex-direction: column !important; gap: 12px !important; }
    .students-table { display: none; }
    .section-card { padding: 14px; margin-bottom: 12px; }
    .section-header { margin-bottom: 12px; }
    .lesson-row { flex-wrap: wrap; gap: 8px; padding: 10px 8px; }
    .lesson-date-block { min-width: 70px; }
    .students-grid { grid-template-columns: 1fr; }
    .form-card { padding: 16px; max-width: 100%; }
    .form-grid { grid-template-columns: 1fr; gap: 12px; }
    .detail-layout { grid-template-columns: 1fr; }
    .auth-card { padding: 24px 20px; margin: 16px; max-width: calc(100vw - 32px); }
    .page-header .btn-primary, .page-header .btn-secondary { width: 100%; justify-content: center; }
    div[style*="grid-template-columns:1fr 1fr"] { display: flex !important; flex-direction: column !important; }
    .flash-container-auth { margin: 10px 14px 0; }
}

@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr; }
    .nav-item span:last-child { display: none; }
    .nav-item { padding: 8px 4px; }
}
