/* Design Tokens */
:root {
    /* Retro Schematic Palette */
    --bg-app: #f4ecd8;
    /* Beige/Cream base */
    --bg-panel: #f4ecd8;
    /* Matches paper */
    --primary: #3b422a;
    /* Olive Dark */
    --primary-light: #6b7a4f;
    /* Olive Light */
    --olive-dark: var(--primary);
    --olive-light: var(--primary-light);
    --bg-paper: var(--bg-app);
    --text-main: #3b422a;
    /* Olive Dark */
    --text-muted: rgba(59, 66, 42, 0.7);
    --border-color: #3b422a;
    --border-focus: #3b422a;
    --danger: #8e2d2d;
    --risk-high: #8e2d2d;
    --risk-medium: #c27c00;
    --risk-low: #6b7a4f;
    /* Muted Earthy Tones */
    --grid-line: rgba(59, 66, 42, 0.15);

    --border-thick: 3px solid var(--primary);
    --border-thin: 1px solid var(--primary);
    --shadow-solid: 6px 6px 0px var(--primary);
    --shadow-solid-sm: 3px 3px 0px var(--primary);

    --radius: 2px;
    /* Sharp corners */
    --notebook-margin: 80px;

    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* Global reset and base styles */
* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    /* Graph Paper Effect */
    background-size: 20px 20px;
    background-image:
        linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: var(--notebook-margin);
    width: 2px;
    height: 100%;
    background: rgba(183, 28, 28, 0.2);
    /* Red notebook margin line */
    z-index: -1;
}


/* Floating Guide Assistant (Guided Mode) */
.guide-assistant-container {
    position: absolute;
    top: 120px;
    left: 15px;
    right: 15px;
    z-index: 2500;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.guide-assistant-container.hidden {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    pointer-events: none;
}

.guide-popup {
    background: #fff;
    border: var(--border-thick);
    box-shadow: 8px 8px 0px var(--primary);
    padding: 20px;
    pointer-events: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.guide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--grid-line);
    padding-bottom: 8px;
}

.guide-step-tag {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 800;
    background: var(--primary);
    color: var(--bg-app);
    padding: 2px 8px;
    text-transform: uppercase;
}

.guide-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    color: var(--text-muted);
}

.guide-content {
    font-size: 0.9rem;
    line-height: 1.5;
    font-weight: 500;
}

.guide-content strong {
    color: var(--primary);
    border-bottom: 1px solid var(--primary);
}

.guide-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 5px;
}

.guide-btn {
    background: var(--primary);
    color: var(--bg-app);
    border: none;
    padding: 6px 15px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 3px 3px 0px var(--primary-light);
}

.guide-btn:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

.guide-back {
    background: var(--bg-app);
    color: var(--text-main);
    border: var(--border-thin);
    padding: 6px 15px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 3px 3px 0px var(--primary);
}

.guide-back:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

/* Mobile Adjustments for Guide */
@media (max-width: 1200px) {
    .guide-assistant-container {
        right: 20px;
        bottom: 100px;
        width: calc(100% - 40px);
        max-width: 350px;
    }
}

@media (max-width: 900px) {
    .guide-assistant-container {
        bottom: 80px;
        left: 20px;
        right: 20px;
        width: auto;
        max-width: none;
    }
}

button {
    font-family: inherit;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Desktop layout */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
    box-sizing: border-box;
}

.app-container {
    display: grid;
    grid-template-columns: 240px 1fr 550px;
    grid-template-rows: 64px 1fr;
    height: 100vh;
    width: 100%;
    overflow: visible;
}

/* Header styling */
.app-header {
    grid-column: 1 / -1;
    grid-row: 1 / 2;
    background-color: var(--bg-panel);
    border-bottom: var(--border-thick);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 60;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.mobile-hamburger {
    display: none;
    background: none;
    border: var(--border-thick);
    cursor: pointer;
    color: var(--text-main);
    padding: 4px;
    margin-right: 5px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    padding: 8px 12px;
    border: var(--border-thin);
    background: var(--bg-app);
    box-shadow: var(--shadow-solid-sm);
    transition: 0.1s;
}

.back-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--primary);
}

.app-header .logo {
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--bg-app);
    background: var(--primary);
    border: var(--border-thin);
    padding: 4px 10px;
    text-transform: uppercase;
    margin-left: 15px;
}

.app-header .logo .highlight {
    color: #c0ca33;
}

.header-right {
    margin-left: auto;
}

#reset-btn {
    background: var(--bg-app);
    border: var(--border-thick);
    color: var(--danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 0;
    transition: 0.1s;
    font-size: 0.75rem;
    text-transform: uppercase;
    box-shadow: var(--shadow-solid-sm);
}

#reset-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--primary);
}

#calculate-btn {
    background: var(--bg-app);
    border: var(--border-thick);
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 0;
    transition: 0.1s;
    font-size: 0.75rem;
    text-transform: uppercase;
    box-shadow: var(--shadow-solid-sm);
}

#calculate-btn:hover {
    background: var(--primary-light);
    color: var(--bg-app);
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--primary);
}

#calculate-btn:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

#calculate-btn svg {
    transition: transform 0.3s ease;
}

#calculate-btn.calculating svg {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.header-btn-content {
    background: var(--primary);
    color: var(--bg-app);
    border: var(--border-thick);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 0;
    transition: 0.1s;
    font-size: 0.75rem;
    text-transform: uppercase;
    box-shadow: var(--shadow-solid-sm);
    height: 38px;
    box-sizing: border-box;
}

.header-btn-content:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--primary);
}

/* Sidebar styling */
.sidebar-nav {
    grid-row: 2 / 3;
    grid-column: 1 / 2;
    background: var(--bg-panel);
    border-right: var(--border-thick);
    color: var(--text-main);
    padding: 20px 12px;
    overflow-y: auto !important;
    overflow-x: visible;
    z-index: 50;
    height: 100%;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.mobile-sidebar-header,
.sidebar-overlay {
    display: none !important;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100%;
}

.sidebar-nav li {
    cursor: pointer;
    margin: 0;
    /* Remove individual margins to rely on parent gap */
    overflow: visible;
}

.sidebar-nav li span {
    display: block;
    padding: 10px 16px;
    border: var(--border-thin);
    font-weight: 800;
    font-size: 0.85rem;
    text-transform: uppercase;
    transition: 0.1s;
    background: var(--bg-app);
}

.sidebar-nav li span:hover {
    background: var(--primary-light);
    color: var(--bg-app);
}

.sidebar-nav li.active>span {
    background: var(--primary);
    color: var(--bg-app);
    box-shadow: var(--shadow-solid-sm);
}

.sidebar-nav .sub-menu {
    padding-left: 12px;
    margin-top: 6px;
    display: none;
    border-left: 2px dashed var(--primary);
}

.sidebar-nav li.active>.sub-menu {
    display: block;
}

.sidebar-nav .sub-menu li {
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-main);
    background: none;
    margin-bottom: 2px;
}

/* Sidebar items spacing */
#nav-audit-shield-tool {
    margin-top: auto;
}

.sidebar-nav .sub-menu li:hover {
    color: var(--bg-app);
    background: var(--primary-light);
}

.sidebar-nav .sub-menu li.active {
    color: var(--bg-app);
    font-weight: 800;
    background: var(--primary-light);
}

