* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, "Microsoft YaHei", sans-serif;
    color: #1f2937;
    background: #f3f6f8;
}

a {
    color: inherit;
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #16324f;
    color: #fff;
    padding: 14px 22px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.brand {
    font-size: 18px;
    font-weight: 700;
}

.nav {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.nav a,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border: 0;
    border-radius: 6px;
    background: #2563eb;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
}

.nav a.secondary,
.button.secondary {
    background: rgba(255, 255, 255, 0.16);
}

.container {
    width: min(1100px, calc(100% - 32px));
    margin: 28px auto;
    flex: 1;
}

.panel {
    background: #fff;
    border: 1px solid #d8e0e7;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.login-panel {
    width: min(420px, calc(100% - 32px));
    margin: 12vh auto 24px;
}

h1 {
    margin: 0 0 20px;
    font-size: 24px;
}

.form-row {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

label {
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 15px;
}

.error {
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 16px;
}

.success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 16px;
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.subject-card {
    display: block;
    background: #fff;
    border: 1px solid #d8e0e7;
    border-radius: 8px;
    padding: 22px;
    min-height: 118px;
    text-decoration: none;
    transition: transform .16s ease, box-shadow .16s ease;
}

.subject-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.10);
}

.subject-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}

.muted {
    color: #64748b;
    font-size: 14px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

th,
td {
    border-bottom: 1px solid #e2e8f0;
    padding: 12px;
    text-align: left;
}

th {
    background: #f8fafc;
}

.inline-form {
    display: inline;
}

.danger {
    background: #dc2626;
}

.footer {
    text-align: center;
    color: #64748b;
    padding: 18px 12px 24px;
    font-size: 14px;
}

.viewer-shell {
    min-height: calc(100vh - 60px);
    display: grid;
    grid-template-rows: 56px 1fr;
}

.viewer-frame {
    width: 100%;
    height: calc(100vh - 56px);
    border: 0;
    background: #fff;
}

.loading {
    display: grid;
    place-items: center;
    height: calc(100vh - 56px);
    color: #475569;
}

@media (max-width: 640px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .container {
        margin-top: 18px;
    }

    .panel {
        padding: 18px;
    }

    th,
    td {
        white-space: nowrap;
    }
}
