/* ========================================
   DAX Toolkit — Styles (Power BI Light Theme + Sidebar)
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #f3f3f3;
    --bg-secondary: #ffffff;
    --bg-tertiary: #fafafa;
    --bg-input: #f8f8f8;
    --bg-card: #ffffff;
    --bg-hover: #f0f0f0;
    --bg-code: #1e1e1e;

    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-placeholder: #bbbbbb;
    --text-on-dark: #e0e0e0;

    /* Power BI brand colors */
    --pbi-yellow: #F2C811;
    --pbi-yellow-hover: #d9b40f;
    --pbi-yellow-light: #fef9e7;
    --pbi-yellow-glow: rgba(242, 200, 17, 0.2);
    --pbi-green: #01B8AA;
    --pbi-green-hover: #019e93;
    --pbi-green-light: #e6f9f7;
    --pbi-dark: #2c2c2c;
    --pbi-darker: #222222;
    --pbi-gray: #A6A6A6;

    --accent: var(--pbi-yellow);
    --accent-hover: var(--pbi-yellow-hover);
    --accent-glow: var(--pbi-yellow-glow);

    --border: #e2e2e2;
    --border-light: #ebebeb;

    --success: var(--pbi-green);
    --warning: #e5a84b;
    --error: #f14c4c;

    /* Syntax highlighting (dark code blocks) */
    --syn-keyword: #569cd6;
    --syn-function: #dcdcaa;
    --syn-string: #ce9178;
    --syn-number: #b5cea8;
    --syn-operator: #d4d4d4;
    --syn-comment: #6a9955;
    --syn-table: #4ec9b0;
    --syn-column: #9cdcfe;
    --syn-placeholder: #F2C811;

    /* Typography */
    --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;

    /* Spacing */
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --transition: 0.2s ease;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 3px 10px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.1);

    --sidebar-width: 230px;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ==========================================
   APP LAYOUT — Sidebar + Main
   ========================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--pbi-dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

/* Brand / Logo area */
.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 1.25rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--pbi-yellow);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}

/* Navigation buttons */
.sidebar__nav {
    flex: 1;
    padding: 0.75rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.65rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--font-sans);
    font-size: 0.87rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    position: relative;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.9);
}

.nav-btn.active {
    background: rgba(242, 200, 17, 0.12);
    color: var(--pbi-yellow);
}

.nav-btn.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--pbi-yellow);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.nav-label {
    white-space: nowrap;
}

/* Sidebar footer */
.sidebar__footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__footer p {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.25);
    line-height: 1.5;
    text-align: center;
    margin-top: 0.75rem;
}

.sidebar__social {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.social-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.social-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
}

.social-btn:active {
    transform: translateY(1px);
}

.social-btn svg {
    flex-shrink: 0;
}

.social-btn--linkedin {
    background: #0A66C2;
    color: #fff;
    border-color: #0A66C2;
}

.social-btn--linkedin:hover {
    background: #0958a8;
    border-color: #0958a8;
}

.social-btn--paypal {
    background: var(--pbi-yellow);
    color: #1a1a1a;
    border-color: var(--pbi-yellow);
}

.social-btn--paypal:hover {
    background: #ffd633;
    border-color: #ffd633;
}

.sidebar__social-divider {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.25rem 0 0;
}

.social-btn--webapp {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.75);
    border-color: rgba(255,255,255,0.1);
    font-weight: 500;
}

.social-btn--webapp:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.22);
    color: #fff;
}

/* --- Mobile Header (hidden on desktop) --- */
.mobile-header {
    display: none;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--pbi-dark);
    position: sticky;
    top: 0;
    z-index: 90;
}

.mobile-header .brand-title {
    font-size: 1.05rem;
    flex: 1;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 0.3rem;
    display: flex;
    align-items: center;
}

.mobile-nav {
    display: none;
    background: var(--pbi-darker);
    padding: 0.5rem;
    gap: 0.25rem;
    border-bottom: 2px solid var(--pbi-yellow);
}

.mobile-nav.open {
    display: flex;
    flex-direction: column;
}

.mobile-nav .nav-btn {
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

/* ==========================================
   MAIN CONTENT
   ========================================== */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 2.25rem;
    max-width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
}

/* --- Page Header --- */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--pbi-dark);
    margin-bottom: 0.2rem;
}

