/* ==========================================================================
   CSS Variables & Theme Setup (Strict Monochromatic + Brand Action)
   ========================================================================== */
:root {
    /* Color Palette */
    --color-bg-main: #F4F7F6;
    --color-bg-alt: #FFFFFF;
    --color-bg-card: #FFFFFF;
    
    --color-text-primary: #1A202C;
    --color-text-secondary: #4A5568;
    --color-text-tertiary: #718096;
    
    /* Brand & Actions */
    --color-brand: #F97316;
    --color-brand-hover: #EA580C;
    --color-brand-active: #C2410C;
    --color-white: #FFFFFF;
    
    /* Borders */
    --color-border: #E2E8F0;
    --color-border-focus: #F97316;
    
    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Sizing & Spacing */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 64px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--color-bg-alt);
    color: var(--color-text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

html {
    width: 100%;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-text-primary);
}

a {
    color: var(--color-text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--color-brand);
}

.container {
    width: 100%;
    max-width: 92%;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

/* ==========================================================================
   Layout Components
   ========================================================================== */
.app-header {
    background-color: var(--color-bg-main);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--space-md) 0;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    flex-shrink: 0;
}

.brand-icon-box {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--color-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-icon {
    color: #ffffff;
    width: 18px;
    height: 18px;
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--color-brand);
    white-space: nowrap;
}

.app-nav {
    display: flex;
    gap: var(--space-lg);
}

.app-nav a {
    font-weight: 500;
    font-size: 0.95rem;
}

/* Header Search Bar */
.header-search-wrap {
    display: none;
}

.global-search-input {
    width: 100%;
    padding: 9px 68px 9px 36px;
    border-radius: 24px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-alt);
    color: var(--color-text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.global-search-input::placeholder {
    color: var(--color-text-secondary);
}

.global-search-input:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}

.search-icon-left {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--color-text-secondary);
    pointer-events: none;
}

.search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    background: var(--color-bg-main);
    border: 1px solid var(--color-border);
    padding: 2px 7px;
    border-radius: 5px;
    pointer-events: none;
    letter-spacing: 0.3px;
}

.search-results-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: var(--color-bg-main);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    z-index: 1001;
    max-height: 280px;
    overflow-y: auto;
}

/* Icon-only round button (theme toggle) */
.header-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.header-icon-btn:hover {
    background-color: var(--color-bg-alt);
    border-color: var(--color-brand);
}

.header-icon-btn i {
    width: 16px;
    height: 16px;
}

.chevron-icon {
    width: 12px !important;
    height: 12px !important;
    margin-left: 1px;
}

.header-cat-dropdown .dropdown-content {
    left: auto;
    right: 0;
}

.app-main {
    flex: 1;
    padding: var(--space-2xl) 0;
    overflow-x: hidden;
}

.app-footer {
    background-color: var(--color-bg-main);
    border-top: 1px solid var(--color-border);
    padding: var(--space-xl) 0;
    margin-top: auto;
}

.footer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.footer-links {
    display: flex;
    gap: var(--space-lg);
}

/* ==========================================================================
   Homepage Hero
   ========================================================================== */
.hero-section {
    text-align: center;
    max-width: 820px;
    margin: 0 auto;
    padding: 12px 20px 44px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    background-color: rgba(249, 115, 22, 0.1);
    color: var(--color-brand);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 22px;
}

.hero-title {
    font-size: 2.9rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-bottom: 18px;
    color: var(--color-text-primary);
}

.hero-title .accent {
    color: var(--color-brand);
}

