* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #eef2f7;
    color: #111827;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    height: 100vh;
    background: #0f172a;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    overflow: hidden;
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    gap: 14px;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,.12);
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px rgba(37,99,235,.35);
}

.brand-title {
    font-size: 20px;
    font-weight: 800;
}

.brand-subtitle {
    font-size: 12px;
    color: #cbd5e1;
}

.sidebar-nav {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.sidebar-nav a,
.sidebar-footer {
    flex-shrink: 0;
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,.12);
    background: #0f172a;
}

.sidebar-nav a:hover,
.sidebar-footer a:hover {
    background: rgba(37,99,235,.25);
    transform: translateX(4px);
}

.sidebar-nav a i,
.sidebar-footer a i {
    width: 18px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: 18px;
    border-top: 1px solid rgba(255,255,255,.12);
}

.main-area {
    margin-left: 260px;
    width: calc(100% - 260px);
    min-height: 100vh;
}

.main-header {
    height: 72px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 18px 32px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(15,23,42,.04);
}

.main-header strong {
    display: block;
    font-size: 16px;
}

.main-header span {
    display: block;
    font-size: 13px;
    color: #6b7280;
    margin-top: 3px;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0 0 8px;
    font-size: 34px;
    font-weight: 800;
}

.page-header p {
    margin: 0;
    color: #4b5563;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 22px;
    margin-bottom: 24px;
    align-items: stretch;
}

.card {
    background: white;
    padding: 24px;
    border-radius: 16px;
    width: 100%;
    box-shadow: 0 8px 24px rgba(15,23,42,.06);
    border: 1px solid #e5e7eb;
    margin-bottom: 24px;
    transition: all .2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(15,23,42,.10);
}

.card h2 {
    margin: 0 0 12px;
    font-size: 26px;
}

.card p {
    margin: 0;
    color: #4b5563;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    margin-bottom: 18px;
    box-shadow: 0 8px 18px rgba(37,99,235,.30);
}

.stat-value {
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 8px;
}

.stat-title {
    font-size: 15px;
    color: #6b7280;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.button,
.btn-primary,
.btn-small {
    background: #2563eb;
    color: white !important;
    text-decoration: none;
    border-radius: 9px;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: bold;
}

.button,
.btn-primary {
    padding: 11px 16px;
    font-size: 14px;
}

.btn-small {
    padding: 7px 10px;
    font-size: 12px;
    margin: 2px;
}

.button:hover,
.btn-primary:hover,
.btn-small:hover {
    background: #1d4ed8;
}

.data-table,
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 18px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

th,
td {
    padding: 13px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    background: #f8fafc;
    color: #374151;
    font-weight: 800;
}

.form-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 14px;
    align-items: center;
}

.form-grid label {
    font-weight: bold;
    color: #374151;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 11px;
    border: 1px solid #d1d5db;
    border-radius: 9px;
    font-family: Arial, sans-serif;
    background: white;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    padding: 13px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    border: 1px solid #bbf7d0;
}

.alert-error,
.error {
    background: #fee2e2;
    color: #991b1b;
    padding: 13px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    border: 1px solid #fecaca;
}

.badge {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 11px;
    font-weight: 800;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.login-body {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: white;
    padding: 35px;
    width: 380px;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(15,23,42,.12);
}

.login-card input {
    width: 100%;
    padding: 11px;
    margin-top: 5px;
    border: 1px solid #d1d5db;
    border-radius: 9px;
}

.login-card button,
.form-card button {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 9px;
    font-weight: bold;
}

.form-card,
.profile-card {
    background: white;
    padding: 25px;
    border-radius: 16px;
    max-width: 760px;
    box-shadow: 0 8px 24px rgba(15,23,42,.06);
    border: 1px solid #e5e7eb;
}

.form-card label {
    display: block;
    margin-top: 15px;
    font-weight: bold;
}

.form-card input,
.form-card textarea,
.form-card select {
    width: 100%;
    padding: 11px;
    margin-top: 5px;
    border: 1px solid #d1d5db;
    border-radius: 9px;
}

.form-card button {
    margin-top: 20px;
    padding: 12px 18px;
}

.cancel-link {
    margin-left: 15px;
}

.section-title {
    margin-top: 35px;
}

@media (max-width: 1100px) {
    .cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .sidebar {
        position: static;
        width: 100%;
    }

    .app-shell {
        flex-direction: column;
    }

    .main-area {
        margin-left: 0;
        width: 100%;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

@media (max-width: 700px) {
    .container {
        padding: 18px;
    }

    .cards {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    table {
        font-size: 13px;
    }
}
.card {
    overflow-wrap: anywhere;
    word-break: normal;
}

.card p,
.card strong,
.card td,
.card th {
    overflow-wrap: anywhere;
}

.cards {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.chart-container {
    position: relative;
    height: 420px;
    width: 100%;
}

.chart-container canvas {
    max-height: 420px;
}

/* Permanent sidebar and logout fix */
.sidebar {
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
}

.sidebar-brand {
    flex: 0 0 auto;
}

.sidebar-nav {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 12px 18px !important;
    gap: 4px !important;
}

.sidebar-nav a {
    padding: 9px 14px !important;
}

.sidebar-footer {
    flex: 0 0 auto !important;
    margin-top: 0 !important;
    padding: 10px 18px !important;
    background: #0f172a !important;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    z-index: 10;
}
/* ===== Sidebar link colour fix ===== */

.sidebar a,
.sidebar a:link,
.sidebar a:visited,
.sidebar a:hover,
.sidebar a:active {
    color: #e5e7eb !important;
    text-decoration: none !important;
}

.sidebar-nav a:hover,
.sidebar-footer a:hover {
    background: rgba(37,99,235,.25) !important;
    color: #ffffff !important;
}