/* Main content area */
.main-content {
    grid-row: 2 / 3;
    grid-column: 2 / 3;
    background: transparent;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.mobile-form-header {
    display: none !important;
}

.form-container {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    padding-bottom: 80px;
}

/* FBR Tables Styling */
.fbr-form {
    display: none;
}

.fbr-form.active {
    display: block;
}

.fbr-table {
    display: flex;
    flex-direction: column;
    border: var(--border-thick);
    background: var(--bg-panel);
    box-shadow: var(--shadow-solid);
    overflow: hidden;
    margin-bottom: 24px;
}

.fbr-row {
    display: flex;
    border-bottom: var(--border-thin);
    align-items: center;
    padding: 8px 0;
}

.fbr-row:last-child {
    border-bottom: none;
}

.fbr-row.header {
    background: var(--primary);
    color: var(--bg-app);
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px 0;
}

.fbr-row div {
    padding: 0 16px;
    box-sizing: border-box;
}

.col-desc {
    flex: 3;
    min-width: 200px;
    line-height: 1.4;
    font-size: 0.85rem;
    font-weight: 700;
}

.col-code {
    flex: 0.6;
    min-width: 80px;
    text-align: center;
    font-family: var(--font-mono);
}

.col-amount,
.col-fair-market,
.col-tax-credit,
.col-eligible,
.col-ineligible,
.col-tax-chargeable,
.col-tax-reduced,
.col-cost-value,
.col-deemed-income,
.col-agri-total,
.col-agri-exempt,
.col-agri-normal,
.col-agri-province {
    flex: 1;
    min-width: 120px;
    font-family: var(--font-mono);
}

/* Code Badge */
.fbr-row:not(.header) .col-code {
    background: var(--primary-light);
    border: var(--border-thin);
    margin: 0 8px;
    padding: 0;
    font-weight: 800;
    color: var(--bg-app);
    font-size: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 32px;
}

/* Inputs */
.fbr-table input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-app);
    border: var(--border-thin);
    font-size: 0.9rem;
    font-family: var(--font-mono);
    font-weight: 700;
    box-sizing: border-box;
    color: var(--text-main);
    height: 38px;
    transition: 0.1s;
}

.fbr-table input:focus {
    border-width: 2px;
    outline: none;
    background: white;
}

.fbr-table input:disabled {
    background: rgba(59, 66, 42, 0.05);
    color: var(--text-muted);
    border-style: dashed;
    font-weight: 700;
    cursor: default;
}

/* Category Rows */
.fbr-row.category-total {
    background: rgba(59, 66, 42, 0.1);
    padding: 12px 0;
    border-bottom: var(--border-thick);
    border-top: var(--border-thick);
}

.fbr-row.category-total .col-desc {
    font-weight: 900;
    text-transform: uppercase;
}

.fbr-row.category-total input {
    border-width: 2px;
    background: var(--bg-app);
    font-weight: 800;
}

.fbr-row.category-total.sub {
    background: rgba(59, 66, 42, 0.05);
    border-bottom: var(--border-thin);
    border-top: var(--border-thin);
}


/* Chat section */
.chat-section {
    grid-row: 2 / 3;
    grid-column: 3 / 4;
    background: var(--bg-panel);
    border-left: var(--border-thick);
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.chat-section header h1 {
    margin: 0;
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 900;
    text-transform: uppercase;
}

.chat-section .subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 4px;
}

/* User Dropdown & Custom Select Shared Styles */
.user-menu-dropdown {
    background: var(--bg-app);
    border: var(--border-thick);
    box-shadow: var(--shadow-solid);
    padding: 4px 0;
    min-width: 160px;
    z-index: 1000;
}

.user-menu-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-main);
    text-decoration: none;
}

.user-menu-dropdown a:hover {
    background: var(--primary);
    color: var(--bg-app);
}

.nav-logout {
    color: var(--danger) !important;
}

.nav-logout:hover {
    color: var(--bg-app) !important;
    background: var(--danger) !important;
}

/* Language Selector Specifics */
.custom-select-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

.custom-select-display {
    padding: 4px 10px;
    border: var(--border-thick);
    background: var(--bg-app);
    color: var(--text-main);
    font-weight: 800;
    font-size: 0.7rem;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: var(--shadow-solid-sm);
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-select-options {
    position: relative;
    /* Push layout instead of overlapping */
    top: 0;
    left: 0;
    margin-top: 5px;
    list-style: none;
    padding: 0;
    width: 100%;
    max-width: 180px;
}

.custom-select-options li a {
    padding: 6px 10px;
    font-size: 0.7rem;
}

.chat-box {
    flex: 1;
    background: rgba(59, 66, 42, 0.02);
    border: var(--border-thick);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.chat-box:hover {
    scrollbar-color: var(--primary) transparent;
}

.chat-box::-webkit-scrollbar {
    width: 6px;
}

.chat-box::-webkit-scrollbar-track {
    background: transparent;
}

.chat-box::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
}

.chat-box:hover::-webkit-scrollbar-thumb {
    background: var(--primary);
}

.chat-box::-webkit-scrollbar-button {
    display: none;
}

.message {
    max-width: 90%;
    padding: 12px 16px;
    border: var(--border-thick);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.5;
    box-shadow: var(--shadow-solid-sm);
}

.user {
    background: var(--primary);
    color: var(--bg-app);
    align-self: flex-end;
    box-shadow: -4px 4px 0px var(--primary-light);
}

.bot {
    background: #fff9c4;
    border: var(--border-thick);
    color: var(--text-main);
    align-self: flex-start;
    border-left-width: 8px;
}

/* Input Area - Dynamic Smooth Transition */
.input-area {
    position: relative;
    background: var(--bg-app);
    border: var(--border-thick);
    border-radius: 28px;
    min-height: 52px;
    max-height: 240px;
    flex-shrink: 0;
    margin-bottom: 15px;
    box-shadow: var(--shadow-solid-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: min-height 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-area textarea {
    width: 100%;
    box-sizing: border-box;
    /* Default: Text level with icons */
    padding: 14px 120px 14px 50px;
    border: none;
    outline: none;
    font-size: 15px;
    background: transparent;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-main);
    text-align: left;
    resize: none;
    height: 52px;
    max-height: 150px;
    line-height: 1.4;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
    z-index: 2;
    transition: padding 0.2s cubic-bezier(0.4, 0, 0.2, 1), height 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Multi-line State: Text flows above icons */
.input-area.has-shelf {
    min-height: 90px;
}

.input-area.has-shelf textarea {
    /* Use margin-bottom instead of padding-bottom so scrollbar stops above toolbar */
    padding: 12px 35px 12px 45px;
    margin-bottom: 52px;
}

.input-area textarea.has-scroll {
    overflow-y: auto;
}

/* Custom Scrollbar - Slim */
.input-area textarea::-webkit-scrollbar {
    width: 5px;
}

.input-area textarea::-webkit-scrollbar-track {
    background: transparent;
}

.input-area textarea::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.input-toolbar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 52px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
    pointer-events: none;
    z-index: 5;
    background: transparent;
    transition: background 0.2s ease;
}

.input-area.has-shelf .input-toolbar {
    background: var(--bg-app);
    border-top: 1px dashed rgba(59, 66, 42, 0.1);
    pointer-events: auto;
}

.custom-placeholder {
    position: absolute;
    left: 66px;
    /* moved slightly left as requested */
    right: 95px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(59, 66, 42, 0.66);
    font-family: var(--font-sans);
    font-weight: 600;
    font-style: normal;
    font-size: 14px;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s ease;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.18);
}

.custom-placeholder.hidden {
    opacity: 0;
}

.input-toolbar button,
.input-toolbar .input-actions {
    pointer-events: auto;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* (scrollbar defined above) */

.input-area button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: all 0.2s ease;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.input-area button:hover {
    background: var(--primary);
    color: var(--bg-app);
}

#record-btn.recording {
    background-color: #fee2e2;
    color: var(--danger);
}

#send-btn:active {
    transform: scale(0.9);
}

.mini-summary {
    margin-top: 10px;
    padding-top: 15px;
    border-top: var(--border-thin);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-main);
}

.summary-item span:last-child {
    font-weight: 900;
    font-family: var(--font-mono);
    font-size: 1rem;
}

.mobile-tab-bar {
    display: none !important;
}

.hidden {
    display: none !important;
}