.page-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.highlight-placeholder {
    color: #a08b0a;
    font-weight: 600;
    background: var(--pbi-yellow-light);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

/* --- Tab Content --- */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Panels --- */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.panel__title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.panel__actions {
    display: flex;
    gap: 0.5rem;
}

/* --- Buttons --- */
.btn {
    padding: 0.45rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn--primary {
    background: var(--pbi-yellow);
    border-color: var(--pbi-yellow);
    color: var(--pbi-dark);
    font-weight: 600;
}

.btn--primary:hover {
    background: var(--pbi-yellow-hover);
    border-color: var(--pbi-yellow-hover);
    box-shadow: 0 2px 8px rgba(242, 200, 17, 0.3);
}

.btn--secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn--secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn--copy {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn--copy:hover:not(:disabled) {
    background: var(--pbi-yellow);
    border-color: var(--pbi-yellow);
    color: var(--pbi-dark);
}

.btn--copy:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn--copy.copied {
    background: var(--pbi-yellow);
    border-color: var(--pbi-yellow);
    color: var(--pbi-dark);
}

.btn--full {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

/* --- Code Input / Output --- */
.code-input {
    width: 100%;
    min-height: 400px;
    padding: 1rem;
    background: var(--bg-code);
    border: none;
    color: var(--text-on-dark);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
}

.code-input::placeholder {
    color: #555;
}

/* Syntax-highlighted overlay for textarea (used by formatter input) */
.code-input-wrap {
    position: relative;
    background: var(--bg-code);
    min-height: 400px;
}

.code-input-highlight {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.7;
    tab-size: 4;
    white-space: pre;
    overflow: hidden;
    pointer-events: none;
    color: var(--text-on-dark);
    background: transparent;
    border: none;
}

.code-input-highlight code {
    display: block;
    font: inherit;
    color: inherit;
    background: transparent;
}

.code-input--overlay {
    position: relative;
    background: transparent;
    color: transparent;
    caret-color: var(--text-on-dark);
}

.code-input--overlay::placeholder {
    color: #555;
}

.code-input--overlay::selection {
    background: rgba(242, 200, 17, 0.35);
    color: transparent;
}

.code-output {
    min-height: 400px;
    padding: 1rem;
    background: var(--bg-code);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.7;
    overflow: auto;
    white-space: pre;
    margin: 0;
}

.code-output code {
    color: #666;
}

.code-output.has-content code {
    color: var(--text-on-dark);
}

/* --- Formatter Layout --- */
.formatter-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* --- Syntax Highlighting (dark code blocks) --- */
.syn-keyword { color: var(--syn-keyword); font-weight: 600; }
.syn-function { color: var(--syn-function); }
.syn-string { color: var(--syn-string); }
.syn-number { color: var(--syn-number); }
.syn-operator { color: var(--syn-operator); }
.syn-comment { color: var(--syn-comment); font-style: italic; }
.syn-table { color: var(--syn-table); }
.syn-column { color: var(--syn-column); }
.syn-placeholder { color: var(--syn-placeholder); font-weight: 600; background: rgba(242, 200, 17, 0.15); border-radius: 2px; padding: 0 2px; }
.syn-identifier { color: #e0e0e0; }
.syn-paren { color: #c586c0; }
.syn-comma { color: #999; }

/* --- Reference Tab --- */
.reference-controls {
    margin-bottom: 1.25rem;
}

.search-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition);
    box-shadow: var(--shadow-sm);
}

.search-input:focus {
    border-color: var(--pbi-yellow);
    box-shadow: 0 0 0 3px var(--pbi-yellow-glow);
}

.search-input::placeholder {
    color: var(--text-placeholder);
}

/* --- Category Chips --- */
.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chip {
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.chip:hover {
    border-color: var(--pbi-yellow);
    color: var(--text-primary);
    background: var(--pbi-yellow-light);
}

.chip.active {
    background: var(--pbi-yellow);
    border-color: var(--pbi-yellow);
    color: var(--pbi-dark);
    font-weight: 600;
}

/* --- Reference Grid --- */
.reference-count {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 0.75rem;
}

.ref-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.ref-card:hover {
    border-color: var(--pbi-yellow);
    box-shadow: var(--shadow-md);
}

.ref-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.ref-name {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--pbi-dark);
}

.ref-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: var(--pbi-yellow-light);
    color: #9a7d00;
    border: 1px solid var(--pbi-yellow);
    font-weight: 600;
}

.ref-syntax {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: #d4d4d4;
    background: var(--bg-code);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    overflow-x: auto;
    white-space: nowrap;
}

.ref-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.ref-example {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: var(--bg-code);
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    white-space: pre;
    color: var(--text-on-dark);
    margin: 0;
    line-height: 1.6;
}

/* --- Snippets Tab --- */
.snippets-controls {
    margin-bottom: 1.25rem;
}

.snippets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1rem;
}

.snippet-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.snippet-card:hover {
    border-color: var(--pbi-yellow);
    box-shadow: var(--shadow-md);
}

.snippet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.snippet-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--pbi-dark);
}

.snippet-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: var(--pbi-yellow-light);
    color: #a08b0a;
    border: 1px solid var(--pbi-yellow);
    font-weight: 600;
}