.hero-desc {
    color: var(--color-text-secondary);
    font-size: 1.1rem;
    line-height: 1.65;
    margin-bottom: 30px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.hero-btn {
    padding: 13px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.18s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.hero-btn-primary {
    background-color: var(--color-brand);
    color: var(--color-white);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

.hero-btn-primary:hover {
    background-color: var(--color-brand-hover);
    transform: translateY(-1px);
}

.hero-btn-secondary {
    background-color: var(--color-bg-card);
    border-color: var(--color-border);
    color: var(--color-text-primary);
}

.hero-btn-secondary:hover {
    border-color: var(--color-brand);
    color: var(--color-brand);
}

@media (max-width: 640px) {
    .hero-title {
        font-size: 2.1rem;
    }
    .hero-desc {
        font-size: 1rem;
    }
}

/* ==========================================================================
   Dashboard / Calculator Grid
   ========================================================================== */
.page-title {
    font-size: 2.5rem;
    margin-bottom: var(--space-xs);
    text-align: center;
}

.page-subtitle {
    color: var(--color-text-secondary);
    text-align: center;
    margin-bottom: var(--space-2xl);
    font-size: 1.1rem;
}

.calc-grid-section {
    margin-bottom: var(--space-2xl);
}

.calc-grid-title {
    font-size: 1.5rem;
    margin-bottom: var(--space-lg);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: var(--space-xs);
    color: var(--color-brand);
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-lg);
}

.calc-card {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.calc-card:hover {
    border-color: var(--color-brand);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.calc-card-icon {
    color: var(--color-brand);
    margin-bottom: var(--space-xs);
}

.calc-card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.calc-card-desc {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    flex: 1;
}

.calc-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background-color: rgba(16, 185, 129, 0.1);
    color: #10B981;
    font-size: 0.65rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   Calculator View Styles
   ========================================================================== */
.calculator-view {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

.calc-header {
    margin-bottom: var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 10px 20px;
    background: #F97316;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.15s ease;
    margin-bottom: 24px;
}
.back-btn:hover {
    background: #ea6008;
    color: #ffffff;
    transform: translateX(-3px);
}

.calc-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    align-items: start;
}

@media (min-width: 768px) {
    .calc-layout {
        grid-template-columns: 1fr 1fr;
    }
}

.calc-panel {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    overflow: hidden;
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: 0 1px 2px rgba(16,24,40,0.03), 0 1px 3px rgba(16,24,40,0.04);
}

.calc-panel-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    color: var(--color-brand);
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.3);
    box-shadow: 0 1px 4px rgba(249, 115, 22, 0.12);
    padding: 9px 16px;
    border-radius: 999px;
    margin-bottom: 24px;
}

.calc-panel-title i {
    width: 14px;
    height: 14px;
    color: var(--color-brand);
    flex-shrink: 0;
}

/* Forms */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label, .form-group > label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-xs);
    color: var(--color-text-secondary);
}

.form-control-wrap {
    position: relative;
    display: flex;
}

.form-input, .form-select {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--color-bg-main);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}

.unit-addon {
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-left: none;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.form-input.has-unit {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* Actions */
.calc-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    flex: 1;
}

.btn-primary {
    background-color: var(--color-brand);
    color: var(--color-white);
}

.btn-primary:hover {
    background-color: var(--color-brand-hover);
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--color-border);
    color: var(--color-text-primary);
}

.btn-secondary:hover {
    background-color: var(--color-bg-alt);
}

/* Results */
.result-item {
    background-color: var(--color-bg-main);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 12px;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.result-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text-primary);
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
}

.result-unit {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* Hero-style emphasis for the primary (first) result in a results panel */
.results-panel .result-item:first-child,
.results-panel .result-item:first-of-type {
    background: linear-gradient(135deg, rgba(249,115,22,0.08), rgba(234,88,12,0.03));
    border-color: rgba(249,115,22,0.25);
}

.results-panel .result-item:first-child .result-value,
.results-panel .result-item:first-of-type .result-value {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, var(--color-brand) 0%, #EA580C 55%, #F59E0B 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.results-panel .result-item:first-child .result-unit,
.results-panel .result-item:first-of-type .result-unit {
    -webkit-text-fill-color: var(--color-text-secondary);
    color: var(--color-text-secondary);
    font-size: 1rem;
    font-weight: 600;
}

.buffer-note {
    font-size: 0.8rem;
    color: var(--color-brand);
    margin-top: var(--space-xs);
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: rgba(249, 115, 22, 0.07);
    padding: 6px 10px;
    border-radius: 999px;
    width: fit-content;
}

/* PDF Section */
#pdf-content {
    background: transparent;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Toggle Switch */
.toggle-wrapper {
    display: flex;
    background-color: var(--color-bg-alt);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--color-border);
}

.toggle-option {
    flex: 1;
    text-align: center;
    padding: 6px 12px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    transition: all 0.2s;
}

.toggle-option.active {
    background-color: var(--color-white);
    color: var(--color-brand);
    box-shadow: var(--shadow-sm);
}

/* Static Pages */
.static-page {
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--color-bg-card);
    padding: var(--space-2xl);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}
