/* ==========================================================================
   SHREE BANKING — DEMURE Design System
   Microfinance & Micro-Credit Operations ERP SaaS (Web + Mobile)
   Creative Philosophy: Editorial, Dark-First Monochrome with Semantic Financial Accents
   ========================================================================== */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+Devanagari:wght@400;500;600;700&display=swap');

:root {
    /* ----------------------------------------------------------------------
       Core Design Tokens (from DESIGN.md)
       ---------------------------------------------------------------------- */
    --bg-primary: #0A0A0A;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-alt: #F7F7F8;
    --bg-card-subtle: #EFEFF1;
    --bg-dark-widget: #141416;
    --bg-dark-surface: #16161A;

    --text-primary: #0A0A0A;
    --text-on-dark: #FFFFFF;
    --text-secondary: #71717A;
    --text-muted: #A1A1AA;
    --text-subtle: #A0A0A8;

    --accent-positive: #1FAD5E;
    --accent-positive-tint: #E7F7EE;
    --accent-negative: #E23F3F;
    --accent-negative-tint: #FCEAEA;

    --border-subtle: #EFEFF1;
    --border-card: #E5E5E8;
    --border-dark: #18181B;
    --border-dark-hover: #28282E;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-canvas: 24px;
    --radius-pill: 999px;

    --header-height: 54px;
    --sidebar-width: 230px;
    --sidebar-collapsed-width: 72px;

    /* Legacy mapping for sub-pages */
    --brand-primary: #0A0A0A;
    --brand-primary-hover: #1c1c1f;
    --brand-primary-light: #F7F7F8;
    --status-success: #1FAD5E;
    --status-success-light: #E7F7EE;
    --status-danger: #E23F3F;
    --status-danger-light: #FCEAEA;
    --status-warning: #D97706;
    --status-warning-light: #FEF3C7;
    --status-info: #0A0A0A;
    --status-info-light: #F7F7F8;
    --text-heading: #0A0A0A;
    --text-body: #18181B;
    --text-faint: #A0A0A8;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-modal: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Base Document & Typography
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: Pretendard, Inter, 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 17px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11", "tnum";
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    margin-top: 0;
    letter-spacing: -0.015em;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #28282E;
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
    background: #3f3f46;
}

/* ==========================================================================
   Editorial Hatch Pattern (Active bar in 31-day chart & indicators)
   ========================================================================== */

.hatch-bar,
.chart-bar.active {
    background: repeating-linear-gradient(
        45deg,
        #0A0A0A,
        #0A0A0A 3.5px,
        #FFFFFF 3.5px,
        #FFFFFF 7px
    ) !important;
    border: 1px solid #0A0A0A !important;
}

/* ==========================================================================
   Authentication Terminal Canvas (Login & OTP Verification)
   ========================================================================== */

body.auth-page-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #0A0A0A;
    background-image: 
        radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 60%),
        linear-gradient(180deg, #0E0E10 0%, #0A0A0A 100%);
    padding: 32px 16px;
    margin: 0;
    overflow-y: auto;
}

body.auth-page-body .auth-card {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* ==========================================================================
   Shell Layout & Viewport Rules (Fixed Sidebar, Scrollable Main Canvas)
   ========================================================================== */

html:has(body.app-shell-body),
html:has(#appShell),
body.app-shell-body,
body:has(#appShell) {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden !important;
}

body.app-shell-body,
body:has(#appShell) {
    display: flex;
    flex-direction: column;
}

#appShell,
.app-shell {
    display: flex;
    flex-direction: row;
    flex: 1;
    height: calc(100vh - var(--header-height));
    min-height: 0;
    max-height: calc(100vh - var(--header-height));
    background-color: var(--bg-primary);
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* Top Navigation Header (54px fixed #0A0A0A) */
#topNavHeader {
    height: var(--header-height);
    flex-shrink: 0;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-dark);
    position: relative;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    color: var(--text-on-dark);
}

.top-brand-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.top-brand-logo {
    height: 22px;
    width: auto;
    object-fit: contain;
}

.top-brand-text {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--text-on-dark);
    text-transform: uppercase;
}

/* Sub-Brand Navigation Dropdowns */
.nav-sub-brands {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sub-brand-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-subtle);
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sub-brand-btn:hover,
.sub-brand-btn:focus,
.sub-brand-btn.active {
    color: var(--text-on-dark);
    background-color: var(--bg-dark-widget);
    border-color: var(--border-dark-hover);
}

.demure-dropdown-menu {
    background: var(--bg-dark-widget);
    border: 1px solid var(--border-dark-hover);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
    padding: 6px;
    margin-top: 8px !important;
}

.demure-dropdown-item {
    color: var(--text-subtle);
    font-size: 12.5px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.12s ease;
}

.demure-dropdown-item:hover {
    color: var(--text-on-dark);
    background-color: #222228;
}

/* Top Nav Right Controls */
.top-nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-wallet-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-dark-widget);
    border: 1px solid var(--border-dark-hover);
    border-radius: var(--radius-pill);
    padding: 5px 14px;
    color: var(--text-on-dark);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
}

