/* 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 */
    --text-main: #3b422a;
    /* Olive Dark */
    --text-muted: rgba(59, 66, 42, 0.7);
    --border-color: #3b422a;
    --border-focus: #3b422a;
    --danger: #b71c1c;
    /* Deep Red */
    --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: 60px;

    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;
}

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: hidden;
}

/* 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);
}

/* 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;
    z-index: 50;
    height: 100%;
}

.mobile-sidebar-header,
.sidebar-overlay {
    display: none !important;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    cursor: pointer;
    margin-bottom: 8px;
}

.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-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;
}

.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);
}

/* 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 95px 14px 45px;
    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: 55px;
    right: 95px;
    top: 26px;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 14px;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s ease;
}

.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;
        /* Above header */
    }

    .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: 48px;
        right: 88px;
        top: 21px;
        /* Centered in 44px toolbar */
        font-size: 12px;
    }

    .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) {
    .form-container {
        padding: 10px 8px 100px;
    }

    .fbr-row {
        min-width: 700px;
    }

    .back-btn {
        font-size: 0.65rem;
        padding: 4px 6px;
    }

    .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);
}

.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 {
    width: auto;
    padding: 8px 16px;
    font-size: 0.8rem;
    box-shadow: 3px 3px 0px var(--primary);
}

.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: 600px) {
    .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: 40px;
    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: 12px;
    border: var(--border-thin);
    display: flex;
    justify-content: space-between;
    background: rgba(59, 66, 42, 0.02);
}

.review-item .label {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.review-item .value {
    font-family: var(--font-mono);
    font-weight: 700;
}

.total-row {
    grid-column: 1 / -1;
    background: rgba(59, 66, 42, 0.1);
    border: var(--border-thick);
    padding: 16px;
    font-size: 1.1rem;
}

.total-row.highlight {
    background: var(--primary);
    color: var(--bg-app);
}

.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: #b71c1c;
    background: #fff5f5;
}

.review-item.error-item .value {
    color: #b71c1c;
}

/* 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: #ffebee;
    border-color: #b71c1c;
    color: #b71c1c;
}

.status-block.success {
    background: #e8f5e9;
    border-color: #2e7d32;
    color: #2e7d32;
}

.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 Navigation Styles */
.mobile-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: var(--bg-app);
    border-left: var(--border-thick);
    z-index: 2001;
    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.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

@media (max-width: 900px) {
    .desktop-only {
        display: none !important;
    }

    .navbar {
        height: 70px;
    }

    .navbar .logo {
        font-size: 1.2rem;
    }
}

@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"] {
    direction: rtl;
    text-align: right;
    font-family: 'Noto Nastaliq Urdu', serif !important;
}

[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: rtl;
}

/* 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;
}