:root {
    --bg: #f5f6fb;
    --card: #ffffff;
    --text: #0e1322;
    --muted: #6b778c;
    --accent: #ef6b57;
    --accent-2: #5b8def;
    --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.08);
    --radius-xl: 22px;
    --radius: 16px;
    --chip: #f8e9e6;
}

/* base */
html,
body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, Helvetica;
    margin: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    background: #fff;
    border-right: 1px solid #eef2f7;
    box-shadow: var(--shadow-soft);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 70;
    transition: transform 0.25s ease;
    transform: translateX(0);
    /* scrollable */
    height: 100vh;
    overflow-y: auto;
}
    /* desktop-capable toggle */
    .sidebar.closed {
        transform: translateX(-100%);
    }

.sb-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 8px 12px;
}

.sb-headleft {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sb-logo {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: #111;
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.sb-title {
    display: grid;
    gap: 2px;
}

    .sb-title strong {
        display: block;
        font-weight: 700;
    }

    .sb-title span {
        font-size: 12px;
        color: var(--muted);
    }

.sb-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 6px;
}

.sb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: #293241;
    text-decoration: none;
}

    .sb-item:hover {
        background: #f3f6ff;
    }

    .sb-item.active {
        background: #eef3ff;
        color: #1d4ed8;
    }

.sb-ico {
    width: 18px;
    height: 18px;
    display: inline-grid;
    place-items: center;
    color: inherit;
}

    .sb-ico svg {
        width: 18px;
        height: 18px;
    }

/* Accordion specifics */
.sb-accordion .sb-accordion-trigger {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font: inherit;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    text-align: left;
}

    .sb-accordion .sb-accordion-trigger:hover {
        background: #f3f6ff;
    }

.sb-accordion .chev {
    margin-left: auto;
    display: inline-grid;
    transition: transform 0.2s ease;
}

.sb-accordion .sb-accordion-trigger[aria-expanded='true'] .chev {
    transform: rotate(180deg);
}

.sb-sub {
    padding: 6px 6px 8px 42px; /* indent under icon area */
    display: grid;
    gap: 6px;
}

.sb-sub-item {
    color: #475569;
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 10px;
}

    .sb-sub-item:hover {
        background: #f6f7fb;
    }

/* --- Edit modal (reuses your card/buttons styles) --- */
.scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
    z-index: 90;
}

/* Sidebar overlay should sit under the sidebar so it stays sharp */
#scrim {
    z-index: 60;
}

/* Modal scrims stay above the sidebar/main content */
#searchScrim,
#editScrim,
#confirmScrim,
#uploadScrim {
    z-index: 90;
}

.scrim.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ---------- Main ---------- */
.main {
    margin-left: 250px;
    padding-bottom: 2rem;
    transition: margin-left 0.25s ease;
}

    .main.expanded {
        margin-left: 0;
    }

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
}

.page-title {
    font-size: 18px;
    margin-left: 10px;
}

.brand-inline {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
}

.topbar-actions .user {
    flex-shrink: 0;
}

.icon-btn {
    background: #fff;
    border: 1px solid #eef2f7;
    border-radius: 999px;
    padding: 10px 12px;
    display: inline-grid;
    place-items: center;
    color: #4b5563;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
}

.icon-btn--sm {
    padding: 6px 8px;
}

.user {
    display: flex;
    align-items: center;
    gap: 10px;
}

    .user img {
        width: 34px;
        height: 34px;
        border-radius: 999px;
    }

.user-info {
    display: flex;
    flex-direction: column;
}

    .user-info strong {
        font-size: 13px;
    }

    .user-info span {
        font-size: 11px;
        color: var(--muted);
    }

/* KPI row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
    padding: 0 24px 10px;
}

.card {
    background: var(--card);
    border: 1px solid #eef2f7;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    padding: 16px;
}

.kpi {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.datetime {
    grid-column: span 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

    .datetime .time {
        font-size: 36px;
        font-weight: 800;
        margin-bottom: 6px;
    }

    .datetime .date {
        font-size: 14px;
        color: var(--muted);
    }

.kpi-label {
    font-size: 12px;
    color: var(--muted);
}

.kpi-value {
    font-weight: 800;
    font-size: 20px;
}

.kpi-sub {
    font-size: 11px;
    color: #7c879a;
}

    .kpi-sub.up {
        color: var(--accent);
    }

/* Content wrapper */
.wrapper {
    width: 100%;
    margin: 0 auto 32px;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px;
    padding: 0 24px;
}

.span-3 {
    grid-column: span 3;
}

.span-4 {
    grid-column: span 4;
}