.top-wallet-chip:hover {
    background: #1c1c22;
    border-color: #383842;
    color: #FFFFFF;
}

.live-pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--accent-positive);
    position: relative;
}

.live-pulse-dot::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 1.5px solid var(--accent-positive);
    animation: pulseRing 1.8s infinite ease-out;
}

@keyframes pulseRing {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

.top-lang-pill {
    background: var(--bg-dark-widget);
    border: 1px solid var(--border-dark-hover);
    border-radius: var(--radius-sm);
    color: var(--text-subtle);
    font-size: 11.5px;
    font-weight: 700;
    padding: 5px 9px;
    cursor: pointer;
    transition: all 0.12s ease;
}

.top-lang-pill:hover {
    color: var(--text-on-dark);
    border-color: #383842;
}

.top-admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-dark-widget);
    border: 1px solid var(--border-dark-hover);
    border-radius: var(--radius-pill);
    padding: 3px 12px 3px 4px;
    color: var(--text-on-dark);
    font-size: 12px;
    font-weight: 600;
}

.top-admin-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #25252b;
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 800;
    border: 1px solid #33333d;
}

.btn-icon-top {
    background: transparent;
    border: 1px solid var(--border-dark-hover);
    color: var(--text-subtle);
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-icon-top:hover {
    color: var(--text-on-dark);
    background: var(--bg-dark-widget);
    border-color: #383842;
}

/* ==========================================================================
   Left Collapsible Sidebar (230px -> 72px)
   ========================================================================== */

#appSidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    height: 100%;
    max-height: 100%;
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1040;
    position: relative;
    overflow: hidden; /* Sidebar stays fixed and does not scroll */
    user-select: none;
}

.app-shell.sidebar-collapsed #appSidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border-dark);
}

.sidebar-corp-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s ease;
}

.app-shell.sidebar-collapsed .sidebar-corp-label {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.btn-collapse-sidebar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--bg-dark-surface);
    border: 1px solid var(--border-dark-hover);
    color: var(--text-on-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.15s ease;
    padding: 0;
}

.btn-collapse-sidebar:hover {
    background-color: #24242c;
    border-color: #40404a;
}

.app-shell.sidebar-collapsed .btn-collapse-sidebar i {
    transform: rotate(180deg);
}

/* Sidebar Nav Items (12 High-Density items) */
.sidebar-nav-list {
    list-style: none;
    padding: 10px 10px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
}

.sidebar-nav-item {
    position: relative;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-subtle);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.12s ease;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-nav-link i.nav-icon {
    font-size: 15px;
    width: 22px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color 0.12s ease;
}

.sidebar-nav-link .nav-text {
    flex: 1;
    margin-left: 8px;
    transition: opacity 0.15s ease;
}

.sidebar-nav-link .nav-chevron {
    font-size: 10px;
    color: #404048;
    margin-left: auto;
    transition: color 0.12s ease;
}

.sidebar-nav-link .nav-badge {
    margin-left: auto;
    background: #25252C;
    color: #F59E0B;
    border: 1px solid #383842;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-pill);
}

