/* =========================================
   1. GLOBAL VARIABLES & RESET
   ========================================= */

/* ── Google Fonts: DM Sans + DM Mono ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* Font Awesome font-display fix - prevents FOIT */
@font-face {
    font-family: 'Font Awesome 6 Free';
    font-display: swap;
}
@font-face {
    font-family: 'Font Awesome 6 Brands';
    font-display: swap;
}

/* Accessibility: Screen reader only content */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Accessibility: Visible focus indicator for keyboard navigation */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary, #00c4d4);
    outline-offset: 2px;
}

:root {
    /* Theme colors are set by inline JS in HTML - DO NOT set defaults here */
    /* Layout variables only */
    --sidebar-w: 0px;
    --ad-col-w: 0px;

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;

    /* Typography */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'DM Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Elevation / shadow */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:  0 8px 28px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);
    --shadow-xl:  0 16px 48px rgba(0,0,0,0.14), 0 6px 16px rgba(0,0,0,0.08);

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 0.12s;
    --duration-base: 0.18s;
    --duration-slow: 0.28s;

    /* Section accent colours (set per-page via inline style or data attr) */
    --page-accent: var(--primary);
    --page-accent-muted: var(--primary-muted, rgba(0,180,200,0.12));

    /* ── Shorthand aliases (used by hero system & new UI components) ── */
    --surf:  var(--surface);
    --surf2: var(--surface-alt, #f4f6f9);
    --text2: var(--text-muted);
    --b:     var(--border);
    --r:     var(--radius-lg, 12px);
    --rxl:   var(--radius-xl, 16px);
    --font:  var(--font-sans);

    /* ── Hero card system ── */
    --hero-h: 56px;           /* icon size */
    --hero-pad: 28px 32px;
    --hero-radius: var(--radius-xl);
}

/* ═══════════════════════════════════════════════
   HERO CARD SYSTEM
   Per-page header with icon, KPIs, and actions.
   Used on all business suite pages.
   ═══════════════════════════════════════════════ */

.page-hero {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    margin: 16px 0 20px;
    overflow: hidden;
}
.page-hero-body {
    padding: var(--hero-pad);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    align-items: start;
}
.page-hero-icon {
    width: 52px; height: 52px;
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}
.page-hero-content { min-width: 0; }
.page-hero-label {
    font-size: 11px; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--primary);
    margin-bottom: 2px;
}
.page-hero-title {
    font-size: 22px; font-weight: 700;
    color: var(--text); margin: 0 0 4px; line-height: 1.2;
}
.page-hero-meta {
    font-size: 12px; color: var(--text-muted);
}
.page-hero-kpis {
    display: flex; gap: 28px; flex-wrap: wrap;
    padding: 14px 32px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-alt) 60%, transparent);
}
.page-hero-kpi { display: flex; flex-direction: column; gap: 1px; }
.page-hero-kpi-value {
    font-size: 20px; font-weight: 700; font-family: var(--font-mono);
    color: var(--text); line-height: 1.1;
}
.page-hero-kpi-label {
    font-size: 10px; font-weight: 600; letter-spacing: .06em;
    text-transform: uppercase; color: var(--text-muted);
}
.page-hero-actions {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    padding: 12px 32px;
    border-top: 1px solid var(--border);
}
.page-hero-actions .btn-primary,
.page-hero-actions .btn-secondary,
.page-hero-actions .btn-ghost {
    min-height: 36px; padding: 0 16px;
    font-size: 13px; font-weight: 600;
    border-radius: var(--radius-md);
    display: inline-flex; align-items: center; gap: 6px;
    cursor: pointer; transition: opacity .14s;
    text-decoration: none;
}
.page-hero-actions .btn-primary {
    background: var(--primary); color: #fff;
    border: none;
}
.page-hero-actions .btn-primary:hover { opacity: .88; }
.page-hero-actions .btn-secondary,
.page-hero-actions .btn-ghost {
    background: var(--surface-alt); color: var(--text);
    border: 1px solid var(--border);
}
.page-hero-actions .btn-secondary:hover,
.page-hero-actions .btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.page-hero-actions .hero-meta-right {
    margin-left: auto; font-size: 12px; color: var(--text-muted);
}

/* ── Hero responsive ── */
@media (max-width: 1130px) {
    .page-hero-kpis { gap: 20px; }
}
@media (max-width: 860px) {
    .page-hero-body { grid-template-columns: 1fr; gap: 12px; }
    .page-hero-icon { width: 44px; height: 44px; font-size: 22px; }
    .page-hero { margin: 12px 0 16px; border-radius: var(--radius-lg); }
    .page-hero-body { padding: 20px; }
    .page-hero-kpis { padding: 12px 20px; gap: 16px; }
    .page-hero-actions { padding: 10px 20px; }
    .page-hero-kpi-value { font-size: 17px; }
}

/* ═══════════════════════════════════════════════
   PAGE LAYOUT — 960px max-width, left-anchored
   Applied to all .page-content wrappers on /user/ pages.
   ═══════════════════════════════════════════════ */

.page-content {
    max-width: 960px;
    margin-left: 0;
    margin-right: auto;
    padding: 0 0 48px;
}

/* Tablet/mid-range responsive grid helpers */
@media (max-width: 1130px) {
    .stat-grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
    .two-col-wide { grid-template-columns: 1fr !important; }
    .three-col-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 910px) {
    .two-col-even { grid-template-columns: 1fr !important; }
    .three-col-grid { grid-template-columns: 1fr !important; }
}

/* ═══════════════════════════════════════════════
   MOBILE BOTTOM NAV
   Injected by sidebar.js on mobile only.
   ═══════════════════════════════════════════════ */

#tf-mob-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    z-index: 1200;
    flex-direction: row;
    align-items: stretch;
}
#tf-mob-nav .mob-nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; text-decoration: none;
    color: var(--text-muted); font-size: 10px; font-weight: 600;
    letter-spacing: .03em; min-height: 44px;
    transition: color .12s;
}
#tf-mob-nav .mob-nav-item i { font-size: 18px; }
#tf-mob-nav .mob-nav-item.active { color: var(--primary); }
#tf-mob-nav .mob-nav-item:hover { color: var(--primary); }

@media (max-width: 768px) {
    #tf-mob-nav { display: flex; }
    body { padding-bottom: 60px; }
}

/* ── Context switcher badge in sidebar ── */
.ctx-switcher {
    margin: 8px 6px 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    overflow: hidden;
}
.ctx-switcher-btn {
    width: 100%; display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; font-size: 12px; font-weight: 600;
    color: var(--text); background: none; border: none;
    cursor: pointer; text-align: left;
    transition: background .12s;
}
.ctx-switcher-btn:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.ctx-switcher-btn .ctx-badge {
    font-size: 10px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; padding: 2px 6px;
    border-radius: 4px; margin-left: auto;
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    color: var(--primary);
}
.ctx-popover {
    display: none; flex-direction: column; padding: 4px 0;
    border-top: 1px solid var(--border);
}
.ctx-switcher.open .ctx-popover { display: flex; }
.ctx-popover-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; font-size: 12px; font-weight: 500;
    color: var(--text); cursor: pointer;
    transition: background .12s;
}
.ctx-popover-item:hover { background: var(--surface); }
.ctx-popover-item.active {
    color: var(--primary); font-weight: 700;
}
.ctx-popover-item i { width: 14px; text-align: center; color: var(--text-muted); }
.ctx-popover-item.active i { color: var(--primary); }

/* Global scroll lock when any modal is open */
body.modal-open,
body.modal-open html,
html:has(body.modal-open) {
    overflow: hidden !important;
}

html {
    overflow-y: scroll;
    overflow-x: hidden;
    max-width: 100vw;
}
* {
    box-sizing: border-box;
}

/* Global touch target accessibility - ensure all clickable elements meet 44x44px minimum on mobile */
@media (max-width: 768px) {
  button, 
  [role="button"],
  input[type="submit"],
  input[type="button"],
  input[type="reset"],
  .clickable {
      min-height: 44px;
      min-width: 44px;
  }
}

