/* ==========================================================================
   Calculators99 Custom Theme (Built on top of Bootstrap 5.3)
   Light Mode Only - Modern Fintech & SaaS Design System
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens & CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
    /* Brand & Accent Defaults */
    --bs-primary: #059669;
    --bs-primary-rgb: 5, 150, 105;
    --bs-primary-hover: #047857;

    --brand-emerald: #059669;
    --brand-rose: #e11d48;
    --brand-indigo: #4f46e5;
    --brand-amber: #d97706;

    /* Slate Neutral Surfaces (Light Mode Only) */
    --surface-page: #f8fafc;
    --surface-card: #ffffff;
    --surface-muted: #f1f5f9;
    --border-subtle: #e2e8f0;
    --border-card: #e5e7eb;

    /* Typography */
    --font-heading: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Layout & Stacking Context Tokens */
    --header-height: 72px;
    --z-content: 1;
    --z-sticky: 100;
    --z-header: 1030;
    --z-dropdown: 1040;
    --z-offcanvas: 1045;
    --z-modal: 1055;
    --z-toast: 1090;

    /* Link Color Overrides (Override Bootstrap default #0d6efd) */
    --bs-link-color: #334155;
    --bs-link-color-rgb: 51, 65, 85;
    --bs-link-hover-color: #059669;
    --bs-link-hover-color-rgb: 5, 150, 105;

    /* Breadcrumb styling tokens */
    --bs-breadcrumb-divider-color: #94a3b8;
    --bs-breadcrumb-item-active-color: #0f172a;

    /* Soft Layered Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 4px 0 rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.04);

    /* Category Accent Tokens (Default / Neutral Brand) */
    --accent: #059669;
    --accent-rgb: 5, 150, 105;
    --accent-soft: #ecfdf5;
    --accent-ink: #047857;
    --accent-ring: rgba(5, 150, 105, 0.25);
}

/* Category Accent Theme Scopes */
body.cat-default,
.cat-default {
    --accent: #059669;
    --accent-rgb: 5, 150, 105;
    --accent-soft: #ecfdf5;
    --accent-ink: #047857;
    --accent-ring: rgba(5, 150, 105, 0.25);
    --bs-primary: #059669;
    --bs-primary-rgb: 5, 150, 105;
}

body.cat-financial,
.cat-financial {
    --accent: #059669;
    --accent-rgb: 5, 150, 105;
    --accent-soft: #ecfdf5;
    --accent-ink: #047857;
    --accent-ring: rgba(5, 150, 105, 0.25);
    --bs-primary: #059669;
    --bs-primary-rgb: 5, 150, 105;
}

body.cat-fitness-health,
.cat-fitness-health {
    --accent: #e11d48;
    --accent-rgb: 225, 29, 72;
    --accent-soft: #fff1f2;
    --accent-ink: #be123c;
    --accent-ring: rgba(225, 29, 72, 0.25);
    --bs-primary: #e11d48;
    --bs-primary-rgb: 225, 29, 72;
}

body.cat-math,
.cat-math {
    --accent: #4f46e5;
    --accent-rgb: 79, 70, 229;
    --accent-soft: #eef2ff;
    --accent-ink: #4338ca;
    --accent-ring: rgba(79, 70, 229, 0.25);
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
}

body.cat-other,
.cat-other {
    --accent: #d97706;
    --accent-rgb: 217, 119, 6;
    --accent-soft: #fffbeb;
    --accent-ink: #92400e;
    /* High-contrast 7.1:1 dark amber for WCAG AA text */
    --accent-ring: rgba(217, 119, 6, 0.25);
    --bs-primary: #d97706;
    --bs-primary-rgb: 217, 119, 6;
}

html {
    scroll-padding-top: calc(var(--header-height) + 16px);
}

/* --------------------------------------------------------------------------
   2. Typography & Base Resets
   -------------------------------------------------------------------------- */