/* Mobile optimization */
@media (max-width: 900px) {
    .app-container {
        display: block;
        position: relative;
        height: 100vh;
        height: 100dvh;
        width: 100%;
        padding-top: 64px;
    }

    .app-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        padding: 0 12px;
        z-index: 60;
        height: 64px;
        justify-content: space-between;
    }

    .header-left {
        gap: 8px;
    }

    .mobile-hamburger {
        display: block;
        border-width: 2px;
        padding: 3px;
    }

    .app-header .logo {
        display: none;
    }

    .back-btn {
        padding: 6px 8px;
        font-size: 0.7rem;
    }

    .back-btn span {
        display: none;
    }

    /* Show only home icon on very small screens if needed, but keeping for now */

    #reset-btn {
        padding: 6px 10px;
    }

    #reset-btn span {
        display: none;
    }

    .sidebar-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85vw;
        max-width: 300px;
        height: 100%;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 10px 0 25px rgba(0, 0, 0, 0.1);
        border-right: var(--border-thick);
        padding: 20px 12px 100px;
        z-index: 2001;
        overflow-y: auto !important;
        /* Mandatory for mobile menu accessibility */
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-nav.open {
        left: 0;
    }

    .mobile-sidebar-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 15px;
        border-bottom: var(--border-thin);
        margin-bottom: 15px;
    }

    #close-sidebar {
        background: none;
        border: var(--border-thick);
        padding: 5px 12px;
        font-weight: 900;
        cursor: pointer;
        color: var(--text-main);
        font-size: 1.2rem;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(59, 66, 42, 0.5);
        z-index: 2000;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active {
        display: block !important;
    }

    .main-content {
        position: absolute;
        top: 64px;
        left: 0;
        width: 100%;
        height: calc(100% - 128px);
        z-index: 10;
        display: none;
        padding-bottom: 0;
        overflow-y: auto;
    }

    .form-container {
        padding: 15px 12px 120px;
    }

    /* Form Table Mobile Fixes */
    .fbr-table {
        display: block;
        overflow-x: auto;
        width: 100%;
        border-width: 2px;
        -webkit-overflow-scrolling: touch;
        background: none;
        /* Let the rows/inner container handle background */
        box-shadow: none;
    }

    .fbr-row {
        min-width: 100%;
        /* Spans at least the viewport */
        width: max-content;
        /* Expands to fit fixed-width columns if they exceed viewport */
        padding: 6px 0;
        background: var(--bg-panel);
        /* Row-level background for scroll consistency */
        display: flex;
    }

    .fbr-row.header {
        font-size: 0.65rem;
        padding: 10px 0;
        background: var(--primary);
        /* Header background spans full row width */
    }

    /* Fixed Widths for Alignment with Flex-Grow for Description */
    .col-desc,
    .col-code,
    .col-amount,
    .col-fair-market,
    .col-tax-credit,
    .col-eligible,
    .col-ineligible,
    .col-tax-chargeable,
    .col-tax-reduced,
    .col-cost-value,
    .col-deemed-income,
    .col-deemed,
    .col-agri-total,
    .col-agri-exempt,
    .col-agri-normal,
    .col-agri-province,
    .col-collected,
    .col-chargeable {
        flex: none !important;
    }

    .col-desc {
        font-size: 0.75rem;
        width: 250px !important;
        flex: 1 0 auto !important;
        /* Grow to fill space, but don't shrink below 250px */
        min-width: 250px;
    }

    .col-code {
        width: 80px !important;
        margin: 0 !important;
    }

    .col-amount,
    .col-fair-market,
    .col-tax-credit,
    .col-eligible,
    .col-ineligible,
    .col-tax-chargeable,
    .col-tax-reduced,
    .col-cost-value,
    .col-deemed-income,
    .col-deemed,
    .col-agri-total,
    .col-agri-exempt,
    .col-agri-normal,
    .col-agri-province,
    .col-collected,
    .col-chargeable {
        width: 160px !important;
    }

    .fbr-table input {
        height: 36px;
        font-size: 0.85rem;
        padding: 4px 10px;
    }

    /* Mobile Chat Adjustments */
    .chat-section {
        position: absolute;
        top: 64px;
        left: 0;
        width: 100%;
        height: calc(100% - 128px);
        z-index: 10;
        display: none;
        border-left: none;
        padding: 12px;
        background-image: none;
    }

    .active-tab {
        display: flex !important;
        flex-direction: column;
    }

    .chat-box {
        padding: 10px;
        gap: 10px;
        border-width: 2px;
        overflow-y: auto;
        /* Standard auto scroll for mobile touch */
    }

    /* Mobile Scrollbar: Thinner and no arrows */
    .chat-box::-webkit-scrollbar {
        width: 4px;
    }

    .chat-box::-webkit-scrollbar-button {
        display: none;
    }

    .chat-box::-webkit-scrollbar-track {
        border-left: none;
    }

    .message {
        font-size: 0.8rem;
        padding: 10px 12px;
        max-width: 95%;
        border-width: 2px;
    }

    /* Mobile Input Area Optimization */
    .input-area {
        gap: 0;
        padding: 0;
        border-width: 2px;
        min-height: 48px;
        /* Slightly slimmer base */
        border-radius: 20px;
    }

    .input-area textarea {
        padding: 12px 80px 12px 40px;
        /* Tighter side padding */
        font-size: 14px;
        height: 48px;
        max-height: 120px;
        /* Less tall on mobile to save space */
    }

    .input-area.has-shelf {
        min-height: 80px;
    }

    .input-area.has-shelf textarea {
        padding: 10px 12px 44px 12px;
    }

    .input-toolbar {
        height: 44px;
    }

    .input-area button {
        width: 38px;
        height: 38px;
    }

    #attach-btn {
        left: 4px;
        bottom: 4px;
    }

    .input-actions {
        right: 4px;
        bottom: 4px;
    }

    .custom-placeholder {
        left: 66px;
        /* align with main setting */
        right: 88px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 14px;
        font-weight: 600;
        color: rgba(59, 66, 42, 0.66);
    }

    .mini-summary {
        padding-top: 10px;
        margin-top: 5px;
    }

    .summary-item {
        margin: 4px 0;
        font-size: 0.7rem;
    }

    .summary-item span:last-child {
        font-size: 0.85rem;
    }

    .mobile-tab-bar {
        display: flex !important;
        justify-content: space-around;
        align-items: center;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 64px;
        background: var(--bg-app);
        border-top: var(--border-thick);
        z-index: 100;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .tab-btn {
        flex: 1;
        background: none;
        border: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--text-main);
        opacity: 0.6;
        cursor: pointer;
        transition: 0.2s;
    }

    .tab-btn svg {
        width: 20px;
        height: 20px;
    }

    .tab-btn span {
        font-size: 0.65rem;
        font-weight: 800;
        text-transform: uppercase;
        margin-top: 2px;
    }

    .tab-btn.active {
        opacity: 1;
        color: var(--primary);
        font-weight: 900;
    }
}

/* Smallest devices (iPhone SE) */
@media (max-width: 380px) {
    .app-header {
        height: 52px;
        padding: 0 4px;
    }

    .mobile-hamburger,
    .back-btn,
    .audit-badge,
    .header-btn-content,
    #reset-btn {
        height: 36px !important;
        min-width: 36px;
        padding: 0 4px !important;
        font-size: 0.6rem !important;
    }

    .audit-badge .label {
        font-size: 0.55rem !important;
    }

    /* Mobile Sidebar Overrides */
    .mobile-sidebar {
        width: 90vw;
    }

    .sidebar-content {
        padding: 15px 15px 50px 15px;
    }

    .sidebar-links li {
        margin-bottom: 10px !important;
    }

    .nav-item {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    .sidebar-auth {
        margin-top: 15px;
        padding-top: 15px;
    }

    .sidebar-header {
        padding: 15px !important;
    }

    .form-container {
        padding: 10px 8px 100px;
    }

    .fbr-row {
        min-width: 650px;
    }

    .chat-section {
        padding: 8px;
    }

    .message {
        font-size: 0.75rem;
    }
}

/* Auth and landing pages */

.navbar {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    background: var(--bg-app);
    border-bottom: var(--border-thick);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .nav-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--bg-app);
    background: var(--primary);
    border: var(--border-thin);
    padding: 4px 12px;
    text-transform: uppercase;
    text-decoration: none;
    display: inline-block;
}

.logo .highlight {
    color: #c0ca33;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 16px;
    padding: 0;
    margin: 0;
    align-items: center;
}

