* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #eef2f6;
    color: #243447;
}

/* Layouts */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.public-layout {
    min-height: 100vh;
    background: #eef2f6;
}

.public-header {
    background: #ffffff;
    border-bottom: 1px solid #d8dee4;
}

.public-header-inner {
    width: min(1100px, 92%);
    margin: 0 auto;
    padding: 24px 0;
}

.public-nav a {
    margin-right: 16px;
    color: #005bbb;
    text-decoration: none;
}

.public-main {
    width: min(1100px, 92%);
    margin: 24px auto;
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
max-width: 280px;
flex: 0 0 280px;
    background: #2f4154;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow:auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: bold;
    margin-bottom: 20px;
}

.sidebar-logo i,
.sidebar-nav i {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffffff;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.15s ease, transform 0.1s ease;
}

.nav-link-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav a:hover {
    background: #3b536b;
}

.sidebar-nav a.active {
    background: #3b536b;
    font-weight: bold;
    box-shadow: inset 3px 0 0 #8fd19e;
}

.sidebar-button.primary {
    background: #2f86c9;
    font-weight: bold;
    margin-bottom: 6px;
}

.sidebar-button.primary:hover {
    background: #2677b3;
}

.sidebar-button.primary.active {
    background: #2677b3;
    box-shadow: inset 3px 0 0 #ffffff;
}

.sidebar-section-title {
    margin-top: 18px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: bold;
    color: #8fd19e;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sidebar-userbox {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.18);
}

.sidebar-userbox-label {
    font-size: 13px;
    opacity: 0.9;
}

.sidebar-userbox-name {
    font-weight: bold;
    margin-top: 4px;
}

.sidebar-userbox-role {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

.sidebar-userbox-note {
    margin-top: 8px;
    font-size: 13px;
    color: #ffd58a;
}

.sidebar-footer-links {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-footer-links a {
    color: #ffffff;
    text-decoration: none;
    font-size: 14px;
}

.sidebar-footer-links .logout-link {
    color: #ff8d8d;
}

/* Main content */
.main-content {
    flex: 1;
    min-width:0;
    padding: 28px;
    background: #eef2f6;
}

.page-title {
    font-size: 26px;
    font-weight: bold;
    margin: 0 0 18px;
    color: #2f4154;
}

/* Cards */
.card {
    background: #ffffff;
    border: 1px solid #d8dee4;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.card h2,
.card h3 {
    margin-top: 0;
}

/* Toolbar / Search */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    align-items: center;
}

.toolbar .toolbar-search {
    flex: 1;
    min-width: 240px;
}

.toolbar input[type="text"],
.toolbar select {
    width: 100%;
    border: 1px solid #c8d0d8;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    background: #ffffff;
}

.toolbar .toolbar-button {
    white-space: nowrap;
}

/* Tables */
.table-list {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border-radius: 10px;
    background: #ffffff;
}

.table-list thead {
    background: #2f86c9;
    color: #ffffff;
}

.table-list th,
.table-list td {
    padding: 11px 14px;
    border-bottom: 1px solid #e5eaf0;
    text-align: left;
    vertical-align: middle;
}

.table-list tbody tr:hover {
    background: #f4f8fc;
}

.table-list td small {
    color: #666;
}

.table-list a {
    color: #005bbb;
    text-decoration: none;
}

.table-list a:hover {
    text-decoration: underline;
}

.mail-unread {
    font-weight: bold;
    background: #f7fbff;
}

/* Mail row helpers */
.mail-cell-from {
    min-width: 220px;
}

.mail-cell-subject {
    width: 100%;
}

.mail-cell-date {
    min-width: 170px;
    white-space: nowrap;
}

.mail-cell-status {
    min-width: 100px;
    white-space: nowrap;
}

.mail-sender-name {
    display: block;
    font-weight: 600;
}

.mail-sender-address {
    display: block;
    font-size: 12px;
    color: #667085;
    margin-top: 2px;
}

.mail-subject-link {
    font-weight: 600;
}

.mail-subject-preview {
    display: block;
    margin-top: 3px;
    color: #667085;
    font-size: 13px;
    font-weight: normal;
    max-width: 680px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status pills */
.status-pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: #eef2f6;
    color: #344054;
}

.status-pill.unread {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-pill.sent {
    background: #ecfdf3;
    color: #027a48;
}

.status-pill.trash {
    background: #fee4e2;
    color: #b42318;
}

/* Forms */
.form-row {
    margin-bottom: 16px;
}

.form-row label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
}

.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="file"],
.form-row select,
.form-row textarea {
    width: 100%;
    border: 1px solid #c8d0d8;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    background: #ffffff;
    font-family: inherit;
}

.form-row textarea {
    min-height: 220px;
    resize: vertical;
}

input[type="checkbox"] {
    margin-right: 8px;
}

small {
    color: #5b6470;
}

/* Buttons */
.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    text-decoration: none;
    cursor: pointer;
    background: #005bbb;
    color: #ffffff;
    font-size: 14px;
}