.snippet-desc {
    padding: 0.6rem 1rem;
    font-size: 0.83rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.snippet-code {
    position: relative;
}

.snippet-code pre {
    margin: 0;
    padding: 0.75rem 1rem;
    background: var(--bg-code);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre;
}

.snippet-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
    background: #444;
    border: 1px solid #555;
    border-radius: var(--radius-sm);
    color: #ccc;
    cursor: pointer;
    transition: all var(--transition);
    opacity: 0;
}

.snippet-card:hover .snippet-copy {
    opacity: 1;
}

.snippet-copy:hover {
    background: var(--pbi-yellow);
    border-color: var(--pbi-yellow);
    color: var(--pbi-dark);
}

.snippet-copy.copied {
    background: var(--pbi-yellow);
    border-color: var(--pbi-yellow);
    color: var(--pbi-dark);
    opacity: 1;
}

/* --- UDF Tab --- */
.udf-preview-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    background: linear-gradient(135deg, rgba(242,200,17,0.08), rgba(242,200,17,0.03));
    border: 1px solid rgba(242,200,17,0.25);
    border-left: 4px solid var(--pbi-yellow);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.1rem;
    margin-bottom: 1.25rem;
}

.udf-preview-banner__icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.udf-preview-banner__body {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.udf-preview-banner__body strong {
    color: var(--pbi-yellow);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}

.udf-preview-banner__body em {
    font-style: italic;
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    font-size: 0.78rem;
}

.udf-syntax-hero {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.udf-syntax-hero__label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.udf-syntax-hero__code {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-on-dark);
    overflow-x: auto;
    white-space: pre;
}

.udf-syntax-hero__code code {
    background: none;
    padding: 0;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}

.page-desc code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: rgba(242,200,17,0.1);
    color: var(--pbi-yellow);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(242,200,17,0.2);
}

.udf-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0.5rem 0 1rem;
}

.udf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(560px, 1fr));
    gap: 1.25rem;
}

.udf-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.udf-card__header {
    padding: 1.1rem 1.25rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

.udf-card__meta {
    margin-bottom: 0.4rem;
}

.udf-card__category {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pbi-yellow);
    background: rgba(242,200,17,0.1);
    border: 1px solid rgba(242,200,17,0.2);
    border-radius: 20px;
    padding: 0.15rem 0.6rem;
}

.udf-card__name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.35rem 0 0.4rem;
}

.udf-card__desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}

.udf-card__body {
    padding: 1rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    flex: 1;
}

.udf-when {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.udf-when__label,
.udf-syntax__label,
.udf-example__label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.udf-when__text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}

.udf-syntax {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.udf-syntax__code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--pbi-yellow);
    background: rgba(242,200,17,0.06);
    border: 1px solid rgba(242,200,17,0.15);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    white-space: pre;
    overflow-x: auto;
    display: block;
}

.udf-example {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.udf-example__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.udf-code {
    min-height: unset;
    border-radius: var(--radius);
    font-size: 0.8rem;
    max-height: 340px;
    overflow-y: auto;
}

.udf-tips {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.udf-tips li {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    padding-left: 1.1rem;
    position: relative;
}

.udf-tips li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--pbi-yellow);
    font-size: 0.7rem;
    top: 0.1rem;
}

@media (max-width: 1024px) {
    .udf-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .udf-syntax-hero__code {
        font-size: 0.78rem;
    }
    .udf-preview-banner {
        padding: 0.75rem 0.9rem;
    }
}

/* --- Date Table Tab --- */
.datatable-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1rem;
    align-items: start;
}

.datatable-form {
    padding: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.83rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.form-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition);
}

.form-input:focus {
    border-color: var(--pbi-yellow);
    box-shadow: 0 0 0 3px var(--pbi-yellow-glow);
}

select.form-input {
    cursor: pointer;
}

.form-group--toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form-group--toggle label:first-child {
    margin-bottom: 0;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle__slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    transition: var(--transition);
}

.toggle__slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked + .toggle__slider {
    background: var(--pbi-yellow);
}

.toggle input:checked + .toggle__slider::before {
    transform: translateX(20px);
}