.nav-links a,
.nav-item {
    font-family: var(--font-mono);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 8px 14px;
    border: var(--border-thin);
    text-decoration: none;
    color: var(--text-main);
    background: var(--bg-app);
    box-shadow: 3px 3px 0px var(--primary);
    transition: transform 0.1s, box-shadow 0.1s, background 0.1s;
    display: block;
}

.nav-links a:hover,
.nav-item:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--primary);
    background: var(--primary-light);
    color: var(--bg-app);
}

.logout-link {
    color: var(--danger) !important;
    background: transparent !important;
    border: 1px solid var(--danger) !important;
    box-shadow: 3px 3px 0px var(--danger) !important;
    text-decoration: none;
    transition: all 0.1s ease;
}

/* Ensure desktop dropdown logout doesn't have chunky border/shadow */
.dropdown-content .logout-link {
    border: none !important;
    box-shadow: none !important;
    width: 100%;
    padding: 10px 15px !important;
    display: flex !important;
    align-items: center;
    background: transparent !important;
}

.logout-link:hover,
.dropdown-content .logout-link:hover {
    color: var(--bg-paper) !important;
    background: var(--danger) !important;
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--danger) !important;
}

.dropdown-content .logout-link:hover {
    transform: none !important;
    box-shadow: none !important;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.auth-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Navbar Buttons specific sizing */
.navbar .btn-primary,
.navbar .btn-secondary,
.navbar .btn-login {
    width: auto;
    padding: 8px 16px;
    font-size: 0.8rem;
    box-shadow: 3px 3px 0px var(--primary);
}

.navbar .btn-primary {
    background: var(--primary);
    color: var(--bg-app);
}

.navbar .btn-primary:hover,
.navbar .btn-secondary:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--primary);
}

/* Dropdown Styles */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    background: var(--bg-app);
    border: var(--border-thick);
    padding: 8px 16px;
    text-transform: uppercase;
    font-weight: 800;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 3px 3px 0px var(--primary);
    max-width: 350px;
    /* Increased limit */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropbtn svg {
    flex-shrink: 0;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: var(--bg-app);
    min-width: 160px;
    box-shadow: var(--shadow-solid);
    border: var(--border-thick);
    z-index: 1000;
    margin-top: 10px;
    /* Restore gap */
    top: 100%;
}

/* Invisible bridge to keep hover active across the gap */
.dropdown-content::before {
    content: "";
    position: absolute;
    top: -15px;
    left: 0;
    width: 100%;
    height: 15px;
    background: transparent;
}

.dropdown-content.dropdown-active {
    display: block;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    color: var(--text-main);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
    border-bottom: var(--border-thin);
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background-color: var(--primary);
    color: var(--bg-app);
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Auth Wrapper */
.auth-wrapper {
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background-color: var(--bg-app);
    background-size: 20px 20px;
    background-image:
        linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
}

/* Auth Card */
.auth-box {
    background: var(--bg-panel);
    width: 100%;
    max-width: 440px;
    padding: 40px;
    border: var(--border-thick);
    box-shadow: var(--shadow-solid);
    margin: 0 auto;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h2 {
    font-size: 1.75rem;
    font-weight: 900;
    text-transform: uppercase;
    margin: 0 0 8px 0;
    color: var(--text-main);
}

.auth-header p {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.logo-circle-wrapper {
    width: 100px;
    height: 100px;
    border: var(--border-thick);
    background: var(--bg-app);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: var(--shadow-solid-sm);
    overflow: hidden;
}

.auth-logo-img {
    width: 80% !important;
    height: auto !important;
    object-fit: contain;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 800;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: var(--border-thick);
    font-size: 1rem;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-main);
    background: var(--bg-app);
    transition: 0.1s;
    border-radius: 0;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233b422a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

.form-input:focus {
    background: white;
    outline: none;
    box-shadow: var(--shadow-solid-sm);
}

.btn-primary {
    background: var(--primary);
    color: var(--bg-app);
    border: var(--border-thick);
    padding: 14px 24px;
    font-weight: 900;
    cursor: pointer;
    text-transform: uppercase;
    transition: 0.1s;
    font-size: 1rem;
    width: 100%;
    display: inline-flex;
    justify-content: center;
    box-shadow: var(--shadow-solid-sm);
    font-family: var(--font-sans);
    text-decoration: none;
}

.btn-primary:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--primary);
    background: var(--primary-light);
}

.btn-secondary {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-app);
    border: var(--border-thick);
    color: var(--text-main);
    padding: 10px 20px;
    font-weight: 800;
    text-transform: uppercase;
    text-decoration: none;
    transition: 0.1s;
    box-shadow: var(--shadow-solid-sm);
    cursor: pointer;
}

.btn-secondary:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--primary);
}

.flash-msg {
    padding: 12px 16px;
    border: var(--border-thick);
    margin-bottom: 24px;
    font-weight: 800;
    font-size: 0.85rem;
    text-transform: uppercase;
    text-align: center;
}

.flash-msg.error {
    background: #fef2f2;
    color: var(--danger);
    border-color: var(--danger);
}

.flash-msg.success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #065f46;
}

.auth-footer {
    margin-top: 32px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 800;
}

.forgot-password-link {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--primary);
    text-decoration: none;
}

.turnstile-wrapper {
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
}

/* --- PAGE HEADER --- */
.page-header {
    background: var(--bg-paper);
    border-bottom: var(--border-thick);
    padding: 40px 0;
    text-align: center;
    box-shadow: 6px 6px 0px var(--olive-dark);
    /* solid offset shadow */
    margin-bottom: 48px;
    /* Add spacing below the header */
}

.page-header h1 {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--olive-dark);
    margin-bottom: 10px;
}

.page-header p {
    font-size: 1rem;
    color: var(--olive-light);
    font-weight: 700;
}

/* --- FAQ Section --- */
.faq-section {
    padding: 40px 0;
}

.faq-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.faq-item {
    background: var(--bg-paper);
    border: var(--border-thick);
    margin-bottom: 20px;
    box-shadow: var(--shadow-solid);
    /* Use solid shadow */
    border-radius: 0;
    /* Sharp corners */
    overflow: hidden;
}

.faq-question {
    padding: 20px;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 1.1rem;
    /* Slightly larger for better readability */
    cursor: pointer;
    background: var(--bg-paper);
    border: none;
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--olive-dark);
    transition: background-color 0.2s, transform 0.1s;
}

.faq-question:hover {
    background-color: rgba(59, 66, 42, 0.05);
    /* Subtle highlight on hover */
}

.faq-question:active {
    transform: translate(2px, 2px);
    /* Physical press effect */
}

.faq-question .icon {
    font-size: 1.5rem;
    /* Larger icon for better visibility */
    font-weight: 900;
    color: var(--olive-dark);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--olive-light);
    /* Distinct background for the icon area */
    color: var(--bg-paper);
    /* Light icon on dark background */
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: var(--border-thick);
    box-shadow: 2px 2px 0px var(--olive-dark);
}

details[open]>summary .icon {
    transform: rotate(135deg);
    /* Distinct rotate animation when open */
}

.faq-answer {
    padding: 24px;
    /* Increased padding for better content breathing space */
    font-weight: 600;
    font-size: 1rem;
    /* Slightly larger for readability */
    color: var(--olive-dark);
    border-top: var(--border-thick);
    /* Thicker separator line */
    background: rgba(255, 255, 255, 0.3);
    /* Slightly brighter background for answer */
    line-height: 1.6;
}

.faq-answer p {
    margin: 0;
    /* Reset default paragraph margin */
    padding-top: 16px;
    /* Space between border and text */
}

/* Landing Footer */
footer {
    background: var(--bg-paper);
    border-top: var(--border-thick);
    padding: 60px 0 20px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    /* Align items to the top */
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 30px;
}

.footer-col {
    flex: 1;
    min-width: 180px;
    flex-basis: 200px;
    display: flex;
    /* Use flex for column content alignment */
    flex-direction: column;
    align-items: flex-start;
    /* Align items to the left */
}