.btn:hover {
    opacity: 0.95;
}

.btn.secondary {
    background: #6c757d;
}

.btn.danger {
    background: #b42318;
}

/* Flash messages */
.flash-error {
    background: #fee4e2;
    color: #7a271a;
    border: 1px solid #fecdca;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.flash-success {
    background: #ecfdf3;
    color: #027a48;
    border: 1px solid #abefc6;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

/* Mail detail */
.meta-list p {
    margin: 6px 0;
}

.mail-body {
    white-space: pre-wrap;
    line-height: 1.6;
}

.mail-body,
.thread-body {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Two-pane layout */
.two-pane {
    display: grid;
    grid-template-columns: minmax(320px, 430px) 1fr;
    gap: 20px;
    align-items: start;
}

.two-pane-list,
.two-pane-detail {
    height: 100vh;
    overflow: auto;
}

.mail-list-compact {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mail-list-item {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid #e7ebef;
    color: inherit;
    text-decoration: none;
    background: #fff;
}

.mail-list-item:hover {
    background: #f4f8fc;
    text-decoration: none;
}

.mail-list-item.active {
    background: #eaf3fb;
    border-left: 4px solid #2f86c9;
    padding-left: 12px;
}

.mail-list-item.unread .mail-list-subject {
    font-weight: 700;
}

.mail-list-topline {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.mail-list-from {
    font-weight: 600;
}

.mail-list-date {
    color: #667085;
    font-size: 13px;
    white-space: nowrap;
}

.mail-list-subject {
    margin-bottom: 4px;
}

.mail-list-snippet {
    color: #667085;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-empty {
    color: #667085;
}

/* Thread */
.thread-item {
    border-top: 1px solid #e7ebef;
    padding-top: 14px;
    margin-top: 14px;
}

.thread-item:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.thread-meta {
    font-size: 14px;
    color: #555;
    margin-bottom: 8px;
}

.thread-subject {
    font-weight: bold;
    margin-bottom: 8px;
}

.thread-body {
    white-space: pre-wrap;
    line-height: 1.5;
    background: #fafbfc;
    border: 1px solid #e7ebef;
    border-radius: 8px;
    padding: 12px;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: #eef2f6;
    color: #344054;
    margin-left: 8px;
}

/* Tagify */
.tagify {
    width: 100%;
    border: 1px solid #c8d0d8;
    border-radius: 8px;
    min-height: 44px;
    padding: 4px;
    background: #fff;
}

.tagify__input {
    margin: 0;
    padding: 6px;
}

/* Badge */
.mail-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: #b42318;
    color: #fff;
    font-size: 12px;
    text-align: center;
    vertical-align: middle;
    margin-left: 6px;
}

/* Print cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.access-card {
    background: #fff;
    border: 1px solid #d8dee4;
    border-radius: 10px;
    padding: 16px;
    page-break-inside: avoid;
}

.access-card h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 18px;
}

.access-card p {
    margin: 6px 0;
    line-height: 1.4;
}

.print-wrap {
    padding: 12px;
}

/* Lists */
ul {
    line-height: 1.6;
}

/* Responsive */
@media (max-width: 1100px) {
    .two-pane {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .app-layout {
        display: block;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
        position: static;
    }

    .main-content {
        padding: 18px;
    }

    .toolbar {
        display: block;
    }

    .toolbar .toolbar-search,
    .toolbar .toolbar-button {
        margin-bottom: 10px;
    }
}

@media print {
    .sidebar,
    .public-header,
    .btn,
    form,
    nav,
    .toolbar {
        display: none !important;
    }

    .main-content,
    .public-main,
    .print-wrap {
        padding: 0;
        margin: 0;
        width: 100%;
    }

    .card-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .access-card {
        border: 1px solid #999;
        box-shadow: none;
    }
}

/* Tagify polishing */
.tagify {
    width: 100%;
    border: 1px solid #c8d0d8;
    border-radius: 8px;
    min-height: 44px;
    padding: 4px;
    background: #fff;
}

.tagify__input {
    margin: 0;
    padding: 6px;
}

.tagify__dropdown {
    border-radius: 10px;
    border: 1px solid #d8dee4;
    box-shadow: 0 8px 18px rgba(0,0,0,0.08);
    overflow: hidden;
}

.recipient-item-name {
    font-weight: 600;
    color: #243447;
}

.recipient-item-meta {
    font-size: 12px;
    color: #667085;
    margin-top: 2px;
}


.type-pill {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.type-pill.system {
    background: #eef2ff;
    color: #4338ca;
}

.type-pill.learning {
    background: #ecfdf3;
    color: #027a48;
}

.type-pill.spam {
    background: #fff7ed;
    color: #c2410c;
}

.type-pill.phishing {
    background: #fee4e2;
    color: #b42318;
}


.empty-state {
    padding: 30px 20px;
    text-align: center;
    color: #667085;
}

.empty-state-title {
    font-weight: 700;
    color: #243447;
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 14px;
}


.mail-header-box {
    margin-top: 14px;
    background: #f4f6f8;
    border: 1px solid #d6dde5;
    border-radius: 6px;
    padding: 12px;
}

.mail-header-box pre {
    margin: 0;
    font-family: monospace;
    font-size: 13px;
    white-space: pre-wrap;
}

.btn-secondary {
    margin-top: 8px;
    background: #e6ebf0;
    color: #2f4154;
    border: 1px solid #ccd3da;
}

.preview-box {
    background: #fafbfc;
    border: 1px solid #e7ebef;
    border-radius: 8px;
    padding: 14px;
}

.preview-meta {
    margin-bottom: 12px;
}

.preview-meta p {
    margin: 6px 0;
}

.preview-note {
    color: #667085;
    margin-bottom: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid #d8dee4;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #2f4154;
}

.stat-label {
    margin-top: 6px;
    color: #667085;
    font-size: 14px;
}

.class-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.class-dashboard-card {
    background: #ffffff;
    border: 1px solid #d8dee4;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.class-dashboard-header h3 {
    margin: 0 0 6px;
}

.class-dashboard-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: #667085;
    font-size: 13px;
    margin-bottom: 12px;
}

.class-dashboard-info {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    color: #344054;
    font-size: 14px;
}

.class-dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.mini-stat {
    background: #f8fafc;
    border: 1px solid #e5eaf0;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
}

.mini-stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #2f4154;
}

.mini-stat-label {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #667085;
}

.class-dashboard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.class-dashboard-actions .btn {
    padding: 8px 10px;
    font-size: 13px;
}

.class-expiry.expiring {
    color: #b54708;
    font-weight: 700;
}

.class-expiry.expired {
    color: #b42318;
    font-weight: 700;
}

.teacher-identity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 10px;
}