/* Date Table Preview */
.datatable-preview {
    margin-top: 1rem;
}

.datatable-preview h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    font-family: var(--font-mono);
}

.preview-table th {
    background: var(--pbi-dark);
    color: var(--pbi-yellow);
    padding: 0.45rem 0.6rem;
    text-align: left;
    font-weight: 600;
    border: 1px solid #444;
    white-space: nowrap;
    font-size: 0.73rem;
}

.preview-table td {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    white-space: nowrap;
    color: var(--text-primary);
}

.preview-table tr:nth-child(even) {
    background: var(--bg-tertiary);
}

.preview-table tr:nth-child(odd) {
    background: var(--bg-secondary);
}

/* ==========================================
   PERFORMANCE TIPS TAB
   ========================================== */

.perf-layout {
    margin-bottom: 2rem;
}

.perf-layout .code-input {
    min-height: 200px;
}

.perf-results {
    margin-top: 1rem;
}

.perf-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.perf-empty strong {
    color: var(--text-secondary);
}

/* Result summary */
.perf-result-summary {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.perf-result-summary strong {
    display: block;
    margin-bottom: 0.15rem;
}

.perf-result-summary p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.perf-result-summary--clean {
    background: var(--pbi-green-light);
    border: 1px solid var(--pbi-green);
    color: #0a6e64;
}

.perf-result-summary--clean svg {
    color: var(--pbi-green);
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.perf-result-summary--issues {
    background: #fff8e1;
    border: 1px solid #f0c040;
    color: #7a5a00;
}

.perf-result-summary--issues svg {
    color: #d4a017;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.perf-summary-counts {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Severity badges & dots */
.severity-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.severity--high {
    background: #fde8e8;
    color: #c0392b;
    border: 1px solid #e74c3c;
}

.severity--medium {
    background: #fff3cd;
    color: #8a6500;
    border: 1px solid #f0c040;
}

.severity--low {
    background: #e8f4fd;
    color: #2471a3;
    border: 1px solid #5dade2;
}

.severity-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.severity-dot.severity--high { background: #e74c3c; }
.severity-dot.severity--medium { background: #f0c040; }
.severity-dot.severity--low { background: #5dade2; }

/* Finding cards */
.perf-finding {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
}

.perf-finding__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.perf-finding__category {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.perf-finding__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--pbi-dark);
    margin-bottom: 0.35rem;
}

.perf-finding__desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.perf-finding__explanation {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-light);
    font-style: italic;
}

/* Comparison blocks (Avoid vs Prefer) */
.perf-finding__comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.perf-comparison-block {
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.perf-comparison-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.3rem 0.6rem;
}

.perf-comparison-block--bad .perf-comparison-label {
    background: #c0392b;
    color: #fff;
}

.perf-comparison-block--good .perf-comparison-label {
    background: var(--pbi-yellow);
    color: var(--pbi-dark);
}

.perf-comparison-block pre {
    margin: 0;
    padding: 0.6rem 0.75rem;
    background: var(--bg-code);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}

/* All rules reference section */
.perf-reference {
    border-top: 2px solid var(--border);
    padding-top: 1.5rem;
    margin-top: 1rem;
}

.perf-reference__title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--pbi-dark);
    margin-bottom: 0.25rem;
}

.perf-reference__desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.perf-category-heading {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--pbi-dark);
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid var(--pbi-yellow);
    display: inline-block;
}

.perf-category-heading:first-child {
    margin-top: 0;
}

.perf-rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-sm);
}

.perf-rule-card__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.perf-rule-card__title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--pbi-dark);
}

.perf-rule-card__desc {
    font-size: 0.83rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

/* ==========================================
   FORMAT STRING FINDER TAB
   ========================================== */

.fsf-layout {
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    gap: 1rem;
    align-items: stretch;
}

.fsf-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* Left panel — Selection */
.fsf-selection {
    padding: 0;
}

.fsf-mode-toggle {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.fsf-mode-btn {
    flex: 1;
    padding: 0.7rem;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.fsf-mode-btn:first-child {
    border-radius: var(--radius-lg) 0 0 0;
}

.fsf-mode-btn:last-child {
    border-radius: 0 var(--radius-lg) 0 0;
}

.fsf-mode-btn.active {
    background: var(--pbi-yellow);
    color: var(--pbi-dark);
}

.fsf-mode-btn:hover:not(.active) {
    background: var(--bg-hover);
}

.fsf-section {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-light);
}

.fsf-section:last-child {
    border-bottom: none;
}

.fsf-section-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.fsf-group-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0.6rem 0 0.3rem;
    padding-left: 0.1rem;
}

.fsf-group-label:first-of-type {
    margin-top: 0;
}

/* Custom radio buttons */
.fsf-radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.84rem;
    color: var(--text-primary);
    transition: background var(--transition);
}

