body {
    background: #f5f7fb;
    color: #212529;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

/* Sidebar Layout & Spacing */
.sidebar {
    width: 240px;
    background: #111827;
    color: #fff;
    position: fixed;
    top: 0;
    bottom: 0;
    padding: 16px 14px;
    overflow-y: auto;
}

.brand {
    font-size: 22px;
    font-weight: 700;
    padding: 0 12px 14px;
}

.brand small {
    font-size: 12px;
    opacity: 0.6;
}

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

.sidebar a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 14px;
    display: block;
}

.sidebar a:hover {
    background: #1f2937;
    color: #fff;
}

/* Main Content Area */
.main-content {
    margin-left: 240px;
    width: calc(100% - 240px);
}

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

.content {
    padding: 28px;
}

/* Cards & Statistics */
.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 22px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.03);
}

.stat-label {
    color: #6b7280;
    font-size: 14px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    margin: 6px 0 10px;
}

.stat-card a {
    text-decoration: none;
}

.card {
    border: 1px solid #e5e7eb;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.03);
}

/* Auth / Login Page */
.login-page {
    min-height: 100vh;
    background: #f5f7fb;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    width: 100%;
    max-width: 430px;
    padding: 36px;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

.login-logo {
    width: 58px;
    height: 58px;
    margin: 0 auto 15px;
    border-radius: 14px;
    background: #0d6efd;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
}

/* Responsive (Mobile/Tablet) */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
        padding: 20px 8px;
    }

    .brand {
        font-size: 0;
        text-align: center;
    }

    .brand:after {
        content: 'MIM';
        font-size: 18px;
    }

    .sidebar a {
        font-size: 0;
        text-align: center;
    }

    .sidebar a:before {
        content: '•';
        font-size: 24px;
    }

    .main-content {
        margin-left: 70px;
        width: calc(100% - 70px);
    }

    .topbar {
        padding: 0 14px;
    }

    .content {
        padding: 15px;
    }
}

/* =========================================
   Student ID Card Styling (Screen & Print)
========================================= */
.id-card-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.id-card {
    width: 340px;
    height: 215px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: Arial, sans-serif;
}

.id-card-header {
    background: #0d6efd;
    color: #fff;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.id-card-header h6 {
    font-size: 13px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.id-card-header small {
    font-size: 9px;
    opacity: 0.85;
}

.id-card-body {
    padding: 10px 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-grow: 1;
}

.student-photo {
    width: 75px;
    height: 90px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    object-fit: cover;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 24px;
}

.student-details {
    font-size: 11px;
    line-height: 1.5;
    color: #334155;
    flex-grow: 1;
}

.student-details strong {
    color: #0f172a;
}

.id-card-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 5px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 9px;
    color: #64748b;
}

/* ID Card Print Rules */
@media print {
    .sidebar, .topbar, .no-print {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }
    .content {
        padding: 0 !important;
    }
    body {
        background: #fff !important;
    }
    .id-card {
        page-break-inside: avoid;
        margin-bottom: 15px;
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
}

/* =========================================
   Certificate Designer & Print Module
========================================= */
.cert-canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    background: #f1f5f9;
    border: 2px dashed #94a3b8;
    border-radius: 8px;
    overflow: hidden;
    user-select: none;
}

.cert-canvas-wrapper img.cert-preview-bg {
    width: 100%;
    height: auto;
    display: block;
}

.cert-canvas-empty {
    height: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 15px;
    font-weight: 500;
}

.cert-drag-elem {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: move;
    border: 1px dashed #0d6efd;
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 10px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
    transition: box-shadow 0.15s ease;
}

.cert-drag-elem:hover,
.cert-drag-elem.active-drag {
    border-color: #0b5ed7;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* Certificate Print Output Rules */
@page {
    size: A4 landscape;
    margin: 0;
}

@media print {
    .no-print,
    .sidebar,
    .topbar {
        display: none !important;
    }
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
    }
    .cert-print-sheet {
        width: 100vw !important;
        height: 100vh !important;
        border: none !important;
        box-shadow: none !important;
    }
}

/* =========================================
   Certificate Designer & Print Module
========================================= */
.cert-canvas-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    background: #f1f5f9;
    border: 2px dashed #94a3b8;
    border-radius: 8px;
    overflow: hidden;
    user-select: none;
    transition: max-width 0.2s ease, min-height 0.2s ease;
}

.cert-canvas-wrapper.landscape {
    max-width: 850px;
    min-height: 550px;
}

.cert-canvas-wrapper.portrait {
    max-width: 550px;
    min-height: 750px;
}

.cert-canvas-wrapper img.cert-preview-bg {
    width: 100%;
    height: auto;
    display: block;
}

.cert-canvas-empty {
    height: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 15px;
    font-weight: 500;
}

.cert-drag-elem {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: move;
    border: 1px dashed #0d6efd;
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 10px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
    transition: box-shadow 0.15s ease;
}

.cert-drag-elem:hover,
.cert-drag-elem.active-drag {
    border-color: #0b5ed7;
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.cert-drag-box {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: move;
    border: 2px dashed #0d6efd;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #0d6efd;
    z-index: 10;
    overflow: hidden;
}

.cert-drag-box.active-drag,
.cert-drag-box:hover {
    border-color: #0a58ca;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.cert-data-box {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 2;
    overflow: hidden;
}

.cert-data-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}