:root {
    --app-primary: #3498db;
    --app-primary-dark: #2d87c4;
    --app-bg: #f5f8fb;
    --app-surface: #ffffff;
    --app-border: #dfe8f2;
    --app-text: #1f2d3d;
    --app-muted: #6f7d8c;
    --sidebar-width: clamp(270px, 20vw, 320px);
    --topbar-height: 88px;
    --shadow-soft: 0 20px 40px rgba(31, 45, 61, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Amiri", serif;
    background:
        radial-gradient(circle at top right, rgba(52, 152, 219, 0.12), transparent 30%),
        linear-gradient(180deg, #fbfdff 0%, var(--app-bg) 100%);
    color: var(--app-text);
}

a {
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.layout-wrapper {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.sidebar-panel {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: rgba(255, 255, 255, 0.92);
    border-left: 1px solid var(--app-border);
    backdrop-filter: blur(18px);
    overflow: hidden;
    transition: width .24s ease, min-width .24s ease, border-color .24s ease;
}

.sidebar-shell {
    height: 100%;
    padding: 1.25rem 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
    scrollbar-width: thin;
    transition: opacity .18s ease, padding .24s ease;
}

.brand-box,
.login-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0;
}

.brand-badge {
    width: 60px;
    height: 60px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--app-primary), #6cc5ef);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    font-weight: 700;
    box-shadow: var(--shadow-soft);
    flex-shrink: 0;
    overflow: hidden;
}

.brand-badge.has-logo {
    background: #fff;
    padding: .28rem;
    border: 1px solid rgba(52, 152, 219, 0.14);
}

.brand-logo {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 16px;
}

.brand-title {
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.5;
}

.brand-subtitle,
.login-brand p {
    color: var(--app-muted);
    margin: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    flex: 1;
    min-height: 0;
    padding-inline-end: .25rem;
}

.sidebar-nav .nav-link {
    border-radius: 18px;
    padding: .8rem .95rem;
    color: var(--app-text);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .8rem;
    min-height: 56px;
    font-size: 1rem;
    line-height: 1.45;
    transition: background-color .2s ease, color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(52, 152, 219, 0.12);
    color: var(--app-primary-dark);
    box-shadow: inset 0 0 0 1px rgba(52, 152, 219, 0.16);
}

.sidebar-nav .nav-link:hover {
    transform: translateX(-2px);
}

.sidebar-nav .nav-link i {
    width: 1.45rem;
    font-size: 1.15rem;
    display: inline-flex;
    justify-content: center;
    flex-shrink: 0;
}

.content-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.sidebar-collapsed .sidebar-panel {
    width: 0;
    min-width: 0;
    border-left-color: transparent;
}

.sidebar-collapsed .sidebar-shell {
    opacity: 0;
    pointer-events: none;
    padding-inline: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: var(--topbar-height);
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid var(--app-border);
    z-index: 20;
    backdrop-filter: blur(16px);
    flex-shrink: 0;
}

.topbar-right,
.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-date {
    font-weight: 700;
    color: var(--app-muted);
    white-space: nowrap;
}

.user-pill {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 999px;
    padding: .5rem 1rem;
    font-weight: 700;
}

.btn-topbar-menu {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.page-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.5rem;
    scrollbar-width: thin;
}

.page-head {
    margin-bottom: 1.5rem;
}

.page-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
}

.page-breadcrumb {
    color: var(--app-muted);
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .35rem;
}

.content-card,
.stat-card,
.login-card,
.list-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 26px;
    box-shadow: var(--shadow-soft);
}

.content-card {
    padding: 1.5rem;
}

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

.stat-card {
    padding: 1.25rem 1.35rem;
}

.stat-card span {
    color: var(--app-muted);
    display: block;
    margin-bottom: .75rem;
    font-weight: 700;
}

.stat-card strong {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-card.accent {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.12), #fff);
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-head h3 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
}

.app-table th {
    color: var(--app-muted);
    font-weight: 700;
}

.app-table td,
.app-table th {
    padding: 1rem .85rem;
    border-bottom-color: #edf2f7;
    vertical-align: middle;
}

.list-stack {
    display: grid;
    gap: .85rem;
}

