:root {
    --app-bg: #f8fafc;
    --app-surface: #ffffff;
    --app-surface-soft: #f1f5f9;
    --app-sidebar: #0f172a;
    --app-sidebar-muted: #94a3b8;
    --app-text: #172033;
    --app-muted: #64748b;
    --app-border: #e2e8f0;
    --app-primary: #635bff;
    --app-primary-dark: #4f46e5;
    --app-primary-soft: #eef2ff;
    --app-success: #10b981;
    --app-warning: #f59e0b;
    --app-danger: #ef4444;
    --app-radius: 18px;
    --app-shadow: 0 10px 35px rgba(15, 23, 42, .06);
    --sidebar-width: 272px;
}

.border-dashed {
    border-style: dashed !important;
}

#importDropzone {
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease, transform .2s ease;
}

#importDropzone:hover,
#importDropzone:focus-visible,
#importDropzone.border-primary {
    background: rgba(99, 91, 255, .06) !important;
    border-color: #635bff !important;
    outline: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--app-text);
    background: var(--app-bg);
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: .925rem;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

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

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1035;
    width: var(--sidebar-width);
    padding: 24px 18px;
    overflow-y: auto;
    color: #fff;
    background:
        radial-gradient(circle at 15% 0, rgba(99, 91, 255, .28), transparent 27%),
        var(--app-sidebar);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 8px 26px;
    color: #fff;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 14px;
    background: linear-gradient(145deg, #7c3aed, #4f46e5);
    box-shadow: 0 10px 24px rgba(79, 70, 229, .38);
    font-size: 1.15rem;
}

.brand-copy strong,
.brand-copy small { display: block; }
.brand-copy strong { font-size: .98rem; letter-spacing: -.02em; }
.brand-copy small { margin-top: 2px; color: var(--app-sidebar-muted); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }

.sidebar-label {
    margin: 12px 10px 8px;
    color: #64748b;
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.sidebar-nav { display: grid; gap: 5px; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 0 13px;
    color: #aebbd0;
    border: 1px solid transparent;
    border-radius: 13px;
    text-decoration: none;
    font-size: .87rem;
    font-weight: 600;
    transition: .2s ease;
}

.sidebar-link i {
    width: 20px;
    color: #8392aa;
    font-size: 1.05rem;
    text-align: center;
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255,255,255,.055);
}

.sidebar-link.active {
    color: #fff;
    border-color: rgba(129, 140, 248, .23);
    background: linear-gradient(90deg, rgba(99, 91, 255, .27), rgba(99, 91, 255, .1));
    box-shadow: inset 3px 0 0 #818cf8;
}

.sidebar-link.active i { color: #a5b4fc; }

.sidebar-summary {
    margin-top: 28px;
    padding: 16px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    background: rgba(255,255,255,.04);
}

.sidebar-summary .summary-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: 12px;
    color: #c4b5fd;
    border-radius: 10px;
    background: rgba(124,58,237,.2);
}

.sidebar-summary strong { display: block; font-size: .82rem; }
.sidebar-summary p { margin: 5px 0 0; color: var(--app-sidebar-muted); font-size: .72rem; line-height: 1.6; }

.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1025;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 12px 30px;
    border-bottom: 1px solid rgba(226,232,240,.88);
    background: rgba(248,250,252,.88);
    backdrop-filter: blur(16px);
}

.topbar-eyebrow { margin-bottom: 2px; color: var(--app-muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.topbar-title { margin: 0; font-size: 1rem; font-weight: 800; letter-spacing: -.02em; }

.mobile-menu-button,
.topbar-icon-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #475569;
    border: 1px solid var(--app-border);
    border-radius: 13px;
    background: #fff;
}

.user-menu-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 7px 5px 5px;
    color: var(--app-text);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    background: #fff;
}

.user-avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: #fff;
    border-radius: 11px;
    background: linear-gradient(145deg, #8b5cf6, #4f46e5);
    font-size: .78rem;
    font-weight: 800;
}

.user-copy { min-width: 92px; text-align: left; }
.user-copy strong, .user-copy small { display: block; }
.user-copy strong { max-width: 130px; overflow: hidden; font-size: .78rem; text-overflow: ellipsis; }
.user-copy small { margin-top: 1px; color: var(--app-muted); font-size: .65rem; text-transform: capitalize; }