.footer-col h4 {
    color: var(--text-main);
    font-weight: 900;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.footer-col a {
    display: block;
    margin-bottom: 12px;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    font-size: 0.8rem;
}

/* Specific styling for the logo and phrase in the first footer-col */
.footer-col:first-child .logo {
    font-size: 1.3rem;
    /* Slightly larger logo */
    font-weight: 900;
    text-transform: uppercase;
    border: var(--border-thin);
    padding: 6px 15px;
    background: var(--olive-dark);
    /* Dark background for logo */
    color: var(--bg-paper);
    /* Light text */
    text-decoration: none;
    display: inline-block;
    /* Ensure it behaves as a block */
    margin-bottom: 15px;
    /* Space between logo and phrase */
}

.footer-col:first-child .logo .highlight {
    color: #c0ca33;
}

/* Consistent highlight color */

.footer-col:first-child p {
    font-family: var(--font-mono);
    /* Mono font for phrase */
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--olive-light);
    /* Accent color for phrase */
    margin: 0;
    /* Reset margin */
}

.copyright {
    text-align: center;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-weight: 700;
    padding-top: 20px;
    border-top: var(--border-thin);
    font-size: 0.75rem;
}

@media (max-width: 900px) {
    .auth-box {
        padding: 24px;
    }

    .auth-header h2 {
        font-size: 1.5rem;
    }
}

.hidden {
    display: none !important;
}

/* =========================================
   5. REVIEW PAGE STYLES
   ========================================= */
.review-wrapper {
    max-width: 900px;
    margin: 40px auto;
    padding: 60px;
    /* Increased padding */
    background: var(--bg-panel);
    border: var(--border-thick);
    box-shadow: var(--shadow-solid);
}

.review-header {
    border-bottom: var(--border-thick);
    margin-bottom: 30px;
    padding-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.review-header h1 {
    margin: 0;
    font-weight: 900;
    text-transform: uppercase;
}

.review-header p {
    margin: 5px 0 0 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.review-section {
    margin-bottom: 40px;
}

.review-section h2 {
    font-size: 1.2rem;
    text-transform: uppercase;
    background: var(--primary);
    color: var(--bg-app);
    padding: 8px 16px;
    margin-bottom: 20px;
    display: inline-block;
}

.review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.review-item {
    padding: 16px 20px;
    /* Increased padding */
    border: var(--border-thin);
    display: flex;
    justify-content: space-between;
    background: #ffffff;
    /* Cleaner white background */
}

.review-item .label {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.review-item .value {
    font-family: var(--font-mono);
    font-weight: 700;
}

/* Review Page Subtotal: Standard box, no margin to keep grid alignment perfect */
.review-item.row-subtotal {
    border: var(--border-thin) !important;
}

.row-surcharge, .row-surcharge span:last-child {
    color: var(--risk-medium) !important;
}

.row-penalty, .row-penalty span:last-child {
    color: var(--danger) !important;
}

/* Grand Total highlight (Review Page Only): Explicit high-contrast theme */
.review-item.total-row.highlight {
    grid-column: 1 / -1;
    background: var(--primary) !important;
    color: var(--bg-app) !important;
    border: var(--border-thick) !important;
    margin-top: 15px;
    padding: 20px !important;
}

.review-item.total-row.highlight .value {
    color: var(--bg-app) !important;
    font-size: 1.3rem;
    font-weight: 900;
}

/* Original total-row removed or consolidated above */

.breakdown-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.breakdown-list li {
    padding: 8px 16px;
    border-left: 4px solid var(--primary-light);
    background: #fff9c4;
    margin-bottom: 8px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.review-item.error-item {
    border-color: var(--risk-high);
    background: rgba(142, 45, 45, 0.04);
}

.review-item.error-item .value {
    color: var(--risk-high);
}

/* Status Alert Styles */
.status-block {
    padding: 20px;
    text-align: center;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 12px;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.status-block.error {
    background: rgba(142, 45, 45, 0.05);
    border-color: var(--risk-high);
    color: var(--risk-high);
}

.status-block.success {
    background: rgba(59, 66, 42, 0.05);
    border-color: var(--primary);
    color: var(--primary);
}

.suggestion-box {
    padding: 20px;
    border: 2px dashed var(--primary);
    background: rgba(107, 122, 79, 0.05);
    font-weight: 700;
    text-align: center;
    line-height: 1.5;
}

.review-actions {
    margin-top: 40px;
    display: flex;
    gap: 20px;
    justify-content: center;
}


/* =========================================
   6. SUPPORT PAGE STYLES
   ========================================= */
.support-section {
    padding: 80px 20px 60px;
    min-height: 80vh;
}

.support-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-panel);
    padding: 40px;
    border: var(--border-thick);
    box-shadow: var(--shadow-solid);
}

.support-header {
    text-align: center;
    margin-bottom: 40px;
}

.support-header h1 {
    color: var(--primary);
    margin-bottom: 10px;
    font-family: var(--font-sans);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -1px;
    font-size: 2.2rem;
}

.support-header p {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-weight: 600;
}

.support-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.support-form textarea {
    resize: vertical;
}

/* Mobile Toggle */
.hamburger-menu {
    display: none !important;
    background: var(--bg-paper);
    border: var(--border-thick);
    padding: 8px;
    cursor: pointer;
}

.mobile-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    /* Start off-screen */
    width: 85vw;
    max-width: 320px;
    height: 100vh;
    background: var(--bg-paper);
    border-left: var(--border-thick);
    z-index: 2000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.mobile-sidebar.active {
    right: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(59, 66, 42, 0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
    display: block !important;
    /* Override global.css display:none !important */
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px 60px 20px;
    /* Right padding 28px to protect 3px shadow + gutter */
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.sidebar-links {
    padding: 0;
    margin: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.no-scroll {
    overflow: hidden !important;
}

/* Mobile Sidebar Specifics */
.sidebar-links .nav-item {
    width: 100%;
    text-align: center;
}

.sidebar-auth {
    margin-top: 30px;
    padding: 30px 0 0 0;
    border-top: var(--border-thin);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar-auth .dropdown {
    width: 100%;
}

.sidebar-auth .dropbtn {
    width: 100%;
    justify-content: center;
    margin-bottom: 5px;
}

.sidebar-auth .dropdown-content {
    position: relative;
    /* Push layout */
    top: 0;
    width: 100%;
    display: none;
    /* Controlled by .dropdown-active */
    box-shadow: none;
    border-style: dashed;
    background: rgba(59, 66, 42, 0.05);
}

.sidebar-auth .dropdown-content.dropdown-active {
    display: block;
}

.sidebar-auth .dropdown-content a {
    text-align: center;
}

@media (max-width: 900px) {
    .desktop-only {
        display: none !important;
    }

    .navbar {
        height: 70px;
    }

    .navbar .logo {
        font-size: 1.2rem;
        display: block !important;
    }

    .navbar .nav-container {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
    }

    .nav-right {
        display: flex !important;
        align-items: center !important;
        margin-left: auto !important;
        /* Forces it to the right */
    }

    .hamburger-menu {
        display: block !important;
    }
}

@media (max-width: 600px) {
    .support-section {
        padding: 40px 15px 40px;
    }

    .support-header h1 {
        font-size: 1.8rem;
    }

    .support-form-grid {
        grid-template-columns: 1fr;
    }

    .support-container {
        padding: 24px 16px;
    }

    .btn-primary {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* =========================================
   URDU LOCALIZATION STYLES
   ========================================= */
[lang="ur"] {
    text-align: right;
    font-family: 'Segoe UI', Tahoma, 'Arial Unicode MS', 'Simplified Arabic', 'Traditional Arabic', sans-serif !important;
    font-weight: 600;
    line-height: 1.9;
    letter-spacing: 0px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

[lang="ur"] .input-area textarea {
    /* Swap padding for RTL: right becomes left */
    padding: 14px 50px 14px 120px;
    text-align: right;
    font-size: 1.15em;
}

[lang="ur"] .input-area.has-shelf textarea {
    padding: 12px 50px 12px 35px;
    font-size: 1.15em;
}

[lang="ur"] .custom-placeholder {
    /* RTL: keep placeholder close to the left-side icon for Urdu */
    left: 40px;
    right: 120px;
    top: 50%;
    transform: translateY(-50%);
    text-align: right;
    font-size: 14px;
    font-family: 'Segoe UI', Tahoma, 'Arial Unicode MS', 'Simplified Arabic', 'Traditional Arabic', sans-serif !important;
    color: rgba(136, 136, 136, 0.9);
    font-weight: 500;
}

/* Apply larger font to chat messages in Urdu */
[lang="ur"] .message {
    font-size: 1.1em;
}

[lang="ur"] .input-toolbar {
    flex-direction: row-reverse;
}

/* Keep standard LTR layout for these desktop elements regardless of language */
[lang="ur"] .nav-links,
[lang="ur"] .auth-buttons,
[lang="ur"] .nav-right,
[lang="ur"] .app-header,
[lang="ur"] .support-form-grid,
[lang="ur"] .footer-content {
    direction: ltr;
}

/* Fix for icons/arrows in RTL */
[lang="ur"] .dropbtn svg,
[lang="ur"] .back-btn svg {
    margin-right: 10px;
    margin-left: 0;
    transform: scaleX(-1);
    /* Flip arrows if needed */
}

[lang="ur"] .logo {
    letter-spacing: 0;
}

/* Audit Shield & Reconciler Features */
.audit-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: var(--border-thin);
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-left: 15px;
    box-shadow: var(--shadow-solid-sm);
}

.audit-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    /* Green by default */
}

.audit-badge.low .dot {
    background: #4caf50;
}

.audit-badge.medium .dot {
    background: #ff9800;
}

.audit-badge.high .dot {
    background: #f44336;
}

.nav-separator {
    height: 1px;
    background: var(--border-color);
    margin: 8px 15px !important;
    /* Balanced within the 8px gap */
    opacity: 0.3;
}

.sidebar-tool-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    overflow: visible;
}

.special-nav {
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    width: 85% !important;
    white-space: nowrap !important;
    overflow: visible;
    text-overflow: ellipsis;
    padding: 10px 16px;
    border: var(--border-thin);
    text-transform: uppercase;
    font-size: 0.85rem;
    background: rgba(74, 93, 35, 0.1);
    line-height: normal;
    box-sizing: border-box;
    transition: background 0.2s;
    z-index: 10;
}

.special-nav:hover {
    background: rgba(74, 93, 35, 0.2);
}


.quick-fix-btn {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 8px;
    height: 20px;
    font-size: 0.65rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 10;
    box-shadow: 2px 2px 0 var(--border-color);
}

.quick-fix-btn::before {
    content: "";
    position: absolute;
    inset: -2px;
    border: 1px solid white;
    opacity: 0.3;
}

.quick-fix-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--border-color);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    /* Very dark for focus */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
    backdrop-filter: blur(8px);
}

.modal-content.schematic-box {
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: var(--border-thick);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 900;
    text-transform: uppercase;
    margin: 0;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.5;
}

.modal-footer {
    padding: 20px;
    border-top: var(--border-thick);
    display: flex;
    justify-content: flex-end;
    background: rgba(59, 66, 42, 0.05);
}

/* Suggestions & Audit Content */
.suggestions-container {
    margin-top: 15px;
}

.suggestion-item {
    background: #ffffff;
    border: var(--border-thick);
    padding: 20px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: 0.1s;
    box-shadow: 4px 4px 0 var(--border-color);
}

.suggestion-item:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--primary);
}

.suggestion-item.selected {
    border-color: var(--primary);
    background: #f1f5e9;
    box-shadow: 6px 6px 0 var(--primary);
}

.suggestion-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 900;
    font-size: 1.1rem;
}

.suggestion-amount {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--primary);
    margin-bottom: 10px;
    font-family: var(--font-mono);
}

.suggestion-code {
    color: var(--text-muted);
    font-size: 0.8rem;
    background: #eee;
    padding: 2px 6px;
}

.suggestion-reason {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.6;
    padding-top: 15px;
}

/* Review Page Audit Shield Styles (Old styles removed for clutter reduction) */
.risk-badge-subtle {
    padding: 6px 14px;
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
    border: 1px solid var(--primary);
    letter-spacing: 0.5px;
    background: rgba(59, 66, 42, 0.05);
    color: var(--primary);
}

.risk-badge-subtle.risk-high {
    background: rgba(142, 45, 45, 0.1);
    color: var(--risk-high);
    border-color: var(--risk-high);
}

.risk-badge-subtle.risk-medium {
    background: rgba(194, 124, 0, 0.12);
    color: var(--risk-medium);
    border-color: var(--risk-medium);
}

.risk-badge-subtle.risk-low {
    background: rgba(107, 122, 79, 0.1);
    color: var(--risk-low);
    border-color: var(--risk-low);
}

.flags-card-list {
    list-style: none;
    padding: 0;
    margin: 20px 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.flag-card {
    background: var(--bg-card-neutral);
    border: 1px solid var(--border-neutral-soft);
    border-left: 6px solid var(--risk-high-text);
    /* Default muted red */
    padding: 20px 24px;
    box-shadow: 3px 3px 0 var(--border-neutral-soft);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s;
}

.flag-card:hover {
    transform: translateX(4px);
}

.flag-card.critical {
    border-left-color: var(--risk-high);
}

.flag-card.warning {
    border-left-color: var(--risk-medium);
}

.flag-card.info {
    border-left-color: var(--primary);
}

.flag-card strong {
    font-size: 1.05rem;
    text-transform: uppercase;
    color: var(--text-main);
    display: block;
}

.flag-card p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-main);
}