.list-card {
    padding: 1rem 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.empty-state {
    padding: 1.25rem;
    text-align: center;
    color: var(--app-muted);
    border: 1px dashed var(--app-border);
    border-radius: 18px;
}

.detail-grid {
    display: grid;
    gap: .75rem;
}

.report-link {
    transition: transform .2s ease, border-color .2s ease;
}

.report-link:hover {
    transform: translateY(-3px);
    border-color: rgba(52, 152, 219, 0.35);
}

.info-box {
    padding: .9rem 1rem;
    border: 1px dashed rgba(52, 152, 219, 0.45);
    border-radius: 16px;
    background: rgba(52, 152, 219, 0.07);
    color: var(--app-primary-dark);
    font-weight: 700;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, .9fr);
    gap: 1.5rem;
    align-items: start;
}

.settings-preview {
    display: grid;
    gap: 1.25rem;
}

.settings-brand-card {
    display: grid;
    gap: 1rem;
    justify-items: center;
    text-align: center;
}

.settings-logo-preview {
    width: min(100%, 220px);
    aspect-ratio: 1 / 1;
    border-radius: 28px;
    background: linear-gradient(135deg, var(--app-primary), #6cc5ef);
    box-shadow: var(--shadow-soft);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 2.6rem;
    font-weight: 700;
    overflow: hidden;
}

.settings-logo-preview.has-logo {
    background: #fff;
    border: 1px solid var(--app-border);
    padding: .4rem;
}

.settings-logo-preview img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 24px;
}

.settings-preview-meta {
    display: grid;
    gap: .35rem;
}

.settings-preview-meta strong {
    font-size: 1.45rem;
}

.settings-preview-meta span {
    color: var(--app-muted);
    font-weight: 700;
}

.btn {
    border-radius: 14px;
    font-weight: 700;
    min-height: 46px;
    padding: .7rem 1.2rem;
}

.btn-primary {
    background: var(--app-primary);
    border-color: var(--app-primary);
}

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

.form-control,
.form-select {
    border-radius: 14px;
    padding: .8rem 1rem;
    border-color: var(--app-border);
}

.form-label {
    font-weight: 700;
}

.sidebar-offcanvas {
    max-width: min(88vw, 340px);
    border-right: 0;
    border-left: 1px solid var(--app-border);
    background: rgba(255, 255, 255, 0.98);
}

.sidebar-offcanvas .offcanvas-header {
    padding: 1rem;
    border-bottom: 1px solid var(--app-border);
}

.sidebar-offcanvas .offcanvas-title {
    font-weight: 700;
}

.sidebar-offcanvas .offcanvas-body {
    overflow: hidden;
}

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-shell {
    width: min(100%, 520px);
}

.login-card {
    padding: 2rem;
}

.login-brand h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
}

.login-hint {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--app-border);
    color: var(--app-muted);
}

.sidebar-shell::-webkit-scrollbar,
.page-content::-webkit-scrollbar {
    width: .65rem;
}

.sidebar-shell::-webkit-scrollbar-track,
.page-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-shell::-webkit-scrollbar-thumb,
.page-content::-webkit-scrollbar-thumb {
    background: rgba(111, 125, 140, 0.3);
    border-radius: 999px;
}

.sidebar-shell::-webkit-scrollbar-thumb:hover,
.page-content::-webkit-scrollbar-thumb:hover {
    background: rgba(52, 152, 219, 0.42);
}

@media (max-width: 991.98px) {
    .app-shell,
    .layout-wrapper {
        min-height: 100vh;
        min-height: 100dvh;
        height: auto;
        overflow: visible;
    }

    .content-panel {
        min-height: 100vh;
        min-height: 100dvh;
        height: auto;
    }

    .page-content {
        overflow: visible;
        padding: 1rem;
    }

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

    .topbar {
        min-height: auto;
        padding: 1rem;
    }

    .topbar,
    .topbar-left,
    .topbar-right {
        flex-wrap: wrap;
    }

    .topbar-right {
        width: 100%;
    }

    .user-pill,
    .topbar form,
    .topbar form .btn {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    .brand-title {
        font-size: 1.05rem;
    }

    .sidebar-nav .nav-link {
        min-height: 52px;
        padding: .75rem .85rem;
        font-size: .96rem;
    }

    .page-title {
        font-size: 1.6rem;
    }
}
