/* ==========================================================================
   Dagyan Centralized Style Core — Enterprise Edition
   ========================================================================== */

:root {
    --bg-main: #050506;
    --bg-card: #0a0a0c;
    --bg-nested: #0c0c0e;
    --border-base: #1c1c21;
    --border-accent: #2d2d37;
    --text-primary: #f4f4f5;
    --text-muted: #a1a1aa;
    --text-dark: #8a8a93;
    --brand-blue: #0a84ff;
    --brand-blue-hover: #0062cc;
    --brand-green: #30d158;
    --max-width: 1000px;
}

html, body {
    margin: 0; padding: 0; width: 100%; min-height: 100vh;
    background-color: var(--bg-main); color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; box-sizing: border-box; }
*, *:before, *:after { box-sizing: border-box; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
        
/* ==========================================================================
   Global Layout Override: Infinite Scroll-Bypass
   ========================================================================== */
html, body { -ms-overflow-style: none; scrollbar-width: none; overflow-y: auto; overflow-x: hidden; }
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; width: 0 !important; height: 0 !important; }

.portal-layout, .portal-canvas, .modal-layer, .modal-surface, div {
    -ms-overflow-style: none !important; scrollbar-width: none !important;
}

.portal-layout::-webkit-scrollbar, .portal-canvas::-webkit-scrollbar, .modal-layer::-webkit-scrollbar, .modal-surface::-webkit-scrollbar, div::-webkit-scrollbar {
    display: none !important; width: 0 !important; height: 0 !important;
}

/* ==========================================================================
   Typography & Gradients
   ========================================================================== */