.sidebar-nav-link:hover {
    color: var(--text-on-dark);
    background-color: var(--bg-dark-surface);
}

.sidebar-nav-link:hover i.nav-icon {
    color: var(--text-on-dark);
}

.sidebar-nav-link.active {
    color: var(--text-on-dark);
    background-color: var(--bg-dark-surface);
    font-weight: 600;
    border: 1px solid var(--border-dark-hover);
}

.sidebar-nav-link.active i.nav-icon {
    color: #FFFFFF;
}

.app-shell.sidebar-collapsed .sidebar-nav-link {
    justify-content: center;
    padding: 10px 0;
}

.app-shell.sidebar-collapsed .sidebar-nav-link .nav-text,
.app-shell.sidebar-collapsed .sidebar-nav-link .nav-chevron,
.app-shell.sidebar-collapsed .sidebar-nav-link .nav-badge {
    display: none;
}

.app-shell.sidebar-collapsed .sidebar-nav-link i.nav-icon {
    margin: 0;
    text-align: center;
}

/* Sidebar Bottom (Profile & Dark Support Box) */
.sidebar-bottom {
    padding: 12px 10px;
    border-top: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-profile-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-dark-widget);
    border: 1px solid var(--border-dark-hover);
    color: var(--text-on-dark);
}

.profile-avatar-initials {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #222228;
    border: 1px solid #383842;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #FFFFFF;
    flex-shrink: 0;
}

.profile-info {
    overflow: hidden;
    line-height: 1.25;
}

.profile-name {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-role {
    font-size: 10.5px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.profile-online-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-positive);
}

.sidebar-support-box {
    background-color: var(--bg-dark-widget);
    border: 1px solid var(--border-dark);
    border-radius: 10px;
    padding: 10px;
    font-size: 11px;
    color: var(--text-secondary);
}

.support-box-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-subtle);
    padding: 4px 0;
    text-decoration: none;
    transition: color 0.12s ease;
}

.support-box-link:hover {
    color: var(--text-on-dark);
}

.app-shell.sidebar-collapsed .sidebar-profile-card .profile-info,
.app-shell.sidebar-collapsed .sidebar-support-box {
    display: none;
}

.app-shell.sidebar-collapsed .sidebar-profile-card {
    justify-content: center;
    padding: 6px 0;
}

/* ==========================================================================
   Main Content Canvas (Seam Rule: 24px top-left rounded corner)
   ========================================================================== */

#appMainCanvas,
.app-main-canvas {
    flex: 1;
    min-width: 0;
    height: 100%;
    max-height: 100%;
    background-color: var(--bg-surface);
    border-top-left-radius: var(--radius-canvas);
    padding: 28px 32px 48px 32px;
    box-shadow: -4px -4px 24px rgba(0, 0, 0, 0.35);
    overflow-y: auto; /* ONLY appMainCanvas scrolls */
    overflow-x: hidden;
    position: relative;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Page Header */
.demure-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-subtle);
}

.demure-h1,
.demure-page-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.25;
}

.demure-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.demure-tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius-pill);
    background: #EFEFF1;
    color: #141416;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.demure-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.demure-header-actions,
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ==========================================================================
   Buttons (DEMURE Editorial Standards)
   ========================================================================== */

.btn-demure-primary,
.btn-bank-primary {
    background-color: #0A0A0A;
    color: #FFFFFF;
    border: 1px solid #0A0A0A;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.3;
}