body {
    font-family: var(--font-body);
    background-color: var(--surface-page);
    color: #1e293b;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6,
.brand-name,
.fw-heading {
    font-family: var(--font-heading);
    letter-spacing: -0.025em;
    font-weight: 700;
}

code,
kbd,
pre {
    font-family: var(--font-mono);
}

/* Accessibility Skip Link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 20px;
    padding: 10px 18px;
    background: var(--bs-primary);
    color: #ffffff;
    font-weight: 600;
    border-radius: 8px;
    z-index: 9999;
    text-decoration: none;
    transition: top 0.2s ease-out;
}

.skip-link:focus {
    top: 20px;
}

:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Shadows Utilities */
.shadow-xs {
    box-shadow: var(--shadow-xs) !important;
}

.shadow-sm {
    box-shadow: var(--shadow-sm) !important;
}

.shadow-md {
    box-shadow: var(--shadow-md) !important;
}

.shadow-lg {
    box-shadow: var(--shadow-lg) !important;
}

/* --------------------------------------------------------------------------
   3. Sticky Navbar & Header
   -------------------------------------------------------------------------- */
.site-header,
.site-navbar {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    min-height: var(--header-height);
    background-color: #ffffff !important;
}

/* Calculators99 Logo sizing */
.brand-logo-img {
    height: 80px;
    width: auto;
    max-width: 100%;
    display: block;
    flex-shrink: 0;
    vertical-align: middle;
    object-fit: contain;
}

.brand-logo-svg .logo-full {
    display: block;
}

.brand-logo-svg .logo-mark {
    display: none;
}

@media (max-width: 480px) {

    .site-header .brand-logo-img,
    .site-header .brand-logo-svg {
        height: 60px;
    }
}

@media (max-width: 360px) {
    .site-header .brand-logo-img {
        height: 50px;
    }

    .site-header .brand-logo-svg .logo-full {
        display: none;
    }

    .site-header .brand-logo-svg .logo-mark {
        display: block;
    }
}

.btn-search-trigger {
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.btn-search-trigger:hover {
    background-color: #ffffff !important;
    border-color: #cbd5e1 !important;
    box-shadow: var(--shadow-sm);
    color: #334155 !important;
}

/* Header Direct Category Navigation Links */
.header-category-nav {
    display: flex;
    flex-wrap: nowrap;
}

.nav-cat-link {
    color: #475569 !important;
    font-size: 0.94rem;
    letter-spacing: -0.01em;
    border-radius: 10px;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    position: relative;
}

.nav-cat-link:hover,
.nav-cat-link:focus {
    background-color: #f1f5f9;
    color: #0f172a !important;
}

/* Category Accent Active Highlight */
.nav-cat-link.active {
    background-color: var(--cat-accent-soft, var(--accent-soft)) !important;
    color: var(--cat-accent, var(--accent)) !important;
    font-weight: 700 !important;
}

.nav-cat-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 12px;
    right: 12px;
    height: 2px;
    background-color: var(--cat-accent, var(--accent));
    border-radius: 2px;
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    .nav-cat-link {
        font-size: 0.88rem;
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}

/* Currency Selector Toggle Button */
.currency-selector-btn,
.currency-selector-wrapper .btn,
#currencySelectorDropdown {
    color: #1e293b !important;
    background-color: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.currency-selector-btn:hover,
.currency-selector-btn:focus,
.currency-selector-btn:active,
.currency-selector-btn.show,
.currency-selector-btn[aria-expanded="true"],
.currency-selector-wrapper .btn:hover,
.currency-selector-wrapper .btn:focus,
.currency-selector-wrapper .btn:active,
.currency-selector-wrapper .btn.show,
.currency-selector-wrapper .btn[aria-expanded="true"],
#currencySelectorDropdown:hover,
#currencySelectorDropdown:focus,
#currencySelectorDropdown:active,
#currencySelectorDropdown.show,
#currencySelectorDropdown[aria-expanded="true"] {
    color: #0f172a !important;
    background-color: #e2e8f0 !important;
    border-color: #94a3b8 !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}

.currency-selector-btn .active-currency-code,
.currency-selector-wrapper .active-currency-code,
#currencySelectorDropdown .active-currency-code {
    color: #1e293b !important;
    transition: color 0.15s ease;
}

.currency-selector-btn:hover .active-currency-code,
.currency-selector-btn:focus .active-currency-code,
.currency-selector-btn:active .active-currency-code,
.currency-selector-btn.show .active-currency-code,
.currency-selector-btn[aria-expanded="true"] .active-currency-code,
.currency-selector-wrapper .btn:hover .active-currency-code,
.currency-selector-wrapper .btn:focus .active-currency-code,
.currency-selector-wrapper .btn:active .active-currency-code,
.currency-selector-wrapper .btn.show .active-currency-code,
.currency-selector-wrapper .btn[aria-expanded="true"] .active-currency-code,
#currencySelectorDropdown:hover .active-currency-code,
#currencySelectorDropdown:focus .active-currency-code,
#currencySelectorDropdown:active .active-currency-code,
#currencySelectorDropdown.show .active-currency-code,
#currencySelectorDropdown[aria-expanded="true"] .active-currency-code {
    color: #0f172a !important;
}