.text-gradient {
    background: linear-gradient(135deg, #ffffff 0%, #a1a1aa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==========================================================================
   Header & Global Menu
   ========================================================================== */
.site-nav {
    border-bottom: 1px solid var(--border-base); background-color: rgba(5, 5, 6, 0.85);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    position: sticky; top: 0; z-index: 1000; height: 64px;
}

.nav-wrapper { display: flex; align-items: center; justify-content: space-between; height: 100%; }
.brand-anchor { display: flex; align-items: center; gap: 8px; text-decoration: none; color: #ffffff; }
.brand-text { font-weight: 800; letter-spacing: -0.02em; font-size: 16px; }
.brand-badge { font-family: monospace; font-size: 10px; color: #fff; background-color: var(--brand-blue); padding: 2px 6px; border-radius: 4px; font-weight: 800; }

.nav-group { display: flex; align-items: center; gap: 24px; }
.nav-link { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-decoration: none; padding-bottom: 4px; transition: all 0.2s ease; border-bottom: 2px solid transparent; color: var(--text-dark); }
.nav-link.active, .nav-link:hover { color: #ffffff; }
.nav-link.active { border-bottom-color: var(--brand-blue); }

.btn-portal { font-size: 12px; font-weight: 600; text-decoration: none; padding: 8px 18px; border-radius: 6px; transition: all 0.2s ease; border: 1px solid var(--border-accent); background-color: #121215; color: #ffffff; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.btn-portal:hover { background-color: #1c1c21; border-color: var(--text-muted); }
.btn-portal.active { background-color: var(--brand-blue); border-color: var(--brand-blue); }

.btn-api { background: #121215; border: 1px solid #2d2d37; color: #ffffff; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 11px; font-weight: 600; text-transform: uppercase; transition: all 0.2s; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.btn-api:hover { background: #1c1c21; border-color: var(--brand-blue); color: var(--brand-blue); }

/* ==========================================================================
   Document Layout Typography & Cards
   ========================================================================== */
.main-content { flex-grow: 1; padding-top: 80px; padding-bottom: 80px; }
.section-hero { max-width: 860px; margin: 0 auto 64px auto; }
.section-hero h1 { font-size: 52px; font-weight: 900; margin-bottom: 24px; line-height: 1.1; letter-spacing: -0.03em;}
.section-hero p { font-size: 18px; color: var(--text-muted); line-height: 1.6; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.card { background-color: var(--bg-card); border: 1px solid var(--border-base); border-radius: 12px; padding: 32px; box-shadow: 0 12px 32px rgba(0,0,0,0.4); }
.card h3 { font-size: 20px; font-weight: 700; margin-bottom: 12px; margin-top: 0; }
.card p { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin: 0; }

.btn-action { display: inline-flex; justify-content: center; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; text-align: center; text-decoration: none; padding: 16px 40px; border-radius: 8px; cursor: pointer; background-color: var(--brand-blue); color: #ffffff; border: 1px solid rgba(255,255,255,0.1); width: 100%; margin-top: auto; box-shadow: 0 8px 24px rgba(10, 132, 255, 0.3), inset 0 1px 1px rgba(255,255,255,0.2); transition: all 0.2s; }
.btn-action:hover { background-color: var(--brand-blue-hover); transform: translateY(-1px); box-shadow: 0 12px 32px rgba(10, 132, 255, 0.4), inset 0 1px 1px rgba(255,255,255,0.2); }

/* ==========================================================================
   Responsive CSS Wireframes
   ========================================================================== */
.mockup-wrapper { display: flex; justify-content: center; align-items: flex-end; gap: 48px; flex-wrap: wrap; margin-bottom: 80px; }
.mockup-desktop { flex: 1 1 500px; max-width: 800px; height: 450px; background: #0a0a0c; border: 1px solid #2d2d37; border-radius: 12px; overflow: hidden; box-shadow: 0 32px 64px rgba(0,0,0,0.6); display: flex; flex-direction: column; }
.mockup-mobile { flex: 0 0 260px; height: 520px; background: #050506; border: 8px solid #2d2d37; border-radius: 36px; overflow: hidden; box-shadow: 0 24px 48px rgba(0,0,0,0.8); position: relative; display: flex; flex-direction: column; margin-bottom: -24px;}

@media (max-width: 900px) {
    .mockup-desktop { display: none !important; }
    .mockup-mobile { margin: 0 auto !important; flex: 0 0 260px !important; height: 520px !important; margin-bottom: 0 !important; }
    .mockup-wrapper { gap: 24px; margin-bottom: 48px !important; align-items: center; }
}

/* ==========================================================================
   Footer & Modals
   ========================================================================== */
.site-footer { border-top: 1px solid var(--border-base); background-color: #050506; padding: 48px 0; }
.footer-wrapper { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.footer-meta { font-family: monospace; font-size: 11px; color: var(--text-dark); }
.footer-links { display: flex; gap: 24px; }
.btn-trigger-modal { background: none; border: none; color: var(--text-dark); font-family: monospace; font-size: 11px; cursor: pointer; padding: 0; transition: color 0.2s; }
.btn-trigger-modal:hover { color: var(--text-primary); text-decoration: underline;}

.modal-layer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 2000; background-color: rgba(0, 0, 0, 0.9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.modal-layer.active { opacity: 1; pointer-events: auto; }
.modal-surface { background-color: #0a0a0c; border: 1px solid var(--border-accent); width: 100%; max-width: 680px; border-radius: 12px; padding: 32px; position: relative; max-height: 85vh; display: flex; flex-direction: column; transform: scale(0.95); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); overflow-y: auto; box-shadow: 0 32px 64px rgba(0,0,0,1); }
.modal-surface { -ms-overflow-style: none; scrollbar-width: none; overflow-y: scroll; }
.modal-surface::-webkit-scrollbar { display: none; }
.modal-layer.active .modal-surface { transform: scale(1); }
.modal-close { position: absolute; right: 24px; top: 24px; background: none; border: none; color: var(--text-dark); font-size: 28px; line-height: 1; cursor: pointer; transition: color 0.2s;}
.modal-close:hover { color: #fff; }

/* ==========================================================================
   Secure Authentication Form
   ========================================================================== */
.form-group { margin-bottom: 20px; text-align: left; }
.form-group-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.input-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-family: ui-monospace, monospace; }
.input-field { width: 100%; background-color: #050506; border: 1px solid var(--border-accent); border-radius: 6px; font-size: 14px; color: #ffffff; padding: 12px 16px; outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; box-sizing: border-box; }
.input-field:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15); }
.link-inline { font-size: 11px; color: var(--brand-blue); text-decoration: none; font-family: ui-monospace, monospace; }
.link-inline:hover { text-decoration: underline; }
.sso-divider { display: flex; align-items: center; text-align: center; color: var(--text-dark); font-size: 10px; font-family: ui-monospace, monospace; text-transform: uppercase; margin: 24px 0; }
.sso-divider::before, .sso-divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--border-base); }
.sso-divider:not(:empty)::before { margin-right: 12px; }
.sso-divider:not(:empty)::after { margin-left: 12px; }
.sso-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 8px; }
.btn-sso { background-color: #121215; border: 1px solid var(--border-accent); border-radius: 6px; padding: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; }
.btn-sso:hover { background-color: #1c1c21; border-color: var(--text-muted); transform: translateY(-1px); }
.sso-svg { width: 20px; height: 20px; }
.error-alert { color: #ff453a; font-family: ui-monospace, monospace; font-size: 11px; text-align: center; margin-top: 12px; background: rgba(255, 69, 58, 0.1); padding: 8px; border-radius: 4px; border: 1px solid rgba(255, 69, 58, 0.3);}

/* ==========================================================================
   SPA Architecture
   ========================================================================== */
.view-section { display: none; animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   Product UI Components (DIE)
   ========================================================================== */
.risk-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 32px; }
@media (max-width: 900px) { .risk-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .risk-grid { grid-template-columns: 1fr; } }
.risk-card { background-color: var(--bg-card); border: 1px solid var(--border-base); border-radius: 8px; padding: 24px; border-top-width: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);}
.risk-critical { border-top-color: #ff453a; }
.risk-high     { border-top-color: #ff9f0a; }
.risk-moderate { border-top-color: #0a84ff; }
.risk-terminal { border-top-color: #636366; }
.risk-label { font-size: 10px; font-family: monospace; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; display: block; font-weight: bold;}
.risk-critical .risk-label { color: #ff453a; }
.risk-high .risk-label     { color: #ff9f0a; }
.risk-moderate .risk-label { color: #0a84ff; }
.risk-terminal .risk-label { color: #8a8a93; }
.risk-card h4 { font-size: 16px; margin-bottom: 8px; font-weight: 700; color: #ffffff; margin-top: 0;}
.risk-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin: 0;}
.pricing-block { background: linear-gradient(145deg, #121215 0%, #050506 100%); border: 1px solid #1c1c21; border-radius: 16px; padding: 48px; text-align: center; max-width: 500px; margin: 64px auto 0 auto; box-shadow: 0 24px 48px rgba(0,0,0,0.6); position: relative; overflow: hidden;}
.pricing-block::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--brand-blue); }
.price-tag { font-size: 56px; font-weight: 900; color: #ffffff; margin: 16px 0; letter-spacing: -0.05em; }
.price-mo { font-size: 16px; color: var(--text-dark); font-weight: 500; letter-spacing: normal;}

/* ==========================================================================
   CLIENT PORTAL (Desktop Baseline)
   ========================================================================== */
.portal-layout { display: flex; height: calc(100vh - 64px); overflow: hidden; background-color: var(--bg-main); border-top: 1px solid var(--border-base); }
.portal-sidebar { width: 280px; background-color: #050506; border-right: 1px solid var(--border-base); display: flex; flex-direction: column; transition: width 0.3s ease; flex-shrink: 0; }
.sidebar-header { padding: 20px; display: flex; align-items: center; border-bottom: 1px solid var(--border-base); height: 72px; box-sizing: border-box; overflow: hidden; }
.btn-toggle-menu { background: #121215; border: 1px solid #1c1c21; color: var(--text-muted); cursor: pointer; padding: 8px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
.btn-toggle-menu:hover { background-color: #1c1c21; color: #fff; border-color: #2d2d37;}
.sidebar-title { font-size: 15px; font-weight: 800; color: #fff; margin-left: 16px; white-space: nowrap; letter-spacing: -0.02em;}
.sidebar-nav { flex-grow: 1; padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; overflow-x: hidden; }
.sidebar-link { display: flex; align-items: center; padding: 12px 16px; color: var(--text-muted); font-size: 13px; font-weight: 500; text-decoration: none; border-radius: 8px; transition: all 0.2s; white-space: nowrap; }
.sidebar-link:hover { background-color: #121215; color: #fff; }
.sidebar-link.active { background-color: rgba(10, 132, 255, 0.1); color: var(--brand-blue); font-weight: 700; border: 1px solid rgba(10, 132, 255, 0.2);}
.sidebar-icon { width: 18px; height: 18px; flex-shrink: 0; margin-right: 16px; }

.portal-canvas { flex-grow: 1; padding: 48px; overflow-y: auto; background-color: var(--bg-main); position: relative;}
.portal-panel { display: none; animation: fadeIn 0.3s ease; }
.portal-panel.active { display: block; }

/* Snapshot Grid */
.snapshot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; margin-top: 24px; }
.snapshot-card { background-color: var(--bg-card); border: 1px solid var(--border-base); border-radius: 10px; padding: 24px; cursor: pointer; transition: all 0.2s ease; box-shadow: 0 8px 24px rgba(0,0,0,0.3);}
.snapshot-card:hover:not(.sandbox-locked) { border-color: var(--brand-blue); transform: translateY(-4px); box-shadow: 0 16px 32px rgba(10, 132, 255, 0.15);}
.sandbox-locked { opacity: 0.4; pointer-events: none; }

/* ==========================================================================
   DASHBOARD ANALYTICS & WIDGETS
   ========================================================================== */
.kpi-card { background: var(--bg-card); border: 1px solid var(--border-base); border-radius: 8px; padding: 20px; position: relative; box-shadow: 0 8px 24px rgba(0,0,0,0.3);}
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; border-radius: 8px 0 0 8px; }
.kpi-card.b-blue::before { background: var(--brand-blue); }
.kpi-card.b-green::before { background: #30d158; }
.kpi-card.b-red::before { background: #ff453a; }
.kpi-card.b-purple::before { background: #bf5af2; }
.kpi-card.b-nri::before { background: #ff9f0a; }
.kpi-label { font-size: 11px; color: var(--text-dark); text-transform: uppercase; font-weight: 800; margin-bottom: 8px; letter-spacing: 0.05em;}
.kpi-value { font-size: 36px; font-weight: 800; color: #ffffff; letter-spacing: -0.03em; }

.badge { display: inline-block; padding: 4px 8px; font-size: 11px; font-weight: 800; border-radius: 4px; text-align: center; letter-spacing: 0.05em; font-family: monospace; text-transform: uppercase;}
.badge.CRITICAL { background-color: rgba(255, 59, 48, 0.15); color: #ff453a; border: 1px solid rgba(255, 59, 48, 0.3); }
.badge.HIGH { background-color: rgba(255, 159, 10, 0.15); color: #ff9f0a; border: 1px solid rgba(255, 159, 10, 0.3); }
.badge.MODERATE { background-color: rgba(48, 209, 88, 0.15); color: #30d158; border: 1px solid rgba(48, 209, 88, 0.3); }
.badge.TERMINAL { background-color: rgba(142, 142, 147, 0.15); color: #ebebf5; border: 1px solid rgba(142, 142, 147, 0.3); }

/* ==========================================================================
   UNIVERSAL ADAPTIVE LEDGER CARDS
   ========================================================================== */
.ledger-cards-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; margin-top: 24px;
}

.ledger-card-item {
    background: #0a0a0c; border: 1px solid var(--border-base); border-radius: 10px; padding: 20px; display: flex; flex-direction: column; gap: 16px; position: relative; border-left-width: 4px; transition: transform 0.2s, border-color 0.2s; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.ledger-card-item:hover { border-color: #2d2d37; transform: translateY(-2px); box-shadow: 0 12px 32px rgba(0,0,0,0.5);}

.ledger-card-item.CRITICAL { border-left-color: #ff453a; }
.ledger-card-item.HIGH     { border-left-color: #ff9f0a; }
.ledger-card-item.MODERATE { border-left-color: #30d158; }
.ledger-card-item.TERMINAL { border-left-color: #8e8e93; }

.ledger-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ledger-card-entity { font-size: 16px; font-weight: 800; color: #ffffff; word-break: break-word; line-height: 1.3; letter-spacing: -0.01em;}

.ledger-card-details { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 12px; color: var(--text-muted); }
.ledger-card-details div { display: flex; flex-direction: column; gap: 4px; }
.ledger-card-details span { color: var(--text-primary); font-family: monospace; font-size: 11px; font-weight: bold;}

.ledger-card-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-base); padding-top: 16px; margin-top: auto; }

/* Pagination Controls */
.pagination-container { display: flex; justify-content: space-between; align-items: center; margin-top: 32px; flex-wrap: wrap; gap: 16px; background: #0a0a0c; padding: 16px 24px; border-radius: 8px; border: 1px solid #1c1c21;}
.pagination-info { font-family: monospace; font-size: 12px; color: var(--text-muted); }
.pagination-controls { display: flex; gap: 8px; align-items: center; }
.btn-page { background: #121215; border: 1px solid var(--border-accent); color: #ffffff; padding: 10px 20px; border-radius: 6px; font-size: 12px; font-weight: bold; cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 12px rgba(0,0,0,0.2);}
.btn-page:hover:not(:disabled) { background: #1c1c21; border-color: var(--brand-blue); color: var(--brand-blue); }
.btn-page:disabled { opacity: 0.3; cursor: not-allowed; }

/* Base Modal Display Settings */
.mobile-pdf-action { display: none; }
#pdf-viewer-frame-container { display: block; }

/* ==========================================================================
   Mobile PWA HUD & Grid Adaptations (< 768px)
   ========================================================================== */

.mobile-top-bar, .mobile-bottom-nav { display: none; }
.footer-wrapper { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.footer-links { display: flex; gap: 16px; }

@media (max-width: 768px) {
    body { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); background-color: #050506; }
    .portal-layout { height: auto !important; }
    .portal-sidebar { display: none !important; }

    .portal-canvas { padding: 16px 12px 110px 12px !important; min-height: 100vh; }

    .mobile-top-bar { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; background: rgba(5, 5, 6, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255,255,255,0.05); position: sticky; top: 0; z-index: 1000; }
    .mobile-bottom-nav { display: flex; justify-content: space-around; align-items: center; position: fixed; bottom: 0; left: 0; right: 0; height: 72px; padding-bottom: env(safe-area-inset-bottom); background: rgba(5, 5, 6, 0.75); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid rgba(10, 132, 255, 0.15); box-shadow: 0 -4px 32px rgba(10, 132, 255, 0.1); z-index: 9999; }
    .mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: 6px; color: #636366; text-decoration: none; font-family: monospace; font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; transition: all 0.2s ease; flex: 1; }
    .mobile-nav-item svg { width: 22px; height: 22px; stroke: currentColor; }
    .mobile-nav-item.active { color: #0a84ff; text-shadow: 0 0 8px rgba(10, 132, 255, 0.4); }
    .mobile-nav-item.active svg { stroke: #0a84ff; filter: drop-shadow(0 0 6px rgba(10, 132, 255, 0.6)); transform: translateY(-2px); }
    .mobile-nav-item.text-danger { color: #ff453a; }
    .mobile-nav-item.text-danger:active { text-shadow: 0 0 8px rgba(255, 69, 58, 0.4); }

    .section-hero h1 { font-size: 36px; }

    .grid-2 { grid-template-columns: 1fr !important; gap: 16px !important; }
    #dashboard-kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 12px !important; }
    
    #dashboard-map-container { height: auto !important; min-height: 280px !important; padding: 12px !important; }
    #germanyGeoMapChart { width: 100% !important; min-height: 260px !important; }

    .modal-surface { width: 92% !important; max-height: 85vh; padding: 20px !important; }

    .footer-wrapper { flex-direction: column; text-align: center; padding-bottom: 90px !important; }
    .footer-lang-container { display: none !important; }
    .footer-legal { flex-wrap: wrap; justify-content: center; }

    #dashboard-header-container { flex-direction: column !important; align-items: flex-start !important; gap: 16px; }
    #dashboard-header-container > div:last-child { text-align: left !important; }
    #dashboard-filter-tabs { flex-direction: column !important; align-items: flex-start !important; gap: 12px; }
    #dashboard-filter-tabs > div { width: 100%; display: flex; }
    #dashboard-filter-tabs button { flex: 1; padding: 10px 4px !important; }
    #dashboard-ledger-container > div:first-child { flex-direction: column !important; align-items: flex-start !important; }
    #dashboard-ledger-tools { width: 100%; flex-direction: column !important; align-items: stretch !important; }
    #custom-ledger-search { width: 100% !important; padding: 12px !important; box-sizing: border-box; }
    #dashboard-ledger-tools .btn-api { width: 100% !important; padding: 12px !important; }

    .ledger-cards-grid { grid-template-columns: 1fr; }
    
    /* Touch-Friendly Mobile Pagination Stack */
    .pagination-container { flex-direction: column; align-items: stretch; gap: 16px; }
    .pagination-info { text-align: center; font-size: 13px; }
    .pagination-controls { justify-content: space-between; }
    .btn-page { flex: 1; padding: 14px !important; font-size: 13px !important; }
}

/* ==========================================================================
   Smooth Navigation & PWA Standalone Handlers
   ========================================================================== */
html { scroll-behavior: smooth; }

@media (display-mode: standalone) {
    #deploy-action-wrapper { 
        display: none !important; 
    }
}

/* ==========================================================================
   Desktop Sidebar Collapsed State (Triggered via JS body class)
   ========================================================================== */
@media (min-width: 769px) {
    body.sidebar-collapsed .portal-sidebar {
        width: 80px; /* Shrinks the sidebar */
    }
    
    /* Hide all text labels and specific badges */
    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .link-text,
    body.sidebar-collapsed #sidebar-lang-indicator {
        display: none !important;
    }
    
    /* Re-center the header and hide the main logo, leaving only the hamburger button */
    body.sidebar-collapsed .sidebar-header {
        justify-content: center !important;
        padding-left: 0;
        padding-right: 0 !important;
    }
    body.sidebar-collapsed .sidebar-title {
        display: none !important; 
    }
    
    /* Center the navigation icons */
    body.sidebar-collapsed .sidebar-link {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }
    body.sidebar-collapsed .sidebar-icon {
        margin-right: 0; /* Removes the margin that pushed text right */
    }
    
    /* Clean up the footer alignment */
    body.sidebar-collapsed .sidebar-footer {
        padding: 16px 0 !important;
        align-items: center;
    }
    body.sidebar-collapsed .sidebar-footer button {
        border-color: transparent !important; /* Hides the border on the language button when minimized */
    }
}