.span-6 {
    grid-column: span 6;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.card-title {
    font-size: 12px;
    color: #7a8598;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    font-weight: 700;
}

/* Charts */
.chart {
    position: relative;
    width: 100%;
}

    .chart > canvas {
        position: absolute;
        inset: 0;
        width: 100% !important;
        height: 100% !important;
        display: block;
    }

.h-240 {
    height: 240px;
}

.h-260 {
    height: 260px;
}

.h-280 {
    height: 280px;
}

.h-320 {
    height: 320px;
}

/* Lists */
.list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

    .list li {
        display: flex;
        justify-content: space-between;
        color: #475569;
        font-size: 14px;
    }

.activity {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

    .activity .dot {
        width: 8px;
        height: 8px;
        border-radius: 999px;
        background: var(--accent-2);
        display: inline-block;
        margin-right: 8px;
    }

    .activity li {
        font-size: 14px;
        color: #475569;
    }

/* Scroll limit for 3 rows (used for lists & notifications) */
.scroll-3 {
    --row-height: 42px;
    max-height: calc(var(--row-height) * 3);
    overflow: auto;
    padding-right: 6px;
}

.list li,
.activity li {
    min-height: var(--row-height);
    display: flex;
    align-items: center;
}

/* Pretty scrollbar */
.scroll-3::-webkit-scrollbar {
    width: 8px;
}

.scroll-3::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-3::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 999px;
}

.scroll-3 {
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb transparent;
}

/* ---------- Responsive ---------- */

/* Laptops */
@media (max-width: 1280px) {
    .kpi {
        grid-column: span 3;
    }
}

/* Tablets: keep width smaller; toggle is handled in JS via classes */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .main {
        margin-left: 0; /* when closed on tablet, content uses full width */
    }

    .span-4,
    .span-3 {
        grid-column: span 6;
    }
}

/* KPI cards go full width under ~930px */
@media (max-width: 930px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }

    .kpi,
    .datetime {
        grid-column: 1 / -1;
    }
}

/* Phones */
@media (max-width: 760px) {
    .grid {
        padding: 0 16px;
    }

    .span-6,
    .span-4,
    .span-3 {
        grid-column: span 12;
    }

    .h-320 {
        height: 280px;
    }
}

/* Stacked column wrapper so small list cards don't create big white gaps */
.stack {
    display: grid;
    gap: 14px;
    align-content: start;
}

/* Make list cards more compact */
.card--compact {
    padding: 12px;
}

    .card--compact .card-head {
        margin-bottom: 6px;
    }

    /* Slightly tighter list rows for compact cards */
    .card--compact .scroll-3 {
        --row-height: 36px;
    }

/* Right-side stacked column fills the full grid row height */
.stack-col {
    display: grid;
    gap: 14px;
    grid-template-rows: 1fr 1fr;
    height: 100%;
    align-content: stretch;
}

/* Compact cards become flexible containers */
.card--compact {
    padding: 12px;
    display: flex;
    flex-direction: column;
}

    .card--compact .card-head {
        margin-bottom: 6px;
    }

    /* The list inside compact cards grows to fill card height */
    .card--compact .scroll-3 {
        --row-height: 36px;
        flex: 1;
        max-height: none;
        overflow: auto;
    }

/* Notifications dropdown */
.notif {
    position: relative;
}

.notif-panel {
    position: absolute;
    left: -3rem;
    top: calc(100% + 8px);
    width: 320px;
    background: var(--card);
    border: 1px solid #eef2f7;
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 20px;
    z-index: 80;
}

.notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.link-btn {
    background: none;
    border: none;
    color: #2563eb;
    font-weight: 600;
    cursor: pointer;
}

.notif-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-left: 0;
}

    .notif-list li {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 8px 10px;
        border-radius: 10px;
        background: #fafbff;
        border: 1px solid #eef2f7;
    }

        .notif-list li .notif-text {
            color: #475569;
            font-size: 14px;
        }

        .notif-list li.empty {
            background: transparent;
            border: none;
            color: #94a3b8;
            justify-content: center;
        }

.x-btn {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: #94a3b8;
}

    .x-btn:hover {
        color: #ef4444;
    }

/* Ensure hidden attribute fully hides (accordion reliability) */
[hidden] {
    display: none !important;
}

@media (max-width: 600px) {
    .page-title {
        display: none;
    }
}

@media (max-width: 779px) {
    .main {
        margin-left: 0;
    }
}

.mainEmpty {
    padding-bottom: 2rem;
    transition: margin-left 0.25s ease;
}

/* === Toasts (top-right) === */
.toasts {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 140; /* above modals & overlay */
    pointer-events: none; /* clicks pass through except the toast itself */
}

.toast {
    pointer-events: auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: min(380px, 90vw);
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    color: #0f172a;
    box-shadow: var(--shadow-soft);
    /* Animation and transition */
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
    transition: opacity 0.25s ease, transform 0.25s ease;
    /* 👇 Center of the screen */
    position: fixed;
    top: 25%;
    left: 50%;
    z-index: 9999;
}

    /* 👇 When showing */
    .toast.show {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }


.toast__icon {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
}

.toast__text {
    font-size: 14px;
    line-height: 1.35;
}

.toast__close {
    border: 0;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: #64748b;
    padding: 2px 6px;
    border-radius: 8px;
}

    .toast__close:hover {
        background: #f1f5f9;
    }

/* Success / Danger variants (light backgrounds) */
.toast--success {
    background: #f0fdf4; /* green-50 */
    border-color: #bbf7d0; /* green-200 */
    color: #166534; /* green-800 */
}

.toast--danger {
    background: #fef2f2; /* red-50 */
    border-color: #fecaca; /* red-200 */
    color: #7f1d1d; /* red-900 */
}

/* Optional icons tint */
.toast--success .toast__icon {
    color: #16a34a;
}
/* green-600 */
.toast--danger .toast__icon {
    color: #dc2626;
}
/* red-600 */