.fsf-radio-label:hover {
    background: var(--bg-hover);
}

.fsf-radio-label input[type="radio"] {
    display: none;
}

.fsf-radio-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    position: relative;
    transition: border-color var(--transition);
}

.fsf-radio-label input:checked + .fsf-radio-dot {
    border-color: var(--pbi-yellow);
}

.fsf-radio-label input:checked + .fsf-radio-dot::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--pbi-yellow);
}

/* Decimal buttons */
.fsf-dec-btns {
    display: flex;
    gap: 0.35rem;
}

.fsf-dec-btn {
    width: 42px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.fsf-dec-btn:hover {
    border-color: var(--pbi-yellow);
    color: var(--text-primary);
}

.fsf-dec-btn.active {
    background: var(--pbi-yellow);
    border-color: var(--pbi-yellow);
    color: var(--pbi-dark);
}

/* Center panel — Preview */
.fsf-center {
    display: flex;
    flex-direction: column;
}

.fsf-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.fsf-preview-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.fsf-sample-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fsf-toggle-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.fsf-table-wrap {
    overflow-y: auto;
    flex: 1;
}

.fsf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    font-family: var(--font-mono);
}

.fsf-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.fsf-th-left,
.fsf-th-right {
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.fsf-th-left {
    text-align: right;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    width: 50%;
    border-right: 1px solid var(--border);
}

.fsf-th-right {
    text-align: right;
    background: var(--pbi-yellow);
    color: var(--pbi-dark);
    width: 50%;
}

.fsf-td-left {
    text-align: right;
    padding: 0.35rem 0.75rem;
    color: var(--text-secondary);
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.82rem;
}

.fsf-td-right {
    text-align: right;
    padding: 0.35rem 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.82rem;
}

.fsf-td-right.fsf-neg {
    color: #c0392b;
}

.fsf-td-right.fsf-pos {
    color: #2e7d32;
}

/* Right panel — Output */
.fsf-right {
    padding: 0;
}

.fsf-format-box {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.fsf-format-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.fsf-format-value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--pbi-dark);
    word-break: break-all;
    margin-bottom: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.fsf-copy-btn {
    width: 100%;
    justify-content: center;
}

.fsf-dax-code {
    margin: 0 0 0.75rem;
    padding: 0.75rem;
    background: var(--bg-code);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
    max-height: 250px;
    overflow-y: auto;
}

.fsf-dax-code code {
    color: var(--text-on-dark);
}

.fsf-output-type {
    margin-bottom: 0.5rem;
}

/* Additional Formatting Options */
.fsf-options-section {
    padding: 0.85rem 1rem;
}

.fsf-options-heading {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-light);
}

.fsf-opt-row {
    margin-bottom: 0.75rem;
}

.fsf-opt-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.fsf-opt-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.fsf-opt {
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.fsf-opt:hover {
    border-color: var(--pbi-yellow);
    color: var(--text-primary);
}

.fsf-opt.active {
    background: var(--pbi-dark);
    border-color: var(--pbi-dark);
    color: #fff;
    font-weight: 600;
}

/* Conditional thresholds */
.fsf-cond-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.fsf-threshold-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.fsf-threshold-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.fsf-threshold-row:hover {
    background: var(--bg-hover);
}

.fsf-threshold-default {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}

.fsf-threshold-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.8rem;
}

.fsf-threshold-toggle input[type="checkbox"] {
    accent-color: var(--pbi-yellow);
}

.fsf-threshold-label {
    font-size: 0.8rem;
    color: var(--text-primary);
}

.fsf-threshold-scale,
.fsf-threshold-dec,
.fsf-default-scale,
.fsf-default-dec {
    padding: 0.25rem 0.3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-family: var(--font-sans);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
}

.fsf-threshold-scale:disabled,
.fsf-threshold-dec:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==========================================
   THEME BUILDER TAB
   ========================================== */

.theme-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1rem;
    align-items: start;
}

