/* ==============================================
   Sales Tracking Module - Premium Design System
   Inspired by Linear / Vercel / Stripe aesthetics
   ============================================== */

.st-sortable { cursor: pointer; user-select: none; }
.st-sortable:hover { color: var(--st-accent, #2C3E50); }

/* ---- Design Tokens ---- */
:root {
    --st-bg: #f8fafc;
    --st-fg: #09090b;
    --st-card: #ffffff;
    --st-border: #e4e4e7;
    --st-muted: #f4f4f5;
    --st-muted-fg: #71717a;
    --st-primary: #18181b;
    --st-primary-fg: #fafafa;
    --st-emerald: #059669;
    --st-emerald-light: #10b981;
    --st-destructive: #dc2626;
    --st-radius-md: 8px;
    --st-radius-lg: 12px;
    --st-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
    --st-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
    --st-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Page Wrapper ---- */
.st-page {
    background: var(--st-bg);
    min-height: 100%;
    animation: st-fade-in 0.4s ease-out;
}

@keyframes st-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Typography ---- */
.st-page-title {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--st-fg);
    line-height: 1.2;
    margin: 0;
}

.st-page-subtitle {
    font-size: 0.875rem;
    color: var(--st-muted-fg);
    margin-top: 0.125rem;
}

.st-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--st-fg);
    margin: 0;
}

/* ---- Links ---- */
.st-page a {
    color: var(--st-fg);
    text-decoration: none;
    transition: color var(--st-transition);
}

.st-page a:hover {
    color: var(--st-muted-fg);
}

.st-page .st-table a {
    font-weight: 600;
    border-bottom: 1px solid var(--st-border);
    padding-bottom: 1px;
}

.st-page .st-table a:hover {
    color: var(--st-fg);
    border-bottom-color: var(--st-fg);
}

/* ---- Header Bar ---- */
.st-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2rem;
}

.st-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ---- Summary Cards ---- */
.st-card {
    background: var(--st-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-lg);
    padding: 1.25rem 1.5rem;
    transition: box-shadow var(--st-transition), transform var(--st-transition);
    box-shadow: var(--st-shadow-sm);
}

.st-card:hover {
    box-shadow: var(--st-shadow-md);
    transform: translateY(-1px);
}

.st-card-label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--st-muted-fg);
    margin-bottom: 0.5rem;
}

.st-card-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--st-fg);
    letter-spacing: -0.025em;
    line-height: 1.1;
}

/* ---- Trend Indicators ---- */
.st-trend-up {
    color: var(--st-emerald);
    font-size: 0.8125rem;
    font-weight: 500;
}

.st-trend-down {
    color: var(--st-destructive);
    font-size: 0.8125rem;
    font-weight: 500;
}

/* ---- Panel / Card Containers ---- */
.st-panel {
    background: var(--st-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-lg);
    box-shadow: var(--st-shadow-sm);
    overflow: hidden;
}

.st-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--st-border);
}

.st-panel-header .st-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.st-panel-header .st-section-title i {
    color: var(--st-muted-fg);
    font-size: 0.875rem;
}

.st-panel-body {
    padding: 1.25rem;
}

.st-panel-body.p-0 {
    padding: 0;
}

.st-panel-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--st-border);
    text-align: center;
}

/* ---- Chart Container ---- */
.st-chart-wrap {
    background: var(--st-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-lg);
    box-shadow: var(--st-shadow-sm);
    overflow: hidden;
    margin-bottom: 2rem;
}

.st-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--st-border);
}

.st-chart-body {
    padding: 1rem 1.25rem;
    position: relative;
}

/* ---- Tables ---- */
.st-table {
    font-size: 0.875rem;
}

.st-table th {
    background: var(--st-muted);
    color: var(--st-fg);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--st-border) !important;
    border-top: none !important;
    padding: 0.625rem 0.875rem !important;
    white-space: nowrap;
}