/* FAQ/Details touch targets - WCAG compliant */
details summary {
    min-height: 44px;
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-weight: 600;
    background: var(--surface, #f8f9fa);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: var(--radius-sm, 4px);
    margin-bottom: 8px;
    transition: background-color 0.2s ease;
}

details summary:hover {
    background: var(--bg, #ffffff);
}

details summary::marker,
details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: '+';
    font-weight: bold;
    font-size: 1.2rem;
    margin-right: 12px;
    color: var(--primary, #00c4d4);
    width: 20px;
    text-align: center;
}

details[open] summary::before {
    content: '\2212';
}

details[open] summary {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
}

details > *:not(summary) {
    padding: 16px;
    background: var(--surface, #f8f9fa);
    border: 1px solid var(--border, #e0e0e0);
    border-top: none;
    border-radius: 0 0 var(--radius-sm, 4px) var(--radius-sm, 4px);
    margin-bottom: 8px;
    margin-top: 0;
}

details > *:not(summary):first-of-type {
    margin-top: 0;
}

details > p:first-of-type,
details > *:not(summary) > *:first-child {
    margin-top: 0;
}

/* Dark theme details */
body.dark-theme details summary {
    background: var(--surface, #111);
    border-color: var(--border, #333);
}

body.dark-theme details summary:hover {
    background: var(--bg, #0a0a0a);
}

body.dark-theme details > *:not(summary) {
    background: var(--surface, #111);
    border-color: var(--border, #333);
}

/* Screen reader only - visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: var(--font-sans, 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: clip;
    /* Prevents sticky positioning breaks */
}

/* =========================================
   GLOBAL MODAL SYSTEM
   ========================================= */
/* Hide global header when modal is open (mobile only) */
@media (max-width: 1299px) {
    body.modal-open header.global-head {
        display: none !important;
    }
}

/* =========================================
   GLOBAL FORM ELEMENT SIZING
   ========================================= */
/* Consistent touch targets across all tools */
.calc-container input,
.calc-container select,
.calc-container textarea {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--border, #ccc);
    background: var(--bg, #fff);
    color: var(--text, #1a1a1a);
}

.calc-container button {
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Time picker selects - consistent sizing */
.calc-container .time-group select,
.calc-container .duration-group select {
    min-height: 44px;
    padding: 8px 4px;
    text-align: center;
    font-size: 0.85rem;
    border-radius: 8px;
    /* Prevent fast scroll - use scroll-snap */
    scroll-snap-type: y mandatory;
}

.calc-container .time-group select option,
.calc-container .duration-group select option {
    scroll-snap-align: center;
}

/* =========================================
   1b. TOOL PAGE — single-column 1200px
   ========================================= */
.tool-page {
    max-width: 1200px;
    margin: 80px auto 40px;
    padding: 0 20px;
    min-height: 80vh;
}

/* =========================================
   2. MASTER LAYOUT GRID
   ========================================= */
/* One rule to rule them all: Forces lanes into alignment */
.layout-grid {
    display: flex;
    justify-content: center;
    gap: 28px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}
.header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    width: 100%;
    height: 100%;
    align-items: center;
    padding: 0 var(--page-edge, 20px);
    box-sizing: border-box;
}

/* HEADER CONFIG */
header.global-head {
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    color: var(--text, #1a1a1a);
    box-shadow: 0 1px 0 rgba(0,0,0,0.06);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 12000;
    height: 64px;
    transition: background 0.3s, box-shadow 0.3s;
}
.dark-theme header.global-head {
    background: rgba(10,10,10,0.82);
    box-shadow: 0 1px 0 rgba(255,255,255,0.06);
}

/* Pro / suite mode: transparent glass header */
body.biz-pro header.global-head,
html.has-sidebar header.global-head {
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    box-shadow: 0 1px 0 rgba(0,0,0,0.06);
    border-bottom: none;
}
body.biz-pro.dark-theme header.global-head,
html.has-sidebar.dark-theme header.global-head {
    background: rgba(10,10,10,0.82);
}
body.biz-pro:not(.dark-theme) header.global-head,
html.has-sidebar:not(.dark-theme) header.global-head {
    color: var(--text, #1a1a1a);
}
body.biz-pro:not(.dark-theme) header.global-head .header-brand-block a,
html.has-sidebar:not(.dark-theme) header.global-head .header-brand-block a {
    color: var(--text, #1a1a1a);
}
body.biz-pro:not(.dark-theme) header.global-head .hdr-btn,
html.has-sidebar:not(.dark-theme) header.global-head .hdr-btn {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.15);
    color: var(--text, #1a1a1a);
}
body.biz-pro:not(.dark-theme) header.global-head .hdr-btn i,
html.has-sidebar:not(.dark-theme) header.global-head .hdr-btn i {
    color: var(--text, #1a1a1a);
}
@media (max-width: 768px) {
    body.biz-pro:not(.dark-theme) header.global-head .hdr-btn,
    html.has-sidebar:not(.dark-theme) header.global-head .hdr-btn {
        background: transparent;
        border-color: transparent;
        box-shadow: none;
    }
}
body.biz-pro:not(.dark-theme) header.global-head .mobile-only-btn,
html.has-sidebar:not(.dark-theme) header.global-head .mobile-only-btn {
    color: var(--text, #1a1a1a) !important;
}

/* Brutalist theme header fix - ensure white text on black bg */
.theme-brutalist header.global-head {
    color: #ffffff;
}
.theme-brutalist header.global-head a,
.theme-brutalist header.global-head .site-title,
.theme-brutalist header.global-head button {
    color: #ffffff !important;
}
.theme-brutalist.dark-theme header.global-head {
    color: #000000;
}
.theme-brutalist.dark-theme header.global-head a,
.theme-brutalist.dark-theme header.global-head .site-title,
.theme-brutalist.dark-theme header.global-head button {
    color: #000000 !important;
}

.header-brand-block {
    grid-column: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    padding-left: 0;
    z-index: 1;
}

/* Logo brand mark */
.header-logo-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0;
    background: none;
    border: none;
    text-decoration: none;
    color: var(--text, #1a1a1a);
    transition: opacity 0.2s;
}
.header-logo-pill img {
    border-radius: 6px;
    flex-shrink: 0;
}
.header-logo-pill:hover {
    opacity: 0.7;
}
.header-logo-text {
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.01em;
}
.hdr-toolbox-btn {
    background: none;
    border: none;
    color: var(--text, #1a1a1a);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

/* search-container & header-account grid-column set in SEARCH BAR section below */

/* Header buttons override global WCAG min-height */
#header-account button:not(.hdr-btn),
#header-account a:not(.hdr-btn) {
    min-height: 38px !important;
    min-width: auto !important;
}

/* MAIN CONTENT CONFIG — padding/min-height extend .layout-grid defined above */
.layout-grid {
    padding: 90px var(--page-edge, 20px) 30px var(--page-edge, 20px);
    min-height: calc(100vh - 60px);
}

/* FOOTER CONFIG */
footer.global-foot {
    background: var(--surface, #f8f9fa);
    /* WCAG AA: #595959 = 4.54:1 on white */
    color: var(--text-muted, #525252);
    margin-top: auto;
    border-top: none;
}

/* Dark theme footer */
.dark-theme footer.global-foot {
    background: var(--surface-alt, #111);
}

/* Pro mode: transparent footer bg */
body.biz-pro footer.global-foot {
    background: transparent;
    box-shadow: none;
}
body.biz-pro.dark-theme footer.global-foot {
    background: transparent;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    font-size: 0.82rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Footer top grid: brand + 3 nav cols + newsletter */
.footer-top {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr 1.4fr;
    gap: 24px;
    padding: 36px var(--page-edge, 24px) 28px;
    border-bottom: 1px solid var(--border, #e0e0e0);
}
.footer-brand-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.footer-brand-col strong {
    font-size: 1.05rem;
    color: var(--text);
}
.footer-brand-col span {
    font-size: 0.8rem;
    color: var(--text-muted, #525252);
    line-height: 1.45;
}
.footer-nav-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.footer-nav-col h4 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #525252);
    margin: 0 0 4px;
    font-weight: 700;
}
.footer-nav-col a {
    text-decoration: none;
    color: var(--text, #1a1a1a);
    font-size: 0.82rem;
    font-weight: 500;
    transition: color 0.2s;
}
.footer-nav-col a:hover {
    color: var(--primary);
}
.footer-newsletter-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.footer-newsletter-col h4 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #525252);
    margin: 0;
    font-weight: 700;
}

/* Footer text colors that adapt to theme */
footer.global-foot .footer-brand-col strong {
    color: var(--text);
}

footer.global-foot .footer-brand-col span {
    color: var(--text-muted, #525252);
}

/* Footer newsletter form */
.footer-newsletter {
    display: flex;
    align-items: center;
    gap: 6px;
}
.footer-newsletter input {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--border, #ddd);
    background: var(--surface-alt, #f0f0f0);
    color: var(--text, #1a1a1a);
    font-size: 0.82rem;
    flex: 1;
    min-width: 0;
}
.footer-newsletter button {
    padding: 7px 14px;
    border-radius: 8px;
    border: none;
    background: var(--primary, #00c4d4);
    color: #fff;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.2s;
}
.footer-newsletter button:hover {
    filter: brightness(1.1);
}
.footer-social-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Footer bottom bar */
.footer-bottom {
    padding: 14px var(--page-edge, 24px);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted, #525252);
}

/* Footer Social Icons */
.footer-social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: var(--text, #1a1a1a);
    opacity: 0.5;
    font-size: 1.05rem;
    text-decoration: none;
    transition: all 0.2s;
}
.footer-social-icon:hover {
    opacity: 1;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.footer-social-icon.disabled {
    opacity: 0.25;
    pointer-events: none;
    cursor: default;
}

/* Disclaimer boxes - ensure proper contrast */
.disclaimer-box {
    color: var(--text-muted, #525252);
}

.disclaimer-box p,
.disclaimer-box strong {
    color: var(--text-muted, #525252);
}

/* ─── Related Tools (horizontal card strip) ─── */
.related-tools {
    margin-top: 28px;
    padding: 16px 0 12px;
    max-width: 100%;
    box-sizing: border-box;
}
.related-tools h3 {
    font-size: 0.82rem;
    margin: 0 0 10px;
    color: var(--text);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.6;
}
.related-tools ul {
    list-style: none;
    padding: 6px 0;
    margin: 0 0 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.related-tools li {
    flex: 0 0 auto;
}
.related-tools li a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--surface, #f8f9fa);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text, #1a1a1a);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.related-tools li a:hover {
    border-color: color-mix(in srgb, var(--primary, #00c4d4) 40%, var(--border));
    box-shadow: 0 4px 12px rgba(0,168,181,0.12);
    color: var(--primary, #00c4d4);
    transform: translateY(-2px);
}
.related-tools li span {
    font-size: 0.7rem;
    color: var(--text-muted, #595959);
    opacity: 0.7;
    font-weight: 400;
    pointer-events: none;
}
.related-browse {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--primary, #00c4d4);
    text-decoration: none;
    font-weight: 600;
}
.related-browse:hover {
    text-decoration: underline;
}

/* ═══════════════════════════════════════════
   BUSINESS SUITE PROMO CARDS — feature ads on free tool pages
   ═══════════════════════════════════════════ */
.suite-promo {
    margin: 48px 0 0;
    padding: 36px 0 0;
    border-top: 2px solid var(--border);
}
.sp-head {
    text-align: center;
    margin-bottom: 28px;
}
.sp-head h2 {
    margin: 0 0 8px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.sp-head h2 i {
    color: var(--primary);
}
.sp-head p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted, #666);
}

/* 3-column card grid */
.sp-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
@media (max-width: 900px) {
    .sp-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .sp-grid { grid-template-columns: 1fr; }
    .sp-head h2 { font-size: 1.1rem; }
}

/* Card */
.sp-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 20px 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.sp-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.07);
}
.sp-card h3 {
    margin: 16px 0 8px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}
.sp-card p {
    margin: 0 0 14px;
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--text-muted, #666);
    flex: 1;
}
.sp-cta {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: gap 0.2s;
}
.sp-cta:hover {
    gap: 10px;
}

/* ── Illustration containers ── */
.sp-illust {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    margin-top: 20px;
    font-size: 0.72rem;
    color: var(--text-muted, #888);
    line-height: 1.4;
}

/* Shared row */
.sp-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.sp-row:last-child { border-bottom: none; }
.sp-lbl { flex: 1; }
.sp-val { font-weight: 700; color: var(--text); font-size: 0.72rem; text-align: right; }

/* Invoice illustration */
.sp-invoice .sp-bar {
    display: inline-block;
    height: 10px;
    background: var(--primary);
    border-radius: 3px;
    opacity: 0.6;
}
.sp-invoice .sp-total {
    border-top: 2px solid var(--border);
    margin-top: 4px;
    padding-top: 6px;
    font-weight: 700;
}
.sp-invoice .sp-total .sp-val {
    font-size: 0.78rem;
    color: var(--primary);
}

/* Expense illustration — colored dots */
.sp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 8px;
}

/* Jobs — kanban columns */
.sp-cols {
    display: flex;
    gap: 8px;
}
.sp-col {
    flex: 1;
    background: color-mix(in srgb, var(--border) 30%, var(--bg));
    border-radius: 6px;
    padding: 6px;
}
.sp-col-head {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #888);
    text-align: center;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.sp-chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.65rem;
    margin-bottom: 4px;
    color: var(--text);
}

/* Reports — vertical bar chart */
.sp-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 80px;
    padding: 0 4px;
}
.sp-bar-v {
    flex: 1;
    background: linear-gradient(180deg, var(--primary), color-mix(in srgb, var(--primary) 50%, var(--bg)));
    border-radius: 3px 3px 0 0;
    min-width: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.sp-card:hover .sp-bar-v { opacity: 1; }
.sp-chart-label {
    text-align: right;
    font-size: 0.65rem;
    margin-top: 6px;
    color: var(--text-muted, #999);
}

/* Documents — icon grid */
.sp-doc-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.sp-doc {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 6px;
    transition: border-color 0.2s;
}
.sp-doc i {
    font-size: 1.1rem;
    color: var(--primary);
    opacity: 0.6;
}
.sp-doc span {
    font-size: 0.62rem;
    color: var(--text-muted, #888);
}
.sp-card:hover .sp-doc {
    border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}

/* People — contact rows */
.sp-person {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.sp-person:last-child { border-bottom: none; }
.sp-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #fff;
    font-size: 0.58rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sp-name {
    flex: 1;
    font-size: 0.72rem;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sp-role {
    font-size: 0.62rem;
    color: var(--text-muted, #888);
    text-transform: capitalize;
}

/* Dark: footer borders */
.dark-theme .footer-top {
    border-bottom-color: rgba(255,255,255,0.1);
}
.dark-theme .footer-newsletter input {
    background: var(--surface, #1a1a1a);
    border-color: rgba(255,255,255,0.15);
}

/* Mobile footer adjustments */
@media (max-width: 768px) {
    .footer-top {
        grid-template-columns: 1fr 1fr;
        gap: 24px 16px;
        padding: 24px 16px 20px;
    }
    .footer-brand-col {
        grid-column: 1 / -1;
    }
    .footer-newsletter-col {
        grid-column: 1 / -1;
    }
    .footer-bottom {
        padding: 12px 16px;
    }
}

/* =========================================
   3. SIDEBARS
   ========================================= */
aside.left-col {
    width: 250px;
    flex-shrink: 0;
    position: sticky;
    top: 64px;
    align-self: flex-start;
}
aside.right-col {
    width: 300px;
    flex-shrink: 0;
    align-self: stretch; /* stretch so sticky child has room to travel */
}

/* Inner container must fill the aside for sticky to work */
#right-sidebar {
    height: 100%;
}

/* Business Suite PRO: hide monetization wrapper immediately
   html.biz-pro fires from theme-init (before body exists) — zero flash
   body.biz-pro is set by components.js as backup */
html.biz-pro aside.left-col, body.biz-pro aside.left-col,
html.biz-pro aside.right-col, body.biz-pro aside.right-col {
    display: none !important;
    width: 0 !important;
}
html.biz-pro .ad-slot, html.biz-pro .ad-leaderboard, html.biz-pro .ad-placeholder,
html.biz-pro .breadcrumbs, html.biz-pro .seo-content, html.biz-pro .disclaimer-box,
html.biz-pro .qr-footer, html.biz-pro .industry-templates {
    display: none !important;
}
html.biz-pro .center-col {
    max-width: 1200px;
    margin: 0 auto;
}
body.tf-ad-free .ad-slot,
body.tf-ad-free .ad-slot.ad-loaded,
body.tf-ad-free .ad-placeholder,
body.tf-ad-free .ad-placeholder.ad-loaded,
body.tf-ad-free .ad-leaderboard,
body.tf-ad-free .ad-leaderboard.ad-loaded {
    display: none !important;
}

/* Center Column — BASIC mode keeps content narrow (matches SEO width) */
.center-col {
    flex: 1;
    min-width: 0;
    min-height: 80vh;
    max-width: 700px;
}
/* Pages without sidebars — slightly wider cap */
.layout-grid > .center-col:only-child {
    max-width: 900px;
    margin: 0 auto;
}
/* PRO mode: full-width on tool pages (no sidebar);
   user pages with sidebar keep their 1200px cap from sidebar.css */
html:not(.has-sidebar) body.biz-pro .center-col,
html:not(.has-sidebar) body.biz-pro .layout-grid > .center-col:only-child {
    max-width: 1200px;
    margin: 0 auto;
}

/* ═══════════════════════════════════════════════
   PRO LAYOUT SYSTEM — Polished tool page overrides
   When biz-pro is active, tools get a completely
   different look: no ads, no breadcrumbs, upgraded
   stage, floating action bar, spacious layout.
   ═══════════════════════════════════════════════ */

/* ── Hide basic-mode visual clutter ── */
body.biz-pro .ad-slot,
body.biz-pro .ad-leaderboard,
body.biz-pro .ad-placeholder {
    display: none !important;
}

body.biz-pro .breadcrumbs {
    display: none;
}
body.biz-pro .seo-content,
body.biz-pro .disclaimer-box,
body.biz-pro .qr-footer,
body.biz-pro .industry-templates {
    display: none !important;
}

/* ── Standalone trust badge: collapse into action bar ── */
body.biz-pro .center-col > .trust-badge {
    display: none;
}

/* ── Pro content width cap — keep tools comfortable ── */
body.biz-pro .center-col {
    max-width: 960px;
    margin: 0 auto;
}

/* ── Sidebar-present layout: cap center content ── */
html.has-sidebar body.biz-pro .center-col {
    max-width: 1200px;
}

/* ── Mobile pro adjustments ── */
@media (max-width: 768px) {
    body.biz-pro .center-col {
        max-width: 100%;
    }
}

/* ═══════════════════════════════════════════════
   GLOBAL MOBILE OPTIMIZATION — tool tables,
   input grids, canvas elements
   ═══════════════════════════════════════════════ */

/* Tables: horizontal scroll wrapper on mobile */
@media (max-width: 768px) {
    .calc-container table,
    .tool-stage table,
    .tool-body table,
    .center-col table:not(.compare-table) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .calc-container thead,
    .tool-stage thead,
    .tool-body thead {
        white-space: nowrap;
    }
}

/* Input grids: collapse 2-col → 1-col on small screens */
@media (max-width: 600px) {
    .inputs-grid,
    .input-grid,
    .form-grid,
    .calc-row,
    .input-row {
        grid-template-columns: 1fr !important;
    }
    /* Stack side-by-side flex rows */
    .input-pair,
    .field-pair,
    .inline-fields {
        flex-direction: column !important;
    }
    .input-pair > *,
    .field-pair > *,
    .inline-fields > * {
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* Canvas responsiveness for creative tools */
canvas {
    max-width: 100%;
    height: auto;
}

/* Prevent fixed-width containers from overflowing on mobile */
@media (max-width: 600px) {
    .calc-container,
    .tool-stage,
    .tool-body {
        overflow-x: hidden;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    /* Results / output sections — prevent overflow */
    .result-box,
    .results-section,
    .output-area,
    .chart-container {
        max-width: 100%;
        overflow-x: auto;
    }
    /* Ensure pre/code blocks scroll rather than overflow */
    pre, code {
        max-width: 100%;
        overflow-x: auto;
        word-break: break-all;
    }
}

@media (max-width: 1299px) {
    aside.left-col,
    aside.right-col { display: none; }
    .center-col {
        max-width: 100%;
    }
}

/* Chrome/Edge/Safari Scrollbar Styling — inherited by drawer body */

/* Firefox scrollbar */
aside.left-col {
    scrollbar-color: var(--border) transparent;
}

/* Ad Placeholders - hidden when empty, shown when ad loads */
.ad-placeholder {
    display: none; /* Hidden by default until ad loads */
}

.ad-placeholder.ad-loaded {
    background: #f4f4f4;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #595959;
    font-size: 0.8rem;
    border-radius: 4px;
}

.ad-placeholder.vertical-sky.ad-loaded {
    min-height: 250px;
    width: 100%;
}

/* Right rail ad overrides — must come after .vertical-sky rules */
#right-sidebar .ad-right-1.ad-loaded {
    width: 300px;
    min-height: 250px;
    margin: 0 auto 20px;
}
#right-sidebar .ad-right-2.ad-loaded {
    width: 300px;
    min-height: calc(100vh - 80px); /* fixed size — fits viewport with 80px reserved */
    margin: 0 auto;
    position: sticky;
    top: 72px; /* position independently of height */
}

.ad-leaderboard {
    display: none; /* Hidden by default — activated via .ad-slot.ad-loaded */
}

/* Hide placeholder text (AD_TOP, AD_BTM, AD_MID) — invisible until real AdSense <ins> tags replace them */
.ad-slot,
.ad-placeholder {
    font-size: 0;
    color: transparent;
    overflow: hidden;
}

.ad-leaderboard.ad-loaded {
    /* Let .ad-slot.ad-loaded handle all styling */
}

/* =========================================
   3b. TYPOGRAPHY & NAVIGATION (Restored)
   ========================================= */
/* Breadcrumbs */
.breadcrumbs {
    font-size: 0.85rem;
    color: #595959;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.breadcrumbs a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

/* Tool Headers (Base Style - for centered text headers outside calc-container) */
.tool-header {
    text-align: left;
    margin-bottom: 20px;
    padding-bottom: 0;
    border-bottom: none;
}

.tool-header h1 {
    color: var(--text);
    margin: 0 0 6px 0;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.tool-header h1 i {
    color: var(--primary);
    opacity: 0.85;
    margin-right: 4px;
}

.tool-header p {
    color: var(--text-muted, #595959);
    font-size: 0.9rem;
    max-width: none;
    margin: 0;
    line-height: 1.5;
}

/* Homepage Hero */
.home-hero {
    text-align: center;
    margin-top: -10px;
    margin-bottom: 20px;
}

.home-hero h1 {
    color: var(--primary);
    font-size: 4rem;
    margin: 15px 0 5px 0;
    letter-spacing: -0.5px;
    font-weight: 900;
}

.home-hero p {
    color: #595959;
    font-size: 1.1rem;
    margin: 0;
}

/* Mobile: Smaller hero title */
@media (max-width: 1299px) {
    .home-hero h1 {
        font-size: 2.5rem;
    }

    .home-hero p {
        font-size: 0.95rem;
    }
}

/* SEARCH BAR */
.header-search-container {
    grid-column: 2;
    display: flex;
    justify-content: center;
    width: 600px;
    max-width: 600px;
    min-width: 0;
}

#header-account {
    grid-column: 3;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    background: var(--surface, #f0f0f0);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 10px;
    transition: 0.2s;
}

.search-input {
    position: relative;
    z-index: 1;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text, #1a1a1a);
    padding: 10px 50px 10px 35px;
    border-radius: 10px;
    outline: none;
    transition: 0.2s;
    font-size: 0.88rem;
}

/* ToolFluency watermark inside search bar background */
.search-wrapper::before {
    content: 'ToolFluency';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: 0.06em;
    color: var(--border, #ddd);
    pointer-events: none;
    opacity: 0.75;
    transition: opacity 0.2s;
    z-index: 0;
}
.search-wrapper:focus-within::before {
    opacity: 0.3;
}

.search-input::placeholder {
    color: var(--text-muted, #888);
}

/* Force readable placeholder */
.search-input:focus {
    background: transparent;
    color: var(--text, #333);
}
.search-wrapper:focus-within {
    background: var(--bg, #fff);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

.search-input:focus~.search-icon {
    color: #333;
}

.search-input:focus~.search-shortcut {
    display: none;
}

/* Hide shortcut on focus */

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #888);
    pointer-events: none;
    font-size: 0.82rem;
}

.search-shortcut {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-alt, #eee);
    color: var(--text-muted, #888);
    border: 1px solid var(--border, #ddd);
    font-size: 0.68rem;
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
    font-family: system-ui, sans-serif;
}

.search-submit {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary);
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    transition: all 0.15s;
}

.search-submit:hover {
    filter: brightness(1.1);
}

.search-dropdown {
    position: absolute;
    top: 48px;
    left: 0;
    width: 100%;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    display: none;
    max-height: 320px;
    overflow-y: auto;
    z-index: 12001;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #eee;
}

.search-result-item:hover {
    background: #f0f7ff;
    color: var(--primary);
}

/* ═══════ UNIVERSAL SEARCH RESULTS ═══════ */
.search-dropdown {
    max-height: 420px;
}
.usearch-cat-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #888);
    border-top: 1px solid var(--border, #eee);
}
.usearch-cat-header:first-child { border-top: none; }
.usearch-cat-header i { font-size: 0.68rem; }
.usearch-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text, #333);
    border-bottom: none;
    transition: background 0.12s;
}
.usearch-item:hover {
    background: color-mix(in srgb, var(--primary) 8%, var(--surface, #fff));
}
.usearch-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.72rem;
}
.usearch-text {
    flex: 1;
    min-width: 0;
}
.usearch-title {
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.usearch-sub {
    font-size: 0.72rem;
    color: var(--text-muted, #888);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.usearch-badge {
    flex-shrink: 0;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border: 1px solid;
    border-radius: 4px;
    white-space: nowrap;
}

/* ═══════ MODE-SWITCH CONFIRMATION POPUP ═══════ */
.usearch-mode-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: usearch-fade-in 0.15s ease;
}
@keyframes usearch-fade-in { from { opacity: 0; } to { opacity: 1; } }
.usearch-mode-card {
    background: var(--surface, #fff);
    color: var(--text, #1a1a1a);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 16px;
    padding: 28px 32px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0,0,0,0.18);
    animation: usearch-slide-up 0.2s ease;
}
@keyframes usearch-slide-up { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.usearch-mode-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 12px;
}
.usearch-mode-card h3 {
    margin: 0 0 6px;
    font-size: 1.1rem;
    font-weight: 700;
}
.usearch-mode-card p {
    margin: 0 0 18px;
    font-size: 0.88rem;
    color: var(--text-muted, #666);
    line-height: 1.5;
}
.usearch-mode-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.usearch-mode-cancel,
.usearch-mode-go {
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}
.usearch-mode-cancel {
    background: var(--surface-alt, #f0f0f0);
    color: var(--text, #333);
}
.usearch-mode-cancel:hover {
    background: var(--border, #ddd);
}
.usearch-mode-go {
    background: var(--primary);
    color: #fff;
}
.usearch-mode-go:hover {
    filter: brightness(1.1);
}

/* USER MENU DROPDOWN ITEMS */
.account-drop-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    text-decoration: none;
    color: #444;
    font-size: 0.9rem;
    border-bottom: 1px solid #f4f4f4;
    transition: all 0.1s;
}

.account-drop-link:hover {
    background: #f0f7ff;
    color: var(--primary);
    padding-left: 18px;
    /* Slight nudge effect */
}

.account-drop-link.danger {
    color: #d32f2f;
}

.account-drop-link.danger:hover {
    background: #fff0f0;
}

/* BUTTONS & TOOL ACTIONS */
.tf-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    padding: 10px 16px;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 14px;
    background: var(--surface, #f8f9fa);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

/* Trust Badge - Local-First, Cloud-Capable */
.trust-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(23, 162, 184, 0.06);
    border: 1px solid rgba(23, 162, 184, 0.2);
    border-radius: 6px;
    font-size: 0.8rem;
    color: #0f5162;
    margin-top: 10px;
    margin-bottom: 20px;
    max-width: fit-content;
}
/* Compact badge when moved inside tf-actions row */
.tf-actions .trust-badge {
    margin: 0;
    margin-right: auto;
    padding: 4px 10px;
    font-size: 0.72rem;
    gap: 6px;
    order: -1;
}
.tf-actions .trust-badge-sub {
    display: none;
}
.tf-actions .trust-badge-icon svg {
    width: 14px;
    height: 14px;
}
.trust-badge-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #17a2b8;
    flex-shrink: 0;
}
.trust-badge-icon svg {
    width: 16px;
    height: 16px;
}
.trust-badge-text {
    font-weight: 500;
    line-height: 1.2;
}
.trust-badge-sub {
    display: inline;
    font-size: 0.75rem;
    opacity: 0.75;
    font-weight: 400;
    margin-left: 4px;
}
body.dark-theme .trust-badge {
    background: rgba(23, 162, 184, 0.1);
    border-color: rgba(23, 162, 184, 0.25);
    color: #7dd3e8;
}
body.dark-theme .trust-badge-icon {
    color: #5bc0de;
}

.tf-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text, #333);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: none;
    /* Touch target accessibility - minimum 38x38px */
    min-height: 38px;
    min-width: 38px;
    justify-content: center;
    white-space: nowrap;
    flex-shrink: 1;
}

.tf-btn:hover {
    background: var(--bg, #fff);
    color: var(--text, #333);
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.tf-btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 25%, transparent);
}

.tf-btn.primary:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 35%, transparent);
}

.tf-btn.pin.active {
    background: #ffa500 !important;
    color: white !important;
    border: 1.5px solid #ffa500 !important;
    box-shadow: 0 2px 6px rgba(255, 165, 0, 0.3) !important;
}

.tf-btn.pin.active:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 3px 10px rgba(255, 165, 0, 0.5) !important;
}

.tf-btn.pin:not(.active):hover {
    background: #f8f9fa;
    color: #333;
    border-color: #aaa;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* =========================================
   GLOBAL RESULT BOX STYLES (WCAG Compliant)
   Used in calculator tools for displaying results
   ========================================= */
.res-box {
    background: var(--surface, #f0f0f0);
    border: 2px solid var(--primary, #00c4d4);
    padding: 15px;
    margin: 15px 0;
    text-align: center;
    border-radius: var(--radius-md, 8px);
}

.res-label {
    font-size: 0.8rem;
    /* WCAG AA compliant - 4.5:1 contrast on light backgrounds */
    color: var(--text-muted, #525252);
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.hero-val {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--primary, #00c4d4);
    display: block;
}

/* Dark theme result box */
body.dark-theme .res-box {
    background: var(--surface, #111);
}

body.dark-theme .res-label {
    color: var(--text-muted, #a0a0a0);
}

body.dark-theme .hero-val {
    color: var(--primary, #00c4d4);
}

/* ADVERTISING SPACERS - Hidden until ads load */
.ad-slot {
    display: none; /* Hidden by default until ad loads */
}

.ad-slot.ad-loaded {
    margin: 15px auto;
    text-align: center;
    clear: both;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--surface, #f8f9fa);
    border: 1px dashed var(--border, #ddd);
    border-radius: 6px;
    padding: 24px 20px;
    color: var(--text-muted, #999);
    font-size: 0.8rem;
    font-weight: 500;
    max-width: 728px;
    min-height: 90px;
}

/* =========================================
   5. WORKBENCH & SIDEBAR (Merged Logic)
   ========================================= */
.sidebar-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.sidebar-header {
    background: var(--surface, #f8f9fa);
    color: var(--primary);
    padding: 15px 20px;
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* EMPTY WORKBENCH STATE */
.sidebar-empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted, #525252);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sidebar-empty-state i {
    font-size: 2.5rem;
    color: var(--border, #e0e0e0);
    margin-bottom: 5px;
    margin-top: 5px;
}

.sidebar-empty-state strong {
    display: block;
    color: var(--text, #555);
    font-size: 0.95rem;
}

.sidebar-empty-state p {
    font-size: 0.85rem;
    margin: 0 0 10px 0;
    line-height: 1.4;
    color: var(--text-muted, #525252);
}

/* Dark Mode Adaptation */
body.dark-theme .sidebar-empty-state i {
    color: #64748b;
}

body.dark-theme .sidebar-empty-state strong {
    color: #ccc;
}

body.dark-theme .sidebar-empty-state p {
    color: #595959;
}

/* Standard Items */
.sidebar-folder-item {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text, #444);
    border-bottom: 1px solid var(--border, #f4f4f4);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.1s;
}

.sidebar-folder-item:hover {
    background: var(--surface-alt, #f9f9f9);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    color: var(--text, #444);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border, #f4f4f4);
    border-left: 4px solid transparent;
}

/* INHERIT FOLDER COLOR ON HOVER */
.sidebar-link:hover {
    background: color-mix(in srgb, var(--folder-color, var(--primary)) 8%, transparent);
    color: var(--folder-color, var(--primary));
    border-left-color: var(--folder-color, var(--primary));
    padding-left: 28px;
}

/* Edit Mode Items */
.sidebar-box.editing-mode {
    border-color: var(--primary);
}

.sidebar-edit-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 4px 0;
    transition: box-shadow 0.2s;
}

/* INHERIT FOLDER COLOR IN EDIT MODE */
.sidebar-edit-row:hover {
    box-shadow: 0 0 12px color-mix(in srgb, var(--folder-color, var(--primary)) 40%, transparent);
    border-color: var(--folder-color, var(--primary));
    z-index: 2;
}

/* Drag & Drop Visuals */
.wb-item {
    display: block;
}

.wb-item.dragging {
    opacity: 0.6;
    background: #e3f2fd;
    border: 1px dashed var(--primary);
}

.drag-over-folder {
    background: #e3f2fd !important;
    border: 2px solid var(--primary) !important;
}

.wb-handle {
    color: #ccc;
    cursor: grab;
    padding: 8px;
}

.wb-handle:hover {
    color: var(--primary);
}

.wb-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    font-size: 0.9rem;
}

.wb-mini-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #f9f9f9;
    color: #595959;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wb-mini-btn:hover {
    background: #fff;
    color: #333;
    border-color: #767676;
}

.wb-folder-dropzone {
    min-height: 10px;
    margin-left: 15px;
    padding-bottom: 4px;
    border-bottom: 2px solid #eee;
}

/* =========================================
   6. TOOL STAGE & PHASE 2 LAYOUTS
   ========================================= */
/* ═══════════════════════════════════════════════
   V2 TOOL PAGE — Clean, full-width layout
   No sidebar columns, no ad slots, no wrapper clutter.
   Paid users get just the tool. Free users get SEO below.
   ═══════════════════════════════════════════════ */
.tf-tool-page {
    max-width: 880px;
    margin: 0 auto;
    padding: 24px 28px 40px;
    min-height: 80vh;
}
.tf-tool-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 32px;
}
.tf-tool-content .tool-body {
    padding: 24px;
}
.tf-tool-content .page-header {
    display: none; /* v2: no gradient header bar inside tools */
}

/* ── Paid topbar (mirrors app.html .topbar for tool pages) ── */
html.has-sidebar header.global-head {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: 54px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px;
    backdrop-filter: none; box-shadow: none;
}
html.has-sidebar header.global-head .header-inner {
    display: flex; align-items: center; width: 100%; height: 100%; gap: 0;
}
html.has-sidebar header.global-head .header-logo-pill {
    display: flex; align-items: center; gap: 9px;
    font-weight: 600; font-size: 15px; letter-spacing: -0.3px;
    text-decoration: none; color: var(--text);
    margin-right: 28px;
}
html.has-sidebar header.global-head .header-logo-pill img {
    width: 28px; height: 28px; border-radius: 7px;
}
html.has-sidebar .tf-tool-page {
    padding-top: 78px; /* account for fixed topbar */
}

/* ═══════════════════════════════════════════════
   EMBEDDED MODE
   All embedded tool styling is in tools/shared.css
   (single source of truth — injected into every iframe by loadTool).
   DO NOT add tf-embedded rules here.
   ═══════════════════════════════════════════════ */

/* Paid users: sidebar present — shift tool content right */
html.has-sidebar .tf-tool-page {
    margin-left: 210px;
    max-width: calc(100% - 210px);
    padding-top: 24px;
}
/* Paid users: hide footer (everything accessible from sidebar/dropdown) */
html.has-sidebar footer.global-foot,
html.biz-pro footer.global-foot {
    display: none !important;
}
@media (max-width: 768px) {
    .tf-tool-page { padding: 12px 14px 24px; }
    .tf-tool-content .tool-body { padding: 16px; }
    html.has-sidebar .tf-tool-page { margin-left: 0; max-width: 100%; }
}

.tool-stage {
    background: transparent;
    border: none;
    border-radius: 16px;
    padding: 0;
    margin-bottom: 32px;
    box-shadow: none;
    width: 100%;
    position: relative;
    min-height: 400px; /* Prevent CLS during content load */
}

.calc-container {
    width: 100%;
    padding: 0;
    box-sizing: border-box;
    background: var(--surface);
    min-height: 200px;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

/* Calc-card: shared.css handles all embedded styling.
   Standalone: transparent so it inherits parent bg. */
.calc-card {
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* ── Suite mode: streamlined tool layout ── */
html.has-sidebar .tool-header { display: none; }
html.has-sidebar .tf-actions  { display: none; }
html.has-sidebar .center-col > .trust-badge { display: none; }
html.has-sidebar footer.global-foot { display: none; }

/* Pin button inside page-header (suite mode) */
.page-header .tf-pin-inline {
    margin-left: auto;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s, transform 0.15s;
    line-height: 1;
}
.page-header .tf-pin-inline:hover {
    background: rgba(255,255,255,0.28);
}
.page-header .tf-pin-inline:active {
    transform: scale(0.96);
}
.page-header .tf-pin-inline.active {
    background: rgba(255,255,255,0.92);
    color: var(--primary, #00c4d4);
    border-color: transparent;
}
.page-header .tf-pin-inline.active i {
    opacity: 1;
}

/* Themed Page Header — Gradient header bar for all tools */
.page-header {\n    background: var(--primary);\n    background-image: linear-gradient(135deg, color-mix(in srgb, var(--primary) 100%, transparent) 0%, color-mix(in srgb, var(--primary) 60%, rgba(0,0,0,0.5)) 100%);\n    color: #fff;\n    padding: 18px 24px;\n    display: flex;\n    align-items: center;\n    gap: 12px;\n    font-size: 1.15rem;\n    font-weight: 700;\n    letter-spacing: -0.01em;\n    border-radius: 12px 12px 0 0;\n    box-shadow: 0 4px 15px rgba(0,0,0,0.06);\n    position: relative;\n    overflow: hidden;\n}
/* Subtle sheen overlay on page-header for depth */
.page-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.07) 0%, transparent 60%);
    pointer-events: none;
    border-radius: inherit;
}
.page-header > * { position: relative; z-index: 1; }
.page-header i { font-size: 1.15rem; opacity: 0.85; }
.page-header .tf-pin-inline i { opacity: 1; font-size: 0.85rem; }

/* Non-calc tool containers: same bordered-box treatment */
.bingo-container, .coin-container, .dice-container, .trivia-container,
.scramble-container, .alarm-container, .timer-container, .stopwatch-container,
.anagram-container, .crossword-container, .maze-container, .puzzle-container,
.sudoku-container, .ws-container, .tool-container {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}
/* Strip direct-child card borders inside these containers */
.bingo-container > div:not(.page-header),
.coin-container > div:not(.page-header),
.dice-container > div:not(.page-header),
.trivia-container > div:not(.page-header),
.scramble-container > div:not(.page-header),
.alarm-container > div:not(.page-header),
.timer-container > div:not(.page-header),
.stopwatch-container > div:not(.page-header),
.anagram-container > div:not(.page-header),
.crossword-container > div:not(.page-header),
.maze-container > div:not(.page-header),
.puzzle-container > div:not(.page-header),
.sudoku-container > div:not(.page-header),
.ws-container > div:not(.page-header),
.tool-container > div:not(.page-header) {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* Content body wrapper — provides inner padding for no-calc-card tools */
.tool-body {
    padding: 20px;
}

/* ── Tighten internal tool spacing ── */
/* Reduce per-tool section-title bottom margin */
.section-title { margin-bottom: 10px !important; }
/* Reduce empty-state padding so initial states don't balloon */
.empty-state { padding: 28px 16px !important; }
.empty-state i { font-size: 2.5rem !important; margin-bottom: 10px !important; }
/* Tool header subtitle - tighten the inline 25px margin */
.tool-header p { margin-bottom: 12px !important; }
/* Tighten card/section spacing inside tool containers */
.calc-card { padding: 20px !important; margin-bottom: 10px !important; }
.coin-card, .dice-card, .trivia-card, .bingo-card-section,
.sudoku-section, .scramble-card, .crossword-card, .maze-card,
.puzzle-card, .anagram-card, .alarm-card, .timer-card,
.stopwatch-card, .ws-card, .tool-card,
.bt-card, .bt-debt-card {
    padding: 16px !important;
    margin-bottom: 10px !important;
}
/* Tighten form-group / input-group vertical stacking */
.calc-card .input-group,
.calc-card .form-group,
.tool-body .input-group,
.tool-body .form-group { margin-bottom: 14px; }
/* Tighten result areas */
.calc-card .result-card,
.calc-card .result-section { margin-top: 16px; }

/* Mobile: Reduce padding for screen efficiency */
@media (max-width: 600px) {
    .page-header {
        padding: 14px 16px;
        font-size: 1rem;
    }
    .tool-body {
        padding: 16px;
    }
    .tf-actions {
        padding: 8px 12px;
        border-radius: 12px;
    }
    .calc-container {
        border-radius: 12px;
    }
}

/* =========================================
   7. DARK MODE OVERRIDES
   ========================================= */
/* Note: CSS variables are set by JavaScript (inline script + components.js)
   These rules provide selector-based styling for dark mode elements */

/* Dark mode tool containers */
body.dark-theme .calc-container {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}
body.dark-theme .tf-actions {
    background: var(--surface-alt, #1a1a1a);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* 1. Form Elements & Scrollbars */
body.dark-theme input,
body.dark-theme select,
body.dark-theme textarea {
    background-color: var(--bg, #1a1a1a) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
}

/* Dark Scrollbars */
body.dark-theme ::-webkit-scrollbar-thumb {
    background-color: var(--surface-alt, #475569);
    border-radius: 4px;
}

body.dark-theme ::-webkit-scrollbar-track {
    background-color: var(--bg);
}

/* Dark Search Bar */
body.dark-theme .search-wrapper {
    background: var(--bg) !important;
    border-color: var(--border) !important;
}
body.dark-theme .search-input {
    background: transparent !important;
    border: none !important;
    color: var(--text) !important;
}

body.dark-theme .search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}
body.dark-theme .search-wrapper::before {
    color: rgba(255,255,255,0.18);
}

/* 2. Dropdowns (User & Search) */
body.dark-theme .search-dropdown,
body.dark-theme .account-dropdown {
    background: var(--surface) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

body.dark-theme .search-result-item,
body.dark-theme .account-drop-link {
    border-bottom-color: var(--border) !important;
    color: var(--text-muted, #cbd5e1) !important;
}

body.dark-theme .search-result-item:hover,
body.dark-theme .account-drop-link:hover {
    background: var(--surface-alt, #334155) !important;
    color: var(--text) !important;
}

/* Dark universal search */
body.dark-theme .usearch-item {
    color: var(--text, #e2e8f0) !important;
}
body.dark-theme .usearch-item:hover {
    background: var(--surface-alt, #334155) !important;
}
body.dark-theme .usearch-cat-header {
    border-top-color: var(--border, #334155);
    color: var(--text-muted, #94a3b8);
}
body.dark-theme .usearch-sub {
    color: var(--text-muted, #94a3b8);
}
body.dark-theme .usearch-mode-card {
    background: var(--surface, #1e293b);
    border-color: var(--border, #334155);
}

/* User Dropdown Dark Mode */
.user-dropdown {
    background: var(--surface);
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border: 1px solid var(--border);
}

.dropdown-header {
    padding: 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted, #666);
    font-weight: bold;
    letter-spacing: 0.5px;
}

body.dark-theme .user-dropdown {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

body.dark-theme .dropdown-header {
    background: var(--bg);
    border-bottom-color: var(--border);
    color: var(--text-muted);
}

/* Admin dropdown styles */
.dropdown-header.admin-header {
    background: rgba(255, 193, 7, 0.15);
    border-bottom-color: #ffc107;
    color: #ffc107;
    display: flex;
    align-items: center;
    gap: 8px;
}

.account-drop-link.admin-link {
    background: rgba(255, 193, 7, 0.05);
}

.account-drop-link.admin-link i {
    color: var(--warning, #ffc107) !important;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

body.dark-theme .dropdown-header.admin-header {
    background: rgba(255, 193, 7, 0.1);
}

body.dark-theme .account-drop-link.admin-link {
    background: rgba(255, 193, 7, 0.05);
}

/* Unified header button style */
.hdr-btn {
    height: 36px;
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--surface, #f0f0f0);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    cursor: pointer;
    box-sizing: border-box;
    color: var(--text, #1a1a1a);
    text-decoration: none;
    position: relative;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.hdr-btn:hover {
    background: color-mix(in srgb, var(--primary) 12%, var(--surface));
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    transform: translateY(-1px);
}
.hdr-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.hdr-btn i {
    font-size: 15px;
    color: var(--text, #1a1a1a);
}
.dark-theme .hdr-btn i {
    color: #fff;
}

/* 3. Dark Mode Depth & Elevation */
body.dark-theme .search-dropdown,
body.dark-theme .account-dropdown,
body.dark-theme .user-dropdown {
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
}
body.dark-theme .hdr-btn {
    background: var(--surface-alt, #1a1a1a);
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
body.dark-theme .hdr-btn:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.08);
}
/* Elevated cards & page boxes in dark mode */
body.dark-theme .page-box,
body.dark-theme .info-box,
body.dark-theme .summary-cards > div {
    box-shadow: 0 2px 10px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.04);
}
body.dark-theme .page-box {
    border-color: rgba(255,255,255,0.06);
}
/* Subtle top-edge highlight for elevated dark surfaces */
body.dark-theme .page-header {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
/* Modal overlays in dark mode */
body.dark-theme .modal-overlay {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
body.dark-theme .modal-content,
body.dark-theme .modal-panel {
    background: var(--surface-alt, #1a1a1a);
    box-shadow: 0 12px 48px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.08);
}
/* Tab bars in dark mode */
body.dark-theme .top-tabs,
body.dark-theme .tab-bar-wrap {
    border-bottom-color: rgba(255,255,255,0.06);
}
body.dark-theme .top-tabs button:hover,
body.dark-theme .biz-nav-btn:hover {
    background: rgba(255,255,255,0.05);
}

/* =============================================
   SANDBOX BANNER
   ============================================= */
#tf-sandbox-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 12001;
    background: linear-gradient(135deg, #1a237e 0%, #4a148c 100%);
    color: #fff;
    font-size: 0.82rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.sandbox-banner-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.sandbox-banner-inner > i {
    font-size: 1.2rem;
    color: #ce93d8;
    flex-shrink: 0;
}
.sandbox-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sandbox-banner-text strong {
    font-size: 0.88rem;
}
.sandbox-banner-text span {
    opacity: 0.85;
    font-size: 0.78rem;
}
.sandbox-exit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.sandbox-exit-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}
/* Push header + content down when sandbox banner is visible */
body.sandbox-active header.global-head {
    top: 58px;
}
body.sandbox-active .layout-grid {
    padding-top: 186px;
}
@media (max-width: 768px) {
    .sandbox-banner-inner {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px;
    }
}

/* =============================================
   NOTIFICATION CENTER
   ============================================= */
.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #e53935;
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 10px;
    padding: 0 4px;
    box-sizing: border-box;
    pointer-events: none;
    animation: notifPulse 0.35s ease;
}
@keyframes notifPulse {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

.notif-panel {
    display: none;
    position: absolute;
    right: 0;
    top: 45px;
    width: 340px;
    max-height: 440px;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #ddd);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    z-index: 13000;
    overflow: hidden;
    font-family: inherit;
}
.notif-panel.open { display: block; }

.notif-panel-header {
    padding: 14px 16px;
    font-weight: 700;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border, #eee);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notif-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.notif-mark-all {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    min-height: auto !important;
    padding: 0;
}
.notif-mark-all:hover { text-decoration: underline; }

.notif-clear-all {
    background: none;
    border: none;
    color: var(--text-muted, #999);
    font-size: 0.75rem;
    cursor: pointer;
    min-height: auto !important;
    padding: 2px 4px;
}
.notif-clear-all:hover { color: #e53935; }

.notif-list {
    overflow-y: auto;
    max-height: 380px;
}
.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border, #f0f0f0);
    transition: background 0.15s;
    align-items: flex-start;
}
.notif-item:hover { background: var(--bg, #f8f8f8); }
.notif-item.unread { background: rgba(33,150,243,0.06); }
.notif-item.unread:hover { background: rgba(33,150,243,0.12); }

.notif-icon {
    width: 32px;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border-radius: 50%;
    background: rgba(0,0,0,0.05);
}
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 2px; }
.notif-body { font-size: 0.8rem; color: var(--text-muted, #767676); line-height: 1.35; }
.notif-reason {
    font-size: 0.78rem;
    color: var(--text-muted, #767676);
    margin-top: 4px;
    padding: 4px 8px;
    background: rgba(0,0,0,0.03);
    border-left: 3px solid var(--border, #ddd);
    border-radius: 0 4px 4px 0;
    font-style: italic;
}
.notif-time { font-size: 0.7rem; color: var(--text-muted, #999); margin-top: 4px; }

.notif-dot {
    width: 8px;
    min-width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    margin-top: 6px;
}
.notif-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted, #999);
}
.notif-empty i { font-size: 2rem; margin-bottom: 10px; opacity: 0.4; display: block; }
.notif-empty p { margin: 0; font-size: 0.85rem; }

/* Notification panel dark theme */
body.dark-theme .notif-panel {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
body.dark-theme .notif-item:hover { background: rgba(255,255,255,0.04); }
body.dark-theme .notif-item.unread { background: rgba(33,150,243,0.08); }
body.dark-theme .notif-item.unread:hover { background: rgba(33,150,243,0.14); }
body.dark-theme .notif-icon { background: rgba(255,255,255,0.06); }
body.dark-theme .notif-reason { background: rgba(255,255,255,0.04); border-left-color: var(--border); }

/* Denial reason modal */
.deny-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}
.deny-modal {
    background: var(--surface, #fff);
    border-radius: 12px;
    width: 420px;
    max-width: 92vw;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    overflow: hidden;
    animation: denyModalIn 0.2s ease;
}
@keyframes denyModalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.deny-modal-header {
    padding: 16px 20px;
    font-weight: 700;
    font-size: 1rem;
    border-bottom: 1px solid var(--border, #eee);
    display: flex;
    align-items: center;
    gap: 10px;
    color: #e53935;
}
.deny-modal-body { padding: 20px; }
.deny-modal-body label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted, #767676);
    margin-bottom: 6px;
}
.deny-reason-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.deny-reason-chip {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid var(--border, #ddd);
    background: var(--bg, #f5f5f5);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    color: var(--text, #333);
}
.deny-reason-chip:hover { border-color: var(--primary); color: var(--primary); }
.deny-reason-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.deny-modal-body textarea {
    width: 100%;
    min-height: 60px;
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    padding: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    resize: vertical;
    box-sizing: border-box;
    background: var(--bg, #f9f9f9);
    color: var(--text, #333);
}
.deny-modal-body textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 0,102,204), 0.1);
}
.deny-modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border, #eee);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.deny-modal-footer button {
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid var(--border, #ddd);
    font-family: inherit;
}
.btn-deny-cancel {
    background: var(--bg, #f5f5f5);
    color: var(--text, #333);
}
.btn-deny-confirm {
    background: var(--danger, #e53935);
    color: #fff;
    border-color: var(--danger, #e53935) !important;
}
.btn-deny-confirm:hover { filter: brightness(1.1); }

body.dark-theme .deny-modal {
    background: var(--surface);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

/* Mobile: notification panel as centered modal */
@media (max-width: 600px) {
    .notif-panel {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        width: calc(100vw - 32px);
        max-height: 80vh;
        border-radius: 14px;
    }
    .notif-panel.open ~ .notif-backdrop,
    .notif-backdrop {
        display: none;
    }
    .notif-backdrop.open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 12999;
    }
}

/* 3. Sidebar & Toolbox Polish */
body.dark-theme .sidebar-box {
    border-color: var(--border);
}

body.dark-theme .sidebar-header {
    background: var(--surface) !important;
    border-bottom-color: var(--border) !important;
    color: var(--text) !important;
}

body.dark-theme .sidebar-folder-item,
body.dark-theme .sidebar-link {
    color: var(--text-muted, #cbd5e1) !important;
    border-bottom-color: var(--surface) !important;
}

body.dark-theme .sidebar-folder-item:hover,
body.dark-theme .sidebar-link:hover {
    background: var(--surface-alt, #334155) !important;
}

/* 4. Mobile Drawer & Buttons */
.dark-theme .mobile-drawer {
    background: var(--bg) !important;
    border-right: 1px solid var(--border);
}

body.dark-theme .tf-btn {
    background: var(--surface);
    color: var(--text-muted, #94a3b8);
    border-color: var(--surface-alt, #334155);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.dark-theme .tf-btn:hover {
    background: var(--surface-alt, #334155);
    color: var(--text);
    border-color: var(--border);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

body.dark-theme .tf-btn.pin:not(.active):hover {
    background: var(--surface-alt, #334155);
    color: var(--text);
    border-color: var(--border);
}

body.dark-theme .sidebar-edit-row {
    background: var(--surface);
    border-color: var(--border);
}

body.dark-theme .wb-mini-btn {
    background: var(--surface-alt, #334155);
    border-color: var(--border);
    color: var(--text-muted, #cbd5e1);
}

body.dark-theme .wb-mini-btn:hover {
    background: var(--border);
    color: var(--text);
}

/* 5. Tool Layouts */
body.dark-theme .ad-placeholder.ad-loaded {
    background: var(--surface);
    border-color: var(--border);
}

body.dark-theme .ad-leaderboard.ad-loaded {
    background: var(--surface);
    border-color: var(--border);
}

body.dark-theme .ad-slot.ad-loaded {
    background: var(--surface);
    border-color: var(--border);
}

body.dark-theme .layout-split-calc .calc-summary {
    background: var(--surface);
    border-color: var(--border);
}

body.dark-theme .layout-text-gen .gen-preview {
    background: var(--text);
    color: var(--bg);
}

/* =========================================
   7a. RESTORED HUB & INDEXER STYLES
   ========================================= */
/* Fixes the "Broken Homepage" Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

/* Homepage: 3-column layout on desktop (sidebars hidden above 1300px) */
@media (min-width: 1300px) {
    body:has(#dynamic-home-feed) .center-col {
        grid-column: 2 / -1;
        max-width: none;
    }

    #dynamic-home-feed .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 15px;
    text-decoration: none;
    color: var(--text);
    display: block;
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    border-color: var(--primary);
}

.card-meta-line {
    font-size: 0.75rem;
    color: #767676;
    text-transform: uppercase;
    margin-bottom: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

/* Container for Metadata Actions (Pin/Badge) */
.card-meta-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Gold Lit State for Fullscreen only */
.tf-btn.fullscreen-btn.active {
    color: var(--warning, #f59f00) !important;
    filter: drop-shadow(0 0 5px rgba(245, 159, 0, 0.4));
}

/* Status Badge logic repurposed for the NEW badge */
.new-badge {
    background: #ffab00;
    color: black;
    font-size: 0.6rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
}

body.dark-theme .status-badge {
    background: #0f172a;
    color: #94a3b8;
    border-color: #334155;
}

/* Pin Button adjustments for card */
.quick-pin-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    color: #767676;
    font-size: 0.9rem;
    transition: 0.2s;
    margin: -8px -12px -8px 0;
    opacity: 0.4;
}

.quick-pin-btn:hover {
    color: var(--primary);
    opacity: 0.7;
}

.quick-pin-btn.disabled {
    opacity: 0.3;
}

.quick-pin-btn.disabled:hover {
    color: var(--primary);
    opacity: 0.6;
}

.quick-pin-btn.active {
    color: #ffa500;
    opacity: 1;
}

/* Prevent disabled buttons from showing gold */
.quick-pin-btn.disabled.active {
    color: var(--text-muted, #767676) !important;
    opacity: 0.3 !important;
}

.quick-pin-btn.pinned {
    color: #ffa500;
    opacity: 1;
}

.section-title {
    margin-top: 50px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 12px;
    color: var(--primary);
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title i {
    font-size: 1.1rem;
}

/* Fixes the "Shared Result" View Actions */
.doc-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.btn-action {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text);
    font-weight: 600;
}

.btn-action:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-action.danger {
    color: var(--danger);
    border-color: var(--danger);
}

/* =========================================
   7a-2. TOOL SELECTOR & SAVE MODAL DARK MODE
   Uses CSS variables instead of hard-coded hex
   so all dark themes (Modern, Retro, Ocean…) work.
   ========================================= */
/* Tool Selector Modal */
body.dark-theme .tool-select-content {
    background: var(--surface-alt) !important;
}

body.dark-theme .tool-select-header {
    border-bottom-color: var(--border) !important;
}

body.dark-theme .tool-select-header h3 {
    color: var(--text) !important;
}

body.dark-theme .tool-select-search {
    border-bottom-color: var(--border) !important;
    background: var(--surface-alt) !important;
}

body.dark-theme .tool-select-search input {
    background: var(--bg) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

body.dark-theme .tool-select-search input::placeholder {
    color: var(--text-muted) !important;
}

body.dark-theme .tool-select-list {
    background: var(--surface-alt) !important;
}

body.dark-theme .tool-item {
    border-color: var(--border) !important;
    background: var(--bg) !important;
}

body.dark-theme .tool-item:hover {
    background: var(--surface-alt) !important;
}

body.dark-theme .tool-item-title {
    color: var(--text) !important;
}

body.dark-theme .tool-item-category {
    color: var(--text-muted) !important;
}

body.dark-theme .tool-item-keywords {
    color: var(--text-muted) !important;
}

/* Save Modal */
body.dark-theme .tf-save-modal-content {
    background: var(--surface-alt) !important;
    color: var(--text) !important;
}



body.dark-theme .tf-save-input {
    background: var(--bg) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

body.dark-theme .tf-save-input::placeholder {
    color: var(--text-muted) !important;
}

body.dark-theme .tf-cancel-btn {
    background: var(--bg) !important;
    color: var(--text-muted) !important;
    border-color: var(--border) !important;
}

/* =========================================
   7b. DASHBOARD & ACCOUNT ECOSYSTEM
   ========================================= */
/* Dashboard Header & Controls */
.dash-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

.view-toggles {
    display: flex;
    gap: 5px;
    background: var(--border);
    padding: 4px;
    border-radius: 4px;
}

.view-btn {
    border: none;
    background: transparent;
    padding: 6px 10px;
    cursor: pointer;
    color: #767676;
    border-radius: 3px;
}

.view-btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.view-btn:hover {
    color: var(--primary);
}

/* Project Grid & Lists */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.dash-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Project Cards */
.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    position: relative;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    border-color: var(--primary);
}

.project-meta {
    font-size: 0.75rem;
    color: #767676;
    margin: 5px 0;
}

/* Folder Cards */
.folder-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: 0.2s;
    border-left: 5px solid #FFC107;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.folder-card:hover {
    transform: translateY(-3px);
    border-color: #FFC107;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

/* List View Overrides */
.dash-list .project-card {
    display: grid;
    grid-template-columns: 40px 2fr 1fr auto;
    align-items: center;
    padding: 12px 20px;
    gap: 15px;
    transform: none;
}

.dash-list .card-icon {
    font-size: 1.2rem;
    color: var(--primary);
    margin: 0;
}

/* Dashboard Actions */
.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.btn-act {
    flex: 1;
    padding: 8px;
    font-size: 0.8rem;
    border-radius: 4px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: 0.2s;
}

.btn-act:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 102, 204, 0.05);
}

.btn-act.danger:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(211, 47, 47, 0.05);
}

/* Empty State */
.empty-state-box {
    text-align: center;
    padding: 60px 20px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.02);
    color: #767676;
    margin-top: 20px;
}

.empty-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ── Z-INDEX LADDER (canonical reference) ──────────────────
   99999  onboarding-gate (full-page blocker)
   50000  auth-modal (login — must beat everything)
   20000  deny-modal (employee-tool denial overlay)
   12000  global header, search dropdown
   10001  sub-modals (e.g. bills.html confirm on top of bill modal)
   10000  ALL normal modal overlays (.modal-overlay, *-modal-overlay)
    9999  drawer overlay, sidebar toast
    9998  catalog overlay/dropdown
   ────────────────────────────────────────────────────────── */

/* Global Modals (Settings/Edit) - Replaces ID-based styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-box {
    background: var(--surface);
    color: var(--text);
    width: 90%;
    max-width: 450px;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: #767676;
}

.form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
}

/* =========================================
   8. MOBILE RESPONSIVE & UTILS
   ========================================= */

/* MOBILE: Full single-column layout */
@media (max-width: 1299px) {

    /* 1. LAYOUT & HEADER CLEARANCE */
    .layout-grid {
        display: flex !important;
        flex-direction: column !important;
        padding: 140px var(--page-edge, 12px) 20px var(--page-edge, 12px) !important;
        /* INCREASED: Clears the wrapped header */
        gap: 15px !important;
    }

    /* Pro mode: slightly less top padding (fewer header buttons) */
    body.biz-pro .layout-grid {
        padding-top: 120px !important;
    }

    .footer-inner {
        flex-direction: column;
        gap: 6px;
        padding: 10px 12px;
    }

    aside.left-col,
    aside.right-col {
        display: none !important;
    }

    /* 2. HEADER ADJUSTMENTS */
    header.global-head {
        /* FIX: Allow blue header to expand for the wrapped search bar */
        height: auto !important;
        min-height: 60px;
        transition: transform 0.3s ease;
        padding-bottom: 6px;
    }

    header.global-head.scroll-hide {
        transform: translateY(-100%);
        /* Slides completely out of view */
    }

    .header-inner {
        display: flex !important;
        /* Force out of grid mode */
        flex-wrap: wrap !important;
        height: auto !important;
        padding: 6px 10px 0 10px !important;
        gap: 4px !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    /* Row 1: Logo & Tools (Left) */
    .header-inner>div:first-child {
        position: static;
        flex: 1;
        display: flex;
        align-items: center;
        gap: 2px;
        min-width: 0;
        padding-left: 0;
    }

    /* Reset brand-block from absolute (desktop) to static (mobile) */
    .header-brand-block {
        position: static !important;
        padding-left: 0 !important;
        height: auto !important;
    }

    /* Row 1: Account (Right) */
    #header-account {
        display: flex !important;
        flex: 0 0 auto;
        order: 2;
        margin-left: auto;
    }
    #header-account > div {
        gap: 4px !important;
    }
    /* Touch targets: ensure 44px min while compact */
    #header-account button:not(.hdr-btn),
    #header-account a:not(.hdr-btn) {
        min-height: 44px !important;
        min-width: 44px !important;
        height: 44px !important;
        width: auto !important;
        padding: 0 8px !important;
    }
    /* Toolbox drawer button: keep 44px tap target, reduce visual padding */
    .mobile-only-btn {
        width: 44px !important;
        padding: 0 !important;
    }

    /* Row 2: Search (Full Width Below) */
    .header-search-container {
        order: 3;
        width: 100%;
        margin-top: 0;
        margin-bottom: 2px;
        border-top: solid 1px rgba(255,255,255,0.15);
        color: #767676;
        padding-top: 2px;
    }
    /* Hide TF watermark on mobile */
    .search-wrapper::before { display: none !important; }

    .header-search-container .search-input {
        padding: 10px 40px !important;
        font-size: 16px !important;
        /* Prevent iOS auto-zoom */
        background: var(--bg, #ffffff) !important;
        border: 1px solid var(--border, #ccc) !important;
        border-radius: 8px !important;
        color: var(--text, #333) !important;
        height: 42px !important;
    }

    /* Fix search icon invisible in pro light mode on white input */
    .search-icon {
        color: var(--text-muted, #767676) !important;
    }
    body.biz-pro:not(.dark-theme) .search-shortcut {
        background: rgba(0, 0, 0, 0.1);
        color: var(--text, #333);
        border-color: rgba(0, 0, 0, 0.2);
    }

    /* Pro mode: stronger glass tint for taller mobile header */
    body.biz-pro header.global-head {
        background: color-mix(in srgb, var(--primary) 40%, transparent) !important;
        backdrop-filter: blur(16px) saturate(1.1) !important;
        -webkit-backdrop-filter: blur(16px) saturate(1.1) !important;
    }

    /* Ensure dropdowns don't get cut off on mobile */
    .account-dropdown {
        position: fixed !important;
        top: 60px !important;
        width: 90% !important;
        left: 5% !important;
        right: 5% !important;
    }
    
    .search-dropdown {
        position: fixed !important;
        top: 110px !important;
        width: 90% !important;
        left: 5% !important;
        right: 5% !important;
        max-height: 60vh !important;
    }

    /* 3. TOOL CONTAINER (Anti-Scroll Fit) */
    .calc-container {
        width: 100% !important;
        border-radius: 10px;
    }

    /* MOBILE AD & BREADCRUMB SPACING CONSISTENCY */
    .ad-slot.ad-loaded {
        margin: 15px 0 !important;
        width: 100% !important;
    }

    .breadcrumbs {
        margin-bottom: 15px !important;
    }

    /* 4. ACTION BUTTONS (Icons Only, One Row, Right Aligned) */
    .tf-actions {
        flex-wrap: nowrap !important;
        justify-content: flex-end !important;
        gap: 8px !important;
    }
    .tf-actions .trust-badge {
        display: none !important;
    }

    /* SCOPED FIX: Only hide text for Tool Actions, NOT Sidebar */
    .tf-actions .tf-btn {
        flex: 0 0 42px !important;
        height: 42px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0 !important;
        line-height: 0 !important;
        gap: 0 !important;
        /* Hides text here only */
    }

    .tf-actions .tf-btn i {
        font-size: 1.1rem !important;
        margin: 0 auto !important;
        line-height: 42px !important;
        display: inline-block !important;
    }

    /* 5. STACKING & UTILS */
    .layout-split-calc {
        grid-template-columns: 1fr;
    }

    .layout-split-calc .calc-summary {
        position: static;
        margin-top: 20px;
    }

    .mobile-drawer {
        position: fixed;
        top: 0;
        left: -320px;
        width: 300px;
        height: 100%;
        background: var(--bg, white);
        z-index: 10000;
        transition: 0.3s;
        box-shadow: 15px 0 50px rgba(0, 0, 0, 0.3);
        display: block;

        /* FIX: Reset text color so it doesn't inherit 'White' from the Header */
        color: var(--text) !important;
    }

    .mobile-drawer.open {
        left: 0;
    }

    .mobile-only-btn {
        display: flex !important;
    }

    .desktop-only-btn {
        display: none !important;
    }
}

@media (min-width: 1300px) {
    .mobile-only-btn {
        display: none !important;
    }

    .desktop-only-btn {
        display: flex !important;
    }

    .mobile-drawer {
        display: none !important;
    }
}

/* Hide site title on narrower desktops to prevent brand overlapping search */
@media (min-width: 1300px) and (max-width: 1599px) {
    .header-brand-block .header-site-title {
        display: none;
    }
}

/* =========================================
   QR FOOTER - Print Only
   ========================================= */
.qr-footer {
    display: none; /* Hidden on screen */
}

@media print {
    .qr-footer {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 15px 20px;
        margin-top: 30px;
        border-top: 2px solid #000;
        background: #f5f5f5;
    }
    
    .qr-footer .qr-info {
        flex: 1;
    }
    
    .qr-footer .qr-brand {
        font-weight: 900;
        font-size: 1.2rem;
        margin: 0 0 4px 0;
        color: #000;
    }
    
    .qr-footer .qr-tagline {
        font-size: 0.85rem;
        color: #595959;
        margin: 0;
    }
    
    .qr-footer .qr-code-img {
        width: 80px;
        height: 80px;
        border: 1px solid #ccc;
    }
    
    /* Hide elements that shouldn't print */
    .tf-actions,
    .global-head,
    .global-foot,
    .left-col,
    .right-col,
    .ad-slot,
    .seo-content,
    .no-print,
    #invoice-action-bar,
    .pro-action-bar,
    .tf-layer-action-bar {
        display: none !important;
    }
    
    /* Reset layout for print */
    .layout-grid {
        display: block !important;
    }
    
    .main-col {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .tool-stage {
        box-shadow: none !important;
        border: none !important;
    }
    
    .calc-container {
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
    }
}

/* --- Auto-linked contextual anchors inside SEO articles --- */
.seo-content a[data-autolink] {
    color: var(--primary, #00c4d4);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.15s;
}
.seo-content a[data-autolink]:hover {
    color: var(--primary-hover, #008c99);
}

/* =========================================
   DARK MODE — Global Card Border Softening
   Replaces the blunt #333 var(--border) with
   subtle rgba so cards breathe in dark UI.
   ========================================= */
body.dark-theme .stat-card,
body.dark-theme .quick-action,
body.dark-theme .pinned-tool-card,
body.dark-theme .biz-stat,
body.dark-theme .biz-tool-card,
body.dark-theme .snap-kpi-card,
body.dark-theme .snap-people-card,
body.dark-theme .snap-activity-card,
body.dark-theme .client-card,
body.dark-theme .dash-person-card,
body.dark-theme .health-widget,
body.dark-theme .tool-container,
body.dark-theme .bingo-container,
body.dark-theme .coin-container,
body.dark-theme .dice-container,
body.dark-theme .trivia-container,
body.dark-theme .alarm-container,
body.dark-theme .timer-container,
body.dark-theme .stopwatch-container,
body.dark-theme .sudoku-container,
body.dark-theme .ws-container,
body.dark-theme .tool-card {
    border-color: rgba(255,255,255,0.09);
}

body.dark-theme .calc-card {
    border-color: rgba(255,255,255,0.08);
}
