/* ── CSS Variables ── */
:root {
    --bg: #f0f4fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --line: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #1e1087;
    --primary-soft: #eeecfa;
    --success-soft: #dcfce7;
    --success-text: #166534;
    --warn-soft: #fef3c7;
    --warn-text: #92400e;
    --r: 0.75rem;
}

.heading-font, h1, h2, h3, .brand-title { font-family: 'DM Sans', sans-serif; }
* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: radial-gradient(circle at 0% 0%, #e0ecff 0%, transparent 40%),
                radial-gradient(circle at 100% 0%, #e8f7ef 0%, transparent 30%),
                var(--bg);
    color: var(--text);
}

/* ── Login / portal ── */
.portal-bg { min-height: 100vh; }

.hero-shell {
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    box-shadow: 0 28px 64px rgba(15,23,42,.12);
    border-radius: var(--r);
}

.capsule {
    display: inline-block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 800;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
}

/* ── Buttons ── */
.primary-btn {
    border: 0;
    background: #1e1087;
    color: #fff;
    border-radius: var(--r);
    padding: 0.65rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.primary-btn:hover  { opacity: .9; }
.primary-btn:active { transform: scale(.98); }

.clean-btn {
    border: 1.5px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: var(--r);
    padding: 0.52rem 0.9rem;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.clean-btn:hover    { border-color: #c5c2f3; color: #1e1087; }
.clean-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ── */
.auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    font-weight: 700;
}

.clean-input {
    border: 1.5px solid var(--line);
    background: #fff;
    border-radius: var(--r);
    padding: 0.65rem 0.9rem;
    font-size: 0.9rem;
    width: 100%;
    color: var(--text);
    outline: 0;
    transition: border-color .15s, box-shadow .15s;
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.clean-input:focus {
    border-color: #a5a0e8;
    box-shadow: 0 0 0 3px rgba(30,16,135,.12);
}

/* ── App shell ── */
.admin-shell { min-height: 100vh; background: var(--bg); }
.app-wrap    { display: flex; align-items: flex-start; min-height: 100vh; }

/* ── Sidebar ── */
.left-nav {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1.5px solid var(--line);
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width 0.25s ease;
}
.left-nav::-webkit-scrollbar { width: 3px; }
.left-nav::-webkit-scrollbar-track { background: transparent; }
.left-nav::-webkit-scrollbar-thumb { background: rgba(148,163,184,.3); border-radius: 2px; }

.client-shell .left-nav {
    background: linear-gradient(180deg, #04070e 0%, #0a1a3a 55%, #0d2b5d 100%);
    border-right: 1px solid rgba(148,163,184,.18);
}

.client-shell.sidebar-collapsed .left-nav { width: 76px; }

/* ── Brand ── */
.brand-block {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 1rem 0.85rem;
    margin: -1.25rem -1rem 0;
    border-bottom: 1px solid rgba(148,163,184,.18);
}

.brand-logo {
    height: 40px; width: 40px;
    border-radius: var(--r);
    background: #111827;
    color: #fff;
    display: grid; place-items: center;
    font-weight: 800; font-size: 0.85rem;
    flex-shrink: 0;
}

.brand-sub   { margin: 0; font-size: 0.62rem; text-transform: uppercase; letter-spacing: .12em; color: #94a3b8; font-weight: 800; }
.brand-title { margin: 0; font-size: 1rem; font-weight: 800; color: #0f172a; }
.client-shell .brand-title { color: #e2e8f0; }

/* ── Navigation ── */
.menu-list { display: flex; flex-direction: column; gap: 0.15rem; }

.menu-group-title {
    display: block; width: 100%; text-align: left;
    border: 0; background: transparent; cursor: pointer;
    margin: 0.75rem 0 0.3rem; padding: 0 0.65rem;
    font-size: 0.63rem; text-transform: uppercase;
    letter-spacing: .13em; color: #9db0cf; font-weight: 800;
}

.menu-item {
    display: flex; align-items: center; gap: 0.7rem;
    text-decoration: none; color: #334155;
    padding: 0.68rem 0.85rem; border-radius: var(--r);
    font-size: 0.875rem; font-weight: 600;
    transition: background .14s, color .14s;
}
.menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.menu-item:hover, .menu-item.is-active { background: #eeecfa; color: #1e1087; }

.client-shell .menu-item { color: #c8d8f0; }
.client-shell .menu-item:hover,
.client-shell .menu-item.is-active { background: rgba(96,165,250,.2); color: #eff6ff; }

.menu-divider {
    margin: 0.5rem -1rem;
    border: 0;
    border-top: 1px solid rgba(148,163,184,.22);
}

.menu-sub {
    margin-left: 0.3rem;
    border-left: 1px dashed rgba(203,213,225,.3);
    padding-left: 0.5rem;
}
.menu-sub.is-collapsed { display: none; }

.menu-item-sub {
    display: flex; align-items: center; text-decoration: none;
    color: #475569; padding: 0.47rem 0.72rem; border-radius: var(--r);
    font-size: 0.84rem; font-weight: 600;
    transition: background .14s, color .14s;
}
.menu-item-sub:hover, .menu-item-sub.is-active { background: #eeecfa; color: #1e1087; }
.client-shell .menu-item-sub { color: #b0c4de; }
.client-shell .menu-item-sub:hover,
.client-shell .menu-item-sub.is-active { background: rgba(147,197,253,.18); color: #dbeafe; }

/* ── Sidebar submenu toggle ── */
.sidebar-parent {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
    border: 0; background: transparent;
    padding: 0.68rem 0.85rem; border-radius: var(--r);
    color: #334155; cursor: pointer;
    transition: background .14s;
}
.client-shell .sidebar-parent { color: #c8d8f0; }
.sidebar-parent:hover, .sidebar-parent.is-open { background: rgba(96,165,250,.15); }
.client-shell .sidebar-parent:hover,
.client-shell .sidebar-parent.is-open { color: #eff6ff; }

.sidebar-parent-label { display: inline-flex; align-items: center; gap: 0.7rem; font-size: 0.875rem; font-weight: 700; }
.sidebar-parent-label svg { width: 16px; height: 16px; }
.sidebar-chevron { width: 14px; height: 14px; transition: transform .2s ease; flex-shrink: 0; }
.sidebar-parent.is-open .sidebar-chevron { transform: rotate(180deg); }
.sidebar-submenu { margin-bottom: 0.2rem; }

/* ── Collapsed sidebar ── */
.client-shell.sidebar-collapsed .brand-sub,
.client-shell.sidebar-collapsed .brand-title,
.client-shell.sidebar-collapsed .menu-item span,
.client-shell.sidebar-collapsed .menu-item-sub span,
.client-shell.sidebar-collapsed .menu-divider,
.client-shell.sidebar-collapsed .menu-sub,
.client-shell.sidebar-collapsed .sidebar-parent-label span,
.client-shell.sidebar-collapsed .sidebar-chevron { display: none; }

.client-shell.sidebar-collapsed .sidebar-parent,
.client-shell.sidebar-collapsed .menu-item { justify-content: center; padding: 0.68rem; }
.client-shell.sidebar-collapsed .brand-block { justify-content: center; }
.client-shell.sidebar-collapsed .menu-item svg { margin: 0; }

/* ── Content area ── */
.content-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.top-bar {
    background: rgba(255,255,255,.95);
    border-bottom: 1.5px solid var(--line);
    padding: 0.85rem 1.75rem;
    min-height: 62px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20;
    backdrop-filter: blur(8px);
    box-shadow: 0 3px 14px rgba(0,0,0,0.05);
}

.top-left    { display: flex; align-items: center; gap: 0.85rem; }
.top-controls { display: flex; align-items: center; gap: 0.6rem; }

.icon-btn {
    height: 36px; width: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1.5px solid var(--line); border-radius: var(--r);
    background: #fff; color: #334155; cursor: pointer;
    transition: border-color .15s;
}
.icon-btn:hover { border-color: #a5a0e8; color: #1e1087; }
.icon-btn svg { width: 15px; height: 15px; }

.header-search {
    display: flex; align-items: center; gap: 0.4rem;
    border: 1.5px solid var(--line); border-radius: var(--r);
    padding: 0.42rem 0.75rem; width: 380px;
    background: var(--surface-2); transition: border-color .15s;
}
.header-search:focus-within { border-color: #a5a0e8; }
.header-search svg { width: 14px; height: 14px; color: #64748b; flex-shrink: 0; }
.header-search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 0.85rem; color: var(--text); font-family: 'Plus Jakarta Sans', sans-serif; }

.header-select {
    border: 1.5px solid var(--line); border-radius: var(--r);
    height: 36px; font-size: 0.8rem; background: #fff;
    color: #334155; padding: 0 0.5rem; cursor: pointer;
}

.avatar-tag {
    height: 36px; width: 36px; border-radius: 999px;
    display: grid; place-items: center;
    background: #1e293b; color: #fff;
    font-weight: 700; cursor: pointer; font-size: 0.85rem;
}

/* ── Main content grid ── */
.main-grid {
    padding: 2rem 2.25rem;
    display: grid; grid-template-columns: 1fr; gap: 1.75rem;
}

/* ── Admin stat tiles ── */
.stats-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }

.tile {
    background: var(--surface);
    border: 1.5px solid var(--line); border-radius: var(--r);
    padding: 1.35rem 1.5rem;
}
.tile-label { margin: 0; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 800; }
.tile-value { margin: 0.35rem 0 0; font-size: 1.65rem; font-weight: 800; font-family: 'DM Sans', sans-serif; }

/* ── Section head ── */
.section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem;
}
.section-title {
    display: inline-flex; align-items: center; gap: 0.5rem;
    font-family: 'DM Sans', sans-serif; font-size: 1.1rem; font-weight: 800; margin: 0;
}
.section-title svg { width: 17px; height: 17px; color: #1e1087; }

/* ── Panel ── */
.plain-section { border-bottom: 1px solid #dce6f4; padding-bottom: 1.35rem; }
.plain-section:last-child { border-bottom: 0; padding-bottom: 0; }

.panel { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.panel-head h2 { margin: 0; font-size: 1rem; font-weight: 800; }
.panel-head span { font-size: 0.76rem; color: var(--muted); }

.tools-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 0.75rem; }

/* ── Service icon grid ── */
.service-icon-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; }
.service-icon-item {
    border: 1.5px solid #d9e4f2; border-radius: var(--r);
    padding: 1.15rem 1.35rem;
    background: linear-gradient(180deg, #fff 0%, #f9fbff 100%);
    display: flex; align-items: center; gap: 0.9rem;
}
.service-icon-item i, .service-icon-item svg { width: 18px; height: 18px; color: #1e1087; }
.service-icon-item strong { font-family: 'DM Sans', sans-serif; font-size: 1.15rem; }

/* ── Tables ── */
.table-shell { border: 1.5px solid var(--line); border-radius: var(--r); overflow: auto; }
.table-clean { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table-clean thead { background: var(--surface-2); }
.table-clean th { text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); padding: 0.9rem 1.1rem; font-weight: 800; }
.table-clean td { padding: 0.9rem 1.1rem; border-top: 1px solid #eef2f7; }

.pager-row { margin-top: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; font-size: 0.8rem; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.85rem; }

/* ── Badges ── */
.badge { border-radius: 999px; padding: 0.2rem 0.65rem; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.badge-green { background: var(--success-soft); color: var(--success-text); }
.badge-amber { background: var(--warn-soft);    color: var(--warn-text);    }
.badge-red   { background: #fee2e2;              color: #991b1b;             }

/* ── Drawers ── */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(2,6,23,.45); opacity: 0;
    pointer-events: none; transition: opacity .2s ease; z-index: 45;
}
.drawer-overlay.show { opacity: 1; pointer-events: auto; }

.drawer {
    position: fixed; top: 0; right: 0; width: 410px;
    max-width: 93vw; height: 100vh;
    background: #fff; border-left: 1.5px solid var(--line);
    transform: translateX(100%); transition: transform .22s ease;
    z-index: 50; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-head { height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 1.1rem; border-bottom: 1px solid #e2e8f0; }
.drawer-head h3 { margin: 0; font-size: 1rem; font-weight: 800; }
.drawer-body { padding: 1.1rem; overflow: auto; }

.drawer-item { border: 1.5px solid #e2e8f0; border-radius: var(--r); padding: 0.9rem 1.1rem; margin-bottom: 0.7rem; }
.drawer-item strong { display: block; font-family: 'DM Sans', sans-serif; }
.drawer-item p { margin: .3rem 0 0; font-size: .84rem; color: #64748b; }

.profile-summary { display: flex; align-items: center; gap: 0.9rem; }
.profile-photo { width: 58px; height: 58px; border-radius: var(--r); object-fit: cover; border: 1.5px solid #cbd5e1; }
.profile-email { margin: 0; font-size: .8rem; color: #64748b; }
.profile-name  { margin: .2rem 0 0; font-family: 'DM Sans', sans-serif; font-weight: 700; }

.drawer-link { display: block; padding: 0.62rem 0.75rem; border-radius: var(--r); color: #1e293b; text-decoration: none; font-weight: 600; }
.drawer-link:hover { background: #eeecfa; color: #1e1087; }

/* ── Notification items ── */
.notif-list { border: 1.5px solid #e2e8f0; border-radius: 12px; overflow: hidden; }
.notif-item {
    display: flex; align-items: flex-start; gap: 0.65rem;
    padding: 0.9rem 1rem 0.9rem 1.4rem; background: #fff; position: relative;
    border-bottom: 1px solid #e2e8f0; transition: background .12s;
    overflow: hidden;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #f8fafc; }
.notif-unread {
    position: absolute; top: 1.1rem; left: 0.55rem;
    width: 7px; height: 7px; border-radius: 50%; background: #1e1087; flex-shrink: 0;
}
.notif-unread-green { background: #22c55e; }
.notif-icon {
    width: 36px; height: 36px; border-radius: 9px;
    display: grid; place-items: center; flex-shrink: 0;
}
.notif-icon svg { width: 15px; height: 15px; }
.notif-icon-amber { background: #fef3c7; color: #92400e; }
.notif-icon-blue  { background: #dbeafe; color: #1d4ed8; }
.notif-icon-green { background: #dcfce7; color: #166534; }
.notif-icon-rose  { background: #fee2e2; color: #991b1b; }
.notif-content { flex: 1; min-width: 0; }
.notif-content strong { display: block; font-family: 'DM Sans', sans-serif; font-size: 0.875rem; font-weight: 700; color: #0f172a; }
.notif-content p { margin: 0.2rem 0 0; font-size: 0.78rem; color: #64748b; line-height: 1.55; }
.notif-close {
    width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; padding: 0;
    border: 1.5px solid #e2e8f0; background: transparent;
    display: grid; place-items: center; cursor: pointer;
    color: #94a3b8; transition: background .12s, color .12s, border-color .12s;
}
.notif-close svg { width: 11px; height: 11px; }
.notif-close:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

/* ── Profile popup ── */
.profile-popup {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.11), 0 2px 6px rgba(0,0,0,0.05);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity .18s ease, transform .18s ease;
    z-index: 60;
}
.profile-popup.open { opacity: 1; pointer-events: auto; transform: translateY(0); }
.profile-popup-arrow {
    position: absolute;
    top: -7px; right: 11px;
    width: 13px; height: 13px;
    background: #fff;
    border-left: 1.5px solid #e2e8f0;
    border-top: 1.5px solid #e2e8f0;
    transform: rotate(45deg);
    border-radius: 2px 0 0 0;
}
.profile-popup-body { padding: 1rem; }
.profile-popup-divider { border-top: 1.5px solid #e2e8f0; margin: 0.6rem -1rem; }

/* ── Dark theme ── */
.client-shell.theme-dark { background: #0b1220; color: #dbeafe; }
.client-shell.theme-dark .content-wrap,
.client-shell.theme-dark .top-bar,
.client-shell.theme-dark .table-clean thead,
.client-shell.theme-dark .table-clean td,
.client-shell.theme-dark .header-search,
.client-shell.theme-dark .header-select,
.client-shell.theme-dark .service-icon-item,
.client-shell.theme-dark .table-shell { background: #101827; color: #dbeafe; border-color: rgba(148,163,184,.25); }
.client-shell.theme-dark .section-title svg,
.client-shell.theme-dark .service-icon-item svg { color: #60a5fa; }


/* ── Responsive ── */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
    .tools-row { grid-template-columns: 1fr 1fr; }
    .form-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .main-grid  { padding: 1.5rem; gap: 1.5rem; }
}

@media (max-width: 900px) {
    .left-nav { position: fixed; left: 0; top: 0; bottom: 0; height: 100vh; z-index: 40; width: 280px; }
    .client-shell.sidebar-collapsed .left-nav { transform: translateX(-100%); width: 280px !important; }
    .tools-row, .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr; }
    .top-bar    { padding: .7rem 1rem; }
    .header-search { width: auto; flex: 1; }
    .main-grid  { padding: 1rem; gap: 1.25rem; }
}