.st-table td {
    vertical-align: middle;
    font-size: 0.8125rem;
    color: var(--st-fg);
    padding: 0.625rem 0.875rem !important;
    border-bottom: 1px solid var(--st-border) !important;
}

.st-table tbody tr {
    transition: background-color var(--st-transition);
}

.st-table tbody tr:hover {
    background-color: var(--st-muted) !important;
}

.st-table tbody tr:last-child td {
    border-bottom: none !important;
}

/* Total row */
.st-table tbody tr.st-total-row {
    background: var(--st-muted);
}

.st-table tbody tr.st-total-row td {
    font-weight: 600;
    border-top: 2px solid var(--st-border) !important;
}

/* Code / monospace in tables */
.st-table code {
    font-size: 0.75rem;
    background: var(--st-muted);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    color: var(--st-fg);
    font-weight: 500;
}

/* ---- Tabs (Pills Style) ---- */
.st-tabs {
    display: inline-flex;
    background: var(--st-muted);
    border-radius: var(--st-radius-md);
    padding: 3px;
    gap: 2px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.st-tabs .nav-item {
    margin: 0;
}

.st-tabs .nav-link {
    color: var(--st-muted-fg);
    font-weight: 500;
    font-size: 0.8125rem;
    padding: 0.4375rem 0.875rem;
    border-radius: 6px;
    border: none;
    background: transparent;
    transition: all var(--st-transition);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.st-tabs .nav-link i {
    font-size: 0.75rem;
}

.st-tabs .nav-link:hover {
    color: var(--st-fg);
    background: rgba(0, 0, 0, 0.04);
}

.st-tabs .nav-link.active {
    color: var(--st-fg);
    font-weight: 600;
    background: var(--st-card);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ---- Metric Toggle (Chart) ---- */
.st-metric-toggle {
    display: inline-flex;
    background: var(--st-muted);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.st-metric-toggle .btn {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.625rem;
    border: none;
    border-radius: 5px;
    color: var(--st-muted-fg);
    background: transparent;
    transition: all var(--st-transition);
}

.st-metric-toggle .btn:hover {
    color: var(--st-fg);
}

.st-metric-toggle .btn.active {
    background: var(--st-card);
    color: var(--st-fg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* ---- Buttons ---- */
.st-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--st-primary);
    color: var(--st-primary-fg);
    border: 1px solid var(--st-primary);
    border-radius: var(--st-radius-md);
    cursor: pointer;
    transition: all var(--st-transition);
    text-decoration: none;
    white-space: nowrap;
}

.st-btn-primary:hover {
    background: #27272a;
    color: var(--st-primary-fg);
    text-decoration: none;
}

.st-btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--st-card);
    color: var(--st-fg);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-md);
    cursor: pointer;
    transition: all var(--st-transition);
    text-decoration: none;
    white-space: nowrap;
}

.st-btn-outline:hover {
    background: var(--st-muted);
    color: var(--st-fg);
    text-decoration: none;
}

.st-btn-sm {
    padding: 0.3125rem 0.625rem;
    font-size: 0.75rem;
}

.st-btn-icon {
    padding: 0.375rem;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--st-radius-md);
    border: 1px solid var(--st-border);
    background: var(--st-card);
    color: var(--st-muted-fg);
    cursor: pointer;
    transition: all var(--st-transition);
}

.st-btn-icon:hover {
    background: var(--st-muted);
    color: var(--st-fg);
}

/* ---- Badges ---- */
.st-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.1875rem 0.5rem;
    border-radius: 4px;
    line-height: 1.4;
}

.st-badge-success {
    background: #ecfdf5;
    color: var(--st-emerald);
}

.st-badge-danger {
    background: #fef2f2;
    color: var(--st-destructive);
}

.st-badge-warning {
    background: #fffbeb;
    color: #d97706;
}

.st-badge-info {
    background: #eff6ff;
    color: #2563eb;
}

.st-badge-neutral {
    background: var(--st-muted);
    color: var(--st-muted-fg);
}