/* --- Audit Shield Standalone Feature --- */
.audit-shield-section {
    padding-top: 20px;
}

.audit-hero {
    background: var(--bg-card-neutral);
    border: var(--border-thick);
    box-shadow: var(--shadow-solid);
    padding: 40px;
    display: flex;
    align-items: center;
    gap: 40px;
    margin-bottom: 30px;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring__circle {
    transition: stroke-dashoffset 0.35s, stroke 0.3s;
    transform-origin: 50% 50%;
    stroke: var(--primary);
    /* Default */
}

.progress-ring__circle.risk-high {
    stroke: var(--risk-high);
}

.progress-ring__circle.risk-medium {
    stroke: var(--risk-medium);
}

.progress-ring__circle.risk-low {
    stroke: var(--risk-low);
}

.health-ring-wrapper {
    position: relative;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

.health-ring-wrapper span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 900;
    font-size: 2.2rem;
    color: var(--text-main);
}

.audit-hero-info {
    flex: 1;
}

.audit-hero-top {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.audit-hero-top h2 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 900;
    text-transform: uppercase;
}

.audit-hero-subtext {
    font-size: 1.05rem;
    max-width: 650px;
    margin-top: 15px;
    background: rgba(59, 66, 42, 0.05);
    padding: 15px;
    border-left: 5px solid var(--primary);
    line-height: 1.5;
    font-weight: 700;
}

/* Red Flags List on Standalone Page */
.flags-card-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.flag-card {
    background: var(--bg-card-neutral);
    border: var(--border-thick);
    box-shadow: var(--shadow-solid-sm);
    padding: 20px;
    transition: transform 0.1s;
}

.flag-card:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0px var(--primary);
}

.flag-card.high {
    border-left: 8px solid var(--risk-high);
}

.flag-card.medium {
    border-left: 8px solid var(--risk-medium);
}

.flag-card.low {
    border-left: 8px solid var(--primary-light);
}

.flag-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 5px;
}

.severity-tag {
    font-size: 0.7rem;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 8px;
    border: 1.5px solid currentColor;
    border-radius: 2px;
    white-space: nowrap;
}

.flag-card.high .severity-tag {
    color: var(--risk-high);
    background: rgba(142, 45, 45, 0.08);
}

.flag-card.medium .severity-tag {
    color: var(--risk-medium);
    background: rgba(194, 124, 0, 0.08);
}

.flag-card.low .severity-tag {
    color: var(--primary);
    background: rgba(59, 66, 42, 0.08);
}