.theme-settings {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.theme-field__label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

/* Presets */
.theme-presets {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.theme-preset-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.theme-preset-btn:hover {
    border-color: var(--pbi-yellow);
    background: var(--bg-hover);
}

.theme-preset-colors {
    display: flex;
    gap: 2px;
}

.theme-preset-colors span {
    width: 18px;
    height: 18px;
    border-radius: 3px;
}

.theme-preset-name {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Color slots */
.theme-colors {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
}

.theme-color-slot {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
}

.theme-color-input {
    position: absolute;
    width: 28px;
    height: 28px;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.theme-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid var(--border);
    flex-shrink: 0;
    cursor: pointer;
}

.theme-color-hex {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.theme-bg-fg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Preview */
.theme-preview {
    padding: 1rem;
    border-radius: 0 0 var(--radius) var(--radius);
    min-height: 200px;
}

.theme-preview__title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.theme-preview__bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 120px;
    margin-bottom: 0.75rem;
    padding-bottom: 1px;
    border-bottom: 1px solid var(--border-light);
}

.theme-preview__bar {
    flex: 1;
    border-radius: 4px 4px 0 0;
    transition: height 0.3s ease;
}

.theme-preview__donut {
    display: flex;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.theme-preview__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.theme-preview__legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
}

.theme-preview__legend-item span {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* Accessibility check */
.theme-a11y {
    padding: 0.75rem 1rem;
}

.theme-a11y-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.theme-a11y-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.theme-a11y-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.theme-a11y-hex {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.theme-a11y-ratio {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: auto;
}

.theme-a11y-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

.theme-contrast--aaa {
    background: #d4edda;
    color: #155724;
}

.theme-contrast--aa {
    background: #d1ecf1;
    color: #0c5460;
}

.theme-contrast--aa-lg {
    background: #fff3cd;
    color: #856404;
}

.theme-contrast--fail {
    background: #f8d7da;
    color: #721c24;
}

/* Theme JSON output */
.theme-json-output {
    max-height: 250px;
    overflow-y: auto;
    font-size: 0.78rem;
    min-height: auto;
}

@media (max-width: 1024px) {
    .theme-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .theme-colors {
        grid-template-columns: repeat(2, 1fr);
    }

    .theme-a11y-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================
   RELATIONSHIPS TAB
   ========================================== */

.rel-section {
    margin-bottom: 2rem;
}

.rel-section__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--pbi-dark);
    margin: 0 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--pbi-yellow);
}

.rel-section__cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.rel-card__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.rel-card__title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}

.rel-card__icon {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    background: var(--pbi-yellow);
    color: var(--pbi-dark);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    white-space: nowrap;
}

.rel-card__name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--pbi-dark);
    margin: 0;
}

.rel-card__desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.rel-card__body {
    padding: 1rem 1.25rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.25rem;
    align-items: start;
}

.rel-card__visual {
    overflow-x: auto;
}

.rel-svg {
    display: block;
}

.rel-card__info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rel-card__label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.rel-card__when p,
.rel-card__filter-detail p {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin: 0;
}

.rel-card__pros-cons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.rel-card__pros ul,
.rel-card__cons ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rel-card__pros li,
.rel-card__cons li {
    font-size: 0.82rem;
    line-height: 1.5;
    padding: 0.15rem 0;
    padding-left: 1.1rem;
    position: relative;
}

.rel-card__pros li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #2e7d32;
    font-weight: 700;
    font-size: 0.75rem;
}

.rel-card__cons li::before {
    content: '✗';
    position: absolute;
    left: 0;
    color: #c0392b;
    font-weight: 700;
    font-size: 0.75rem;
}

.rel-card__label--pro {
    color: #2e7d32;
}

.rel-card__label--con {
    color: #c0392b;
}

@media (max-width: 900px) {
    .rel-card__body {
        grid-template-columns: 1fr;
    }

    .rel-card__pros-cons {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   VISUAL CALCULATIONS TAB
   ========================================== */

.vc-count {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.vc-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.vc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.vc-card__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.vc-card__title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.vc-card__name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--pbi-dark);
    margin: 0;
}

.vc-card__badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    background: var(--pbi-yellow-light);
    color: #9a7d00;
    border: 1px solid var(--pbi-yellow);
    font-weight: 600;
}

.vc-card__desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.vc-card__body {
    padding: 1rem 1.25rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.vc-card__label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.vc-card__syntax {
    grid-column: 1 / -1;
}

.vc-card__code {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    background: var(--bg-input);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    display: block;
    color: var(--text-primary);
}

.vc-card__dax {
    display: flex;
    flex-direction: column;
}

.vc-card__dax-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.vc-card__dax-header .vc-card__label {
    margin-bottom: 0;
}

.vc-copy-btn {
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
}

.vc-card__dax-code {
    background: var(--bg-code);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.5;
    overflow-x: auto;
    margin: 0;
    flex: 1;
}

.vc-card__dax-code code {
    color: var(--text-on-dark);
}

.vc-card__preview {
    display: flex;
    flex-direction: column;
}

.vc-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    flex: 1;
}