.dropdown-menu {
    padding: 8px;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--app-shadow);
}

.dropdown-item { padding: 9px 11px; border-radius: 9px; font-size: .82rem; }

.app-content { width: 100%; max-width: 1680px; margin: 0 auto; padding: 30px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.page-kicker { margin-bottom: 7px; color: var(--app-primary); font-size: .69rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.page-title { margin: 0; font-size: clamp(1.55rem, 2.2vw, 2.15rem); font-weight: 800; letter-spacing: -.045em; }
.page-subtitle { max-width: 680px; margin: 7px 0 0; color: var(--app-muted); font-size: .86rem; line-height: 1.6; }

.card,
.saas-card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: var(--app-surface);
    box-shadow: var(--app-shadow);
}

.card-header,
.card-footer { border-color: var(--app-border); }
.card-header:first-child { border-radius: var(--app-radius) var(--app-radius) 0 0; }
.card-footer:last-child { border-radius: 0 0 var(--app-radius) var(--app-radius); }

.btn {
    min-height: 42px;
    padding: .62rem 1rem;
    border-radius: 12px;
    font-size: .8rem;
    font-weight: 700;
}

.btn-sm { min-height: 34px; padding: .38rem .65rem; border-radius: 10px; }
.btn-primary { border-color: var(--app-primary); background: var(--app-primary); box-shadow: 0 8px 20px rgba(99,91,255,.2); }
.btn-primary:hover, .btn-primary:focus { border-color: var(--app-primary-dark); background: var(--app-primary-dark); }
.btn-light { border-color: var(--app-border); background: #fff; }
.btn-icon { display: inline-grid; place-items: center; width: 38px; min-height: 38px; padding: 0; }

.form-label { margin-bottom: 7px; color: #334155; font-size: .75rem; font-weight: 700; }
.form-control, .form-select {
    min-height: 44px;
    padding: .65rem .85rem;
    border-color: #dbe3ee;
    border-radius: 11px;
    background-color: #fff;
    font-size: .82rem;
}
.form-control:focus, .form-select:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 4px rgba(99,91,255,.1);
}
.input-group-text { border-color: #dbe3ee; border-radius: 11px; background: #fff; }

.metric-card {
    position: relative;
    height: 100%;
    padding: 20px;
    overflow: hidden;
}

.metric-card::after {
    position: absolute;
    top: -42px;
    right: -42px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: var(--metric-glow, rgba(99,91,255,.08));
    content: "";
}

.metric-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.metric-label { margin: 0; color: var(--app-muted); font-size: .73rem; font-weight: 700; }
.metric-value { margin: 13px 0 0; font-size: 2rem; font-weight: 800; letter-spacing: -.06em; line-height: 1; }
.metric-note { margin-top: 11px; color: #94a3b8; font-size: .67rem; }

.metric-icon {
    display: grid;
    place-items: center;
    width: 43px;
    height: 43px;
    color: var(--metric-color, var(--app-primary));
    border-radius: 13px;
    background: var(--metric-bg, var(--app-primary-soft));
    font-size: 1.1rem;
}

.metric-primary { --metric-color:#635bff; --metric-bg:#eef2ff; --metric-glow:rgba(99,91,255,.11); }
.metric-slate { --metric-color:#475569; --metric-bg:#f1f5f9; --metric-glow:rgba(71,85,105,.08); }
.metric-success { --metric-color:#059669; --metric-bg:#ecfdf5; --metric-glow:rgba(16,185,129,.1); }
.metric-danger { --metric-color:#dc2626; --metric-bg:#fef2f2; --metric-glow:rgba(239,68,68,.09); }

.section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--app-border);
}
.section-card-header h2 { margin: 0; font-size: .96rem; font-weight: 800; letter-spacing: -.02em; }
.section-card-header p { margin: 4px 0 0; color: var(--app-muted); font-size: .7rem; }

.chart-wrap { position: relative; min-height: 248px; padding: 12px; }
.chart-legend { display: grid; gap: 10px; margin-top: 10px; }
.chart-legend-item { display: flex; align-items: center; justify-content: space-between; color: var(--app-muted); font-size: .72rem; }
.chart-legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .92rem .85rem; vertical-align: middle; border-bottom-color: #edf1f6; }
.table thead th {
    color: #64748b;
    background: #f8fafc;
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .055em;
    text-transform: uppercase;
    white-space: nowrap;
}
.table tbody td { color: #334155; font-size: .76rem; }
.table tbody tr { transition: background-color .18s ease; }
.table tbody tr:hover { background: #fafbff; }

.section-number {
    display: inline-grid;
    place-items: center;
    min-width: 46px;
    height: 34px;
    padding: 0 9px;
    color: #4338ca;
    border: 1px solid #dfe3ff;
    border-radius: 10px;
    background: #f5f5ff;
    font-weight: 800;
}

.pill-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: .63rem;
    font-weight: 800;
    letter-spacing: .03em;
}
.pill-status::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.pill-success { color:#047857; border-color:#a7f3d0; background:#ecfdf5; }
.pill-warning { color:#b45309; border-color:#fde68a; background:#fffbeb; }
.pill-danger { color:#b91c1c; border-color:#fecaca; background:#fef2f2; }
.pill-neutral { color:#475569; border-color:#e2e8f0; background:#f8fafc; }

.goal-progress { min-width: 170px; }
.goal-copy { display:flex; justify-content:space-between; gap:12px; margin-bottom:7px; color:#64748b; font-size:.65rem; }
.progress { height: 6px; border-radius: 99px; background:#edf2f7; }
.progress-bar { border-radius: 99px; }

.status-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    color: #64748b;
    border: 0;
    background: transparent;
    font-size: .68rem;
    font-weight: 700;
}
.toggle-track {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    border-radius: 99px;
    background: #cbd5e1;
    transition: .2s ease;
}
.toggle-track::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 5px rgba(15,23,42,.25);
    content: "";
    transition: .2s ease;
}
.status-toggle[aria-checked="true"] { color: #047857; }
.status-toggle[aria-checked="true"] .toggle-track { background: var(--app-success); }
.status-toggle[aria-checked="true"] .toggle-track::after { transform: translateX(16px); }
.status-toggle:disabled { opacity: .55; }

.dataTables_wrapper { padding: 0; }
.dt-container .dt-layout-row { margin: 0; padding: 14px 18px; }
.dt-container .dt-layout-row:first-child { border-bottom: 1px solid var(--app-border); }
.dt-container .dt-layout-row:last-child { border-top: 1px solid var(--app-border); }
.dt-container .dt-search input,
.dt-container .dt-length select {
    min-height: 36px;
    border: 1px solid var(--app-border) !important;
    border-radius: 10px !important;
    background: #fff !important;
}
.dt-container .dt-search label,
.dt-container .dt-length label,
.dt-container .dt-info { color: var(--app-muted); font-size: .7rem; }
.dt-buttons .btn { min-height: 34px; padding: .4rem .65rem; color:#475569; border-color:var(--app-border); background:#fff; box-shadow:none; }
.page-link { color:#475569; border-color:var(--app-border); font-size:.72rem; }
.active > .page-link, .page-link.active { border-color:var(--app-primary); background:var(--app-primary); }

.password-meter {
    height: 7px;
    overflow: hidden;
    border-radius: 99px;
    background: #e8edf4;
}
.password-meter-bar { width: 0; height: 100%; border-radius: inherit; transition: width .2s ease, background .2s ease; }
.password-hint { color: var(--app-muted); font-size: .68rem; }

.auth-page {
    min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(circle at 12% 10%, rgba(99,91,255,.18), transparent 27%),
        radial-gradient(circle at 90% 90%, rgba(45,212,191,.14), transparent 30%),
        #eef2f7;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(400px, .92fr);
    width: min(1120px, 100%);
    min-height: 680px;
    margin: auto;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 30px;
    background: #fff;
    box-shadow: 0 30px 80px rgba(15,23,42,.13);
}

.auth-visual {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 52px;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(circle at 75% 12%, rgba(45,212,191,.22), transparent 25%),
        linear-gradient(145deg, #111827 0%, #172554 50%, #312e81 100%);
}
.auth-visual::before, .auth-visual::after { position:absolute; border:1px solid rgba(255,255,255,.08); border-radius:50%; content:""; }
.auth-visual::before { width:420px; height:420px; right:-180px; bottom:-150px; }
.auth-visual::after { width:260px; height:260px; right:-70px; bottom:-70px; }
.auth-brand { position:relative; z-index:1; display:flex; align-items:center; gap:12px; font-weight:800; }
.auth-hero { position:relative; z-index:1; max-width:480px; }
.auth-hero .eyebrow { color:#a5b4fc; font-size:.72rem; font-weight:800; letter-spacing:.12em; text-transform:uppercase; }
.auth-hero h1 { margin:14px 0 18px; font-size:clamp(2.4rem,4.7vw,4.3rem); font-weight:800; letter-spacing:-.065em; line-height:1.02; }
.auth-hero p { max-width:430px; margin:0; color:#cbd5e1; line-height:1.75; }
.auth-feature-row { position:relative; z-index:1; display:flex; gap:12px; flex-wrap:wrap; }
.auth-feature { display:flex; align-items:center; gap:8px; padding:9px 12px; border:1px solid rgba(255,255,255,.1); border-radius:12px; background:rgba(255,255,255,.06); color:#dbeafe; font-size:.7rem; font-weight:700; }

.auth-form-panel { display:flex; align-items:center; justify-content:center; padding:52px; }
.auth-form-wrap { width:min(390px,100%); }
.auth-form-wrap h2 { margin:0; font-size:1.65rem; font-weight:800; letter-spacing:-.04em; }
.auth-form-wrap > p { margin:9px 0 30px; color:var(--app-muted); line-height:1.6; }
.password-input-wrap { position:relative; }
.password-input-wrap .form-control { padding-right:48px; }
.password-toggle { position:absolute; top:50%; right:8px; display:grid; place-items:center; width:34px; height:34px; transform:translateY(-50%); color:#64748b; border:0; background:transparent; }

.offcanvas.app-mobile-sidebar { width:min(310px,88vw); color:#fff; background:var(--app-sidebar); }
.offcanvas.app-mobile-sidebar .btn-close { filter:invert(1); }

@media (max-width: 1199.98px) {
    .app-sidebar { display: none; }
    .app-main { margin-left: 0; }
}

@media (max-width: 991.98px) {
    .app-content { padding: 24px 20px; }
    .auth-shell { grid-template-columns: 1fr; min-height: auto; }
    .auth-visual { min-height: 330px; padding: 38px; }
    .auth-hero h1 { font-size: 2.65rem; }
    .auth-form-panel { padding: 44px 30px; }
}

@media (max-width: 767.98px) {
    body { font-size: .88rem; }
    .app-topbar { min-height: 68px; padding: 10px 15px; }
    .app-content { padding: 22px 14px 40px; }
    .page-header { align-items:flex-start; flex-direction:column; }
    .page-header .btn-group-mobile { display:grid; width:100%; grid-template-columns:1fr 1fr; }
    .page-header .btn-group-mobile .btn { width:100%; }
    .user-copy { display:none; }
    .user-menu-button { padding-right:5px; }
    .metric-card { padding:17px; }
    .metric-value { font-size:1.7rem; }
    .section-card-header { align-items:flex-start; flex-direction:column; }
    .dt-container .dt-layout-row { gap:10px; align-items:flex-start !important; flex-direction:column; }
    .dt-container .dt-layout-cell { width:100%; }
    .dt-container .dt-search input { width:calc(100% - 55px); }
    .dt-buttons { display:flex; width:100%; overflow-x:auto; }
    .auth-page { padding:10px; }
    .auth-shell { border-radius:22px; }
    .auth-visual { min-height:285px; padding:28px; }
    .auth-hero h1 { font-size:2.2rem; }
    .auth-feature-row { display:none; }
    .auth-form-panel { padding:36px 24px; }
}

@media (max-width: 480px) {
    .topbar-heading { display:none; }
    .auth-visual { min-height:245px; }
    .auth-hero h1 { font-size:1.9rem; }
    .auth-hero p { font-size:.78rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior:auto !important; transition-duration:.01ms !important; animation-duration:.01ms !important; }
}