.static-page h1 {
    margin-bottom: var(--space-lg);
}
.static-page p {
    margin-bottom: var(--space-md);
    color: var(--color-text-secondary);
}

/* ==========================================================================
   Dark Mode Theme
   ========================================================================== */
[data-theme="dark"] {
    --color-bg-main: #0B1120;
    --color-bg-alt: #131B2F;
    --color-bg-card: #1A2235;
    
    --color-text-primary: #F8FAFC;
    --color-text-secondary: #94A3B8;
    --color-text-tertiary: #64748B;
    
    /* Brand & Actions (Slightly lightened for dark mode contrast) */
    --color-brand: #F97316; 
    --color-brand-hover: #EA580C;
    --color-brand-active: #C2410C;
    --color-white: #FFFFFF;
    
    --color-border: #2E364F;
    --color-border-focus: #F97316;
}

/* ==========================================================================
   Global Modal Styles (for Currency)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--color-bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    padding: var(--space-xl);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
    transform: translateY(-20px);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.modal-close {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--color-brand);
}

/* ==========================================================================
   Currency Dropdown (search + flag list)
   ========================================================================== */
.currency-dropdown-wrap {
    position: relative;
    display: inline-block;
}

#currency-flag img {
    width: 18px;
    height: 13px;
    object-fit: cover;
    border-radius: 2px;
    display: block;
}

.currency-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 300px;
    max-width: 92vw;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    overflow: hidden;
}

.currency-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.currency-search-wrap {
    position: relative;
    padding: 10px;
    border-bottom: 1px solid var(--color-border);
}

.currency-search-icon {
    position: absolute !important;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px !important;
    height: 14px !important;
    color: var(--color-text-tertiary);
    pointer-events: none;
}

.currency-search-input {
    width: 100%;
    padding: 9px 10px 9px 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: var(--color-bg-main);
    color: var(--color-text-primary);
    font-size: 0.85rem;
    font-family: var(--font-family);
}

.currency-search-input:focus {
    outline: none;
    border-color: var(--color-brand);
}

.currency-list {
    max-height: 280px;
    overflow-y: auto;
    padding: 6px;
}

.currency-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.currency-option:hover {
    background-color: var(--color-bg-alt);
}

.currency-option.active {
    background-color: rgba(249, 115, 22, 0.12);
}

.currency-option img {
    width: 24px;
    height: 18px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
    background: var(--color-border);
}

.currency-option-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.currency-option-code {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.currency-option-name {
    font-size: 0.72rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.currency-option-symbol {
    font-size: 0.8rem;
    color: var(--color-text-tertiary);
    flex-shrink: 0;
}

.currency-empty {
    padding: 24px 10px;
    text-align: center;
    color: var(--color-text-tertiary);
    font-size: 0.85rem;
}

.currency-list::-webkit-scrollbar {
    width: 6px;
}
.currency-list::-webkit-scrollbar-track {
    background: transparent;
}
.currency-list::-webkit-scrollbar-thumb {
    background-color: var(--color-border);
    border-radius: 10px;
}

@media (max-width: 640px) {
    .currency-panel {
        right: -60px;
    }
}

/* ==========================================================================
   Left Sidebar Navigation
   ========================================================================== */
body {
    margin-left: 222px;
    transition: margin-left 0.2s ease;
}

.side-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 222px;
    height: 100vh;
    background-color: var(--color-bg-card);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 150;
    transition: width 0.2s ease;
    padding-bottom: var(--space-lg);
}

.side-nav::-webkit-scrollbar {
    width: 5px;
}
.side-nav::-webkit-scrollbar-thumb {
    background-color: var(--color-border);
    border-radius: 10px;
}

.side-nav-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px 10px;
}