.vc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-family: var(--font-mono);
}

.vc-table thead {
    background: var(--pbi-yellow);
}

.vc-table th {
    padding: 0.4rem 0.6rem;
    text-align: right;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--pbi-dark);
    white-space: nowrap;
}

.vc-table th:first-child {
    text-align: left;
}

.vc-table td {
    padding: 0.35rem 0.6rem;
    text-align: right;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    white-space: nowrap;
}

.vc-table td:first-child {
    text-align: left;
    color: var(--text-secondary);
}

.vc-table td:last-child {
    font-weight: 600;
}

.vc-cell--pos {
    color: #2e7d32 !important;
}

.vc-cell--neg {
    color: #c0392b !important;
}

.vc-blank {
    color: var(--text-muted);
}

.vc-card__tip {
    grid-column: 1 / -1;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--pbi-yellow-light);
    border: 1px solid var(--pbi-yellow);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    line-height: 1.5;
}

.vc-card__tip strong {
    color: #9a7d00;
}

@media (max-width: 900px) {
    .vc-card__body {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   MEASURE DEPENDENCIES TAB
   ========================================== */

.dep-results {
    margin-top: 1.25rem;
}

.dep-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.dep-empty code {
    font-family: var(--font-mono);
    background: var(--bg-input);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

/* Stats row */
.dep-summary {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.dep-stat {
    flex: 1;
    min-width: 100px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.dep-stat__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--pbi-dark);
}

.dep-stat__label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.15rem;
}

.dep-stat--warn .dep-stat__value {
    color: var(--warning);
}

/* Graph section */
.dep-graph-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.dep-graph-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dep-graph-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.dep-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.dep-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.dep-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.dep-legend-dot--root {
    background: var(--pbi-yellow);
}

.dep-legend-dot--mid {
    background: var(--pbi-dark);
}

.dep-legend-dot--leaf {
    background: #5b9bd5;
}

.dep-legend-dot--orphan {
    background: var(--pbi-gray);
}

.dep-graph-wrap {
    overflow-x: auto;
    padding: 1rem;
    background: var(--bg-tertiary);
}

.dep-svg {
    display: block;
    margin: 0 auto;
}

/* SVG nodes */
.dep-node rect {
    fill: var(--pbi-dark);
    stroke: var(--pbi-dark);
    stroke-width: 1.5;
}

.dep-node text {
    fill: #fff;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
}

.dep-node--root rect {
    fill: var(--pbi-yellow);
    stroke: var(--pbi-yellow-hover);
}

.dep-node--root text {
    fill: var(--pbi-dark);
}

.dep-node--leaf rect {
    fill: #5b9bd5;
    stroke: #4a8bc2;
}

.dep-node--leaf text {
    fill: #fff;
}

.dep-node--orphan rect {
    fill: var(--bg-secondary);
    stroke: var(--pbi-gray);
}

.dep-node--orphan text {
    fill: var(--text-secondary);
}

/* Detail cards */
.dep-detail-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
}

.dep-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.75rem;
}

.dep-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.dep-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-tertiary);
}

.dep-card__name {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pbi-dark);
}

.dep-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.45rem;
    border-radius: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.dep-badge--root {
    background: var(--pbi-yellow-light);
    color: #9a7d00;
    border: 1px solid var(--pbi-yellow);
}

.dep-badge--leaf {
    background: #e8f0fa;
    color: #3a6fa0;
    border: 1px solid #5b9bd5;
}

.dep-badge--orphan {
    background: var(--bg-hover);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.dep-card__body {
    padding: 0.6rem 0.85rem;
}

.dep-card__section {
    margin-bottom: 0.5rem;
}

.dep-card__section:last-child {
    margin-bottom: 0;
}

.dep-card__label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    display: block;
    margin-bottom: 0.25rem;
}

.dep-card__label--muted {
    text-transform: none;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dep-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.dep-tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-weight: 500;
}

.dep-tag--uses {
    background: var(--pbi-yellow-light);
    color: #9a7d00;
}

.dep-tag--usedby {
    background: #e8f0fa;
    color: #3a6fa0;
}

/* ==========================================
   KEYBOARD SHORTCUTS TAB
   ========================================== */

.shortcuts-controls {
    margin-bottom: 1.25rem;
}