/* --- Audit Shield CTA in Review Page --- */
/* --- Audit Shield CTA in Review Page --- */
.audit-shield-cta {
    background: var(--bg-card-neutral);
    border: var(--border-thick);
    box-shadow: var(--shadow-solid);
    padding: 30px 35px;
    display: grid;
    grid-template-columns: 1fr 240px;
    align-items: center;
    gap: 30px;
    margin: 40px 0;
    position: relative;
}

.audit-shield-cta h2 {
    color: var(--primary);
    margin: 0;
    font-size: 1.5rem;
    font-weight: 900;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 12px;
}

.audit-shield-cta h2::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 24px;
    background: var(--primary);
    border-radius: 1px;
}

.audit-shield-cta p {
    margin: 10px 0 0 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
    line-height: 1.4;
}

.audit-cta-right {
    background: rgba(59, 66, 42, 0.03);
    border-left: 2px solid var(--primary);
    padding-left: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.audit-score-instrument {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.instrument-label {
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: 1px;
}

.instrument-meter {
    height: 12px;
    background: #e0d8c3;
    border: 2px solid var(--primary);
    position: relative;
    display: flex;
}

.meter-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.5s ease;
}

.meter-fill.risk-high {
    background: var(--risk-high);
}

.meter-fill.risk-medium {
    background: var(--risk-medium);
}

.meter-fill.risk-low {
    background: var(--risk-low);
}

.score-value-display {
    font-size: 1.8rem;
    font-weight: 900;
    font-family: var(--font-mono);
    color: var(--primary);
}

.audit-shield-btn {
    background: var(--primary);
    color: var(--bg-app);
    font-weight: 900;
    border: var(--border-thin);
    text-transform: uppercase;
    padding: 8px 16px;
    box-shadow: var(--shadow-solid-sm);
    font-size: 0.8rem;
    text-decoration: none;
    transition: 0.1s;
    text-align: center;
}

.audit-shield-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0px var(--primary);
}

.audit-shield-btn {
    background: var(--bg-app);
    color: var(--primary);
    font-weight: 950;
    border: var(--border-thick);
    text-transform: uppercase;
    padding: 10px 20px;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.4);
    font-size: 0.85rem;
    text-decoration: none;
    transition: 0.1s;
    width: 100%;
    text-align: center;
}

.audit-shield-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.4);
    background: white;
}

.obs-status-line {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary);
}

.obs-status-line svg {
    color: #4caf50;
    stroke-width: 4;
}

/* Mobile Responsive Adjustments (900px and below) */
@media (max-width: 900px) {
    :root {
        --notebook-margin: 20px;
    }

    .review-wrapper {
        padding: 15px;
        margin: 10px auto;
        border: var(--border-thin);
        box-shadow: 4px 4px 0 var(--primary);
    }

    .review-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .review-header h1 {
        font-size: 1.5rem !important;
    }

    .review-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .review-item {
        padding: 12px 16px;
    }

    .audit-hero {
        flex-direction: column;
        text-align: center;
        padding: 24px 20px;
        gap: 24px;
        margin-bottom: 20px;
    }

    .audit-hero-top {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .audit-hero-top h2 {
        font-size: 1.4rem;
    }

    .audit-hero-subtext {
        font-size: 0.95rem;
        padding: 12px;
        text-align: left;
    }

    .flags-card-list {
        grid-template-columns: 1fr;
    }

    .flag-card {
        padding: 16px;
    }

    .progress-ring {
        transform: rotate(-90deg);
    }

    .progress-ring__circle {
        transition: stroke-dashoffset 0.35s, stroke 0.3s;
        transform-origin: 50% 50%;
        stroke: var(--primary);
    }

    .risk-high {
        stroke: var(--risk-high) !important;
    }

    .risk-medium {
        stroke: var(--risk-medium) !important;
    }

    .risk-low {
        stroke: var(--risk-low) !important;
    }

    .health-ring-wrapper {
        margin: 0 auto;
    }


    .review-actions-inner {
        flex-direction: column;
        gap: 10px;
    }

    .review-actions-inner .btn-primary,
    .review-actions-inner .btn-secondary {
        width: 100%;
        min-height: 48px;
    }

    .audit-shield-cta {
        grid-template-columns: 1fr;
        padding: 30px 20px;
        text-align: center;
        gap: 25px;
    }

    .audit-cta-right {
        border-left: none;
        padding-left: 0;
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .audit-shield-btn {
        width: auto;
        min-width: 200px;
    }
}

/* Distinct Sidebar Features */
#nav-audit-shield-tool,
#nav-7e-wizard-tool,
#nav-auto-reconciler-tool {
    background: none !important;
    /* Move background to individual elements if needed, but wrapper and li are transparent */
    border: none !important;
}

#nav-audit-shield-tool .special-nav,
#nav-7e-wizard-tool .special-nav,
#nav-auto-reconciler-tool .special-nav {
    border-left: 4px solid var(--primary) !important;
}

#nav-audit-shield-tool {
    margin-top: 15px;
    /* Maintain group separation from the list above */
}

#nav-7e-wizard-tool,
#nav-auto-reconciler-tool {
    margin-top: 0;
}

/* Fix Modal Overlay transparency */
.modal-overlay {
    background: rgba(0, 0, 0, 0.85);
    /* Darker backdrop */
    backdrop-filter: blur(4px);
}

/* Fix With AI Button refinements */
.quick-fix-btn {
    padding: 2px 8px;
    height: 24px;
    border-radius: 0;
    transition: all 0.2s;
}

.quick-fix-btn:hover {
    background: var(--text-main);
    color: white;
}

.modal-body .loading {
    padding: 40px;
    text-align: center;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* 4-Column Table Utility */
.fbr-row.four-col {
    display: flex;
    gap: 0;
}

.fbr-row.four-col .col-desc {
    flex: 2;
    min-width: 250px;
}

.fbr-row.four-col .col-code {
    flex: 0 0 60px;
}

.fbr-row.four-col .col-amount {
    flex: 1;
    min-width: 150px;
}

/* Info Icon Styling */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-left: 8px;
    cursor: help;
    color: var(--primary);
    position: relative;
}

.info-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.info-icon:hover::after {
    content: attr(data-tooltip);
    display: block !important;
    position: absolute !important;
    /* Position above the icon, extending leftward into the sidebar */
    bottom: calc(100% + 10px) !important;
    right: -4px !important;
    left: auto !important;
    transform: none !important;
    top: auto !important;
    height: auto !important;
    margin-left: 0 !important;
    background: var(--primary);
    color: var(--bg-app);
    padding: 10px 12px !important;
    width: 200px;
    max-width: 210px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1001 !important;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
    text-transform: none;
    pointer-events: none !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.4;
    border-radius: 2px;
    box-sizing: border-box !important;
}

/* Small arrow pointing down from the tooltip to the icon */
.info-icon:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    right: 1px;
    left: auto;
    transform: none;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--primary);
    z-index: 1002;
    pointer-events: none;
}

/* Tooltip Mobile Centering Fix (Screens < 900px) */
@media (max-width: 900px) {

    /* Set the WRAPPER as the relative parent for centering across the sidebar width */
    .sidebar-tool-wrapper {
        position: relative !important;
    }

    /* Disable the icon as the positioning parent */
    .info-icon {
        position: static !important;
    }

    /* Configure tooltip to span the sidebar width with gutters */
    .info-icon:hover::after {
        display: block !important;
        position: absolute !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        min-height: 0 !important;
        bottom: calc(100% + 10px) !important;
        transform: none !important;
        text-align: left !important;
        padding: 12px 16px !important;
        background: #3b422a !important;
        color: #f5f5f0 !important;
        z-index: 9999 !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        box-sizing: border-box !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 4px;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        overflow: visible !important;
    }
}

