* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    color: #1f2933;
}

a {
    color: #2563eb;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: #303030;
}

.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}

.login-card h1 {
    margin: 0 0 20px;
    color: #111827;
}

label {
    display: grid;
    gap: 7px;
    margin-bottom: 16px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
}

.password-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.password-toggle {
    background: #e5e7eb;
    color: #111827;
    white-space: nowrap;
}

textarea {
    resize: vertical;
}

button,
.primary-link,
.secondary-link {
    border: none;
    border-radius: 7px;
    padding: 11px 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button,
.primary-link {
    background: #2563eb;
    color: #fff;
}

.secondary-link {
    background: #e5e7eb;
    color: #111827;
}

.admin-shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-sidebar {
    background: #111827;
    color: #fff;
    padding: 22px;
}

.admin-brand {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 24px;
}

.admin-nav {
    display: grid;
    gap: 8px;
}

.admin-nav a {
    color: #dbeafe;
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 7px;
}

.admin-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.admin-logout-form {
    margin: 0;
}

.admin-nav .admin-logout-button {
    display: block;
    width: 100%;
    padding: 11px 12px;
    color: #dbeafe;
    background: transparent;
    text-align: left;
    font: inherit;
}

.admin-nav .admin-logout-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.admin-main {
    min-width: 0;
}

.admin-topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.menu-button {
    display: none;
}

.admin-content {
    padding: 28px;
}

.admin-content h1 {
    margin: 0 0 22px;
}

.dashboard-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #fff;
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
}

.dashboard-intro p {
    margin: 0;
    color: #475569;
    line-height: 1.5;
}

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

.page-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

.page-card h2 {
    margin: 0 0 8px;
    font-size: 1.05rem;
    color: #111827;
}

.page-card p {
    margin: 0 0 16px;
    color: #64748b;
    font-size: 0.94rem;
}

.page-card-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
}

.stat-card span {
    color: #64748b;
}

.stat-card strong {
    display: block;
    font-size: 2rem;
    margin-top: 8px;
}

.action-row,
.toolbar,
.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 22px 0;
}

.search-form {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 260px;
}

.table-wrap {
    overflow-x: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.admin-table th,
.admin-table td {
    padding: 13px 14px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    background: #f8fafc;
}

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.actions form {
    margin: 0;
}

.actions button {
    background: #dc2626;
}

.admin-card-list {
    display: grid;
    gap: 14px;
}

.admin-content-card,
.empty-admin-list {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
}

.admin-content-card h2 {
    margin: 10px 0;
    color: #111827;
    font-size: 1.06rem;
    line-height: 1.35;
}

.admin-content-card p {
    margin: 7px 0;
    color: #334155;
    line-height: 1.45;
}

.admin-card-meta {
    color: #64748b !important;
    font-weight: 700;
}

.grade-admin-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    border-top: 1px solid #e5e7eb;
    padding: 12px 0;
}

.grade-admin-row span {
    font-weight: 800;
    color: #166534;
}

.grade-admin-row small {
    color: #64748b;
}

.admin-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #dbeafe;
    color: #1e3a8a;
    padding: 5px 9px;
    margin: 0 6px 6px 0;
    font-size: 0.82rem;
    font-weight: 800;
}

.muted-pill {
    background: #f1f5f9;
    color: #475569;
}

.published-pill {
    background: #dcfce7;
    color: #166534;
}

.hidden-pill {
    background: #fee2e2;
    color: #991b1b;
}

.message-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 18px;
    align-items: start;
}

.message-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

.message-card.message-new {
    border-left: 5px solid #2563eb;
}

.message-card h2,
.message-detail h2 {
    margin: 0 0 8px;
    color: #111827;
    font-size: 1.05rem;
}

.message-card p {
    margin: 8px 0;
    color: #475569;
    line-height: 1.45;
}

.message-detail {
    position: sticky;
    top: 82px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
}

.message-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.message-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
    color: #1f2937;
    line-height: 1.55;
}

.content-form {
    background: #fff;
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.07);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.wide {
    grid-column: 1 / -1;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.checkbox-line input {
    width: auto;
}

.upload-drop {
    border: 2px dashed #94a3b8;
    border-radius: 8px;
    background: #f8fafc;
    padding: 16px;
    min-height: 110px;
    display: grid;
    place-items: center;
    text-align: center;
    color: #334155;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.upload-drop span {
    font-weight: 800;
}

.upload-drop small {
    color: #64748b;
    font-weight: 600;
}

.upload-drop input {
    border: 0;
    padding: 0;
    background: transparent;
}

.upload-drop.is-dragover {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}

.upload-drop.has-file {
    border-color: #16a34a;
    background: #f0fdf4;
}

.upload-progress {
    margin-top: 18px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    padding: 14px;
}

.upload-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    color: #1e3a8a;
}

.upload-progress-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #dbeafe;
}

.upload-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #2563eb;
    transition: width 0.18s ease;
}

.upload-progress small {
    display: block;
    margin-top: 9px;
    color: #1e40af;
    font-weight: 700;
}

.upload-progress-done {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.upload-progress-done .upload-progress-head,
.upload-progress-done small {
    color: #166534;
}

.upload-progress-done .upload-progress-bar {
    background: #16a34a;
}

.upload-progress-error {
    border-color: #fecaca;
    background: #fef2f2;
}

.upload-progress-error .upload-progress-head,
.upload-progress-error small {
    color: #991b1b;
}

.upload-progress-error .upload-progress-bar {
    background: #dc2626;
}

.flash,
.form-error,
.muted {
    border-radius: 7px;
    padding: 12px 14px;
}

.flash-success {
    background: #dcfce7;
    color: #166534;
}

.flash-error,
.form-error {
    background: #fee2e2;
    color: #991b1b;
}

.muted {
    background: #f8fafc;
    color: #475569;
    font-size: 0.92rem;
}

@media screen and (max-width: 820px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: fixed;
        top: 0;
        left: -270px;
        width: 250px;
        height: 100vh;
        z-index: 50;
        transition: left 0.2s ease;
    }

    .admin-sidebar.show {
        left: 0;
    }

    .menu-button {
        display: inline-flex;
    }

    .admin-content {
        padding: 16px;
    }

    .stats-grid,
    .form-grid,
    .page-grid,
    .message-layout {
        grid-template-columns: 1fr;
    }

    .message-detail {
        position: static;
    }

    .dashboard-intro,
    .toolbar,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-intro .secondary-link,
    .toolbar a,
    .toolbar button,
    .form-actions a,
    .form-actions button {
        width: 100%;
    }

    .search-form {
        flex-direction: column;
    }

    .search-form {
        min-width: 100%;
    }

    .admin-table {
        min-width: 760px;
    }

    .grade-admin-row {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 480px) {
    .login-card,
    .content-form,
    .page-card,
    .dashboard-intro {
        padding: 16px;
    }

    .admin-topbar {
        padding: 0 14px;
    }

    .admin-content h1 {
        font-size: 1.35rem;
    }

    .password-field {
        grid-template-columns: 1fr;
    }
}
