*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
    --bg:#0d0d1a;--bg-card:#151530;--bg-card-hover:#1a1a3e;
    --text:#e8e8f0;--text-muted:#8888aa;--text-dim:#555570;
    --primary:#4fc3f7;--primary-dark:#0288d1;
    --accent:#7c4dff;--accent-dark:#5c2de0;
    --success:#66bb6a;--danger:#ef5350;--warning:#ffa726;
    --border:#252545;--radius:12px;--radius-sm:8px;
    --shadow:0 4px 24px rgba(0,0,0,0.4);
    --font:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,sans-serif;
}
html{font-size:16px;-webkit-tap-highlight-color:transparent}
body{font-family:var(--font);background:var(--bg);color:var(--text);min-height:100vh;min-height:100dvh;overflow-x:hidden}
.screen{display:none;flex-direction:column;min-height:100vh;min-height:100dvh}
.screen.active{display:flex}
input,select,button,textarea{font-family:inherit;font-size:inherit}

.login-container{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100vh;min-height:100dvh;padding:24px;text-align:center}
.login-logo{margin-bottom:20px;opacity:0.9}
.login-title{font-size:1.6rem;font-weight:700;color:var(--text);margin-bottom:4px}
.login-subtitle{font-size:0.9rem;color:var(--text-muted);margin-bottom:32px}
#login-form,#admin-login-form{width:100%;max-width:360px}
.input-group{margin-bottom:18px;text-align:left}
.input-group label{display:block;font-size:0.8rem;color:var(--text-muted);margin-bottom:6px;font-weight:500;text-transform:uppercase;letter-spacing:0.5px}
.input-group input,.search-input,.plan-select{width:100%;padding:12px 16px;background:var(--bg-card);border:1.5px solid var(--border);border-radius:var(--radius-sm);color:var(--text);font-size:1rem;transition:border-color 0.2s}
.input-group input:focus,.search-input:focus,.plan-select:focus{outline:none;border-color:var(--primary)}
.plan-select{cursor:pointer;appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z' fill='%238888aa'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;padding-right:32px}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:12px 24px;border:none;border-radius:var(--radius-sm);font-size:0.95rem;font-weight:600;cursor:pointer;transition:all 0.2s;text-decoration:none}
.btn-primary{background:linear-gradient(135deg,var(--primary),var(--accent));color:#fff}
.btn-primary:hover{opacity:0.9;transform:translateY(-1px)}
.btn-primary:active{transform:translateY(0)}
.btn-outline{background:transparent;border:1.5px solid var(--border);color:var(--text)}
.btn-outline:hover{border-color:var(--primary);color:var(--primary)}
.btn-danger{background:var(--danger);color:#fff}
.btn-danger:hover{opacity:0.9}
.btn-sm{padding:8px 16px;font-size:0.85rem}
.btn-full{width:100%}
.btn-icon{background:none;border:none;color:var(--text-muted);cursor:pointer;padding:8px;border-radius:50%;transition:all 0.2s;display:flex;align-items:center;justify-content:center;position:relative}
.btn-icon:hover{background:var(--bg-card);color:var(--text)}
.notif-badge{position:absolute;top:2px;right:2px;background:var(--danger);color:#fff;font-size:0.6rem;font-weight:700;min-width:16px;height:16px;border-radius:8px;display:flex;align-items:center;justify-content:center;padding:0 4px}
.notif-dropdown{width:320px;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);box-shadow:0 8px 32px rgba(0,0,0,0.5);z-index:1000;display:flex;flex-direction:column;overflow:visible}
.notif-dropdown-arrow{position:absolute;top:-6px;right:18px;width:12px;height:12px;background:var(--bg-card);border-top:1px solid var(--border);border-left:1px solid var(--border);transform:rotate(45deg);pointer-events:none}
.notif-dropdown-header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid var(--border)}
.notif-dropdown-title{font-size:0.85rem;font-weight:600;color:var(--text)}
.notif-dropdown-list{flex:1;overflow-y:auto;padding:8px;max-height:300px}
.notif-dropdown-footer{padding:10px 14px;border-top:1px solid var(--border);display:flex;justify-content:flex-end}
.notif-dropdown-empty{padding:24px 16px;color:var(--text-dim);font-size:0.85rem;text-align:center}
.btn-loader{display:inline-flex;align-items:center}
.spinner{width:18px;height:18px;border:2px solid rgba(255,255,255,0.3);border-top-color:#fff;border-radius:50%;animation:spin 0.6s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.hidden{display:none!important}
.error-msg{color:var(--danger);font-size:0.85rem;margin-top:12px;text-align:center}

.login-loader{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100vh;min-height:100dvh;gap:20px}
.login-loader-spinner{width:40px;height:40px;border:3px solid rgba(255,255,255,0.1);border-top-color:var(--primary);border-radius:50%;animation:spin 0.8s linear infinite}
.login-loader-text{color:var(--text-muted);font-size:0.9rem}

.app-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;background:var(--bg-card);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:10}
.header-left{display:flex;align-items:center;gap:8px}
.header-right{display:flex;align-items:center;gap:4px}
.header-title{font-size:1rem;font-weight:600;flex:1;text-align:center}
.header-title-small{font-size:0.95rem;font-weight:600}
.admin-header{background:linear-gradient(135deg,#151530,#1a1040)}

.connection-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}
.connection-dot.connected{background:var(--success);box-shadow:0 0 8px var(--success)}
.connection-dot.disconnected{background:var(--danger);box-shadow:0 0 8px var(--danger)}
.connection-text{font-size:0.8rem;color:var(--text-muted)}

.notification-banner{padding:12px 16px;background:var(--bg-card);border-bottom:1px solid var(--border)}
.notif-content{display:flex;align-items:center;gap:12px}
.notif-icon{flex-shrink:0}
.notif-icon.warn-icon{color:var(--warning)}
.notif-text{flex:1}
.notif-title{font-size:0.85rem;color:var(--text);margin-bottom:6px}
.notif-title.success-text{color:var(--success)}
.notif-sub{font-size:0.75rem;color:var(--text-muted)}

.dashboard-content{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px 16px}
.usage-gauge-container{text-align:center}
.gauge-wrapper{position:relative;width:220px;height:220px;margin:0 auto 12px}
.gauge-svg{width:100%;height:100%}
.gauge-progress{transition:stroke-dashoffset 1.5s cubic-bezier(0.4,0,0.2,1)}
.gauge-center{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);text-align:center}
.gauge-value{font-size:2.8rem;font-weight:700;color:var(--text);line-height:1}
.gauge-unit{font-size:0.9rem;color:var(--text-muted);margin-left:2px}
.gauge-value-sm{font-size:1.3rem;font-weight:600;color:var(--text-muted);display:block;margin-top:2px}
.gauge-unit-sm{font-size:0.7rem;color:var(--text-dim)}
.gauge-label{font-size:0.85rem;color:var(--text-muted);margin-top:8px}

.study-plan-card{display:flex;align-items:center;gap:12px;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);padding:14px 18px;margin-top:20px;width:100%;max-width:360px}
.plan-card-icon{color:var(--accent);flex-shrink:0}
.plan-card-label{font-size:0.7rem;color:var(--text-muted);text-transform:uppercase;letter-spacing:0.5px}
.plan-card-name{font-size:0.95rem;font-weight:600;color:var(--text);margin-top:2px}

.bottom-nav{display:flex;background:var(--bg-card);border-top:1px solid var(--border);position:sticky;bottom:0;z-index:10}
.nav-tab{flex:1;display:flex;flex-direction:column;align-items:center;gap:4px;padding:10px 0;background:none;border:none;color:var(--text-dim);cursor:pointer;transition:color 0.2s;font-size:0.7rem}
.nav-tab.active{color:var(--primary)}
.nav-tab:hover{color:var(--text-muted)}

.history-list{flex:1;padding:16px;overflow-y:auto}
.history-card{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px;display:flex;align-items:center;gap:16px}
@media(min-width:768px){.history-card{margin-bottom:0}}
.history-wheel{flex-shrink:0;width:64px;height:64px;position:relative}
.history-wheel svg{width:100%;height:100%}
.history-wheel .wheel-bg{fill:none;stroke:var(--border);stroke-width:6}
.history-wheel .wheel-progress{fill:none;stroke-width:6;stroke-linecap:round;transition:stroke-dashoffset 1s cubic-bezier(0.4,0,0.2,1)}
.history-wheel .wheel-text{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:0.75rem;font-weight:700;color:var(--text)}
.history-info{flex:1;min-width:0}
.history-scenario{font-size:0.9rem;font-weight:600;color:var(--text);margin-bottom:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.history-meta{font-size:0.75rem;color:var(--text-muted)}
.history-score{font-size:0.8rem;color:var(--text-muted);margin-top:4px}
.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:48px 16px;color:var(--text-muted);text-align:center}

.admin-content{flex:1;padding:16px;overflow-y:auto;padding-bottom:24px}
.connected-section{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:16px}
.section-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;flex-wrap:wrap;gap:8px}
.section-title{font-size:0.9rem;font-weight:600;display:flex;align-items:center;gap:8px}
.auto-refresh-label{font-size:0.7rem;color:var(--text-dim)}
.badge{background:var(--success);color:#fff;font-size:0.7rem;padding:2px 8px;border-radius:10px;font-weight:600}
.pulse-dot{width:8px;height:8px;border-radius:50%;background:var(--success);animation:pulse 2s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}

.connected-list{display:flex;flex-direction:column;gap:8px}
.connected-user{display:flex;align-items:center;gap:10px;padding:10px 12px;background:var(--bg);border-radius:var(--radius-sm);border:1px solid var(--border)}
.connected-user .user-dot{width:8px;height:8px;border-radius:50%;background:var(--success);box-shadow:0 0 6px var(--success);flex-shrink:0}
.connected-user .user-name{flex:1;font-size:0.85rem;font-weight:500}
.connected-user .user-time{font-size:0.8rem;color:var(--primary);font-weight:600}
.empty-text{font-size:0.85rem;color:var(--text-dim);text-align:center;padding:12px}

.students-section{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:16px}
.filter-bar{display:flex;gap:10px;margin-bottom:12px;align-items:center;flex-wrap:wrap}
.search-input{flex:1;min-width:0;padding:10px 14px;font-size:0.9rem}
.select-all-label{display:flex;align-items:center;gap:6px;font-size:0.8rem;color:var(--text-muted);cursor:pointer;white-space:nowrap}
.select-all-label input{accent-color:var(--primary);width:16px;height:16px}

.student-list{max-height:300px;overflow-y:auto;margin-bottom:12px}
.student-item{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:var(--radius-sm);transition:background 0.15s;border-bottom:1px solid var(--border)}
.student-item:last-child{border-bottom:none}
.student-item:hover{background:var(--bg-card-hover)}
.student-item.selected{background:rgba(79,195,247,0.08)}
.student-item input[type="checkbox"]{accent-color:var(--primary);width:16px;height:16px;flex-shrink:0}
.student-item-info{flex:1;min-width:0}
.student-item-name{font-size:0.85rem;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.student-item-id{font-size:0.7rem;color:var(--text-dim)}
.student-item-meta{display:flex;flex-direction:column;align-items:flex-end;gap:2px;flex-shrink:0}
.student-item-time{font-size:0.8rem;color:var(--primary);font-weight:600}
.student-item-plan{font-size:0.65rem;color:var(--accent);max-width:120px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.student-item .conn-dot{width:6px;height:6px;border-radius:50%;flex-shrink:0}
.student-item .conn-dot.on{background:var(--success);box-shadow:0 0 4px var(--success)}
.student-item .conn-dot.off{background:var(--text-dim)}

.action-bar{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.action-bar .plan-select{flex:1;min-width:140px;padding:8px 12px;font-size:0.85rem}

.plans-section{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);padding:16px}
.plans-list{display:flex;flex-direction:column;gap:8px}
.plan-item{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;background:var(--bg);border:1px solid var(--border);border-radius:var(--radius-sm);cursor:pointer;transition:all 0.15s}
.plan-item:hover{border-color:var(--accent);background:var(--bg-card-hover)}
.plan-item-info{flex:1;min-width:0}
.plan-item-name{font-size:0.85rem;font-weight:600;color:var(--text)}
.plan-item-meta{font-size:0.7rem;color:var(--text-muted);margin-top:2px}
.plan-item-arrow{color:var(--text-dim);flex-shrink:0}

.editor-content{flex:1;padding:16px;overflow-y:auto}
.milestones-title{font-size:0.85rem;font-weight:600;color:var(--text-muted);margin:16px 0 10px;text-transform:uppercase;letter-spacing:0.5px}
.milestones-container{display:flex;flex-direction:column;gap:10px}
.milestone-card{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-sm);padding:14px;position:relative}
.milestone-card .remove-milestone{position:absolute;top:8px;right:8px;background:none;border:none;color:var(--text-dim);cursor:pointer;padding:4px;border-radius:50%;transition:all 0.15s;display:flex}
.milestone-card .remove-milestone:hover{color:var(--danger);background:rgba(239,83,80,0.1)}
.milestone-row{display:flex;gap:8px;margin-bottom:8px;flex-wrap:wrap}
.milestone-row:last-child{margin-bottom:0}
.milestone-row .input-group{flex:1;min-width:120px;margin-bottom:0}
.milestone-row .input-group label{font-size:0.7rem;margin-bottom:4px}
.milestone-row .input-group input,.milestone-row .input-group select{padding:8px 12px;font-size:0.85rem;width:100%;background:var(--bg);border:1px solid var(--border);border-radius:6px;color:var(--text)}
.milestone-row .input-group select{appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z' fill='%238888aa'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 8px center;padding-right:28px}
.editor-actions{margin-top:24px;display:flex;flex-direction:column;gap:10px}

.toast{position:fixed;bottom:80px;left:50%;transform:translateX(-50%);background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-sm);padding:12px 20px;font-size:0.85rem;color:var(--text);box-shadow:var(--shadow);z-index:100;animation:toastIn 0.3s ease,toastOut 0.3s ease 2.7s forwards;max-width:90vw;text-align:center}
.toast.success{border-color:var(--success)}
.toast.error{border-color:var(--danger)}
@keyframes toastIn{from{opacity:0;transform:translate(-50%,20px)}to{opacity:1;transform:translate(-50%,0)}}
@keyframes toastOut{from{opacity:1}to{opacity:0}}

.notif-item{display:flex;align-items:flex-start;gap:10px;padding:10px;border-radius:var(--radius-sm);margin-bottom:4px;background:var(--bg)}
.notif-item-icon{flex-shrink:0;width:26px;height:26px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:0.7rem;font-weight:700;color:#fff}
.notif-item-success{background:var(--success)}
.notif-item-error{background:var(--danger)}
.notif-item-text{flex:1;min-width:0}
.notif-item-msg{font-size:0.8rem;color:var(--text);margin-bottom:2px;line-height:1.3}
.notif-item-date{font-size:0.65rem;color:var(--text-dim)}

@media(min-width:768px){
    .login-container{padding:40px}
    .dashboard-content{padding:40px 24px}
    .gauge-wrapper{width:280px;height:280px}
    .gauge-value{font-size:3.6rem}
    .admin-content{max-width:800px;margin:0 auto}
    .student-list{max-height:400px}
    .history-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:12px;max-width:1100px;margin:0 auto;padding:24px}
    .filter-bar{flex-wrap:nowrap}
}
@media(min-width:1200px){
    .history-list{grid-template-columns:repeat(auto-fill,minmax(340px,1fr));max-width:1300px}
}