/* --- Mobile Optimization (Header Row - Specific for 600px and below) --- */
@media (max-width: 600px) {
    .app-header {
        padding: 0 8px;
        height: 60px;
        justify-content: space-between;
    }

    .header-left,
    .header-right {
        gap: 6px;
        margin: 0;
        display: flex;
        align-items: center;
    }

    /* Uniform Height and Sizing for all header items */
    .mobile-hamburger,
    .back-btn,
    .audit-badge,
    .header-btn-content,
    #reset-btn {
        height: 40px !important;
        /* Slightly smaller to fit more items */
        min-width: 40px;
        padding: 0 8px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 2px 2px 0 var(--primary) !important;
        margin: 0 !important;
        font-size: 0.65rem !important;
        box-sizing: border-box;
        flex-shrink: 0;
    }

    .mobile-hamburger {
        display: flex !important;
    }

    /* Hide text labels on very small screens to maintain row, EXCEPT Audit Risk */
    .back-btn span,
    #reset-btn span,
    .header-btn-content span {
        display: none;
    }

    .logo {
        display: none;
        /* Hide logo on mobile to make room for buttons */
    }

    .audit-badge {
        gap: 6px;
        width: auto !important;
        /* Allow width to expand for text */
        padding: 0 12px !important;
    }

    .audit-badge .label {
        display: inline-block !important;
        /* Show label as requested */
        font-size: 0.65rem;
        white-space: nowrap;
    }

    .header-btn-content svg,
    #reset-btn svg,
    .back-btn svg {
        margin: 0;
    }
}

/* =========================================
   AUTO-RECONCILER FEATURE STYLES
   ========================================= */

.reconcile-hero-card {
    background: var(--bg-card-neutral);
    border: var(--border-thick);
    box-shadow: 8px 8px 0 var(--border-color);
    padding: 30px;
    margin-bottom: 40px;
    position: relative;
    overflow: hidden;
}


.balance-status-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

.balance-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.balance-info .label {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.balance-value-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.balance-info .value {
    font-size: 2.5rem;
    font-weight: 900;
    font-family: var(--font-mono);
    line-height: 1;
}

.status-badge {
    padding: 6px 12px;
    font-size: 0.7rem;
    font-weight: 900;
    border: 2px solid currentColor;
    border-radius: 4px;
}

.status-badge.success {
    color: var(--primary);
    background: rgba(59, 66, 42, 0.08);
}

.status-badge.error {
    color: var(--risk-high);
    background: rgba(142, 45, 45, 0.08);
}

.hero-advice {
    padding: 20px;
    background: rgba(0, 0, 0, 0.03);
    border-left: 4px solid var(--border-color);
    font-size: 0.95rem;
    line-height: 1.6;
}

.hero-advice.success {
    border-left-color: var(--primary);
    background: rgba(59, 66, 42, 0.05);
}

.section-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.ai-powered-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    box-shadow: 4px 4px 0 var(--border-color);
}

.suggestions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.suggestion-card {
    background: white;
    border: var(--border-thick);
    box-shadow: 6px 6px 0 var(--border-color);
    padding: 25px;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.suggestion-card:hover {
    transform: translate(-3px, -3px);
    box-shadow: 9px 9px 0 var(--primary);
}

.suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.impact-info .impact-value {
    font-size: 1.2rem;
    font-weight: 900;
    font-family: var(--font-mono);
}

.apply-fix-btn {
    min-width: 140px;
    height: 44px;
    font-size: 0.85rem;
    font-weight: 900;
}

.btn-fix-reconcile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--risk-high);
    color: white;
    padding: 8px 20px;
    font-weight: 900;
    text-transform: uppercase;
    font-size: 0.8rem;
    border: none;
    cursor: pointer;
    box-shadow: 4px 4px 0 #5a1d1d;
    /* Dark solid red shadow */
    text-decoration: none;
    transition: all 0.2s;
    margin-top: 0;
}

.btn-fix-reconcile:hover {
    transform: translate(-3px, -3px);
    box-shadow: 7px 7px 0 #5a1d1d;
    background: #732424;
    /* Muted darker red on hover */
}

.btn-hero-fix {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 25px;
    font-weight: 800;
    background: var(--border-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 4px 4px 0 var(--primary);
    text-transform: uppercase;
    transition: all 0.2s;
}

.btn-hero-fix:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--primary);
}



.pulse-loader {
    animation: pulse-bg 1.5s infinite ease-in-out;
}

@keyframes pulse-bg {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
        box-shadow: 0 0 20px var(--primary);
    }

    100% {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* Mobile optimization for page header */
.page-header {
    padding: 20px 0;
    margin-bottom: 24px;
    box-shadow: 3px 3px 0px var(--olive-dark);
}

.page-header h1 {
    font-size: 1.8rem;
}

.page-header p {
    font-size: 0.85rem;
}

/* Mobile optimization for custom placeholder */
.custom-placeholder {
    left: 56px;
    right: 75px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
}

/* Mobile optimization for Urdu custom placeholder */
[lang="ur"] .custom-placeholder {
    left: 36px;
    right: 90px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
}

.hidden {
    display: none !important;
}


/* Observation Card Styles (Schmatic Theme) */
.observation-card {
    background: var(--bg-card-neutral);
    border: var(--border-thick);
    box-shadow: var(--shadow-solid-sm);
    margin-top: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.obs-header {
    background: var(--primary);
    color: white;
    padding: 10px 20px;
}

.obs-header h2 {
    margin: 0 !important;
    font-size: 1rem !important;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px;
    color: white !important;
}

.obs-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.obs-status-line {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.obs-status-line span {
    font-size: 1.1rem;
    font-weight: 800;
}

/* Clear Status Success Card */
.clear-status {
    padding: 24px;
    background: rgba(107, 122, 79, 0.08); /* Light success tint */
    border-color: var(--risk-low) !important;
    box-shadow: 6px 6px 0px var(--risk-low) !important;
}

.clear-status .obs-status-line svg {
    color: var(--risk-low);
}

.clear-status .obs-status-line span {
    color: var(--primary);
}

.suggestion-reason {
    padding: 15px;
    background: rgba(59, 66, 42, 0.05);
    border-left: 4px solid var(--primary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.suggestion-reason strong {
    color: var(--primary);
    text-transform: uppercase;
    font-size: 0.8rem;
    display: block;
    margin-bottom: 5px;
}


/* --- Auto Reconciler Mobile Optimization (Screens < 600px) --- */
@media (max-width: 600px) {

    .reconcile-hero-card,
    .loading-card {
        padding: 20px 15px;
        margin-bottom: 25px;
        box-shadow: 4px 4px 0 var(--border-color);
    }

    .balance-status-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .balance-info .value {
        font-size: 1.8rem;
        word-break: break-all;
    }

    .balance-icon svg {
        width: 32px;
        height: 32px;
    }

    .hero-advice {
        padding: 15px;
        font-size: 0.85rem;
    }

    .section-header-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .section-header-flex h2 {
        font-size: 1.2rem;
    }

    .suggestion-card {
        padding: 15px;
        gap: 12px;
    }

    .suggestion-header {
        flex-direction: column;
        gap: 8px;
    }

    .suggestion-title-group h3 {
        font-size: 1rem;
    }

    .suggestion-explanation {
        font-size: 0.85rem;
    }

    .suggestion-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .apply-fix-btn,
    .btn-hero-fix {
        width: 100%;
        padding: 12px 15px !important;
    }

    .reconcile-footer {
        font-size: 0.8rem;
        padding: 10px;
    }

    .review-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding-bottom: 20px;
    }

    .review-header h1 {
        font-size: 1.5rem !important;
    }

    .header-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 12px;
    }

    .header-actions .back-btn {
        width: 100%;
        text-align: center;
        justify-content: center;
        margin: 0;
    }

    /* Mobile Success Card Layout */
    .clear-status {
        padding: 20px 15px;
        text-align: center;
    }

    .clear-status .obs-status-line {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    .clear-status .obs-status-line span {
        font-size: 1rem;
        line-height: 1.4;
        text-align: center;
        max-width: 100%;
    }
}



.btn-expert-mode {
    width: 100%;
    font-size: 0.85rem;
    border: 3px solid var(--risk-high);
    color: var(--risk-high);
    background: none;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    padding: 15px;
    box-shadow: 4px 4px 0 var(--risk-high);
    transition: all 0.2s;
    margin-bottom: 5px;
}

.btn-expert-mode:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--risk-high);
    background: rgba(142, 45, 45, 0.05);
}