/* ---- P&L Colors ---- */
.st-pnl-positive {
    color: var(--st-emerald) !important;
    font-weight: 600;
}

.st-pnl-negative {
    color: var(--st-destructive) !important;
    font-weight: 600;
}

/* ---- Navigation Buttons (Profile Selector) ---- */
.st-nav {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.st-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--st-card);
    color: var(--st-fg);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-md);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--st-transition);
    min-width: 120px;
    justify-content: center;
    box-shadow: var(--st-shadow-sm);
}

.st-nav-btn:hover,
.st-nav-btn.active {
    background: var(--st-primary);
    color: var(--st-primary-fg);
    border-color: var(--st-primary);
    text-decoration: none;
    box-shadow: var(--st-shadow-md);
}

/* ---- Form Controls (Date Picker, Selects) ---- */
.st-page .form-control,
.st-page .form-select {
    border-color: var(--st-border);
    border-radius: var(--st-radius-md);
    font-size: 0.8125rem;
    transition: border-color var(--st-transition), box-shadow var(--st-transition);
}

.st-page .form-control:focus,
.st-page .form-select:focus {
    border-color: var(--st-primary);
    box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}

.st-page .form-control-sm,
.st-page .form-select-sm {
    font-size: 0.75rem;
    padding: 0.3125rem 0.625rem;
}

.st-page .form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--st-fg);
}

/* ---- Switch Toggles ---- */
.st-page .form-check-input:checked {
    background-color: var(--st-primary);
    border-color: var(--st-primary);
}

.st-page .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
    border-color: var(--st-primary);
}

/* ---- Alerts ---- */
.st-page .alert {
    border-radius: var(--st-radius-md);
    font-size: 0.8125rem;
    border: 1px solid;
}

/* ---- Client Detail Header ---- */
.st-client-header {
    padding-bottom: 0;
    margin-bottom: 0;
    border: none;
}

.st-client-name {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--st-fg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.st-client-icon {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--st-muted);
    border-radius: var(--st-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--st-muted-fg);
    font-size: 1rem;
    flex-shrink: 0;
}

.st-client-meta {
    font-size: 0.8125rem;
    color: var(--st-muted-fg);
    margin-top: 0.25rem;
}

.st-client-badges {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.st-platform-badge {
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.1875rem 0.5rem;
    border-radius: 4px;
    background: var(--st-muted);
    color: var(--st-muted-fg);
}

/* ---- Empty States ---- */
.st-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.st-empty-state i {
    font-size: 2.5rem;
    color: var(--st-border);
    margin-bottom: 1rem;
}

.st-empty-state h5 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--st-muted-fg);
    margin-bottom: 0.375rem;
}

.st-empty-state p {
    font-size: 0.8125rem;
    color: var(--st-muted-fg);
}

/* ---- History Page ---- */
.st-history-subtitle {
    font-size: 0.875rem;
    color: var(--st-muted-fg);
}

/* ---- Progress Bar Override ---- */
.st-page #importProgress .progress {
    height: 8px;
    border-radius: 999px;
    background: var(--st-muted);
}

.st-page #importProgress .progress-bar {
    background: var(--st-primary);
    border-radius: 999px;
    font-size: 0;
}

/* ---- Modals ---- */
.st-page .modal-content {
    border-radius: var(--st-radius-lg);
    border: 1px solid var(--st-border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.st-page .modal-header {
    background: var(--st-card);
    border-bottom: 1px solid var(--st-border);
    padding: 1rem 1.25rem;
}

.st-page .modal-header .modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--st-fg);
}

.st-page .modal-body {
    padding: 1.25rem;
}

.st-page .modal-footer {
    border-top: 1px solid var(--st-border);
    padding: 0.875rem 1.25rem;
}

/* ---- List Group (Omnibus) ---- */
.st-page .list-group-item {
    border-color: var(--st-border);
    font-size: 0.8125rem;
    padding: 0.75rem 1rem;
    transition: background-color var(--st-transition);
}

