* {
    box-sizing: border-box;
}

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

/* Sidebar */
aside {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    min-height: 100vh;
    padding: 22px 16px;
    background: linear-gradient(180deg, #0f766e, #115e59);
    color: #fff;
    overflow: auto;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12);
}

aside h2 {
    margin: 0 0 18px;
    font-size: 22px;
    text-align: center;
    letter-spacing: 0.5px;
}

aside p {
    margin-bottom: 18px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    text-align: center;
    line-height: 1.5;
}

aside p small {
    color: #ccfbf1;
    text-transform: uppercase;
    font-weight: bold;
}

/* Navigation */
aside nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

aside nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: #ecfeff;
    text-decoration: none;
    border-radius: 12px;
    font-size: 15px;
    transition: 0.2s ease;
}

aside nav a i {
    width: 22px;
    text-align: center;
    font-size: 16px;
}

aside nav a:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateX(4px);
}

aside nav a.active,
aside nav a:focus {
    background: #ffffff;
    color: #0f766e;
    font-weight: bold;
}

/* Main Content */
main {
    margin-left: 260px;
    min-height: 100vh;
    padding: 22px;
}

/* Top Bar */
.top {
    background: #ffffff;
    padding: 16px 24px;
    margin-bottom: 18px;
    border-radius: 10px;
    box-shadow: 0 3px 18px rgba(0, 0, 0, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.cards div,
.panel {
    background: #ffffff;
    padding: 18px;
    border-radius: 12px;
    box-shadow: 0 3px 12px #dce3ee;
}

.cards b {
    display: block;
    margin-top: 10px;
    font-size: 24px;
    color: #0f766e;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.inline {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: end;
}

/* Form */
label {
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    margin-top: 5px;
    padding: 10px;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
}

textarea {
    min-height: 70px;
}

/* Button */
button,
.btn {
    background: #0f766e;
    color: #ffffff;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.btn:hover {
    background: #115e59;
}

/* Table */
table {
    width: 100%;
    margin-top: 16px;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 3px 12px #dce3ee;
}

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

th {
    background: #e8f0fb;
}

/* Alert */
.alert {
    margin-bottom: 12px;
    padding: 14px 16px;
    background: #d1fae5;
    color: #065f46;
    border-left: 5px solid #10b981;
    border-radius: 10px;
}

.alert.danger,
.danger {
    background: #ffe1e1;
    color: #7f1d1d;
    border-left-color: #b60000;
}

/* Login Page */
.login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #0f766e;
}

.loginbox {
    width: 360px;
    padding: 28px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Responsive */
@media (max-width: 768px) {
    aside {
        position: relative;
        width: 100%;
        min-height: auto;
        border-radius: 0 0 20px 20px;
    }

    main {
        margin-left: 0;
        padding: 16px;
    }

    aside nav {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    aside nav a {
        font-size: 14px;
    }

    .top {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}

/* Print */
@media print {
    aside,
    .top,
    form,
    button,
    .btn {
        display: none;
    }

    main {
        margin: 0;
        padding: 0;
    }

    table {
        box-shadow: none;
    }
}

/* Logo sekolah */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 18px;
    text-align: center;
}

.sidebar-brand h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
}

.logo-sidebar {
    width: 46px !important;
    height: 46px !important;
    max-width: 46px !important;
    max-height: 46px !important;
    object-fit: contain;
    flex: 0 0 auto;
    background: #ffffff;
    border-radius: 10px;
    padding: 4px;
}

.login-logo-wrap {
    text-align: center;
    margin-bottom: 18px;
}

.logo-login {
    width: 110px !important;
    height: 110px !important;
    max-width: 110px !important;
    max-height: 110px !important;
    object-fit: contain;
    display: block;
    margin: 0 auto 12px;
}

.login-logo-wrap h2 {
    margin: 0;
    font-size: 22px;
    color: #0f766e;
}

.login-subtitle {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 14px;
}

.logo-preview-box {
    margin: 8px 0;
}

.logo-preview {
    width: 130px !important;
    height: 130px !important;
    max-width: 130px !important;
    max-height: 130px !important;
    object-fit: contain;
    display: block;
    padding: 8px;
    border: 1px solid #cfd8e3;
    border-radius: 10px;
    background: #fff;
}
.login-logo-wrap {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo-wrap img.logo-login {
    width: 100px !important;
    height: 100px !important;
    max-width: 100px !important;
    max-height: 100px !important;
    object-fit: contain !important;
    display: block;
    margin: 0 auto 10px auto;
}
.sidebar-logo,
.brand-logo,
img.logo-sidebar {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    object-fit: contain !important;
}
/* Modal & action icons */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 24px 12px;
    background: rgba(15, 23, 42, 0.55);
}

.modal.show {
    display: block;
}

.modal-content {
    width: min(780px, 96%);
    margin: 30px auto;
    padding: 18px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #0f766e;
}

.modal-close {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: #e2e8f0;
    color: #0f172a;
    font-size: 24px;
    line-height: 1;
}

.modal-close:hover {
    background: #cbd5e1;
}

.modal .panel {
    box-shadow: none;
    padding: 0;
}

.aksi {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    text-decoration: none;
    cursor: pointer;
}

.btn-icon.info {
    background: #2563eb;
}

.btn-icon.warning {
    background: #f59e0b;
}

.btn-icon.danger {
    background: #dc2626;
    border-left: 0;
}

.btn-icon:hover {
    filter: brightness(0.92);
}

@media (max-width: 768px) {
    .modal-content {
        margin: 10px auto;
        width: 98%;
    }
}

/* Perbaikan modal tanpa bergantung CDN/FontAwesome/JavaScript */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 12px 0;
    background: #0f766e;
    color: #fff !important;
    text-decoration: none;
    border-radius: 8px;
    padding: 10px 14px;
}
.icon { display: inline-block; line-height: 1; }
.modal:target { display: block; }
.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: bold;
}
.btn-icon {
    font-size: 16px;
    line-height: 1;
}
.btn-icon.warning,
.btn-icon.danger,
.btn-icon.info {
    color: #fff !important;
}


