:root{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC",sans-serif;color:#172033;background:#f4f6f8;--blue:#1769aa;--navy:#16263a;--line:#dce3ea;--muted:#667085;--green:#198754;--red:#c0392b}*{box-sizing:border-box}body{margin:0}.app-shell{display:grid;grid-template-columns:238px 1fr;min-height:100vh}.sidebar{position:sticky;top:0;height:100vh;background:var(--navy);color:#fff;padding:24px 16px;display:flex;flex-direction:column}.brand{display:flex;align-items:center;gap:12px;padding:0 8px 24px}.brand>span{display:grid;place-items:center;width:42px;height:42px;border-radius:12px;background:#fff;color:var(--blue);font-weight:800}.brand strong,.brand small{display:block}.brand small{margin-top:3px;color:#aebdca}.sidebar nav{display:grid;gap:5px}.nav-item{border:0;background:transparent;color:#c7d2dc;text-align:left;padding:12px 14px;border-radius:9px;font-size:15px;cursor:pointer}.nav-item:hover,.nav-item.active{background:#24415f;color:#fff}.sidebar-footer{margin-top:auto;padding:12px;color:#aebdca;font-size:13px;display:flex;align-items:center;gap:8px}.status-dot{width:9px;height:9px;border-radius:50%;background:#9aa4af}.status-dot.ok{background:#37c878}main{min-width:0}.topbar{height:96px;background:#fff;border-bottom:1px solid var(--line);padding:20px 32px;display:flex;align-items:center;justify-content:space-between}.topbar h1{margin:0 0 6px;font-size:24px}.topbar p{margin:0;color:var(--muted)}.identity-switch{display:flex;align-items:center;gap:10px;color:var(--muted);font-size:13px}.identity-switch select,select,input,textarea{border:1px solid #cbd5df;border-radius:8px;background:#fff;padding:10px 12px;color:#172033}.content{padding:28px 32px}.notice{margin:18px 32px 0;padding:12px 14px;border-radius:8px;background:#fff3cd;color:#705b00}.notice.error{background:#fdecea;color:#a5281b}.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px}.card{background:#fff;border:1px solid var(--line);border-radius:12px;padding:20px;box-shadow:0 2px 8px rgba(23,32,51,.04)}.card h2,.card h3{margin-top:0}.metric strong{display:block;font-size:30px;margin-top:10px}.muted{color:var(--muted)}.toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:18px}.button,button{border:0;border-radius:8px;padding:10px 15px;cursor:pointer;font-weight:600}.primary{background:var(--blue);color:#fff}.secondary{background:#e9f1f8;color:#174d77}.danger{background:#fdecea;color:var(--red)}button:disabled{opacity:.45;cursor:not-allowed}.table-wrap{overflow:auto;background:#fff;border:1px solid var(--line);border-radius:12px}table{border-collapse:collapse;width:100%}th,td{padding:12px 14px;border-bottom:1px solid #edf0f3;text-align:left;white-space:nowrap}th{background:#f8fafb;color:#475467;font-size:13px}.student-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.student-button{border:1px solid #cfd8e2;background:#fff;color:#172033;text-align:left}.student-button.selected{background:#fff1e8;border-color:#df8d4b}.status-buttons{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}.status-button.active{outline:3px solid #31455a}.score{float:right;font-weight:800}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.form-grid label{display:grid;gap:6px;color:#475467;font-size:13px}.full{grid-column:1/-1}.empty,.loading{text-align:center;color:var(--muted);padding:60px}.badge{display:inline-block;border-radius:999px;background:#e9f1f8;color:#174d77;padding:3px 9px;font-size:12px}.badge.good{background:#e8f6ee;color:#176c43}.badge.off{background:#edf0f3;color:#667085}@media(max-width:900px){.app-shell{grid-template-columns:minmax(0,1fr);width:100%}.sidebar{position:static;height:auto;min-width:0}.sidebar nav{display:flex;max-width:100vw;overflow:auto}.sidebar-footer{display:none}.topbar{min-width:0;padding:16px 20px}.content{min-width:0;padding:20px}.grid{grid-template-columns:1fr}.student-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.identity-switch{min-width:0}.identity-switch label{display:none}}
.account-actions{display:flex;align-items:center;gap:12px;color:var(--muted);font-size:14px}.account-actions[hidden]{display:none}.login-wrap{min-height:calc(100vh - 152px);display:grid;place-items:center}.login-card{width:min(420px,100%);display:grid;gap:16px}.login-card label{display:grid;gap:7px;color:#475467;font-size:14px}.login-card input{width:100%}.account-card{max-width:620px}@media(max-width:900px){.account-actions span{display:none}}
.button-link{display:inline-flex;align-items:center;justify-content:center;text-decoration:none;border-radius:8px;padding:9px 14px;font-weight:600}.button-link.primary{color:#fff;background:#1769aa}.button-link.secondary{color:#344054;background:#fff;border:1px solid #d0d5dd}details pre{max-width:520px;max-height:260px;overflow:auto;white-space:pre-wrap;word-break:break-all;background:#f8fafc;padding:10px;border-radius:6px;font-size:12px}

/* Login follows the compact, calm visual language already used by the mini program. */
body.login-mode{background:#f5f6f8}
body.login-mode .app-shell{display:block;min-height:100svh}
body.login-mode .sidebar,body.login-mode .topbar{display:none}
body.login-mode main{min-height:100svh}
body.login-mode .content{padding:24px;min-height:100svh}
body.login-mode .notice{position:fixed;z-index:20;top:18px;left:50%;width:min(440px,calc(100% - 32px));margin:0;transform:translateX(-50%)}
.login-wrap{min-height:calc(100svh - 48px);display:grid;place-items:center}
.login-card{width:min(420px,100%);display:grid;gap:18px;padding:30px;border-radius:16px;box-shadow:0 12px 36px rgba(22,38,58,.09)}
.login-card h2{margin:4px 0 0;font-size:26px}
.login-card p{margin:0;line-height:1.65}
.login-brand{display:flex;align-items:center;gap:13px}
.login-brand>span{display:grid;place-items:center;width:50px;height:50px;border-radius:14px;background:#1769aa;color:#fff;font-size:19px;font-weight:800}
.login-brand strong,.login-brand small{display:block}
.login-brand strong{font-size:19px}
.login-brand small{margin-top:3px;color:#667085}
.login-tabs{display:grid;grid-template-columns:1fr 1fr;gap:4px;padding:4px;border-radius:10px;background:#edf2f7}
.login-tab{min-height:40px;border-radius:7px;background:transparent;color:#667085;font-size:15px}
.login-tab.active{background:#fff;color:#1769aa;box-shadow:0 1px 4px rgba(16,24,40,.1)}
#teacher-login-fields,#student-login-fields{display:grid;gap:18px}
#teacher-login-fields[hidden],#student-login-fields[hidden]{display:none}
.login-card select{width:100%;min-height:46px;font-size:16px}
.login-card label{display:grid;gap:8px;color:#475467;font-size:14px;font-weight:600}
.login-card input{width:100%;min-height:46px;font-size:16px}
.login-help{display:grid;gap:4px;padding:11px 13px;border-radius:9px;background:#f2f7fb;color:#475467;font-size:13px}
.login-help p{line-height:1.5}
.login-help strong{color:#174d77}
.login-submit{width:100%;min-height:48px;font-size:16px;margin-top:2px}
.task-options{display:flex;flex-wrap:wrap;gap:8px 16px;min-width:360px}
.task-options label{display:flex;align-items:center;gap:6px;white-space:nowrap}
.task-options input{width:18px;height:18px}
.switch-label{display:inline-flex;align-items:center;gap:7px;white-space:nowrap}.switch-label input{width:18px;height:18px}.duty-students{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:14px 0;padding:12px;border:1px solid var(--line);border-radius:9px}.duty-students label,.duty-weekdays label{display:flex;align-items:center;gap:6px}.duty-students input,.duty-weekdays input{width:17px;height:17px}.duty-weekdays{display:flex;gap:12px;flex-wrap:wrap;margin:0}.duty-table{margin-top:18px}.duty-actions{display:flex;align-items:center;gap:7px;flex-wrap:wrap}.duty-actions select,.duty-actions input{max-width:160px;padding:8px}.rotation-result{display:grid;gap:6px;max-height:180px;overflow:auto}.duty-note{margin:12px 2px}
.compact-roster-card{padding:16px 20px}
.compact-roster-card h2{margin-bottom:12px}
.roster-form{display:grid;grid-template-columns:68px minmax(120px,1fr) 92px minmax(120px,1fr) minmax(110px,1fr) 106px minmax(100px,1fr) minmax(100px,1fr) auto;gap:10px;align-items:end}
.roster-form label{display:grid;gap:5px;color:#475467;font-size:13px}
.roster-seat,.roster-seat input{width:56px}
.roster-actions{margin:0;flex-wrap:nowrap}
.roster-batch-card{margin-top:14px;padding:14px 20px}
.roster-batch-heading{display:flex;align-items:center;gap:12px;margin-bottom:10px}
.roster-batch-heading h2{margin:0;font-size:18px}
.roster-batch-form{display:grid;grid-template-columns:92px minmax(120px,1fr) 110px minmax(110px,1fr) minmax(110px,1fr) auto;gap:10px;align-items:end}
.roster-batch-form label{display:grid;gap:5px;color:#475467;font-size:13px}
.roster-batch-form button{white-space:nowrap}
.roster-table-wrap{margin-top:14px}
.roster-table .selection-column{width:44px;text-align:center;padding-inline:8px}
.roster-table input[type="checkbox"]{width:18px;height:18px}
.sort-button{position:relative;padding:0 16px 0 0;border-radius:0;background:transparent;color:inherit;font-size:inherit}
.sort-button::after{content:'↕';position:absolute;right:0;color:#98a2b3}
.sort-button[data-direction="asc"]::after{content:'↑';color:var(--blue)}
.sort-button[data-direction="desc"]::after{content:'↓';color:var(--blue)}
.roster-row-actions{margin:0;flex-wrap:nowrap}
.compact-interval-card{padding:16px 20px}
.compact-interval-card h2{margin-bottom:12px}
.interval-form{display:grid;grid-template-columns:minmax(160px,1.25fr) 100px minmax(190px,1fr) minmax(190px,1fr) auto;gap:12px;align-items:end}
.interval-form label{display:grid;min-width:0;gap:5px;color:#475467;font-size:13px}
.interval-form select,.interval-form input{width:100%;min-width:0}
.interval-actions{align-self:end}
.interval-actions button{white-space:nowrap}

/* Table headings use one consistent alignment across teacher and student views. */
th{text-align:center}

/* Students use a phone-first shell; teacher and committee desktop views stay unchanged. */
@media(max-width:900px){
  .duty-students{grid-template-columns:repeat(2,minmax(0,1fr))}.duty-actions{min-width:250px}
  body.student-mobile{background:#f5f6f8}
  body.student-mobile .app-shell{display:block;min-height:100svh}
  body.student-mobile .sidebar{position:fixed;z-index:1000;inset:auto 0 0;height:auto;padding:0;background:#fff;border-top:1px solid #e5e7eb;box-shadow:0 -2px 10px rgba(16,24,40,.07)}
  body.student-mobile .brand,body.student-mobile .sidebar-footer{display:none}
  body.student-mobile .sidebar nav{display:flex;min-height:74px;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none;padding-bottom:max(6px,env(safe-area-inset-bottom))}
  body.student-mobile .sidebar nav::-webkit-scrollbar{display:none}
  body.student-mobile .nav-item{flex:1 0 25%;min-width:78px;padding:16px 5px 14px;border-radius:0;text-align:center;color:#667085;background:#fff;font-size:13px;line-height:1.25;white-space:nowrap}
  body.student-mobile .nav-item:hover,body.student-mobile .nav-item.active{background:#fff;color:#1769aa;box-shadow:inset 0 3px #1769aa}
  body.student-mobile main{padding-bottom:calc(82px + env(safe-area-inset-bottom))}
  body.student-mobile .topbar{position:sticky;z-index:500;top:0;height:auto;min-height:74px;padding:13px 16px;background:rgba(255,255,255,.96);backdrop-filter:blur(8px)}
  body.student-mobile .topbar h1{margin-bottom:4px;font-size:20px}
  body.student-mobile .topbar p{font-size:13px}
  body.student-mobile .account-actions{gap:7px}
  body.student-mobile .account-actions span{display:none}
  body.student-mobile .account-actions button{padding:8px 10px;font-size:12px}
  body.student-mobile .notice{margin:12px 16px 0;padding:11px 12px;font-size:14px}
  body.student-mobile .content{padding:16px}
  body.student-mobile .grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
  body.student-mobile .grid>.metric:nth-child(3){grid-column:1/-1}
  body.student-mobile .card{padding:17px;border-radius:10px;box-shadow:none}
  body.student-mobile .metric strong{font-size:26px;margin-top:8px}
  body.student-mobile .toolbar{gap:8px;margin-bottom:14px}
  body.student-mobile .toolbar>button{flex:1;min-width:88px}
  body.student-mobile .form-grid{grid-template-columns:1fr}
  body.student-mobile .full{grid-column:1}
  body.student-mobile .account-card{max-width:none}
  body.student-mobile .account-card button{width:100%;min-height:46px}
  body.student-mobile .table-wrap{border-radius:10px}
  body.student-mobile th,body.student-mobile td{padding:11px 12px}
  body.student-mobile .empty,body.student-mobile .loading{padding:42px 16px}
}

@media(max-width:1400px) and (min-width:1101px){
  .roster-form{grid-template-columns:68px repeat(4,minmax(120px,1fr))}
  .roster-actions{grid-column:4/6}
  .roster-actions button{min-width:96px}
}

@media(max-width:1100px) and (min-width:901px){
  .roster-form{grid-template-columns:72px repeat(3,minmax(130px,1fr))}
  .roster-actions{grid-column:1/-1}
  .roster-batch-form{grid-template-columns:repeat(3,minmax(0,1fr))}
}

/* Compact duty workspace: keep related inputs on one line and feedback near actions. */
.topbar{height:68px;padding:10px 24px}
.topbar h1{margin:0;font-size:22px}
.content{padding-top:20px}
.duty-tab-card{padding:0;overflow:hidden}
.duty-tabs{display:flex;gap:4px;padding:6px 8px 0;border-bottom:1px solid var(--line);background:#f8fafb}
.duty-tab{min-width:132px;border-radius:8px 8px 0 0;background:transparent;color:#667085;font-size:16px}
.duty-tab.active{background:#fff;color:var(--blue);box-shadow:inset 0 -3px var(--blue)}
.duty-tab-panel{padding:16px 20px 18px}
.duty-tab-panel[hidden]{display:none}
.duty-manual-row{display:flex;align-items:center;gap:14px;flex-wrap:nowrap}
.duty-date-row{display:flex!important;align-items:center;gap:10px!important;color:#475467}
.duty-date-row span{white-space:nowrap;font-weight:600}
.duty-date-row input,.rotation-fields-row input[type="date"]{width:168px;min-width:168px}
.duty-selection-tools{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:14px}
.duty-selection-tools button{padding:8px 11px}
.duty-filter-option{display:inline-flex;align-items:center;gap:5px;min-height:36px;padding:7px 10px;border-radius:8px;background:#f2f6fa;color:#174d77;font-weight:600;white-space:nowrap}
.duty-filter-option input{width:17px;height:17px;margin:0}
.duty-students{grid-template-columns:repeat(auto-fit,minmax(138px,1fr));max-height:none;overflow:visible;margin:12px 0}
.duty-submit-row{margin-bottom:0}
.duty-rotation-note{margin:0 0 12px}
.rotation-fields-row{display:flex;align-items:flex-end;gap:12px;flex-wrap:wrap}
.rotation-fields-row>label,.skip-date-field{display:grid;gap:5px;color:#475467;font-size:13px}
.rotation-fields-row .compact-number{width:82px}
.skip-date-picker{display:flex;align-items:center;gap:8px}
.skip-date-picker input[type="date"]{width:168px;min-width:168px}
.skip-date-picker #rotation-skips{width:250px;background:#f8fafb}
.rotation-options-row{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-top:14px;flex-wrap:wrap}
.inline-feedback{margin-top:8px;color:#a5281b;font-size:13px;line-height:1.45}
.inline-feedback.success{color:#176c43}
.inline-feedback[hidden]{display:none}
.duty-actions+.inline-feedback{max-width:420px;white-space:normal}

@media(max-width:900px){
  .topbar{height:60px;padding:10px 16px}
  .duty-manual-row{align-items:flex-start;flex-wrap:wrap}
  .duty-selection-tools{align-items:stretch}
  .rotation-fields-row{align-items:stretch}
  .skip-date-picker{flex-wrap:wrap}
}

@media(max-width:900px){
  .roster-form{grid-template-columns:repeat(2,minmax(0,1fr))}
  .roster-actions{grid-column:1/-1}
  .roster-batch-form{grid-template-columns:repeat(2,minmax(0,1fr))}
  .roster-batch-form button{min-height:42px}
  .interval-form{grid-template-columns:repeat(6,minmax(0,1fr));gap:10px}
  .interval-student{grid-area:1/1/2/4}
  .interval-kind{grid-area:1/4/2/6}
  .interval-actions{grid-area:1/6/2/7}
  .interval-start{grid-area:2/1/3/4}
  .interval-end{grid-area:2/4/3/7}
  .interval-actions button{width:100%;padding-inline:8px}
  .interval-form input[type="datetime-local"]{padding-inline:8px;font-size:12px}
}

@media(max-width:520px){
  body.login-mode .content{padding:18px}
  .login-wrap{min-height:calc(100svh - 36px)}
  .login-card{padding:24px 20px;border:0;border-radius:12px;box-shadow:none}
  .login-card h2{font-size:24px}
  body.student-mobile .grid{grid-template-columns:1fr}
  body.student-mobile .grid>.metric:nth-child(3){grid-column:1}
}

.attendance-submit-row{margin-top:20px;margin-bottom:0}
.attendance-report-card{margin-top:18px}
.report-heading{display:flex;align-items:center;gap:12px}
.report-heading-line{overflow-x:auto;white-space:nowrap;margin-bottom:14px}
.report-heading-line .badge{margin-left:auto}
.report-heading h2{margin:0}
.report-heading p{margin:0}
.report-students{white-space:normal;line-height:1.7}
.unmarked-row{background:#fff8e6;color:#8a5a00}
.report-all-normal{padding:14px;border-radius:9px;background:#e8f6ee;color:#176c43}
.wechat-notice{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:10px;margin-top:16px}
.wechat-notice label{display:grid;gap:6px;color:#475467;font-size:13px}
.wechat-notice textarea{width:100%;resize:vertical;line-height:1.65;background:#f8fafb}
.wechat-notice .inline-feedback{grid-column:1/-1;margin-top:0}
.attendance-history-card{padding:14px}
.attendance-history-filter{display:flex;align-items:center;gap:14px;overflow-x:auto;white-space:nowrap}
.attendance-history-filter label{display:flex;align-items:center;gap:7px;color:#475467;font-size:13px;white-space:nowrap}
.attendance-history-filter input{width:158px;padding:8px 10px}
.attendance-history-filter button{padding:9px 14px;white-space:nowrap}
#attendance-history-result{margin-top:12px}
.attendance-history-table th,.attendance-history-table td{padding:8px 11px}
.history-row-actions{display:flex;align-items:center;gap:6px}
.history-row-actions button{padding:7px 10px;white-space:nowrap}
.history-pagination{display:flex;align-items:center;justify-content:flex-end;gap:10px;min-height:34px;margin-top:10px;color:#667085;font-size:13px}
.history-pagination button{padding:6px 10px}
#attendance-report-detail{scroll-margin-top:80px}

@media(max-width:700px){
  .wechat-notice{grid-template-columns:1fr}
  .wechat-notice .inline-feedback{grid-column:1}
}