.btn-demure-primary:hover,
.btn-bank-primary:hover {
    background-color: #222226;
    border-color: #222226;
    color: #FFFFFF;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.btn-demure-outline,
.btn-demure-secondary,
.btn-bank-secondary {
    background-color: #FFFFFF;
    color: #0A0A0A;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.3;
}

.btn-demure-outline:hover,
.btn-bank-secondary:hover {
    background-color: var(--bg-card-alt);
    border-color: #D5D5DA;
    color: #0A0A0A;
}

.btn-demure-accent,
.btn-bank-success {
    background-color: var(--accent-positive);
    color: #FFFFFF;
    border: 1px solid var(--accent-positive);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-demure-accent:hover,
.btn-bank-success:hover {
    background-color: #19944f;
    border-color: #19944f;
    color: #FFFFFF;
    transform: translateY(-1px);
}

.btn-demure-sm,
.btn-bank-sm {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Section 5.1: Stat Cards (Top Row)
   ========================================================================== */

.demure-stat-card,
.metric-tile {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.demure-stat-card:hover,
.metric-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.04);
    border-color: var(--border-card);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-label,
.metric-desc {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    margin: 0;
    letter-spacing: -0.01em;
}

.stat-chip-positive {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background-color: var(--accent-positive-tint);
    color: var(--accent-positive);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    line-height: 1.2;
}

.stat-chip-negative {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background-color: var(--accent-negative-tint);
    color: var(--accent-negative);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    line-height: 1.2;
}

.stat-big-num,
.metric-num {
    color: var(--text-primary);
    font-size: 36px;
    font-weight: 700;
    line-height: 1.0;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    margin: 0;
}

.stat-footer-text {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ==========================================================================
   Section 5.2: Middle Sales / Repayments 31-Day Bar Chart
   ========================================================================== */

.chart-card-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.chart-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-title-area {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chart-h2 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin: 0;
}

.chart-grand-total {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.chart-total-num {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.chart-subtext {
    font-size: 12px;
    color: var(--text-secondary);
}

.chart-controls-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Segmented Pill Control */
.segmented-pill-group {
    display: inline-flex;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-subtle);
    padding: 3px;
    border-radius: var(--radius-pill);
}

.segmented-pill-btn {
    background: transparent;
    border: none;
    padding: 4px 14px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.segmented-pill-btn.active {
    background: #0A0A0A;
    color: #FFFFFF;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.chart-view-toggles {
    display: flex;
    gap: 4px;
}

.chart-view-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-card);
    background: #FFFFFF;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    cursor: pointer;
}

.chart-view-icon-btn.active {
    background: #0A0A0A;
    border-color: #0A0A0A;
    color: #FFFFFF;
}

/* 31-Day Bars Visual Container */
.bars-stage-container {
    position: relative;
    padding-top: 40px;
    padding-bottom: 8px;
}

.bars-rail {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 140px;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 4px;
    position: relative;
}

.chart-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
    justify-content: flex-end;
    position: relative;
    cursor: pointer;
}

.chart-bar {
    width: 13px;
    border-radius: 4px 4px 0 0;
    background-color: var(--bg-card-subtle);
    transition: height 0.25s ease, background 0.15s ease;
    min-height: 4px;
}

.chart-col:hover .chart-bar {
    background-color: #0A0A0A;
}

.chart-bar.filled-dark {
    background-color: #222226;
}

/* Day 17 Active Highlight (from DESIGN.md) */
.chart-bar.active-hatch,
.chart-col.selected .chart-bar {
    background: repeating-linear-gradient(
        45deg,
        #0A0A0A,
        #0A0A0A 3.5px,
        #FFFFFF 3.5px,
        #FFFFFF 7px
    ) !important;
    border: 1px solid #0A0A0A !important;
}

/* Micro Day Axis */
.bars-axis-days {
    display: flex;
    justify-content: space-between;
    padding: 8px 4px 0;
}

.axis-day-label {
    flex: 1;
    text-align: center;
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 500;
}

.axis-day-label.active {
    font-weight: 700;
    color: var(--text-primary);
}

/* Floating Tooltip with Downward Pointer Triangle */
.chart-floating-tooltip {
    position: absolute;
    background: #FFFFFF;
    border: 1px solid #D5D5DA;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    padding: 8px 12px;
    font-size: 12px;
    pointer-events: none;
    z-index: 20;
    transition: left 0.15s ease, top 0.15s ease;
    transform: translate(-50%, -100%);
    white-space: nowrap;
}

.chart-floating-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: #D5D5DA transparent transparent transparent;
}

.tooltip-date {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.tooltip-value {
    font-size: 13.5px;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    margin-top: 1px;
}

/* ==========================================================================
   Section 5.3: Bottom Analytics Grid (3 Cards)
   ========================================================================== */

.analytics-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.analytics-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.analytics-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.analytics-korean-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 4px;
}

.analytics-metric-num {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    margin: 2px 0;
}

/* Card 1: 4 Vertical Block Bars (Q1 - Q4) */
.quarterly-bars-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 80px;
    margin-top: 14px;
}

.quarter-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    justify-content: flex-end;
}