.st-page .list-group-item:hover,
.st-page .list-group-item-action:hover {
    background: var(--st-muted);
}

/* ---- Badge overrides inside .st-page ---- */
.st-page .badge {
    font-weight: 500;
    font-size: 0.6875rem;
    border-radius: 4px;
}

.st-page .badge.bg-success {
    background: #ecfdf5 !important;
    color: var(--st-emerald) !important;
}

.st-page .badge.bg-secondary {
    background: var(--st-muted) !important;
    color: var(--st-muted-fg) !important;
}

.st-page .badge.bg-warning {
    background: #fffbeb !important;
    color: #d97706 !important;
}

.st-page .badge.bg-danger {
    background: #fef2f2 !important;
    color: var(--st-destructive) !important;
}

.st-page .badge.bg-info {
    background: #eff6ff !important;
    color: #2563eb !important;
}

/* ---- Card overrides inside .st-page ---- */
.st-page .card {
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-lg);
    box-shadow: var(--st-shadow-sm);
    overflow: hidden;
}

.st-page .card-header {
    background: var(--st-card);
    border-bottom: 1px solid var(--st-border);
    padding: 0.875rem 1.25rem;
}

.st-page .card-header h5,
.st-page .card-header h6 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--st-fg);
}

.st-page .card-body {
    padding: 1.25rem;
}

.st-page .card-footer {
    background: var(--st-card);
    border-top: 1px solid var(--st-border);
    padding: 0.75rem 1.25rem;
}

/* ---- Button overrides inside .st-page ---- */
.st-page .btn-primary {
    background: var(--st-primary);
    border-color: var(--st-primary);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--st-radius-md);
}

.st-page .btn-primary:hover {
    background: #27272a;
    border-color: #27272a;
}

.st-page .btn-outline-primary {
    color: var(--st-fg);
    border-color: var(--st-border);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--st-radius-md);
}

.st-page .btn-outline-primary:hover,
.st-page .btn-outline-primary.active {
    background: var(--st-primary);
    border-color: var(--st-primary);
    color: var(--st-primary-fg);
}

.st-page .btn-outline-secondary {
    color: var(--st-muted-fg);
    border-color: var(--st-border);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--st-radius-md);
}

.st-page .btn-outline-secondary:hover {
    background: var(--st-muted);
    border-color: var(--st-border);
    color: var(--st-fg);
}

.st-page .btn-outline-danger {
    color: var(--st-destructive);
    border-color: #fecaca;
    font-size: 0.8125rem;
    border-radius: var(--st-radius-md);
}

.st-page .btn-outline-danger:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: var(--st-destructive);
}

.st-page .btn-outline-warning {
    color: #d97706;
    border-color: #fde68a;
    font-size: 0.8125rem;
    border-radius: var(--st-radius-md);
}

.st-page .btn-outline-warning:hover {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #d97706;
}

.st-page .btn-outline-success {
    color: var(--st-emerald);
    border-color: #a7f3d0;
    font-size: 0.8125rem;
    border-radius: var(--st-radius-md);
}

.st-page .btn-outline-success:hover {
    background: #ecfdf5;
    border-color: #6ee7b7;
    color: var(--st-emerald);
}

.st-page .btn-outline-info {
    color: #2563eb;
    border-color: #bfdbfe;
    font-size: 0.8125rem;
    border-radius: var(--st-radius-md);
}

.st-page .btn-outline-info:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
}

.st-page .btn-secondary {
    background: var(--st-muted);
    border-color: var(--st-border);
    color: var(--st-fg);
    font-size: 0.8125rem;
    border-radius: var(--st-radius-md);
}

.st-page .btn-secondary:hover {
    background: #e4e4e7;
    border-color: #d4d4d8;
}

.st-page .btn-sm {
    padding: 0.3125rem 0.625rem;
    font-size: 0.75rem;
}