.side-nav-brand-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-primary);
    overflow: hidden;
    white-space: nowrap;
}

.side-nav-brand-mini i {
    color: var(--color-brand);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.side-nav-toggle {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text-secondary);
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.side-nav-toggle:hover {
    border-color: var(--color-brand);
    color: var(--color-brand);
}

.side-nav-toggle i {
    width: 13px !important;
    height: 13px !important;
    transition: transform 0.2s ease;
}

.side-nav.collapsed .side-nav-toggle i {
    transform: rotate(180deg);
}

.side-nav-list {
    display: flex;
    flex-direction: column;
    padding: 4px 8px;
    gap: 1px;
}

.side-nav-item-header {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 9px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-text-primary);
    font-family: var(--font-family);
    text-align: left;
}

.side-nav-item-header:hover {
    background-color: var(--color-bg-alt);
    color: var(--color-brand);
}

.side-nav-item.active-cat > .side-nav-item-header {
    color: var(--color-brand);
}

.side-nav-item-left {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    overflow: hidden;
    min-width: 0;
    padding-top: 1px;
}

.side-nav-icon {
    width: 15px !important;
    height: 15px !important;
    flex-shrink: 0;
    margin-top: 1px;
}

.side-nav-label {
    white-space: normal;
    line-height: 1.35;
    word-break: break-word;
}

.side-nav-chevron {
    width: 13px !important;
    height: 13px !important;
    flex-shrink: 0;
    margin-top: 2px;
    transition: transform 0.2s ease;
}

.side-nav-item.open > .side-nav-item-header .side-nav-chevron {
    transform: rotate(180deg);
}

.side-nav-submenu {
    display: none;
    flex-direction: column;
    padding: 2px 0 6px 33px;
}

.side-nav-item.open .side-nav-submenu {
    display: flex;
}

.side-nav-submenu a {
    padding: 6px 8px;
    font-size: 0.76rem;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
}

.side-nav-submenu a:hover {
    background-color: var(--color-bg-alt);
    color: var(--color-brand);
}

.side-nav-submenu a.active-link {
    color: var(--color-brand);
    font-weight: 600;
}

body.side-nav-collapsed {
    margin-left: 56px;
}

.side-nav.collapsed {
    width: 56px;
}

.side-nav.collapsed .side-nav-brand-mini span,
.side-nav.collapsed .side-nav-label,
.side-nav.collapsed .side-nav-chevron,
.side-nav.collapsed .side-nav-submenu {
    display: none;
}

.side-nav.collapsed .side-nav-toggle-row {
    justify-content: center;
    padding: 14px 0 10px;
}

.side-nav.collapsed .side-nav-item-header {
    justify-content: center;
    padding: 9px 0;
}

.side-nav.collapsed .side-nav-item-left {
    gap: 0;
}

@media (max-width: 960px) {
    .side-nav {
        display: none;
    }
    body,
    body.side-nav-collapsed {
        margin-left: 0 !important;
    }
}

/* Header Buttons styling */
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.header-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn:hover {
    background-color: var(--color-bg-alt);
    border-color: var(--color-brand);
}

/* Dropdown Navigation */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--color-bg-main);
    min-width: 250px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    z-index: 1000;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 8px 0;
    max-height: 400px;
    overflow-y: auto;
    left: 0;
}

.nav-dropdown:hover .dropdown-content,
.nav-dropdown.open .dropdown-content {
    display: block;
}

.dropdown-category {
    padding: 10px 16px 4px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-brand);
    background-color: var(--color-bg-alt);
    margin-top: 8px;
}
.dropdown-category:first-child {
    margin-top: 0;
}

.dropdown-content a {
    color: var(--color-text-primary) !important;
    padding: 8px 16px !important;
    text-decoration: none;
    display: block;
    font-weight: 500 !important;
    font-size: 0.9rem;
    border-bottom: none !important;
    margin: 0 !important;
}

.dropdown-content a:hover {
    background-color: var(--color-bg-hover);
    color: var(--color-brand) !important;
}