.shortcuts-count {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.shortcuts-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.shortcut-group {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.shortcut-group__title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 0.6rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.shortcut-table {
    display: flex;
    flex-direction: column;
}

.shortcut-row {
    display: flex;
    align-items: center;
    padding: 0.55rem 1rem;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.shortcut-row:last-child {
    border-bottom: none;
}

.shortcut-row:hover {
    background: var(--bg-hover);
}

.shortcut-keys {
    flex-shrink: 0;
    width: 220px;
    display: flex;
    align-items: center;
    gap: 0.15rem;
    flex-wrap: wrap;
}

.shortcut-action {
    font-size: 0.87rem;
    color: var(--text-primary);
}

/* Keyboard key styling */
.key {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.key-plus {
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0 0.15rem;
}

.shortcut-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 1024px) {
    .formatter-layout {
        grid-template-columns: 1fr;
    }

    .datatable-layout {
        grid-template-columns: 1fr;
    }

    .perf-finding__comparison {
        grid-template-columns: 1fr;
    }

    .shortcut-keys {
        width: 180px;
    }

    .fsf-layout {
        grid-template-columns: 280px 1fr;
    }

    .fsf-right-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    /* Hide sidebar, show mobile header */
    .sidebar {
        display: none !important;
    }

    .mobile-header {
        display: flex !important;
    }

    .app-layout {
        flex-direction: column;
    }

    .main {
        margin-left: 0;
        max-width: 100%;
        padding: 1.25rem 1rem;
    }

    .reference-grid {
        grid-template-columns: 1fr;
    }

    .snippets-grid {
        grid-template-columns: 1fr;
    }

    .fsf-layout {
        grid-template-columns: 1fr;
    }

    .fsf-right-panel {
        grid-column: auto;
    }
}

@media (max-width: 600px) {
    .main {
        padding: 1rem 0.75rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .code-input,
    .code-output {
        min-height: 250px;
    }

    .shortcut-keys {
        width: 140px;
    }

    .shortcut-action {
        font-size: 0.8rem;
    }

    .key {
        font-size: 0.7rem;
        padding: 0.15rem 0.35rem;
    }

    .fsf-preview-table th,
    .fsf-preview-table td {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }

    .fsf-format-box {
        font-size: 0.85rem;
    }
}

/* ============================================
   Visual Picker Tab
   ============================================ */
.vp-count {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0.5rem 0 1rem;
}

.vp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.25rem;
}

.vp-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.vp-card:hover {
    border-color: var(--pbi-yellow);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
}

.vp-card__header {
    padding: 1.1rem 1.25rem 0.85rem;
    border-bottom: 1px solid var(--border);
}

.vp-card__preview {
    background: #1a1a1a;
    border-radius: 10px;
    padding: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.85rem;
}

.vp-card__preview svg {
    width: 100%;
    height: 80px;
    max-width: 220px;
}

.vp-card__title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.vp-card__name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.vp-card__badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--pbi-yellow);
    color: #1a1a1a;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
}

.vp-card__desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.vp-card__body {
    padding: 1rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

.vp-card__cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.vp-card__col {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    padding: 0.7rem 0.85rem;
    border-left: 3px solid transparent;
}

.vp-card__col--good {
    border-left-color: #3ecf8e;
}

.vp-card__col--bad {
    border-left-color: #ff5e5e;
}

.vp-card__col-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    margin: 0 0 0.45rem;
}

.vp-card__col--good .vp-card__col-title {
    color: #2ba968;
}

.vp-card__col--bad .vp-card__col-title {
    color: #d63838;
}

.vp-card__col ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.vp-card__col li {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
    padding-left: 0.85rem;
    position: relative;
}

.vp-card__col--good li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 0;
    color: #3ecf8e;
    font-weight: 700;
}

.vp-card__col--bad li::before {
    content: '×';
    position: absolute;
    left: 0;
    top: -1px;
    color: #ff5e5e;
    font-weight: 700;
    font-size: 0.95rem;
}

.vp-card__example-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.vp-card__example-label span {
    text-transform: none;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0;
}

.vp-card__table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.vp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.vp-table th,
.vp-table td {
    padding: 0.5rem 0.7rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.vp-table th {
    background: rgba(242, 200, 17, 0.12);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.vp-table tbody tr:last-child td {
    border-bottom: none;
}

.vp-table tbody tr:hover {
    background: rgba(242, 200, 17, 0.05);
}

@media (max-width: 720px) {
    .vp-grid {
        grid-template-columns: 1fr;
    }
    .vp-card__cols {
        grid-template-columns: 1fr;
    }
}