.currency-selector-btn .active-currency-sym,
.currency-selector-wrapper .active-currency-sym,
#currencySelectorDropdown .active-currency-sym {
    color: var(--bs-primary, #2563eb) !important;
    transition: color 0.15s ease;
}

.currency-selector-btn:hover .active-currency-sym,
.currency-selector-btn:focus .active-currency-sym,
.currency-selector-btn:active .active-currency-sym,
.currency-selector-btn.show .active-currency-sym,
.currency-selector-btn[aria-expanded="true"] .active-currency-sym,
.currency-selector-wrapper .btn:hover .active-currency-sym,
.currency-selector-wrapper .btn:focus .active-currency-sym,
.currency-selector-wrapper .btn:active .active-currency-sym,
.currency-selector-wrapper .btn.show .active-currency-sym,
.currency-selector-wrapper .btn[aria-expanded="true"] .active-currency-sym,
#currencySelectorDropdown:hover .active-currency-sym,
#currencySelectorDropdown:focus .active-currency-sym,
#currencySelectorDropdown:active .active-currency-sym,
#currencySelectorDropdown.show .active-currency-sym,
#currencySelectorDropdown[aria-expanded="true"] .active-currency-sym {
    color: var(--bs-primary, #2563eb) !important;
}

/* Currency Dropdown Menu */
.currency-dropdown-menu {
    min-width: 300px;
    max-width: calc(100vw - 24px);
    max-height: 60vh;
    overflow-y: auto;
    padding: 8px;
    z-index: var(--z-dropdown);
    border: 1px solid var(--border-subtle) !important;
}

.currency-dropdown-menu .dropdown-item {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #1f2937;
    background: transparent;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.currency-dropdown-menu .dropdown-item span {
    color: inherit;
}

.currency-dropdown-menu .dropdown-item .currency-opt-symbol {
    min-width: 28px;
    color: var(--bs-primary);
}

.currency-dropdown-menu .dropdown-item .currency-opt-name {
    color: #64748b;
}

.currency-dropdown-menu .dropdown-item:hover,
.currency-dropdown-menu .dropdown-item:focus {
    background-color: #f1f5f9;
    color: #0f172a;
}

.currency-dropdown-menu .dropdown-item:hover .currency-opt-symbol,
.currency-dropdown-menu .dropdown-item:focus .currency-opt-symbol {
    color: var(--bs-primary);
}

.currency-dropdown-menu .dropdown-item:not(.active):hover .currency-opt-name,
.currency-dropdown-menu .dropdown-item:not(.active):focus .currency-opt-name {
    color: #475569;
}

.currency-dropdown-menu .dropdown-item.active,
.currency-dropdown-menu .dropdown-item:active {
    background-color: var(--bs-primary) !important;
    color: #ffffff !important;
    font-weight: 700;
}

.currency-dropdown-menu .dropdown-item.active span,
.currency-dropdown-menu .dropdown-item.active .currency-opt-symbol,
.currency-dropdown-menu .dropdown-item.active .currency-opt-name,
.currency-dropdown-menu .dropdown-item.active i {
    color: #ffffff !important;
}

/* Offcanvas & Modals Z-Index Scale */
.offcanvas,
.offcanvas-lg {
    z-index: var(--z-offcanvas);
}

.modal {
    z-index: var(--z-modal);
}

.modal-backdrop {
    z-index: calc(var(--z-modal) - 5);
}

.offcanvas-backdrop {
    z-index: calc(var(--z-offcanvas) - 5);
}

/* Sticky Sidebar & Panels */
.sidebar-sticky,
.sticky-panel {
    position: sticky;
    top: calc(var(--header-height, 72px) + 16px);
    max-height: calc(100vh - var(--header-height, 72px) - 32px);
    overflow-y: auto;
    z-index: var(--z-sticky);
    align-self: start;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

.sidebar-sticky::-webkit-scrollbar,
.sticky-panel::-webkit-scrollbar {
    width: 5px;
}

.sidebar-sticky::-webkit-scrollbar-thumb,
.sticky-panel::-webkit-scrollbar-thumb {
    background-color: rgba(148, 163, 184, 0.4);
    border-radius: 9999px;
}

/* --------------------------------------------------------------------------
   Wide Calculator Detail Page Layout (Left Main Wide, Right Sidebar 280px/320px)
   -------------------------------------------------------------------------- */
.calc-layout-grid {
    display: block;
    width: 100%;
}

@media (min-width: 992px) {
    .calc-layout-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 280px;
        gap: 24px;
        align-items: start;
    }
}

@media (min-width: 1200px) {
    .calc-layout-grid {
        grid-template-columns: minmax(0, 1fr) 320px;
        gap: 32px;
    }
}

.calc-main-column {
    min-width: 0;
    width: 100%;
}

.calc-sidebar-column {
    min-width: 0;
}

@media (min-width: 992px) {
    .calc-sidebar-column {
        position: sticky;
        top: calc(var(--header-height, 72px) + 16px);
        max-height: calc(100vh - var(--header-height, 72px) - 32px);
        overflow-y: auto;
        z-index: var(--z-sticky);
        align-self: start;
        scrollbar-width: thin;
        scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
    }

    .calc-sidebar-column::-webkit-scrollbar {
        width: 5px;
    }

    .calc-sidebar-column::-webkit-scrollbar-thumb {
        background-color: rgba(148, 163, 184, 0.4);
        border-radius: 9999px;
    }
}

@media (max-width: 991.98px) {
    .calc-sidebar-column {
        width: 100%;
    }
}

/* --------------------------------------------------------------------------
   4. Home Page Components (Hero, Two-Column Category Panels)
   -------------------------------------------------------------------------- */
.home-hero-compact {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid var(--border-subtle);
}

.home-search-wrap {
    max-width: 680px;
    margin: 0 auto;
}

.home-search-input-group {
    background-color: #ffffff;
    border: 2px solid var(--border-subtle);
    border-radius: 9999px;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease-in-out;
}

.home-search-input-group:focus-within {
    border-color: var(--brand-emerald);
    box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.12), var(--shadow-lg);
}

