:root {
    --pf-font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
    --pf-bg: #f3f5fb;
    --pf-surface: #ffffff;
    --pf-ink: #111827;
    --pf-muted: #6b7280;
    --pf-line: #e6e8f0;
    --pf-primary: #4f46e5;
    --pf-primary-dark: #4338ca;
    --pf-primary-soft: #eef2ff;
    --pf-teal: #0f766e;
    --pf-sidebar: #0f172a;
    --pf-sidebar-2: #111c34;
    --pf-radius: 16px;
    --pf-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px rgba(15, 23, 42, .05);
}

* { font-family: var(--pf-font); }

body {
    background: var(--pf-bg);
    color: var(--pf-ink);
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
    background: var(--pf-bg);
}

.app-sidebar {
    background: linear-gradient(180deg, var(--pf-sidebar) 0%, var(--pf-sidebar-2) 100%);
    box-shadow: 12px 0 40px rgba(15, 23, 42, .12);
    padding: 1.15rem .9rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.app-main {
    min-width: 0;
}

.app-content {
    padding: 1.4rem 0 2.5rem;
}

.navbar-vertical {
    width: 272px;
    background: linear-gradient(180deg, var(--pf-sidebar) 0%, var(--pf-sidebar-2) 100%) !important;
    border-right: 0;
    box-shadow: 12px 0 40px rgba(15, 23, 42, .12);
}

.navbar-vertical .container-fluid {
    padding: 1.1rem .9rem 1.5rem;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .35rem .4rem 1.15rem;
    text-decoration: none;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    letter-spacing: -.04em;
    background: linear-gradient(135deg, #6366f1, #4f46e5 55%, #0ea5e9);
    box-shadow: 0 10px 24px rgba(79, 70, 229, .35);
}

.brand-copy {
    color: #fff;
}

.brand-copy strong {
    display: block;
    font-size: .98rem;
    line-height: 1.15;
}

.brand-copy small {
    color: #94a3b8;
    font-size: .75rem;
}

.app-nav {
    list-style: none;
    margin: 0;
    padding: 0;
}

.app-nav a,
.navbar-vertical .nav-link {
    color: #cbd5e1 !important;
    text-decoration: none;
    border-radius: 12px;
    margin: .15rem 0;
    padding: .7rem .85rem;
    display: flex;
    align-items: center;
    gap: .7rem;
    font-weight: 550;
}

.app-nav a i,
.navbar-vertical .nav-link i {
    font-size: 1.15rem;
    width: 1.3rem;
    color: #94a3b8;
}

.app-nav a:hover,
.navbar-vertical .nav-link:hover {
    background: rgba(255,255,255,.06);
    color: #fff !important;
}

.app-nav a.active,
.navbar-vertical .nav-link.active {
    background: linear-gradient(90deg, rgba(99,102,241,.28), rgba(99,102,241,.08));
    color: #fff !important;
    box-shadow: inset 0 0 0 1px rgba(165,180,252,.18);
}

.app-nav a.active i,
.navbar-vertical .nav-link.active i {
    color: #c7d2fe;
}

.nav-section {
    color: #64748b;
    font-size: .7rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    padding: 1.1rem .85rem .35rem;
    font-weight: 700;
}

.page-wrapper {
    margin-left: 0;
    background: transparent;
}

.topbar {
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--pf-line);
    min-height: 72px;
    padding: .7rem 0;
}

.topbar .container-xl {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar-title {
    font-weight: 800;
    font-size: 1.05rem;
    margin: 0;
}

.topbar-sub {
    color: var(--pf-muted);
    font-size: .82rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .7rem;
    background: #f8fafc;
    border: 1px solid var(--pf-line);
    border-radius: 999px;
    padding: .28rem .7rem .28rem .3rem;
}

.user-chip .meta {
    line-height: 1.15;
}

.user-chip .meta strong {
    display: block;
    font-size: .82rem;
}

.user-chip .meta small {
    color: var(--pf-muted);
    font-size: .72rem;
}

.btn {
    border-radius: 11px;
    font-weight: 650;
    padding: .52rem .95rem;
}

.btn-primary {
    background: var(--pf-primary);
    border-color: var(--pf-primary);
    box-shadow: 0 8px 18px rgba(79, 70, 229, .22);
}

.btn-primary:hover {
    background: var(--pf-primary-dark);
    border-color: var(--pf-primary-dark);
}

.btn-ghost {
    background: #fff;
    border: 1px solid var(--pf-line);
    color: var(--pf-ink);
}

.page-body {
    padding-top: 1.4rem;
}

.page-header .page-title {
    font-weight: 800;
    letter-spacing: -.03em;
}

.card {
    border: 1px solid #edf0f7;
    border-radius: var(--pf-radius);
    box-shadow: var(--pf-shadow);
}

.card-header {
    background: transparent;
    border-bottom-color: var(--pf-line);
    padding: 1rem 1.15rem;
}

.card-title {
    font-weight: 750;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card .card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
}

.stat-icon.indigo { background: #eef2ff; color: #4f46e5; }
.stat-icon.teal { background: #ccfbf1; color: #0f766e; }
.stat-icon.amber { background: #fef3c7; color: #b45309; }
.stat-icon.rose { background: #ffe4e6; color: #e11d48; }

.stat-label {
    color: var(--pf-muted);
    font-size: .78rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .2rem;
}

.stat-value {
    font-size: 1.28rem;
    font-weight: 800;
    letter-spacing: -.03em;
    margin: 0;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
    font-size: .78rem;
    font-weight: 800;
    color: #fff;
    flex: none;
}

.avatar-sm { width: 32px; height: 32px; font-size: .7rem; border-radius: 10px; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.05rem; border-radius: 16px; }
.avatar-indigo { background: linear-gradient(135deg, #6366f1, #4338ca); }
.avatar-teal { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.avatar-amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.avatar-rose { background: linear-gradient(135deg, #fb7185, #e11d48); }
.avatar-sky { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.avatar-violet { background: linear-gradient(135deg, #a78bfa, #7c3aed); }

.entity {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.entity-name {
    font-weight: 700;
    color: var(--pf-ink);
    text-decoration: none;
}

.entity-name:hover { color: var(--pf-primary); }
.entity-meta { color: var(--pf-muted); font-size: .78rem; }

.table {
    --tblr-table-bg: transparent;
}

.table thead th {
    color: #6b7280;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 750;
    background: #f8fafc;
    border-bottom: 1px solid var(--pf-line);
}

.table tbody td {
    vertical-align: middle;
    border-color: #f1f5f9;
    padding-top: .9rem;
    padding-bottom: .9rem;
}

.table-hover tbody tr:hover {
    background: #f8faff;
}

.badge {
    border-radius: 999px;
    font-weight: 700;
    padding: .35em .7em;
}

.pf-tabs {
    display: flex;
    gap: .4rem;
    background: #eef1f8;
    padding: .3rem;
    border-radius: 14px;
    width: fit-content;
    margin-bottom: 1.1rem;
}

.pf-tabs a {
    color: #4b5563;
    text-decoration: none;
    padding: .55rem .95rem;
    border-radius: 11px;
    font-weight: 700;
    font-size: .9rem;
}

.pf-tabs a.active {
    background: #fff;
    color: var(--pf-ink);
    box-shadow: 0 6px 16px rgba(15, 23, 42, .08);
}

.toolbar {
    background: #fff;
    border: 1px solid #edf0f7;
    border-radius: var(--pf-radius);
    box-shadow: var(--pf-shadow);
    padding: .9rem;
    margin-bottom: 1rem;
}

.aging-row {
    display: grid;
    grid-template-columns: 130px 1fr auto auto;
    gap: .8rem;
    align-items: center;
    padding: .7rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.aging-row:last-child { border-bottom: 0; }

.bar {
    height: 8px;
    background: #eef2ff;
    border-radius: 99px;
    overflow: hidden;
}

.bar > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #22d3ee);
    border-radius: 99px;
}

.timeline {
    position: relative;
    padding-left: 1.4rem;
}

.timeline::before {
    content: "";
    position: absolute;
    left: .42rem;
    top: .3rem;
    bottom: .3rem;
    width: 2px;
    background: #e5e7eb;
}

.timeline-item {
    position: relative;
    padding: 0 0 1.2rem;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -1.22rem;
    top: .35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4f46e5;
    box-shadow: 0 0 0 4px #eef2ff;
}

.note-card {
    background: #f8fafc;
    border: 1px solid #eef2f7;
    border-radius: 14px;
    padding: .9rem 1rem;
}

.company-hero {
    background: linear-gradient(135deg, #111827, #1e1b4b 60%, #312e81);
    color: #fff;
    border: 0;
    overflow: hidden;
}

.company-hero .text-secondary,
.company-hero .entity-meta { color: #c7d2fe !important; }
.company-hero a.btn-ghost { color: #111827; }

.alert {
    border: 0;
    border-radius: 14px;
}

.form-control, .form-select {
    border-radius: 11px;
    border-color: #e5e7eb;
    min-height: 42px;
}

.form-control:focus, .form-select:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(280px, 1.05fr) minmax(360px, .95fr);
    background: #0f172a;
}

.login-art {
    padding: 3rem;
    color: #fff;
    background:
        radial-gradient(circle at 20% 20%, rgba(99,102,241,.35), transparent 28%),
        radial-gradient(circle at 80% 80%, rgba(14,165,233,.25), transparent 32%),
        linear-gradient(180deg, #0f172a, #111827);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-panel {
    background: #fff;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.login-card { width: min(420px, 100%); }

.empty-state {
    text-align: center;
    padding: 2.4rem 1rem;
    color: var(--pf-muted);
}

.danger-card {
    border-color: #fecdd3;
}

.danger-card .card-header {
    background: #fff1f2;
}

.btn-danger {
    background: #e11d48;
    border-color: #e11d48;
    color: #fff;
    box-shadow: 0 8px 18px rgba(225, 29, 72, .18);
}

.btn-danger:hover {
    background: #be123c;
    border-color: #be123c;
    color: #fff;
}

.backup-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
}

.assignment-heading {
    font-size: .92rem;
    font-weight: 750;
    margin: 0 0 .75rem;
}

.assignment-unit {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .85rem 1rem;
    border: 1px solid var(--pf-line);
    border-radius: 12px;
    margin-bottom: .6rem;
    background: #f8fafc;
}

.assignment-unit input {
    margin-top: .2rem;
}

.assignment-unit strong {
    display: block;
}

.assignment-unit small {
    color: var(--pf-muted);
}

.assignment-group {
    border: 1px solid var(--pf-line);
    border-radius: 12px;
    margin-bottom: .75rem;
    overflow: hidden;
}

.assignment-group-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .7rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--pf-line);
}

.assignment-group-head strong {
    margin-right: auto;
}

.assignment-companies {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: .15rem .75rem;
    padding: .75rem 1rem 1rem;
}

.assignment-company {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .25rem 0;
    font-size: .9rem;
}

@media (max-width: 991px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-art { display: none; }
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar { position: relative; height: auto; }
}
