:root {
    --bg: #09111f;
    --panel: #101826;
    --panel-2: #182336;
    --line: rgba(255,255,255,.09);
    --text: #edf2f7;
    --muted: #9aa8bd;
    --accent: #14b8a6;
    --accent-2: #f97316;
    --green: #22c55e;
    --amber: #f59e0b;
    --rose: #e11d48;
}

:root.light-mode {
    --bg: #f6f8fb;
    --panel: #ffffff;
    --panel-2: #eef4f7;
    --line: rgba(29,78,90,.14);
    --text: #172033;
    --muted: #607083;
    --accent: #087f7a;
    --accent-2: #d97706;
    --green: #15803d;
    --amber: #b45309;
    --rose: #be123c;
}

body.admin-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(20,184,166,.16), transparent 32%),
        radial-gradient(circle at top right, rgba(249,115,22,.10), transparent 30%),
        var(--bg);
    color: var(--text);
    font-size: 15px;
    letter-spacing: 0;
}

html.light-mode body.admin-body {
    background:
        radial-gradient(circle at top left, rgba(8,127,122,.10), transparent 34%),
        radial-gradient(circle at top right, rgba(217,119,6,.10), transparent 30%),
        linear-gradient(180deg, #f9fbfd 0%, #edf4f7 100%);
}

a { text-decoration: none; }

.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 270px;
    background: linear-gradient(180deg, #08111d 0%, #101826 55%, #0b1320 100%);
    border-right: 1px solid var(--line);
    padding: 22px 18px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
    transition: width .2s ease, transform .2s ease;
}
.sidebar-collapse-btn {
    position: absolute;
    top: 22px;
    right: 16px;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-color: rgba(255,255,255,.18);
    background: rgba(255,255,255,.04);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    margin-bottom: 30px;
}

.brand:hover { color: #fff; }
.brand-icon {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #04221f;
}
.brand small { display: block; color: var(--muted); font-size: 12px; }
.sidebar-label { color: var(--muted); text-transform: uppercase; font-size: 12px; margin: 18px 12px 8px; }
.sidebar .nav-link {
    color: #cbd5e1;
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar .nav-link i { width: 20px; text-align: center; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { background: rgba(20,184,166,.14); color: #fff; }
.sidebar .nav-link.active { border-left: 3px solid var(--accent-2); }

.admin-main { margin-left: 270px; width: calc(100% - 270px); min-height: 100vh; transition: margin-left .2s ease, width .2s ease; }
body.sidebar-collapsed .sidebar, .admin-layout.sidebar-collapsed .sidebar { width: 84px; padding-left: 14px; padding-right: 14px; }
html.sidebar-collapsed .sidebar,
body.sidebar-collapsed .sidebar,
.admin-layout.sidebar-collapsed .sidebar { width: 84px; padding-left: 14px; padding-right: 14px; }
html.sidebar-collapsed .brand span:last-child,
html.sidebar-collapsed .sidebar-label,
html.sidebar-collapsed .sidebar .nav-link span,
.sidebar-collapsed .brand span:last-child,
.sidebar-collapsed .sidebar-label,
.sidebar-collapsed .sidebar .nav-link span { display: none; }
html.sidebar-collapsed .brand,
.sidebar-collapsed .brand { justify-content: center; margin-top: 42px; }
html.sidebar-collapsed .sidebar-collapse-btn,
.sidebar-collapsed .sidebar-collapse-btn { right: 24px; top: 18px; }
html.sidebar-collapsed .sidebar .nav-link,
.sidebar-collapsed .sidebar .nav-link { justify-content: center; padding-left: 12px; padding-right: 12px; }
html.sidebar-collapsed .admin-main,
body.sidebar-collapsed .admin-main,
.admin-layout.sidebar-collapsed .admin-main { margin-left: 84px; width: calc(100% - 84px); }
.topbar {
    height: 72px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(9, 17, 31, .88);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}
.content-wrap { padding: 28px; }
.content-fullscreen { padding: 14px; }
.breadcrumb-dark .breadcrumb-item, .breadcrumb-dark a { color: var(--muted); }
.breadcrumb-dark .active { color: #fff; }

.page-title { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 22px; }
.page-title h1 { font-size: 28px; margin: 0; }
.card-dark {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    box-shadow: 0 14px 34px rgba(0,0,0,.22);
}
.stat-card { padding: 22px; min-height: 128px; }
.stat-icon {
    width: 46px;
    height: 46px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    color: #07111f;
    background: var(--accent);
}
.stat-value { font-size: 34px; font-weight: 700; line-height: 1.1; }
.muted { color: var(--muted); }
.table-darkish { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--line); }
.form-control, .form-select {
    background-color: #0b1220;
    border-color: var(--line);
    color: var(--text);
}

html.light-mode .sidebar {
    background: linear-gradient(180deg, #ffffff 0%, #eef7f5 100%);
    box-shadow: 8px 0 28px rgba(15,23,42,.08);
}
html.light-mode .brand-icon {
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(8,127,122,.22);
}
html.light-mode .sidebar-label {
    color: #708092;
}
html.light-mode .sidebar .nav-link,
html.light-mode .brand,
html.light-mode .topbar,
html.light-mode .table-darkish {
    color: var(--text);
}
html.light-mode .sidebar .nav-link {
    color: #4b5d70;
}
html.light-mode .sidebar .nav-link:hover,
html.light-mode .sidebar .nav-link.active {
    background: rgba(8,127,122,.10);
    color: #075e59;
}
html.light-mode .sidebar .nav-link.active {
    border-left-color: #d97706;
}
html.light-mode .topbar,
html.light-mode .form-control,
html.light-mode .form-select,
html.light-mode .dataTables_wrapper .dataTables_filter input,
html.light-mode .dataTables_wrapper .dataTables_length select {
    background: #ffffff;
    color: var(--text);
}
html.light-mode .card-dark {
    box-shadow: 0 12px 28px rgba(15,23,42,.08);
}
html.light-mode .modal-content,
html.light-mode .card-dark {
    background: #ffffff;
    border-color: rgba(31,89,101,.14);
}
html.light-mode .breadcrumb-dark .active,
html.light-mode .page-title h1,
html.light-mode .profile-name {
    color: #142033;
}
html.light-mode .breadcrumb-dark .breadcrumb-item,
html.light-mode .breadcrumb-dark a,
html.light-mode .muted,
html.light-mode .dataTables_wrapper,
html.light-mode .dataTables_info,
html.light-mode .dataTables_length,
html.light-mode .dataTables_filter {
    color: #637387 !important;
}
html.light-mode .form-control,
html.light-mode .form-select,
html.light-mode .dataTables_wrapper .dataTables_filter input,
html.light-mode .dataTables_wrapper .dataTables_length select,
html.light-mode .page-link {
    background: #ffffff;
    color: var(--text);
    border-color: rgba(29,78,90,.16);
}
html.light-mode .form-control:focus,
html.light-mode .form-select:focus {
    background: #ffffff;
    color: var(--text);
    border-color: #087f7a;
    box-shadow: 0 0 0 .2rem rgba(8,127,122,.14);
}
html.light-mode .form-control::placeholder {
    color: #8795a7;
}
html.light-mode .table-darkish {
    --bs-table-color: #172033;
    --bs-table-border-color: rgba(31,89,101,.13);
}
html.light-mode .table-darkish > :not(caption) > * > * {
    color: #172033;
    background-color: transparent;
    border-bottom-color: rgba(31,89,101,.13);
}
html.light-mode .table-darkish tbody tr:hover > * {
    background: rgba(8,127,122,.055);
}
html.light-mode .dropdown-menu-dark {
    background: #ffffff;
    border-color: rgba(29,78,90,.16);
    box-shadow: 0 18px 36px rgba(15,23,42,.12);
}
html.light-mode .dropdown-menu-dark .dropdown-item {
    color: var(--text);
}
html.light-mode .dropdown-menu-dark .dropdown-item:hover {
    background: rgba(8,127,122,.10);
}
html.light-mode .btn-outline-light {
    color: #164e63;
    border-color: rgba(22,78,99,.32);
}
html.light-mode .btn-outline-light:hover {
    background: #e6f3f2;
    color: #0f3f46;
}
html.light-mode .table-darkish a {
    color: #087f7a;
}
html.light-mode .badge-soft {
    background: rgba(217,119,6,.12);
    color: #9a4d00;
    border-color: rgba(217,119,6,.24);
}
html.light-mode .table-darkish thead th,
html.light-mode .details-table th,
html.light-mode .member-list-table thead th {
    background: #f8fafc;
}
html.light-mode .page-link:hover {
    background: #edf7f6;
    color: #075e59;
}
html.light-mode .page-item.active .page-link {
    background: #087f7a;
    border-color: #087f7a;
    color: #ffffff;
}
html.light-mode .relation-preview {
    color: #526579;
}
.form-control:focus, .form-select:focus {
    background-color: #0b1220;
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(34,211,238,.14);
}
.form-control::placeholder { color: #64748b; }
.modal-content { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.btn-info { background: var(--accent); border-color: var(--accent); color: #04221f; font-weight: 700; }
.btn-info:hover { background: #0f9f91; border-color: #0f9f91; color: #fff; }
.badge-soft { background: rgba(249,115,22,.14); color: #fdba74; border: 1px solid rgba(249,115,22,.28); }
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select {
    background: #0b1220;
    border: 1px solid var(--line);
    color: var(--text);
}
.dataTables_wrapper, .dataTables_info, .dataTables_length, .dataTables_filter { color: var(--muted) !important; }
.page-link { background: #0b1220; border-color: var(--line); color: var(--text); }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: #04221f; }
.details-title { margin-bottom: 14px; }
.details-panel, .details-toolbar { border-color: rgba(34,211,238,.18); }
.list-panel-header {
    padding: 4px 2px 14px;
    border-bottom: 1px solid var(--line);
}
.list-panel-header h1 {
    color: var(--text);
}
.list-panel-header > div:last-child {
    max-width: 100%;
}
.member-table-wrap {
    max-height: calc(100vh - 260px);
    overflow: auto;
}
.details-table-wrap { max-height: calc(100vh - 260px); overflow: auto; }
.details-table { font-size: 12px; white-space: nowrap; }
.table-darkish thead th,
.member-list-table thead th,
.details-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #111827;
}
.table-darkish thead th,
.member-list-table thead th {
    box-shadow: 0 1px 0 var(--line);
}
.table-responsive thead {
    position: sticky;
    top: 0;
    z-index: 5;
}
.table-responsive thead th {
    white-space: nowrap;
}
.compact-list-table {
    font-size: 13px;
}
.compact-list-table > :not(caption) > * > * {
    padding: .48rem .6rem;
}
.details-table td, .details-table th { padding: .45rem .55rem; vertical-align: top; }
.details-table td:nth-child(17) {
    max-width: 280px;
    white-space: normal;
    min-width: 180px;
}
.member-photo-preview {
    width: 76px;
    height: 76px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}
.member-photo-large {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}
.profile-card {
    overflow: hidden;
}
.profile-hero {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 22px;
    align-items: center;
    padding: 22px;
    background: linear-gradient(135deg, rgba(20,184,166,.16), rgba(249,115,22,.08));
    border-bottom: 1px solid var(--line);
}
.profile-photo-wrap {
    width: 170px;
    height: 170px;
    border-radius: 8px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    display: grid;
    place-items: center;
    overflow: hidden;
}
.profile-photo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.profile-photo-placeholder {
    font-size: 52px;
    color: var(--muted);
}
.profile-name {
    font-size: 32px;
    line-height: 1.15;
    margin: 0 0 8px;
}
.profile-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.profile-pill {
    border: 1px solid var(--line);
    background: rgba(255,255,255,.06);
    border-radius: 999px;
    padding: 6px 10px;
    color: var(--text);
    font-size: 13px;
}
html.light-mode .profile-pill {
    background: rgba(255,255,255,.72);
}
.profile-type {
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: .06em;
}
html.light-mode .profile-hero {
    background:
        linear-gradient(135deg, rgba(8,127,122,.12), rgba(217,119,6,.08)),
        #f8fbfc;
}
html.light-mode .profile-photo-wrap {
    background: #ffffff;
    box-shadow: 0 12px 28px rgba(15,23,42,.10);
}
html.light-mode .profile-section-title {
    color: #087f7a;
}
.profile-section {
    padding: 18px 22px;
    border-top: 1px solid var(--line);
}
.profile-section:first-of-type {
    border-top: 0;
}
.profile-section-title {
    font-size: 15px;
    margin: 0 0 14px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.profile-field {
    min-height: 58px;
    background: rgba(255,255,255,.035);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}
.profile-field-wide {
    grid-column: 1 / -1;
}
html.light-mode .profile-field {
    background: #f8fbfc;
    border-color: rgba(31,89,101,.12);
}
.profile-label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}
.profile-value {
    color: var(--text);
    overflow-wrap: anywhere;
}
.profile-value.empty {
    color: var(--muted);
}
.profile-relations {
    overflow: hidden;
}
.member-photo-thumb {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}
.relation-preview {
    min-width: 180px;
    max-width: 280px;
    white-space: normal;
    font-size: 13px;
    color: #cbd5e1;
}
.relation-create-box {
    border-color: rgba(255,255,255,.12) !important;
}
.column-menu {
    min-width: 180px;
}
.column-menu .dropdown-item {
    cursor: pointer;
    user-select: none;
}
.table-toolbar,
.details-toolbar {
    row-gap: 10px;
}
.datatable-control-target .toolbar-control {
    margin: 0;
}
.datatable-control-target .dataTables_length label,
.datatable-control-target .dataTables_filter label,
.datatable-control-target .toolbar-control label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    min-height: 31px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255,255,255,.035);
    color: var(--muted);
    font-size: 13px;
}
.datatable-control-target .dataTables_filter input,
.datatable-control-target .dataTables_length select,
.datatable-control-target .toolbar-control input,
.datatable-control-target .toolbar-control select {
    margin-left: 0;
    height: 29px;
    min-height: 29px;
    padding-top: 2px;
    padding-bottom: 2px;
    border-radius: 6px;
    font-size: 13px;
}
html.light-mode .datatable-control-target .toolbar-control label {
    background: #f8fbfc;
    border-color: rgba(31,89,101,.14);
}
.toolbar-status {
    min-height: 31px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255,255,255,.035);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
html.light-mode .toolbar-status {
    background: #f8fbfc;
    border-color: rgba(31,89,101,.14);
    color: #637387;
}
.datatable:not(.dt-ready) {
    visibility: hidden;
}
.dataTables_wrapper {
    min-height: 140px;
}
.selected-count {
    min-width: 92px;
    text-align: center;
}
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2,6,23,.62);
    z-index: 2000;
    display: grid;
    place-items: center;
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.show { transform: translateX(0); }
    .admin-main { margin-left: 0; width: 100%; }
    .content-wrap { padding: 18px; }
    .page-title { align-items: flex-start; flex-direction: column; }
    .profile-hero { grid-template-columns: 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
}