.dropdown-content::-webkit-scrollbar {
    width: 6px;
}
.dropdown-content::-webkit-scrollbar-track {
    background: transparent;
}
.dropdown-content::-webkit-scrollbar-thumb {
    background-color: var(--color-border);
    border-radius: 10px;
}

/* Scientific Calculator Custom CSS */
.sci-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 8px;
    margin-top: 16px;
    background: var(--color-bg-alt);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.sci-btn {
    background: var(--color-bg-main);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 12px 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    display: flex;
    justify-content: center;
    align-items: center;
}

.sci-btn:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-brand);
}

.sci-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.sci-btn.num {
    background: var(--color-brand);
    color: #ffffff;
    border-color: var(--color-brand);
}

.sci-btn.num:hover {
    opacity: 0.9;
}

.sci-btn.action {
    background: var(--color-text-primary);
    color: var(--color-bg-main);
}

.sci-display {
    background: var(--color-brand);
    color: #ffffff;
    padding: 16px 24px;
    text-align: right;
    border-radius: 8px;
    font-family: monospace;
    overflow: hidden;
    word-break: break-all;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.sci-display-expr {
    font-size: 1rem;
    opacity: 0.8;
    margin-bottom: 8px;
}
.sci-display-val {
    font-size: 2.5rem;
    font-weight: 700;
}


/* ==========================================================================
   Responsive Media Queries (Mobile, iPad, Laptop)
   ========================================================================== */

/* Tablet & Smaller Laptops (max-width: 992px) */
@media (max-width: 992px) {
    .app-nav {
        gap: var(--space-md);
    }
    .header-container {
        gap: var(--space-md);
    }
}

/* iPads & Tablets (max-width: 768px) */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }
    
    .brand {
        justify-content: center;
    }

    .app-nav {
        justify-content: center;
        flex-wrap: wrap;
        gap: var(--space-sm) var(--space-md);
    }
    
    .header-actions {
        justify-content: center;
        flex-wrap: wrap;
    }

    .header-search-wrap {
        width: 100%;
        order: 3;
    }

    .search-container {
        width: 100%;
        text-align: center;
        margin-right: 0 !important;
    }

    .search-container input {
        width: 100% !important;
        max-width: 100%;
    }

    .search-kbd {
        display: none;
    }

    .page-title {
        font-size: 1.8rem;
    }
    
    .page-subtitle {
        font-size: 0.95rem;
        margin-bottom: var(--space-lg);
    }
    
    .calc-panel {
        padding: var(--space-md);
    }
    
    .static-page {
        padding: var(--space-lg) var(--space-md);
    }
    
    .footer-links {
        flex-direction: column;
        align-items: center;
        gap: var(--space-sm);
    }
    
    /* Adjust Scientific Calculator Grid for tablets */
    .sci-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Mobile Phones (max-width: 480px) */
@media (max-width: 480px) {
    .sci-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .calc-grid {
        grid-template-columns: 1fr;
    }
    
    .app-nav a {
        font-size: 0.85rem;
    }
    
    .modal-content {
        padding: var(--space-md);
        width: 95%;
    }

    /* Fix hardcoded grids breaking mobile */
    .calc-panel [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

/* Ultrawide Monitors */
@media (min-width: 1920px) {
    html { font-size: 18px; }
    .container { max-width: 94%; }
}
@media (min-width: 2560px) {
    html { font-size: 22px; }
    .container { max-width: 95%; }
}

.calculator-view { max-width: 1200px !important; margin: 0 auto; }


.hidden-results { display: none !important; }


/* SEO Topic Boxes */
.seo-box {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.seo-box:hover {
    border-color: rgba(249, 115, 22, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.seo-box h2 {
    margin-top: 0 !important;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 16px;
    margin-bottom: 24px !important;
    color: var(--color-text-primary);
}

.seo-box p:last-child {
    margin-bottom: 0 !important;
}

/* Make links inside SEO box orange */
.seo-box a {
    color: var(--color-brand);
    text-decoration: none;
    font-weight: 500;
}

.seo-box a:hover {
    text-decoration: underline;
}

/* Compact Print Button */
.print-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.85rem;
    width: auto;
    margin-bottom: var(--space-lg);
}

.print-btn svg {
    width: 14px;
    height: 14px;
}