/* ---- Scrollbar ---- */
.st-page ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.st-page ::-webkit-scrollbar-track {
    background: transparent;
}

.st-page ::-webkit-scrollbar-thumb {
    background: rgba(113, 113, 122, 0.3);
    border-radius: 999px;
}

.st-page ::-webkit-scrollbar-thumb:hover {
    background: rgba(113, 113, 122, 0.5);
}

/* ---- Spacing Helpers ---- */
.st-section {
    margin-bottom: 2rem;
}

.st-grid-gap {
    gap: 1.5rem;
}

/* ---- Admin Page Specific ---- */
.st-admin-container {
    max-width: 80rem;
    margin: 0 auto;
}

/* Admin tabs with overflow scroll */
.st-admin-tabs {
    display: flex;
    background: var(--st-muted);
    border-radius: var(--st-radius-md);
    padding: 3px;
    gap: 2px;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.st-admin-tabs::-webkit-scrollbar {
    display: none;
}

.st-admin-tabs .nav-item {
    margin: 0;
    flex-shrink: 0;
}

.st-admin-tabs .nav-link {
    color: var(--st-muted-fg);
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    border: none;
    background: transparent;
    transition: all var(--st-transition);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.st-admin-tabs .nav-link i {
    font-size: 0.6875rem;
}

.st-admin-tabs .nav-link:hover {
    color: var(--st-fg);
    background: rgba(0, 0, 0, 0.04);
}

.st-admin-tabs .nav-link.active {
    color: var(--st-fg);
    font-weight: 600;
    background: var(--st-card);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ---- Flow Metrics Panel ---- */
.st-flow-card {
    background: var(--st-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--st-shadow-sm);
}

/* ---- Reconciliation Summary ---- */
.st-recon-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---- Input Group Overrides ---- */
.st-page .input-group .form-control,
.st-page .input-group .form-select {
    border-radius: var(--st-radius-md);
}

.st-page .input-group .btn {
    border-radius: var(--st-radius-md);
}

/* ---- Opacity for ignored items ---- */
.st-page .opacity-50 {
    opacity: 0.5;
}

/* ---- Table within admin panels ---- */
.st-page .table {
    margin-bottom: 0;
}

.st-page .table th {
    background: var(--st-muted);
    color: var(--st-fg);
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--st-border) !important;
    border-top: none !important;
    padding: 0.625rem 0.875rem !important;
    white-space: nowrap;
}

.st-page .table td {
    vertical-align: middle;
    font-size: 0.8125rem;
    color: var(--st-fg);
    padding: 0.625rem 0.875rem !important;
    border-bottom: 1px solid var(--st-border) !important;
}

.st-page .table tbody tr {
    transition: background-color var(--st-transition);
}

.st-page .table tbody tr:hover {
    background-color: var(--st-muted) !important;
}

.st-page .table tbody tr:last-child td {
    border-bottom: none !important;
}

.st-page .table code {
    font-size: 0.75rem;
    background: var(--st-muted);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    color: var(--st-fg);
    font-weight: 500;
}

/* ---- Loading State ---- */
.st-loading {
    color: var(--st-muted-fg);
    font-size: 0.8125rem;
    text-align: center;
    padding: 2rem 0;
}

/* ---- Chart Container ---- */
#historyChart {
    min-height: 300px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .st-header {
        flex-direction: column;
        gap: 0.75rem;
    }

    .st-header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .st-page-title {
        font-size: 1.5rem;
    }

    .st-card-value {
        font-size: 1.5rem;
    }

    .st-nav {
        flex-direction: column;
    }

    .st-nav-btn {
        width: 100%;
    }

    .st-tabs {
        width: 100%;
        overflow-x: auto;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .st-tabs::-webkit-scrollbar {
        display: none;
    }

    .st-admin-tabs {
        width: 100%;
    }

    .st-table {
        font-size: 0.75rem;
    }

    .d-flex.gap-2 {
        flex-wrap: wrap;
    }
}

@media (max-width: 576px) {
    .st-card {
        padding: 1rem;
    }

    .st-panel-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}

/* ---- Management: Total Banner ---- */
.st-total-banner {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: var(--st-radius-lg);
    padding: 1.5rem 1.75rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(30, 41, 59, 0.15);
}
.st-total-content {
    display: flex; gap: 2rem; align-items: stretch;
    flex-wrap: wrap;
}
.st-total-main {
    flex: 1 1 300px; display: flex; gap: 2rem;
    align-items: center; flex-wrap: wrap;
}
.st-total-aum-block { min-width: 160px; }
.st-total-label {
    font-size: 0.65rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: rgba(255,255,255,0.5); margin-bottom: 0.15rem;
}
.st-total-aum {
    font-size: 2.25rem; font-weight: 700; line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.st-total-growth {
    font-size: 0.8rem; font-weight: 500;
    color: rgba(255,255,255,0.65); margin-top: 0.2rem;
}
.st-total-growth.st-pnl-positive { color: #6ee7b7; }
.st-total-growth.st-pnl-negative { color: #fca5a5; }
.st-total-metrics {
    display: flex; flex-direction: column; gap: 0.35rem;
    min-width: 140px;
}
.st-total-metric {
    display: flex; justify-content: space-between; gap: 1rem;
    font-size: 0.8rem;
}
.st-total-metric-label {
    color: rgba(255,255,255,0.45); font-weight: 500;
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.st-total-metric-value { font-weight: 600; color: rgba(255,255,255,0.9); }
.st-total-metric-value.st-pnl-positive { color: #6ee7b7; }
.st-total-metric-value.st-pnl-negative { color: #fca5a5; }
.st-total-quality {
    display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem;
    align-items: center; padding-left: 1.5rem;
    border-left: 1px solid rgba(255,255,255,0.12);
}
.st-total-quality-item { text-align: center; min-width: 80px; }
.st-total-quality-label {
    display: block; font-size: 0.6rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: rgba(255,255,255,0.4); margin-bottom: 0.1rem;
}
.st-total-quality-value {
    display: block; font-size: 0.95rem; font-weight: 700;
    color: rgba(255,255,255,0.9); font-variant-numeric: tabular-nums;
}

/* ---- Management: Profile Scorecards ---- */
.st-scoreboard {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.st-score-card {
    flex: 1 1 200px;
    background: var(--st-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-lg);
    padding: 1.1rem 1.25rem;
    min-width: 170px;
    box-shadow: var(--st-shadow-sm);
    transition: box-shadow var(--st-transition);
}
.st-score-card:hover { box-shadow: var(--st-shadow-md); }
.st-score-label {
    font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--st-muted-fg); margin-bottom: 0.2rem;
}
.st-score-value {
    font-size: 1.5rem; font-weight: 700;
    color: var(--st-fg); line-height: 1.2; margin-bottom: 0.3rem;
    font-variant-numeric: tabular-nums;
}
.st-score-row {
    display: flex; align-items: center;
    gap: 0.4rem; font-size: 0.8rem; font-weight: 500;
    margin-bottom: 0.2rem;
}
.st-score-header {
    display: flex; justify-content: space-between; align-items: flex-start;
}
.st-score-view {
    color: var(--st-muted-fg); font-size: 0.75rem;
    opacity: 0.4; transition: opacity var(--st-transition);
}
.st-score-card:hover .st-score-view { opacity: 1; }
.st-score-flows {
    margin-top: 0.3rem; padding-top: 0.3rem;
    border-top: 1px solid var(--st-border);
}
.st-score-flow-row {
    display: flex; justify-content: space-between;
    font-size: 0.75rem; line-height: 1.6;
}
.st-score-flow-label {
    color: var(--st-muted-fg); font-weight: 500; font-size: 0.65rem;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.st-score-meta {
    font-size: 0.7rem; color: var(--st-muted-fg); margin-top: 0.2rem;
    line-height: 1.4;
}

/* ---- Management: Profile Banners (same layout as total, light theme) ---- */
.st-profile-banner {
    background: var(--st-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--st-shadow-sm);
    transition: box-shadow var(--st-transition);
}
.st-profile-banner:hover { box-shadow: var(--st-shadow-md); }
.st-profile-banner .st-total-label { color: var(--st-muted-fg); }
.st-profile-banner .st-total-aum { color: var(--st-fg); font-size: 1.8rem; }
.st-profile-banner .st-total-growth { color: var(--st-muted-fg); }
.st-profile-banner .st-total-growth.st-pnl-positive { color: var(--st-emerald); }
.st-profile-banner .st-total-growth.st-pnl-negative { color: var(--st-destructive); }
.st-profile-banner .st-total-metric-label { color: var(--st-muted-fg); }
.st-profile-banner .st-total-metric-value { color: var(--st-fg); }
.st-profile-banner .st-total-metric-value.st-pnl-positive { color: var(--st-emerald); }
.st-profile-banner .st-total-metric-value.st-pnl-negative { color: var(--st-destructive); }
.st-profile-banner .st-total-quality { border-left-color: var(--st-border); }
.st-profile-banner .st-total-quality-label { color: var(--st-muted-fg); }
.st-profile-banner .st-total-quality-value { color: var(--st-fg); }
.st-prof-header {
    display: flex; justify-content: space-between; align-items: flex-start;
}
.st-prof-link {
    color: var(--st-muted-fg); font-size: 0.7rem;
    opacity: 0.4; transition: opacity var(--st-transition);
}
.st-profile-banner:hover .st-prof-link { opacity: 1; }

/* ---- Pie Chart Components ---- */
.st-pie-wrap {
    display: flex; flex-direction: column; align-items: center;
    gap: 0.75rem; padding: 0.75rem 0 0.25rem;
}
.st-pie-wrap canvas { flex-shrink: 0; }
.st-pie-legend { width: 100%; }
.st-pie-legend-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.25rem 0; font-size: 0.8rem;
    border-bottom: 1px solid var(--st-muted);
}
.st-pie-legend-item:last-child { border-bottom: none; }
.st-pie-swatch { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.st-pie-legend-label {
    flex: 1; min-width: 0; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    color: var(--st-fg); font-weight: 500;
}
.st-pie-legend-value {
    font-weight: 600; color: var(--st-fg);
    white-space: nowrap; font-variant-numeric: tabular-nums;
}
.st-pie-legend-pct {
    color: var(--st-muted-fg); font-size: 0.72rem;
    white-space: nowrap; min-width: 2.5rem; text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---- Management: Dimension Tabs ---- */
.st-dim-tabs {
    display: inline-flex; gap: 2px;
    background: var(--st-muted); border-radius: 6px; padding: 2px;
}
.st-dim-tab {
    padding: 0.25rem 0.65rem; font-size: 0.72rem; font-weight: 500;
    border: none; background: transparent; color: var(--st-muted-fg);
    border-radius: 4px; cursor: pointer; transition: all var(--st-transition);
}
.st-dim-tab:hover { color: var(--st-fg); }
.st-dim-tab.active {
    background: var(--st-card); color: var(--st-fg);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* ---- Management Responsive ---- */
@media (max-width: 768px) {
    .st-total-banner { padding: 1rem 1.25rem; }
    .st-total-aum { font-size: 1.6rem; }
    .st-total-quality { padding-left: 0; border-left: none; border-top: 1px solid rgba(255,255,255,0.12); padding-top: 0.75rem; }
    .st-profile-banner { padding: 1rem 1.1rem; }
    .st-profile-banner .st-total-aum { font-size: 1.4rem; }
    .st-profile-banner .st-total-quality { padding-left: 0; border-left: none; border-top: 1px solid var(--st-border); padding-top: 0.6rem; }
    .st-pie-wrap canvas { width: 150px !important; height: 150px !important; }
}