/* ===============================
   Mobile Responsive Improvements
   =============================== */
.mobile-menu-btn,
.sidebar-backdrop {
    display: none;
}

img {
    max-width: 100%;
    height: auto;
}

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

.table-responsive table {
    min-width: 720px;
}

@media (max-width: 768px) {
    body.sidebar-open {
        overflow: hidden;
    }

    aside {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 10000;
        width: 285px;
        max-width: 86vw;
        min-height: 100vh;
        border-radius: 0;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        padding-bottom: 80px;
    }

    body.sidebar-open aside {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 9998;
        background: rgba(15, 23, 42, 0.55);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

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

    aside nav a {
        font-size: 15px;
        padding: 13px 14px;
        min-height: 46px;
    }

    main {
        margin-left: 0;
        padding: 12px;
        width: 100%;
    }

    .top {
        position: sticky;
        top: 0;
        z-index: 50;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 12px;
        margin: -12px -12px 14px;
        border-radius: 0 0 14px 14px;
    }

    .top b {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .top span {
        display: none;
    }

    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        padding: 0;
        border-radius: 10px;
        background: #0f766e;
        color: #fff;
        flex: 0 0 auto;
    }

    h1 {
        font-size: 24px;
        line-height: 1.25;
        margin: 12px 0;
    }

    .cards {
        grid-template-columns: 1fr;
    }

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

    .inline {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .panel,
    .cards div {
        padding: 14px;
        border-radius: 12px;
    }

    input,
    select,
    textarea,
    button,
    .btn,
    .btn-primary {
        min-height: 44px;
        font-size: 16px;
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        border-radius: 10px;
    }

    th,
    td {
        padding: 9px 10px;
        font-size: 14px;
    }

    .aksi {
        flex-wrap: nowrap;
    }

    .modal {
        padding: 10px;
    }

    .modal-content,
    .modal-content.modal-sm {
        width: 100%;
        max-width: 100%;
        margin: 8px auto;
        padding: 14px;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .login {
        padding: 16px;
    }

    .loginbox {
        width: 100%;
        max-width: 380px;
        padding: 22px;
    }
}

@media (max-width: 420px) {
    main {
        padding: 10px;
    }

    .top {
        margin: -10px -10px 12px;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
    }
}