.quarter-bar-fill {
    width: 100%;
    border-radius: 10px;
    background-color: var(--bg-card-subtle);
    transition: height 0.3s ease;
}

.quarter-bar-fill.active-quarter {
    background-color: #28282D;
}

.quarter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Card 2 & 3: Smooth Bezier Spline Curves */
.spline-svg-wrap {
    width: 100%;
    height: 80px;
    margin-top: 10px;
}

.spline-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* ==========================================================================
   Section 5.4: High-Density Loan Accounts & Repayment Ledger Table
   ========================================================================== */

.ledger-section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    overflow: hidden;
    margin-top: 24px;
}

.ledger-filter-toolbar {
    padding: 16px 22px 14px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

/* Tabs: All Loans, Due Today, Pending OTP, Daily (100-Day), Monthly (Interest), Completed */
.ledger-tabs-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ledger-tab-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.12s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ledger-tab-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-card-alt);
}

.ledger-tab-btn.active {
    background-color: #0A0A0A;
    color: #FFFFFF;
}

.ledger-tab-badge {
    background: #EFEFF1;
    color: #0A0A0A;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-pill);
}

.ledger-tab-btn.active .ledger-tab-badge {
    background: #252528;
    color: #FFFFFF;
}

.ledger-search-box {
    position: relative;
    width: 260px;
}

.ledger-search-box i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--text-muted);
}

.ledger-search-input {
    width: 100%;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    padding: 6px 10px 6px 30px;
    font-size: 12.5px;
    color: var(--text-primary);
    background: var(--bg-card);
    outline: none;
    transition: border-color 0.15s ease;
}

.ledger-search-input:focus {
    border-color: #0A0A0A;
}

/* High-Density Ledger Table */
.demure-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.demure-table thead th {
    background-color: var(--bg-card-alt);
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.demure-table tbody td {
    padding: 12px 18px;
    font-size: 13.5px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.demure-table tbody tr:hover {
    background-color: #FAFBFB;
}

.demure-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Pills */
.pill-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.pill-status.active {
    background-color: var(--accent-positive-tint);
    color: var(--accent-positive);
}

.pill-status.draft,
.pill-status.pending-otp {
    background-color: #FEF3C7;
    color: #D97706;
}

.pill-status.closed {
    background-color: #F1F1F4;
    color: var(--text-secondary);
}

.pill-status .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.pill-status.active .dot { background-color: var(--accent-positive); }
.pill-status.pending-otp .dot { background-color: #D97706; }
.pill-status.closed .dot { background-color: var(--text-muted); }

/* Table Reference Pills & Borrower Chips */
.demure-ref-pill {
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-card-alt);
    border: 1px solid var(--border-subtle);
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    display: inline-block;
}

.borrower-flex-cell {
    display: flex;
    align-items: center;
    gap: 9px;
}

.borrower-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-card);
    color: #0A0A0A;
    font-weight: 700;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.borrower-name {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.25;
}

.borrower-subtext {
    font-size: 11px;
    color: var(--text-muted);
}

/* ==========================================================================
   Section 6: Workflow Dialogs & Modal Specifications
   ========================================================================== */

.modal-content.demure-modal {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-modal);
    overflow: hidden;
}

.demure-modal-header {
    background: #0A0A0A;
    color: #FFFFFF;
    padding: 18px 24px;
    border-bottom: 1px solid #18181B;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.demure-modal-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0;
    color: #FFFFFF;
}

.demure-modal-body {
    padding: 24px;
    background: #FFFFFF;
}