.home-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background-color: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    max-height: 360px;
    overflow-y: auto;
}

/* Unified Search Item Active / Highlight State */
.modal-result-item,
.home-result-item {
    transition: background-color 0.12s ease, border-left-color 0.12s ease;
    border-left: 3px solid transparent !important;
    text-decoration: none !important;
}

.modal-result-item:hover,
.home-result-item:hover,
.modal-result-item.search-item-active,
.home-result-item.search-item-active,
.modal-result-item[aria-selected="true"],
.home-result-item[aria-selected="true"] {
    background-color: var(--accent-soft, #ecfdf5) !important;
    border-left: 3px solid var(--accent, #059669) !important;
    color: #0f172a !important;
}

.modal-result-item.search-item-active .text-dark,
.home-result-item.search-item-active .text-dark,
.modal-result-item[aria-selected="true"] .text-dark,
.home-result-item[aria-selected="true"] .text-dark {
    color: var(--accent-ink, #064e3b) !important;
}

/* Sidebar Filter Active Item Highlight */
.sidebar-calc-link.sidebar-filter-active {
    background-color: var(--accent-soft, #ecfdf5) !important;
    color: var(--accent-ink, #064e3b) !important;
    border-left: 3px solid var(--accent, #059669) !important;
    font-weight: 700 !important;
}

/* Category Scannable Panels (Left Column of Home) */
.home-category-tile {
    border: 1px solid var(--border-subtle) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-category-tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md) !important;
}

.home-category-tile-icon {
    width: 44px;
    height: 44px;
    background-color: var(--tile-accent-light, #ecfdf5);
    color: var(--tile-accent, var(--bs-primary));
}

.btn-category-tile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 12px;
    background-color: var(--tile-accent-light, #ecfdf5);
    color: var(--tile-accent, var(--bs-primary)) !important;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all 0.15s ease;
}

.btn-category-tile:hover {
    background-color: var(--tile-accent, var(--bs-primary));
    color: #ffffff !important;
}

.btn-category-tile:hover i {
    transform: translateX(3px);
}

.btn-category-tile i {
    transition: transform 0.15s ease;
}

.category-panel-block {
    background-color: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 30px;
    /* Generous 28-32px padding */
    margin-bottom: 28px;
    /* 24-32px between cards */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.category-panel-block:hover {
    box-shadow: var(--shadow-md);
}

.cat-panel-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.cat-icon-badge {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* --------------------------------------------------------------------------
   CSS Grid: Large Rectangular Category Cards
   Equal widths and heights across all categories
   3 cols desktop (≥992px), 2 cols tablet, 1 col mobile (<480px)
   -------------------------------------------------------------------------- */
.calc-grid-container {
    --cols: 3;
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: 14px;
}

@media (max-width: 991.98px) {
    .calc-grid-container {
        --cols: 2;
    }
}

@media (max-width: 480px) {
    .calc-grid-container {
        --cols: 1;
    }

    .category-panel-block {
        padding: 20px;
    }
}

.calc-grid-btn {
    min-height: 64px;
    padding: 12px 14px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #1e293b;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
    text-align: left;
}

.calc-grid-btn-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 9px;
    background-color: var(--cat-accent-light, #ecfdf5);
    color: var(--cat-accent, var(--bs-primary));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    transition: transform 0.15s ease;
}

.calc-grid-btn-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.25;
    color: #1e293b;
    flex-grow: 1;
    word-break: normal;
    overflow-wrap: break-word;
}

.calc-grid-btn-arrow {
    font-size: 0.85rem;
    color: #94a3b8;
    transition: transform 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.calc-grid-btn:hover {
    background-color: #ffffff;
    border-color: var(--cat-accent, var(--bs-primary));
    transform: translateY(-2px);
    box-shadow: 0 6px 14px -3px rgba(0, 0, 0, 0.08);
    color: #0f172a;
}

.calc-grid-btn:hover .calc-grid-btn-icon {
    transform: scale(1.05);
}

.calc-grid-btn:hover .calc-grid-btn-arrow {
    transform: translateX(3px);
    color: var(--cat-accent, var(--bs-primary));
}

.calc-grid-btn:focus-visible {
    outline: 2px solid var(--cat-accent, var(--bs-primary));
    outline-offset: 2px;
}

/* Right Column Sidebar on Home */
.quick-links-pill-list a {
    transition: all 0.15s ease;
}

.quick-links-pill-list a:hover {
    background-color: #f1f5f9;
    transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   5. Calculator Cards & Components
   -------------------------------------------------------------------------- */
.calc-card {
    border-radius: 18px;
    transition: all 0.2s ease;
    border: 1px solid var(--border-subtle) !important;
}

.calc-card:hover,
.calc-card.category-filter-active {
    transform: translateY(-4px);
    border-color: var(--card-accent, var(--accent)) !important;
    box-shadow: 0 14px 28px -4px rgba(15, 23, 42, 0.08), 0 0 0 3px var(--accent-ring, rgba(5, 150, 105, 0.2)) !important;
}

.calc-icon-tile {
    width: 44px;
    height: 44px;
    background-color: var(--card-accent-soft, var(--accent-soft));
    color: var(--card-accent, var(--accent));
}

.calc-card .calc-card-action {
    color: var(--card-accent-ink, var(--accent-ink));
    transition: color 0.15s ease;
}

.calc-card:hover .calc-card-arrow {
    transform: translateX(4px);
    color: var(--card-accent, var(--accent));
}

.calc-card-arrow {
    transition: transform 0.2s ease;
}

/* --------------------------------------------------------------------------
   6. Calculator Page Layout & Interactive Panels
   -------------------------------------------------------------------------- */
.calc-page-hero {
    border-left: 4px solid var(--accent);
}

/* Outer Card Container */
.calc-card,
.calc-main-card {
    background: #ffffff;
    border: 1px solid var(--border-card, #e2e8f0) !important;
    border-radius: 18px;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
    padding: 24px;
    container-type: inline-size;
    container-name: calc;
    min-width: 0;
}

@media (max-width: 576px) {

    .calc-card,
    .calc-main-card {
        padding: 16px;
    }
}

@container calc (max-width: 480px) {

    .calc-card,
    .calc-main-card {
        padding: 16px;
    }
}

/* Stacked Layout (Default for financial, math with diagrams, complex tools) */
.calc-card[data-layout="stacked"] .calc-body,
.calc-main-card[data-layout="stacked"] .calc-body {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.calc-card[data-layout="stacked"] .calc-inputs,
.calc-main-card[data-layout="stacked"] .calc-inputs {
    width: 100%;
}

.calc-card[data-layout="stacked"] .calc-results,
.calc-main-card[data-layout="stacked"] .calc-results {
    width: 100%;
    padding-top: 28px;
    border-top: 1px solid var(--border-subtle, #e2e8f0);
}

/* Split Layout (For compact calculators: BMI, Age, Percentage, etc.) */
.calc-card[data-layout="split"] .calc-body,
.calc-main-card[data-layout="split"] .calc-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

.calc-card[data-layout="split"] .calc-results,
.calc-main-card[data-layout="split"] .calc-results {
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle, #e2e8f0);
}

@container calc (min-width: 860px) {

    .calc-card[data-layout="split"] .calc-body,
    .calc-main-card[data-layout="split"] .calc-body {
        grid-template-columns: minmax(300px, 2fr) minmax(0, 3fr);
        gap: 0;
        align-items: start;
    }

    .calc-card[data-layout="split"] .calc-inputs,
    .calc-main-card[data-layout="split"] .calc-inputs {
        padding-right: 32px;
        align-self: start;
        height: fit-content;
    }

    .calc-card[data-layout="split"] .calc-results,
    .calc-main-card[data-layout="split"] .calc-results {
        padding-left: 32px;
        padding-top: 0;
        border-top: none;
        border-left: 1px solid var(--border-subtle, #e2e8f0);
        align-self: stretch;
        min-width: 0;
    }
}

/* Legacy .calc-interactive-row backwards-compatibility (during migration) */
.calc-interactive-row {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.calc-inputs-panel,
.calc-results-panel {
    width: 100%;
}

@container (min-width: 860px) {
    .calc-interactive-row {
        display: grid;
        grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
        align-items: start;
        gap: 2rem;
    }

    .calc-inputs-panel {
        align-self: start;
        height: fit-content;
    }
}

/* Headings for Sections */
.calc-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.calc-section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    line-height: 1.3;
}

.calc-section-title i {
    color: var(--accent);
    font-size: 1.25rem;
    display: inline-flex;
}

/* Inputs Field Grid */
.calc-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px 20px;
    align-items: start;
}

.calc-fields-grid>.col-12,
.calc-fields-grid>.grid-full-width {
    grid-column: 1 / -1;
}

/* Form controls consistency across all calculators */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.calc-main-card .form-label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    display: block;
    line-height: 1.35;
}

.calc-main-card .form-text {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}

.calc-main-card .form-control,
.calc-main-card .form-select {
    height: 44px;
    min-height: 44px;
    font-size: 0.95rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

.calc-main-card .form-control:focus,
.calc-main-card .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring, rgba(5, 150, 105, 0.2));
}

.calc-main-card .input-group {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
}

.calc-main-card .input-group>.form-control,
.calc-main-card .input-group>.form-select {
    min-width: 0;
    flex: 1 1 0%;
}

.calc-main-card .input-group-text {
    height: 44px;
    min-height: 44px;
    font-size: 0.9rem;
    padding: 0 12px;
    color: #64748b;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.calc-main-card .input-group-addon-badge {
    min-width: 44px;
    padding: 0 8px;
    text-align: center;
    font-weight: 600;
    color: #475569;
}

/* Actions Row */
.calc-actions-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

/* Number formatting and metric displays */
.tabular-nums,
.result-metric-value,
.calc-hero-val,
.calc-metric-tile .tile-val,
.calc-kv-row .kv-val,
.calc-result-box strong,
.calc-table-wrap td {
    font-variant-numeric: tabular-nums;
}

/* 1. Hero Result Strip */
.calc-hero-strip {
    background-color: var(--accent-soft, #ecfdf5);
    border: 1px solid var(--accent-ring, rgba(5, 150, 105, 0.2));
    border-radius: 14px;
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
}

.calc-hero-strip .badge {
    white-space: normal;
    text-align: left;
    display: inline-block;
    max-width: 100%;
    word-break: break-word;
}

@container (min-width: 640px) {
    .calc-hero-strip.has-sub {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-end;
    }
}

.calc-hero-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-ink, #065f46);
    margin-bottom: 2px;
}

.calc-hero-val {
    font-family: var(--font-heading);
    font-weight: 800;
    line-height: 1.1;
    color: var(--accent, #059669);
    font-size: clamp(2rem, 5cqi, 3rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calc-hero-sub {
    font-size: 0.9rem;
    color: var(--accent-ink, #065f46);
    opacity: 0.9;
}

/* 2. Metric Tiles Grid */
.calc-metric-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.calc-metric-tile {
    background-color: var(--accent-soft, #f8fafc);
    border: 1px solid var(--accent-ring, rgba(0, 0, 0, 0.05));
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.calc-metric-tile .tile-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calc-metric-tile .tile-val {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Legacy summary box fallback */
.calc-summary-boxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
    gap: 12px;
}

.calc-summary-box {
    background-color: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 12px 14px;
}

.calc-summary-box .summary-box-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calc-summary-box .summary-box-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 3. Chart + Summary Block */
.calc-chart-summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 24px;
    align-items: stretch;
}

@container (min-width: 640px) {
    .calc-chart-summary-grid {
        grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
        align-items: center;
    }
}

.calc-chart-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chart-wrapper {
    position: relative;
    width: min(100%, 280px);
    aspect-ratio: 1;
    margin-inline: auto;
    min-width: 0;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

.calc-summary-panel {
    background-color: #f8fafc;
    border: 1px solid var(--border-subtle, #e2e8f0);
    border-radius: 14px;
    padding: 20px;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Key-Value Breakdown Rows */
.calc-kv-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.calc-kv-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.9rem;
    min-width: 0;
}

.calc-kv-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.calc-kv-row .kv-label {
    color: #64748b;
    flex: 1 1 auto;
    min-width: 0;
}

.calc-kv-row .kv-val {
    color: #0f172a;
    font-weight: 700;
    white-space: nowrap;
    text-align: right;
    flex-shrink: 0;
}

/* 4. Tables and Schedules */
.calc-table-wrap {
    overflow-x: auto;
    max-height: 420px;
    overflow-y: auto;
    border-radius: 12px;
    border: 1px solid var(--border-subtle, #e2e8f0);
    margin-top: 16px;
}

.calc-table-wrap table {
    margin-bottom: 0;
    min-width: 640px;
    width: 100%;
}

.calc-table-wrap th,
.calc-table-wrap td {
    padding: 10px 14px !important;
    white-space: nowrap;
}

.calc-table-wrap td.text-end,
.calc-table-wrap th.text-end {
    text-align: right;
}

.calc-table-wrap thead th {
    position: sticky;
    top: 0;
    background-color: #f8fafc;
    z-index: 2;
    white-space: nowrap;
    font-weight: 700;
    font-size: 0.825rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid #cbd5e1;
}

.calc-table-wrap th:first-child,
.calc-table-wrap td:first-child {
    position: sticky;
    left: 0;
    background-color: #ffffff;
    z-index: 1;
    font-weight: 600;
}

.calc-table-wrap thead th:first-child {
    z-index: 3;
    background-color: #f8fafc;
}

/* Calculator Action Buttons (.btn-calc & .btn-calc-secondary) */
.btn-calc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    min-width: 170px;
    height: 44px;
    padding: 10px 22px;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    border-radius: 12px;
    background: var(--accent);
    border: 1px solid transparent;
    color: #ffffff !important;
    text-decoration: none;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-calc i {
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-calc:hover {
    filter: brightness(0.92);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    background: #000 !important;
    color: #ffffff !important;
}

.btn-calc:active {
    transform: translateY(0);
}

.btn-calc-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #475569 !important;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-calc-secondary i {
    font-size: 16px;
    line-height: 1;
}

.btn-calc-secondary:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a !important;
}

@media (max-width: 575.98px) {

    .btn-calc,
    .btn-calc-secondary {
        width: 100%;
    }
}

/* In-Content Links */
a {
    color: var(--bs-link-color);
    text-underline-offset: 3px;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--bs-link-hover-color);
}

.breadcrumb a {
    color: #64748b;
    text-decoration: none;
}

.breadcrumb a:hover {
    color: #0f172a;
}

.result-metric-value {
    font-family: var(--font-heading);
    font-weight: 800;
    line-height: 1.1;
    color: var(--bs-primary);
}

/* Chart Canvas Wrapper */
.chart-container-wrap {
    position: relative;
    max-height: 280px;
    margin: 0 auto;
}

/* Scientific Calculator Keypad Grid */
.calc-keypad-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.btn-calc-key {
    height: 48px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease-in-out;
}

.btn-calc-key:active {
    transform: scale(0.96);
}

.calc-display-screen {
    font-family: var(--font-mono);
    min-height: 72px;
    background-color: #0f172a;
    color: #38bdf8;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: right;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.calc-screen-history {
    font-size: 0.85rem;
    color: #94a3b8;
    min-height: 18px;
}

.calc-screen-current {
    font-size: 1.75rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
    overflow-x: auto;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   7. Sidebar Category Accordion (Inner Pages)
   -------------------------------------------------------------------------- */
.calc-sidebar-card {
    border-radius: 16px;
}

.sidebar-calc-link {
    font-size: 0.825rem;
    transition: all 0.12s ease;
}

.sidebar-calc-link:hover {
    background-color: var(--accent-soft, #f1f5f9);
    color: var(--accent-ink, var(--accent)) !important;
}

.sidebar-calc-link.active {
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #ffffff !important;
}

/* --------------------------------------------------------------------------
   8. Custom Accordion Styling (FAQs)
   -------------------------------------------------------------------------- */
.custom-faq-accordion .accordion-item {
    border: 1px solid var(--border-subtle) !important;
    background-color: #ffffff;
    transition: border-color 0.15s ease;
}

.custom-faq-accordion .accordion-button {
    background-color: #ffffff;
    color: #0f172a;
    font-size: 1rem;
    box-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.custom-faq-accordion .accordion-button:not(.collapsed) {
    background-color: var(--accent-soft, #f8fafc);
    color: var(--accent-ink, var(--accent));
    border-left: 4px solid var(--accent);
}

.custom-faq-accordion .accordion-button:focus {
    box-shadow: 0 0 0 3px var(--accent-ring);
    border-color: var(--accent);
}

/* Result metric value & badges */
.result-metric-value {
    font-family: var(--font-heading);
    font-weight: 800;
    line-height: 1.1;
    color: var(--accent);
}

.result-badge {
    background-color: var(--accent-soft);
    color: var(--accent-ink);
    border: 1px solid var(--accent-ring);
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   9. Footer Styling
   -------------------------------------------------------------------------- */
.site-footer {
    border-top: 1px solid var(--border-subtle);
}

.footer-link {
    transition: color 0.15s ease;
}

.footer-link:hover {
    color: var(--bs-primary) !important;
}

/* --------------------------------------------------------------------------
   10. Responsiveness & Utilities
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .calc-keypad-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 575.98px) {
    .calc-screen-current {
        font-size: 1.4rem;
    }

    .btn-calc-key {
        height: 42px;
        font-size: 0.85rem;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --------------------------------------------------------------------------
   11. Scientific Calculator Widget (Dark contrasting card)
   -------------------------------------------------------------------------- */
.sci-widget-card {
    background-color: #111827 !important;
    /* deep charcoal */
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.2) !important;
}

.sci-keypad-grid .sci-key {
    height: 38px;
    padding: 2px 4px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-mono);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.08s ease, filter 0.1s ease, background-color 0.1s ease;
}

.sci-keypad-grid .sci-key:active {
    transform: scale(0.95);
}

/* Row 1 Memory Keys & AC (soft red/pink label) */
.sci-key-mem {
    background-color: #1f2937;
    color: #f472b6 !important;
    /* soft pink */
}

.sci-key-mem:hover {
    background-color: #374151;
    color: #fbcfe8 !important;
}

.sci-key-danger {
    background-color: #371b26;
    color: #fb7185 !important;
    /* soft red/pink */
    border-color: rgba(251, 113, 133, 0.3) !important;
}

.sci-key-danger:hover {
    background-color: #4c1d30;
    color: #ffe4e6 !important;
}

/* Function Keys (dark slate) */
.sci-key-fn {
    background-color: #1f2937;
    color: #e5e7eb;
}

.sci-key-fn:hover {
    background-color: #374151;
    color: #ffffff;
}

/* Highlighted DEG/RAD Key */
.sci-deg-toggle-key {
    background-color: #0e3a47 !important;
    color: #38bdf8 !important;
    /* cyan */
    border-color: rgba(56, 189, 248, 0.4) !important;
}

.sci-deg-toggle-key:hover {
    background-color: #155e75 !important;
    color: #bae6fd !important;
}

/* Delete / Backspace */
.sci-key-warn {
    background-color: #292524;
    color: #fdba74;
}

.sci-key-warn:hover {
    background-color: #44403c;
    color: #fed7aa;
}

/* Number Digits (darker than function keys) */
.sci-key-num {
    background-color: #161e2e;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 700;
}

.sci-key-num:hover {
    background-color: #242f42;
    color: #ffffff;
}

/* Operator Keys (÷ × − +) are Orange */
.sci-key-op {
    background-color: #ea580c !important;
    /* vibrant orange */
    color: #ffffff !important;
    border-color: #c2410c !important;
    font-size: 1.05rem;
}

.sci-key-op:hover {
    background-color: #f97316 !important;
    color: #ffffff !important;
}

/* Equals Key (=): Cyan-to-blue gradient */
.sci-key-equals {
    background: linear-gradient(135deg, #06b6d4 0%, #2563eb 100%) !important;
    color: #ffffff !important;
    border: none !important;
    font-size: 1.1rem;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
}

.sci-key-equals:hover {
    filter: brightness(1.1);
    color: #ffffff !important;
}

@media (max-width: 400px) {
    .sci-keypad-grid .sci-key {
        height: 35px;
        font-size: 0.78rem;
    }
}