:root {
    --bg: #f4f7f6;
    --panel: #ffffff;
    --ink: #1f2933;
    --muted: #6b7280;
    --line: #d8e0df;
    --primary: #176b63;
    --primary-dark: #0f4f49;
    --primary-soft: #e8f4f1;
    --info: #1d4ed8;
    --info-soft: #e8f0ff;
    --warning: #b7791f;
    --warning-soft: #fff7e6;
    --sap-blue: #0a6ed1;
    --sap-blue-dark: #083c8c;
    --sap-navy: #00144a;
    --accent: #c48827;
    --danger: #b42318;
    --danger-soft: #fff0ef;
    --success: #18794e;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}
a { color: inherit; text-decoration: none; }
.zh { display: block; font-weight: 700; }
.en { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 500; margin-top: 2px; }
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: #123b37; color: #fff; padding: 20px 16px; }
.brand { font-size: 1.28rem; line-height: 1.25; margin-bottom: 22px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 8px; margin-bottom: 4px; color: #edf7f5; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,0.12); }
.nav-icon {
    display: inline-grid;
    flex: 0 0 28px;
    place-items: center;
    width: 28px;
    height: 28px;
}
.nav-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.nav-label {
    display: grid;
    gap: 2px;
    line-height: 1.18;
}
.nav-label .zh {
    color: #fff;
    font-size: .98rem;
    font-weight: 800;
}
.nav-label .en {
    color: rgba(237, 247, 245, .72);
    font-size: .72rem;
    font-weight: 600;
    margin-top: 0;
}
.main { padding: 24px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 1.55rem; }
.userbox { text-align: right; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 18px; }
.collapsible-panel {
    padding: 0;
    overflow: hidden;
}
.panel-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 18px;
    cursor: pointer;
    list-style: none;
}
.panel-summary::-webkit-details-marker {
    display: none;
}
.panel-summary h2 {
    margin: 0;
}
.panel-summary-toggle {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fbfa;
    transition: transform .18s ease;
}
.panel-summary-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.collapsible-panel[open] .panel-summary-toggle {
    transform: rotate(180deg);
}
.panel-body {
    padding: 0 18px 18px;
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { border-left: 4px solid var(--primary); }
.stat strong { display: block; font-size: 2rem; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.btn, button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    font-weight: 650;
    transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.btn:hover, button:hover { border-color: #b9c7c5; box-shadow: 0 1px 4px rgba(31, 41, 51, .08); }
.btn:active, button:active { transform: translateY(1px); }
.btn.primary, button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover, button.primary:hover { background: var(--primary-dark); }
.btn.danger, button.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger:hover, button.danger:hover { background: #8f1c13; border-color: #8f1c13; }
.btn.ghost, button.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover, button.ghost:hover { background: #f8fbfa; }
.btn.reset, button.reset { color: var(--warning); border-color: #f1d69b; background: var(--warning-soft); }
.btn.reset:hover, button.reset:hover { background: #ffefc2; border-color: #d8a94e; }
.btn.cancel, button.cancel { color: #475569; border-color: #d8e0df; background: #f8fafc; }
.btn.cancel:hover, button.cancel:hover { background: #edf2f7; }
.btn.edit, button.edit { color: var(--info); border-color: #bfcef8; background: var(--info-soft); }
.btn.edit:hover, button.edit:hover { background: #dbe7ff; border-color: #9bb7f4; }
.btn svg, button svg {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-btn {
    justify-content: center;
    width: 42px;
    min-width: 42px;
    padding: 9px;
}
.icon-btn svg {
    width: 20px;
    height: 20px;
}
.table-wrap {
    overflow: auto;
    max-height: 68vh;
    border: 1px solid var(--line);
    border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eef5f3;
    box-shadow: 0 1px 0 var(--line);
    font-size: .88rem;
}
tbody tr:nth-child(even) td { background: #f8fbfa; }
tbody tr:hover td { background: #eef7f5; }
tr:last-child td { border-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: grid; gap: 6px; font-weight: 650; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
    font: inherit;
    background: #fff;
}
input[readonly],
select[data-auto-derived="1"] {
    color: #4b5563;
    background: #f8fbfa;
}
textarea { min-height: 84px; resize: vertical; }
.alert { padding: 11px 12px; border-radius: 8px; margin-bottom: 14px; }
.alert.success { color: var(--success); background: #eaf7ef; border: 1px solid #bfe7cb; }
.alert.danger { color: var(--danger); background: #fff0ef; border: 1px solid #f2b8b5; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #eef5f3; font-size: .78rem; }
.student-master-form {
    display: grid;
    gap: 16px;
}
.record-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
}
.record-tab {
    display: grid;
    gap: 2px;
    justify-items: start;
    min-height: 44px;
    padding: 10px 14px;
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    line-height: 1.15;
}
.record-tab .en {
    margin-top: 0;
}
.record-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: #eef7f5;
}
.tab-pane {
    display: none;
}
.tab-pane.active {
    display: grid;
    gap: 16px;
}
.section-head {
    padding: 10px 12px;
    border-left: 4px solid var(--primary);
    background: #f8fbfa;
    font-weight: 800;
}
.student-photo-row {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 16px;
    align-items: end;
}
.photo-preview {
    display: grid;
    place-items: center;
    width: 120px;
    aspect-ratio: 1;
    overflow: hidden;
    color: var(--muted);
    background: #eef5f3;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.student-form-actions {
    justify-content: flex-start;
    margin-bottom: 0;
}
.list-filter-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 14px;
}
.teacher-filter-bar {
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
}
.announcement-filter-bar {
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(260px, 1.35fr);
    align-items: end;
}
.announcement-filter-bar .filter-actions {
    grid-column: auto;
    justify-content: flex-start;
    padding-top: 2px;
}
.class-filter-bar,
.user-filter-bar {
    grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
}
.report-filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
}
.filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.landing-body {
    min-height: 100vh;
    background: #f5f7fa;
}
.landing-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 72px;
    padding: 0 48px;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid #d9e2ec;
    box-shadow: 0 1px 8px rgba(13, 35, 67, .08);
}
.landing-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
}
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 68px;
    height: 34px;
    color: #fff;
    background: linear-gradient(135deg, var(--sap-blue), var(--sap-navy));
    border-radius: 0 14px 14px 0;
    font-size: 1.05rem;
}
.landing-nav {
    display: flex;
    align-items: center;
    gap: 18px;
    color: #2f3f54;
    font-weight: 650;
}
.landing-nav a:not(.btn):hover { color: var(--sap-blue); }
.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
    gap: 32px;
    align-items: center;
    min-height: calc(100vh - 72px);
    padding: 58px 48px 72px;
    color: #fff;
    background:
        linear-gradient(115deg, rgba(0, 20, 74, .96), rgba(10, 110, 209, .86)),
        radial-gradient(circle at 78% 20%, rgba(255, 255, 255, .24), transparent 28%),
        #0a3276;
}
.hero-copy {
    max-width: 780px;
}
.eyebrow {
    margin: 0 0 14px;
    color: #7dd3fc;
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
}
.hero-copy h1 {
    margin: 0;
    font-size: clamp(2.4rem, 6vw, 5.4rem);
    line-height: .98;
}
.hero-copy h1 .en {
    color: #dbeafe;
    font-size: clamp(1.1rem, 2vw, 1.7rem);
    margin-top: 14px;
}
.hero-text {
    max-width: 620px;
    margin: 24px 0 0;
    color: #eef6ff;
    font-size: 1.12rem;
    line-height: 1.7;
}
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 32px;
}
.btn.light {
    border-color: rgba(255, 255, 255, .75);
    color: #fff;
}
.announcement-panel {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 380px;
    padding: 28px;
    color: var(--ink);
    background: #fff;
    border-top: 5px solid #19a0ff;
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(0, 20, 74, .28);
}
.announcement-panel .eyebrow { color: var(--sap-blue); }
.announcement-panel h2 {
    margin: 0 0 12px;
    font-size: 1.8rem;
}
.announcement-panel h2 .zh,
.feed-card h2 .zh {
    display: block;
    font-weight: 800;
    line-height: 1.25;
}
.announcement-panel h2 .en,
.feed-card h2 .en {
    display: block;
    margin-top: 5px;
    color: #6b7280;
    font-size: .68em;
    font-weight: 650;
    line-height: 1.3;
}
.announcement-panel p {
    margin: 0;
    color: #4b5563;
    line-height: 1.65;
}
.announcement-date {
    display: inline-block;
    margin-top: 28px;
    color: #6b7280;
    font-size: .88rem;
    font-weight: 700;
}
.quick-band {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    background: #cbd5e1;
}
.quick-band article {
    min-height: 230px;
    padding: 34px;
    background: #fff;
}
.quick-band span {
    color: var(--sap-blue);
    font-size: .84rem;
    font-weight: 900;
}
.quick-band h2 {
    margin: 18px 0 10px;
    font-size: 1.45rem;
}
.quick-band p {
    margin: 0;
    color: #536274;
    line-height: 1.65;
}
.feed-section {
    display: grid;
    gap: 24px;
    padding: 42px 48px 64px;
    background: #eef2f7;
}
.feed-title {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
}
.feed-title .eyebrow { color: var(--sap-blue); }
.feed-title h2 {
    margin: 0;
    font-size: 2rem;
}
.feed-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 680px);
    justify-content: center;
    gap: 24px;
    align-items: start;
}
.feed-filter {
    position: sticky;
    top: 92px;
    display: grid;
    gap: 10px;
    padding: 18px;
    background: #fff;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
}
.feed-filter a {
    padding: 8px 10px;
    border-radius: 6px;
    color: #2f3f54;
    font-weight: 700;
}
.feed-filter a:hover { background: #edf5ff; color: var(--sap-blue); }
.feed-list {
    display: grid;
    gap: 16px;
}
.feed-list h3 {
    margin: 8px 0 0;
    color: #536274;
    font-size: .95rem;
}
.feed-card {
    overflow: hidden;
    background: #fff;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(13, 35, 67, .08);
}
.feed-card > *:not(.feed-media) {
    margin-left: 18px;
    margin-right: 18px;
}
.feed-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 18px;
}
.feed-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #fff;
    background: linear-gradient(135deg, var(--sap-blue), var(--sap-navy));
    border-radius: 50%;
    font-size: .78rem;
    font-weight: 900;
}
.feed-card h2 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: 1.3rem;
}
.feed-card p {
    color: #2f3f54;
    line-height: 1.65;
}
.feed-media {
    display: block;
    width: 100%;
    max-height: 560px;
    object-fit: cover;
    background: #d9e2ec;
}
video.feed-media { object-fit: contain; }
.link-preview {
    display: grid;
    gap: 4px;
    margin-top: 16px;
    margin-bottom: 18px;
    padding: 12px 14px;
    background: #f5f7fa;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
}
.link-preview span {
    color: var(--sap-blue);
    font-size: .75rem;
    font-weight: 900;
    text-transform: uppercase;
}
.link-preview strong {
    overflow-wrap: anywhere;
    color: #243b53;
}
.current-media {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 12px;
    background: #f5f7fa;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.actions-cell {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    white-space: nowrap;
    vertical-align: middle;
}
.actions-cell form {
    display: inline-flex;
    margin: 0;
}
.actions-cell .icon-btn {
    flex: 0 0 42px;
    height: 42px;
    min-height: 42px;
    margin: 0;
    padding: 0;
}
.announcement-table {
    table-layout: fixed;
    min-width: 760px;
}
.announcement-table th:nth-child(1),
.announcement-table td.date-cell {
    width: 122px;
}
.announcement-table th:nth-child(3),
.announcement-table td.media-cell {
    width: 94px;
}
.announcement-table th:nth-child(4),
.announcement-table td.status-cell {
    width: 102px;
}
.announcement-table th:nth-child(5),
.announcement-table td.actions-cell {
    width: 112px;
}
.announcement-title-cell {
    min-width: 0;
}
.announcement-title-cell strong,
.announcement-title-cell .muted {
    display: block;
    overflow-wrap: anywhere;
}
.announcement-excerpt {
    line-height: 1.45;
    margin-top: 4px;
}
.announcement-table td.actions-cell {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}
.announcement-table td.actions-cell > .icon-btn,
.announcement-table td.actions-cell > form {
    vertical-align: middle;
}
.announcement-table td.actions-cell > form {
    margin-left: 8px;
}
.login-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: none;
    place-items: center;
    padding: 20px;
}
.login-modal:target,
.login-modal-open .login-modal {
    display: grid;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 20, 74, .62);
}
.modal-card {
    position: relative;
    z-index: 1;
    width: min(430px, calc(100vw - 32px));
}
.modal-card h2 {
    margin: 0 34px 12px 0;
    font-size: 1.65rem;
}
.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #52606d;
    font-size: 1.55rem;
    line-height: 1;
}
.modal-close:hover { background: #eef2f7; }
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
    background: linear-gradient(140deg, #e7f0ee, #f8f4ec);
}
.login-card {
    width: min(430px, 100%);
    max-width: 100%;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(20, 45, 42, .12);
}
.login-card h1 { margin-top: 0; }
.login-card form { display: grid; gap: 14px; }
@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .grid.cols-2, .grid.cols-3, .form-grid { grid-template-columns: 1fr; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .userbox { text-align: left; }
    .landing-header {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px 20px;
    }
    .landing-nav {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
        overflow-x: auto;
        padding-bottom: 4px;
    }
    .landing-hero {
        grid-template-columns: 1fr;
        min-height: auto;
        padding: 44px 20px 52px;
    }
    .announcement-panel {
        min-height: 260px;
    }
    .quick-band {
        grid-template-columns: 1fr;
    }
    .feed-section {
        padding: 32px 20px 48px;
    }
    .feed-layout {
        grid-template-columns: 1fr;
    }
    .feed-filter {
        position: static;
        display: flex;
        flex-wrap: wrap;
    }
    .student-photo-row {
        grid-template-columns: 1fr;
    }
    .list-filter-bar {
        grid-template-columns: 1fr;
    }
    .teacher-filter-bar {
        grid-template-columns: 1fr;
    }
    .announcement-filter-bar {
        grid-template-columns: 1fr;
    }
    .announcement-filter-bar .filter-actions {
        grid-column: auto;
    }
    .class-filter-bar,
    .user-filter-bar,
    .report-filter-bar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 430px) {
    .login-body { padding: 12px; }
    .login-card {
        width: min(100%, calc(100vw - 24px));
        padding: 20px;
    }
    .login-card h1 {
        font-size: 1.45rem;
        line-height: 1.22;
        overflow-wrap: anywhere;
    }
    .login-card .btn,
    .login-card button {
        justify-content: center;
        min-width: 0;
        width: 100%;
        text-align: center;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .login-card .icon-btn {
        justify-self: start;
        min-width: 42px;
        width: 42px;
    }
    .landing-nav a {
        white-space: nowrap;
    }
    .hero-actions .btn {
        justify-content: center;
        width: 100%;
        white-space: normal;
        text-align: center;
    }
    .hero-actions .icon-btn {
        width: 42px;
    }
    .announcement-panel,
    .quick-band article {
        padding: 22px;
    }
    .modal-card {
        padding: 20px;
    }
}