.demure-modal-footer {
    padding: 16px 24px;
    background: var(--bg-card-alt);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* Drag & Drop File Upload Zone */
.demure-dropzone {
    border: 2px dashed var(--border-card);
    border-radius: var(--radius-md);
    background: var(--bg-card-alt);
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.demure-dropzone:hover,
.demure-dropzone.dragover {
    border-color: #0A0A0A;
    background: #F0F0F2;
}

.dropzone-icon {
    font-size: 24px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.dropzone-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.dropzone-hint {
    font-size: 11px;
    color: var(--text-muted);
}

/* Real-Time Loan Math Breakdown Widget */
.loan-math-box {
    background: var(--bg-card-alt);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-top: 14px;
}

.math-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
    margin-bottom: 6px;
}

.math-row:last-child {
    margin-bottom: 0;
    padding-top: 6px;
    border-top: 1px solid var(--border-card);
    font-weight: 700;
    color: var(--text-primary);
}

/* Wallet Liquidity Banner */
.wallet-liquidity-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 12px;
}

.wallet-liquidity-banner.sufficient {
    background-color: var(--accent-positive-tint);
    border: 1px solid #c7eed6;
    color: #12753e;
}

.wallet-liquidity-banner.insufficient {
    background-color: var(--accent-negative-tint);
    border: 1px solid #f8cdcd;
    color: #b22626;
}

/* Sanction Certificate Print Surface */
.sanction-agreement-paper {
    background: #FFFFFF;
    border: 1px solid #E5E5E8;
    padding: 32px 36px;
    border-radius: var(--radius-md);
    font-size: 12px;
    line-height: 1.5;
    color: #18181B;
}

.sanction-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 16px;
    border-bottom: 2px solid #0A0A0A;
    margin-bottom: 18px;
}

.sanction-title {
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #0A0A0A;
}

.sanction-clauses-box {
    background: #FBFBFC;
    border: 1px solid #EFEFF1;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 11px;
    color: var(--text-secondary);
    margin: 14px 0;
}

.sanction-signatures {
    display: flex;
    justify-content: space-between;
    padding-top: 28px;
    margin-top: 24px;
    border-top: 1px dashed #CBD5E1;
}

.sig-col {
    text-align: center;
    width: 140px;
}

.sig-line {
    border-bottom: 1px solid #0A0A0A;
    height: 36px;
    margin-bottom: 6px;
}

/* ==========================================================================
   Responsive & Backward-Compatibility Rules
   ========================================================================== */

@media (max-width: 991px) {
    #topNavHeader {
        padding: 0 16px;
    }

    .nav-sub-brands {
        display: none;
    }

    .app-main-canvas {
        border-top-left-radius: 0;
        padding: 20px 16px;
    }

    #appSidebar {
        position: fixed;
        left: -240px;
        top: var(--header-height);
        bottom: 0;
        transition: left 0.25s ease;
    }

    .app-shell.sidebar-mobile-open #appSidebar {
        left: 0;
    }
}

@media print {
    html, body, body.app-shell-body, #appShell, .app-main-canvas {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
    }

    #topNavHeader,
    #appSidebar,
    .demure-page-header .header-actions,
    .modal-footer,
    .btn,
    .no-print {
        display: none !important;
    }

    body {
        background: #FFFFFF !important;
        color: #000000 !important;
    }

    .app-main-canvas {
        padding: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    .sanction-agreement-paper {
        border: none !important;
        padding: 0 !important;
    }
}


.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-control, .btn, .btn-demure-primary, .btn-demure-outline {
    min-height: 44px;
}

/* Mobile Tab Bar */
.mobile-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-dark);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1040;
    padding-bottom: env(safe-area-inset-bottom);
}

.tab-bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-subtle);
    font-size: 10px;
    font-weight: 500;
    text-decoration: none;
    min-width: 44px;
    min-height: 44px;
    padding: 4px;
}

.tab-bar-item.active {
    color: var(--text-on-dark);
}

.tab-bar-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

@media (max-width: 767.98px) {
    #appSidebar {
        display: none !important;
    }
    .app-main-canvas {
        padding-bottom: calc(60px + env(safe-area-inset-bottom)) !important;
        height: calc(100vh - var(--header-height) - 60px) !important;
    }
}
