:root {
    --bg: #f3f5fa;
    --sidebar-bg: #0f1b2e;
    --sidebar-bg-alt: #16233a;
    --sidebar-text: #9aa7bd;
    --accent: #d81f2c;
    --accent-dark: #a8141f;
    --accent-soft: #fbe6e7;
    --text-main: #1f2636;
    --text-muted: #6b7280;
    --border-soft: #edf0f6;
    --card-radius: 16px;
    --card-shadow: 0 1px 2px rgba(15, 27, 46, .04), 0 10px 24px rgba(15, 27, 46, .05);
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-dark);
    text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-main);
}

/* ---------------------------------------------------------------- */
/* App shell / sidebar                                              */
/* ---------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 256px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 24px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 22px 22px 18px;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    margin-bottom: 14px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

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

.sidebar-section-label {
    margin: 20px 24px 6px;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #56637d;
    font-weight: 700;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin: 2px 12px;
    padding: .62rem .9rem;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: .92rem;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.nav-link-item i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
    opacity: .95;
}

.nav-link-item:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
}

.nav-link-item.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(216, 31, 44, .35);
}

/* ---------------------------------------------------------------- */
/* Topbar                                                            */
/* ---------------------------------------------------------------- */
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 66px;
    background: #fff;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.user-level-badge {
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: .3em .7em;
    border-radius: 999px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
}

.user-name {
    font-weight: 600;
    font-size: .92rem;
}

.topbar-logout {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f3f5f9;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    transition: background-color .15s ease, color .15s ease;
}

.topbar-logout:hover {
    background: #fdecec;
    color: #c0392b;
}

.page-body {
    padding: 26px 28px 44px;
    flex: 1;
}

/* ---------------------------------------------------------------- */
/* Guest (login) page                                                */
/* ---------------------------------------------------------------- */
.guest-wrapper {
    min-height: 100vh;
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #16233a, var(--sidebar-bg) 60%);
    padding: 1.5rem;
}

.login-card {
    max-width: 400px;
    width: 100%;
    border: none;
    border-radius: 20px;
    overflow: hidden;
}

.login-card .card-body {
    padding: 2.25rem 2rem;
}

/* ---------------------------------------------------------------- */
/* Cards, lists, tables                                              */
/* ---------------------------------------------------------------- */
.card {
    border: 1px solid var(--border-soft);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-soft);
    font-weight: 700;
    padding: 1rem 1.25rem;
}

.list-group-item {
    border-color: var(--border-soft);
    padding: .85rem 1.25rem;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 700;
    background: transparent;
    border-bottom: 1px solid var(--border-soft);
}

.table td, .table th {
    padding: .85rem 1.1rem;
    vertical-align: middle;
    border-color: var(--border-soft);
}

.table-hover tbody tr:hover {
    background-color: #f7f9fd;
}

.table a {
    font-weight: 600;
}

/* ---------------------------------------------------------------- */
/* Buttons                                                           */
/* ---------------------------------------------------------------- */
.btn {
    border-radius: 10px;
    font-weight: 600;
    font-size: .88rem;
}

.btn-sm {
    border-radius: 8px;
    padding: .38rem .8rem;
    font-size: .8rem;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 10px rgba(216, 31, 44, .25);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.btn-outline-secondary {
    border-color: transparent;
    background: #eef1f7;
    color: #3a4459;
}

.btn-outline-secondary:hover {
    background: #e2e7f1;
    color: #1f2937;
    border-color: transparent;
}

.btn-outline-primary {
    border-color: transparent;
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.btn-outline-primary:hover {
    background: #d7e3fd;
    color: var(--accent-dark);
    border-color: transparent;
}

.btn-outline-warning {
    border-color: transparent;
    background: #fff3e0;
    color: #9a5b00;
}

.btn-outline-warning:hover {
    background: #ffe6bf;
    color: #7a4700;
    border-color: transparent;
}

.btn-outline-light {
    border-color: rgba(255, 255, 255, .5);
    color: #fff;
}

/* ---------------------------------------------------------------- */
/* Status badges                                                     */
/* ---------------------------------------------------------------- */
.status-badge {
    color: #fff;
    padding: .38em .9em;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
}

/* ---------------------------------------------------------------- */
/* Dashboard stat cards                                              */
/* ---------------------------------------------------------------- */
.card-stat .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    margin-bottom: .85rem;
}

.card-stat .display-6 {
    font-weight: 700;
}

/* ---------------------------------------------------------------- */
/* Timeline                                                           */
/* ---------------------------------------------------------------- */
.timeline {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.timeline li {
    border-left: 3px solid var(--border-soft);
    padding: .25rem 0 1.25rem 1.1rem;
    margin-left: .5rem;
    position: relative;
}

.timeline li::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 4px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.timeline li:last-child {
    border-left-color: transparent;
}

.timeline-delete {
    border: none;
    background: transparent;
    color: #b6bdcc;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    flex-shrink: 0;
    transition: background-color .15s ease, color .15s ease;
}

.timeline-delete:hover {
    background: #fdecec;
    color: #c0392b;
}

/* ---------------------------------------------------------------- */
/* Responsive                                                        */
/* ---------------------------------------------------------------- */
@media (max-width: 768px) {
    .sidebar {
        width: 76px;
    }

    .sidebar-brand .brand-text,
    .nav-link-item span,
    .sidebar-section-label {
        display: none;
    }

    .nav-link-item {
        justify-content: center;
        margin: 2px 10px;
    }

    .topbar {
        padding: 0 16px;
    }

    .page-body {
        padding: 18px 16px 36px;
    }
}
