/*
 * Tetra UI Component Library
 * Custom CSS with CSS variables for theming
 * Works alongside Tailwind CSS (via CDN)
 */

/* ==========================================================================
   CSS Custom Properties (Theme Variables)
   ========================================================================== */

:root {
    /* Primary Colors - Tetra Brand */
    --color-primary: #00a96e;
    --color-primary-hover: #008f5d;
    --color-primary-light: #00d68f;
    
    /* Secondary Colors */
    --color-secondary: #1456b8;
    --color-secondary-hover: #0f408a;
    --color-secondary-light: #4a8af4;
    
    /* Neutral Colors */
    --color-background: #f5f5f5;
    --color-surface: #ffffff;
    --color-surface-secondary: #f8f9fa;
    --color-surface-elevated: #ffffff;
    --color-border: #e5e5e5;
    --color-border-hover: #d0d0d0;

    /* Text Colors */
    --color-text-primary: #333333;
    --color-text-secondary: #666666;
    --color-text-tertiary: #999999;
    --color-text-muted: #999999;
    --color-text-inverse: #ffffff;
    
    /* Status Colors */
    --color-success: #28a745;
    --color-success-hover: #218838;
    --color-success-light: #d4edda;
    --color-success-bg: #d4edda;
    --color-success-border: #c3e6cb;
    --color-warning: #ffc107;
    --color-warning-hover: #e0a800;
    --color-warning-light: #fff3cd;
    --color-warning-bg: #fff3cd;
    --color-warning-border: #ffeeba;
    --color-error: #dc3545;
    --color-error-hover: #c82333;
    --color-error-light: #f8d7da;
    --color-error-bg: #f8d7da;
    --color-error-border: #f5c6cb;
    --color-info: #17a2b8;
    --color-info-hover: #138496;
    --color-info-light: #d1ecf1;
    --color-info-bg: #d1ecf1;
    --color-info-border: #bee5eb;
    
    /* Extended Color Palette - Catppuccin-inspired (Latte flavor for light mode) */
    
    /* Rosewater & Flamingo */
    --color-rosewater: #dc8a78;
    --color-rosewater-hover: #d07a68;
    --color-rosewater-light: #f9ecea;
    --color-flamingo: #dd7878;
    --color-flamingo-hover: #d06868;
    --color-flamingo-light: #f9e9e9;
    
    /* Pink & Mauve (Purple) */
    --color-pink: #ea76cb;
    --color-pink-hover: #e060bf;
    --color-pink-light: #fbeaf6;
    --color-mauve: #8839ef;
    --color-mauve-hover: #7629df;
    --color-mauve-light: #f0e5fd;
    
    /* Maroon & Peach */
    --color-maroon: #e64553;
    --color-maroon-hover: #d63543;
    --color-maroon-light: #fce8ea;
    --color-peach: #fe640b;
    --color-peach-hover: #e85800;
    --color-peach-light: #fff0e5;
    
    /* Yellow & Teal */
    --color-yellow: #df8e1d;
    --color-yellow-hover: #c97f15;
    --color-yellow-light: #fbf3e4;
    --color-teal: #179299;
    --color-teal-hover: #128289;
    --color-teal-light: #e4f4f5;
    
    /* Sky & Sapphire */
    --color-sky: #04a5e5;
    --color-sky-hover: #0395d0;
    --color-sky-light: #e2f4fb;
    --color-sapphire: #209fb5;
    --color-sapphire-hover: #1a8fa3;
    --color-sapphire-light: #e4f3f7;
    
    /* Blue & Lavender */
    --color-blue: #1e66f5;
    --color-blue-hover: #1456e0;
    --color-blue-light: #e5edfe;
    --color-lavender: #7287fd;
    --color-lavender-hover: #5f76fc;
    --color-lavender-light: #eef1ff;
    
    /* Extended Gray Scale - Catppuccin Latte surfaces */
    --color-gray-50: #eff1f5;
    --color-gray-100: #e6e9ef;
    --color-gray-200: #dce0e8;
    --color-gray-300: #ccd0da;
    --color-gray-400: #bcc0cc;
    --color-gray-500: #9ca0b0;
    --color-gray-600: #7c7f93;
    --color-gray-700: #6c6f85;
    --color-gray-800: #5c5f77;
    --color-gray-900: #4c4f69;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Z-Index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;
}

/* Dark Mode */
[data-theme="dark"] {
    --color-primary: #00d68f;
    --color-primary-hover: #00e69c;
    --color-primary-light: #00ffb3;
    
    --color-secondary: #4a8af4;
    --color-secondary-hover: #6ba0f7;
    --color-secondary-light: #8bb8fa;
    
    --color-background: #0f172a;
    --color-surface: #1e293b;
    --color-surface-secondary: #162033;
    --color-surface-elevated: #334155;
    --color-border: #334155;
    --color-border-hover: #475569;

    --color-text-primary: #f1f5f9;
    --color-text-secondary: #cbd5e1;
    --color-text-tertiary: #94a3b8;
    --color-text-muted: #94a3b8;
    --color-text-inverse: #0f172a;
    
    --color-success: #4ade80;
    --color-success-hover: #22c55e;
    --color-success-light: #14532d;
    --color-success-bg: #14532d;
    --color-success-border: #166534;
    --color-warning: #fbbf24;
    --color-warning-hover: #f59e0b;
    --color-warning-light: #713f12;
    --color-warning-bg: #713f12;
    --color-warning-border: #854d0e;
    --color-error: #f87171;
    --color-error-hover: #ef4444;
    --color-error-light: #7f1d1d;
    --color-error-bg: #7f1d1d;
    --color-error-border: #991b1b;
    --color-info: #38bdf8;
    --color-info-hover: #0ea5e9;
    --color-info-light: #0c4a6e;
    --color-info-bg: #0c4a6e;
    --color-info-border: #075985;
    
    /* Extended Color Palette - Catppuccin-inspired (Mocha flavor for dark mode) */
    
    /* Rosewater & Flamingo */
    --color-rosewater: #f5e0dc;
    --color-rosewater-hover: #f8ebe8;
    --color-rosewater-light: #2d2520;
    --color-flamingo: #f2cdcd;
    --color-flamingo-hover: #f7dcdc;
    --color-flamingo-light: #2d2323;
    
    /* Pink & Mauve (Purple) */
    --color-pink: #f5c2e7;
    --color-pink-hover: #f9d4ef;
    --color-pink-light: #2d2029;
    --color-mauve: #cba6f7;
    --color-mauve-hover: #d9bdf9;
    --color-mauve-light: #262030;
    
    /* Maroon & Peach */
    --color-maroon: #eba0ac;
    --color-maroon-hover: #f1b5bf;
    --color-maroon-light: #2d2022;
    --color-peach: #fab387;
    --color-peach-hover: #fcc5a3;
    --color-peach-light: #2d2318;
    
    /* Yellow & Teal */
    --color-yellow: #f9e2af;
    --color-yellow-hover: #fbebc5;
    --color-yellow-light: #2d2a1c;
    --color-teal: #94e2d5;
    --color-teal-hover: #abe9de;
    --color-teal-light: #1a2d2a;
    
    /* Sky & Sapphire */
    --color-sky: #89dceb;
    --color-sky-hover: #a3e4f0;
    --color-sky-light: #182a2e;
    --color-sapphire: #74c7ec;
    --color-sapphire-hover: #92d4f1;
    --color-sapphire-light: #18272e;
    
    /* Blue & Lavender */
    --color-blue: #89b4fa;
    --color-blue-hover: #a4c5fb;
    --color-blue-light: #1a2230;
    --color-lavender: #b4befe;
    --color-lavender-hover: #c7cffe;
    --color-lavender-light: #1e2030;
    
    /* Extended Gray Scale - Catppuccin Mocha surfaces */
    --color-gray-50: #1e1e2e;
    --color-gray-100: #181825;
    --color-gray-200: #313244;
    --color-gray-300: #45475a;
    --color-gray-400: #585b70;
    --color-gray-500: #6c7086;
    --color-gray-600: #7f849c;
    --color-gray-700: #9399b2;
    --color-gray-800: #a6adc8;
    --color-gray-900: #cdd6f4;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--color-background);
    color: var(--color-text-primary);
    line-height: 1.5;
    margin: 0;
    padding: 0;
    transition: background-color var(--transition), color var(--transition);
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    color: var(--color-text-primary);
    font-weight: 600;
    line-height: 1.25;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-top: 0;
    margin-bottom: 1rem;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

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

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

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 169, 110, 0.3);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary Button */
.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-text-inverse);
    border-color: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: var(--color-text-inverse);
    text-decoration: none;
}

/* Secondary Button */
.btn-secondary {
    background-color: var(--color-secondary);
    color: var(--color-text-inverse);
    border-color: var(--color-secondary);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--color-secondary-hover);
    border-color: var(--color-secondary-hover);
    text-decoration: none;
}

/* Outline Button */
.btn-outline {
    background-color: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--color-primary);
    color: var(--color-text-inverse);
    text-decoration: none;
}

/* Ghost Button */
.btn-ghost {
    background-color: transparent;
    color: var(--color-text-primary);
    border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
    background-color: var(--color-surface-elevated);
    text-decoration: none;
}

/* Danger Button */
.btn-danger {
    background-color: var(--color-error);
    color: var(--color-text-inverse);
    border-color: var(--color-error);
}

.btn-danger:hover:not(:disabled) {
    background-color: #c82333;
    border-color: #c82333;
    text-decoration: none;
}

/* Success Button */
.btn-success {
    background-color: var(--color-success);
    color: var(--color-text-inverse);
    border-color: var(--color-success);
}

.btn-success:hover:not(:disabled) {
    background-color: var(--color-success-hover);
    border-color: var(--color-success-hover);
    text-decoration: none;
}

/* Warning Button */
.btn-warning {
    background-color: var(--color-warning);
    color: #333;
    border-color: var(--color-warning);
}

.btn-warning:hover:not(:disabled) {
    background-color: var(--color-warning-hover);
    border-color: var(--color-warning-hover);
    text-decoration: none;
}

/* Info Button */
.btn-info {
    background-color: var(--color-info);
    color: var(--color-text-inverse);
    border-color: var(--color-info);
}

.btn-info:hover:not(:disabled) {
    background-color: var(--color-info-hover);
    border-color: var(--color-info-hover);
    text-decoration: none;
}

/* Rosewater Button */
.btn-rosewater {
    background-color: var(--color-rosewater);
    color: var(--color-text-inverse);
    border-color: var(--color-rosewater);
}

.btn-rosewater:hover:not(:disabled) {
    background-color: var(--color-rosewater-hover);
    border-color: var(--color-rosewater-hover);
    text-decoration: none;
}

/* Flamingo Button */
.btn-flamingo {
    background-color: var(--color-flamingo);
    color: var(--color-text-inverse);
    border-color: var(--color-flamingo);
}

.btn-flamingo:hover:not(:disabled) {
    background-color: var(--color-flamingo-hover);
    border-color: var(--color-flamingo-hover);
    text-decoration: none;
}

/* Pink Button */
.btn-pink {
    background-color: var(--color-pink);
    color: var(--color-text-inverse);
    border-color: var(--color-pink);
}

.btn-pink:hover:not(:disabled) {
    background-color: var(--color-pink-hover);
    border-color: var(--color-pink-hover);
    text-decoration: none;
}

/* Mauve Button */
.btn-mauve {
    background-color: var(--color-mauve);
    color: var(--color-text-inverse);
    border-color: var(--color-mauve);
}

.btn-mauve:hover:not(:disabled) {
    background-color: var(--color-mauve-hover);
    border-color: var(--color-mauve-hover);
    text-decoration: none;
}

/* Maroon Button */
.btn-maroon {
    background-color: var(--color-maroon);
    color: var(--color-text-inverse);
    border-color: var(--color-maroon);
}

.btn-maroon:hover:not(:disabled) {
    background-color: var(--color-maroon-hover);
    border-color: var(--color-maroon-hover);
    text-decoration: none;
}

/* Peach Button */
.btn-peach {
    background-color: var(--color-peach);
    color: var(--color-text-inverse);
    border-color: var(--color-peach);
}

.btn-peach:hover:not(:disabled) {
    background-color: var(--color-peach-hover);
    border-color: var(--color-peach-hover);
    text-decoration: none;
}

/* Yellow Button */
.btn-yellow {
    background-color: var(--color-yellow);
    color: #333;
    border-color: var(--color-yellow);
}

.btn-yellow:hover:not(:disabled) {
    background-color: var(--color-yellow-hover);
    border-color: var(--color-yellow-hover);
    text-decoration: none;
}

/* Teal Button */
.btn-teal {
    background-color: var(--color-teal);
    color: var(--color-text-inverse);
    border-color: var(--color-teal);
}

.btn-teal:hover:not(:disabled) {
    background-color: var(--color-teal-hover);
    border-color: var(--color-teal-hover);
    text-decoration: none;
}

/* Sky Button */
.btn-sky {
    background-color: var(--color-sky);
    color: var(--color-text-inverse);
    border-color: var(--color-sky);
}

.btn-sky:hover:not(:disabled) {
    background-color: var(--color-sky-hover);
    border-color: var(--color-sky-hover);
    text-decoration: none;
}

/* Sapphire Button */
.btn-sapphire {
    background-color: var(--color-sapphire);
    color: var(--color-text-inverse);
    border-color: var(--color-sapphire);
}

.btn-sapphire:hover:not(:disabled) {
    background-color: var(--color-sapphire-hover);
    border-color: var(--color-sapphire-hover);
    text-decoration: none;
}

/* Blue Button */
.btn-blue {
    background-color: var(--color-blue);
    color: var(--color-text-inverse);
    border-color: var(--color-blue);
}

.btn-blue:hover:not(:disabled) {
    background-color: var(--color-blue-hover);
    border-color: var(--color-blue-hover);
    text-decoration: none;
}

/* Lavender Button */
.btn-lavender {
    background-color: var(--color-lavender);
    color: var(--color-text-inverse);
    border-color: var(--color-lavender);
}

.btn-lavender:hover:not(:disabled) {
    background-color: var(--color-lavender-hover);
    border-color: var(--color-lavender-hover);
    text-decoration: none;
}

/* Button Sizes */
.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-xl {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* Icon Button */
.btn-icon {
    padding: 0.5rem;
    line-height: 1;
}

.btn-icon.btn-sm {
    padding: 0.375rem;
}

.btn-icon.btn-lg {
    padding: 0.75rem;
}

/* Button Group */
.btn-group {
    display: inline-flex;
}

.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
}

.btn-group .btn:last-child {
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.btn-group .btn:not(:last-child) {
    border-right-width: 0;
}

/* Loading Button */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.btn-loading.btn-primary::after,
.btn-loading.btn-secondary::after,
.btn-loading.btn-danger::after,
.btn-loading.btn-success::after {
    border-color: var(--color-text-inverse);
    border-right-color: transparent;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Forms
   ========================================================================== */

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

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.form-label-required::after {
    content: " *";
    color: var(--color-error);
}

.form-input,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text-primary);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 169, 110, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--color-text-muted);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background-color: var(--color-background);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Input Sizes */
.form-input-sm {
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
}

.form-input-lg {
    padding: 0.875rem 1rem;
    font-size: 1rem;
}

/* Select */
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Textarea */
.form-textarea {
    min-height: 5rem;
    resize: vertical;
}

/* Checkbox and Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-check-input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.form-check-label {
    font-size: 0.875rem;
    color: var(--color-text-primary);
    cursor: pointer;
}

/* Switch Toggle */
.form-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.form-switch-input {
    position: relative;
    width: 2.5rem;
    height: 1.375rem;
    appearance: none;
    background-color: var(--color-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.form-switch-input::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.125rem;
    height: 1.125rem;
    background-color: var(--color-surface);
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.form-switch-input:checked {
    background-color: var(--color-primary);
}

.form-switch-input:checked::before {
    transform: translateX(1.125rem);
}

.form-switch-label {
    font-size: 0.875rem;
    color: var(--color-text-primary);
}

/* Validation States */
.form-input.is-valid,
.form-select.is-valid,
.form-textarea.is-valid {
    border-color: var(--color-success);
}

.form-input.is-valid:focus,
.form-select.is-valid:focus,
.form-textarea.is-valid:focus {
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.15);
}

.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
    border-color: var(--color-error);
}

.form-input.is-invalid:focus,
.form-select.is-invalid:focus,
.form-textarea.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

.form-error {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--color-error);
}

.form-hint {
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* Price input — currency-adornment wrapper.
   Renders a bordered number input with a non-interactive "$" prefix and
   right-aligned value. Uses secondary token for focus so currency inputs
   read as financial/informational rather than primary-brand fields. */
.price-input {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 9rem;
}

.price-input > .price-input-prefix {
    position: absolute;
    left: 0.75rem;
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    pointer-events: none;
}

.price-input > .form-input,
.price-input > input[type="number"] {
    width: 100%;
    padding-left: 1.75rem;
    text-align: right;
    font-weight: 500;
}

.price-input > .form-input:focus,
.price-input > input[type="number"]:focus {
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(20, 86, 184, 0.15);
}

/* Input Group */
.input-group {
    display: flex;
}

.input-group .form-input {
    flex: 1;
    border-radius: 0;
}

.input-group .form-input:first-child {
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
}

.input-group .form-input:last-child {
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
}

.input-group-text:first-child {
    border-right: none;
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
}

.input-group-text:last-child {
    border-left: none;
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.input-group .btn {
    border-radius: 0;
}

.input-group .btn:last-child {
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}

.card-clickable {
    cursor: pointer;
}

.card-clickable:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background-color: var(--color-background);
}

.card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background-color: var(--color-background);
}

/* Highlighted card — for selected/active-state cards (e.g. active pricing policy).
   Uses secondary-token tint so dark mode adapts automatically. */
.card-highlighted {
    border-color: var(--color-secondary);
    background-color: rgba(20, 86, 184, 0.06);
}

[data-theme="dark"] .card-highlighted {
    background-color: rgba(74, 138, 244, 0.12);
}

/* Stat Card */
.stat-card {
    padding: 1.25rem;
    text-align: center;
}

.stat-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.75rem;
    background-color: var(--color-primary);
    color: var(--color-text-inverse);
    border-radius: var(--radius-lg);
    font-size: 1.25rem;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.2;
}

.stat-card-label {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.stat-card-change {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.stat-card-change.positive {
    color: var(--color-success);
}

.stat-card-change.negative {
    color: var(--color-error);
}

/* Feature Card */
.feature-card {
    padding: 1.5rem;
}

.feature-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin-bottom: 1rem;
    background-color: rgba(0, 169, 110, 0.1);
    color: var(--color-primary);
    border-radius: var(--radius);
    font-size: 1.25rem;
}

[data-theme="dark"] .feature-card-icon {
    background-color: rgba(0, 214, 143, 0.15);
}

.feature-card-title {
    margin-bottom: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.feature-card-description {
    margin: 0;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 0.875rem;
}

.alert-icon {
    flex-shrink: 0;
    font-size: 1.125rem;
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-title {
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.alert-message {
    margin: 0;
    line-height: 1.5;
}

.alert-dismiss {
    flex-shrink: 0;
    padding: 0.25rem;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.alert-dismiss:hover {
    opacity: 1;
}

/* Alert Variants */
.alert-success {
    background-color: var(--color-success-bg);
    border-color: var(--color-success-border);
    color: var(--color-success);
}

[data-theme="dark"] .alert-success {
    color: var(--color-text-primary);
}

.alert-warning {
    background-color: var(--color-warning-bg);
    border-color: var(--color-warning-border);
    color: #856404;
}

[data-theme="dark"] .alert-warning {
    color: var(--color-text-primary);
}

.alert-error {
    background-color: var(--color-error-bg);
    border-color: var(--color-error-border);
    color: var(--color-error);
}

[data-theme="dark"] .alert-error {
    color: var(--color-text-primary);
}

.alert-info {
    background-color: var(--color-info-bg);
    border-color: var(--color-info-border);
    color: var(--color-info);
}

[data-theme="dark"] .alert-info {
    color: var(--color-text-primary);
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    border-radius: var(--radius-full);
}

.badge-primary {
    background-color: var(--color-primary);
    color: var(--color-text-inverse);
}

.badge-secondary {
    background-color: var(--color-secondary);
    color: var(--color-text-inverse);
}

.badge-success {
    background-color: var(--color-success);
    color: var(--color-text-inverse);
}

.badge-warning {
    background-color: var(--color-warning);
    color: #333;
}

.badge-error {
    background-color: var(--color-error);
    color: var(--color-text-inverse);
}

.badge-info {
    background-color: var(--color-info);
    color: var(--color-text-inverse);
}

.badge-outline {
    background-color: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

/* Neutral gray pill — for low-emphasis status (e.g. "Default" vs "Customized").
   Named -neutral to avoid colliding with app/scraper/templates/scraper/base.html's
   local .badge-muted definition. */
.badge-neutral {
    background-color: var(--color-surface-secondary);
    color: var(--color-text-secondary);
}

/* Extended Badge Colors - Catppuccin-inspired */
.badge-rosewater {
    background-color: var(--color-rosewater);
    color: var(--color-text-inverse);
}

.badge-flamingo {
    background-color: var(--color-flamingo);
    color: var(--color-text-inverse);
}

.badge-pink {
    background-color: var(--color-pink);
    color: var(--color-text-inverse);
}

.badge-mauve {
    background-color: var(--color-mauve);
    color: var(--color-text-inverse);
}

.badge-maroon {
    background-color: var(--color-maroon);
    color: var(--color-text-inverse);
}

.badge-peach {
    background-color: var(--color-peach);
    color: var(--color-text-inverse);
}

.badge-yellow {
    background-color: var(--color-yellow);
    color: #333;
}

.badge-teal {
    background-color: var(--color-teal);
    color: var(--color-text-inverse);
}

.badge-sky {
    background-color: var(--color-sky);
    color: var(--color-text-inverse);
}

.badge-sapphire {
    background-color: var(--color-sapphire);
    color: var(--color-text-inverse);
}

.badge-blue {
    background-color: var(--color-blue);
    color: var(--color-text-inverse);
}

.badge-lavender {
    background-color: var(--color-lavender);
    color: var(--color-text-inverse);
}

/* Light Badge Variants (Soft backgrounds) */
.badge-primary-light {
    background-color: rgba(0, 169, 110, 0.15);
    color: var(--color-primary);
}

.badge-secondary-light {
    background-color: rgba(20, 86, 184, 0.15);
    color: var(--color-secondary);
}

.badge-success-light {
    background-color: var(--color-success-light);
    color: var(--color-success);
}

.badge-warning-light {
    background-color: var(--color-warning-light);
    color: #856404;
}

[data-theme="dark"] .badge-warning-light {
    color: var(--color-warning);
}

.badge-error-light {
    background-color: var(--color-error-light);
    color: var(--color-error);
}

.badge-info-light {
    background-color: var(--color-info-light);
    color: var(--color-info);
}

.badge-rosewater-light {
    background-color: var(--color-rosewater-light);
    color: var(--color-rosewater);
}

.badge-flamingo-light {
    background-color: var(--color-flamingo-light);
    color: var(--color-flamingo);
}

.badge-pink-light {
    background-color: var(--color-pink-light);
    color: var(--color-pink);
}

.badge-mauve-light {
    background-color: var(--color-mauve-light);
    color: var(--color-mauve);
}

.badge-maroon-light {
    background-color: var(--color-maroon-light);
    color: var(--color-maroon);
}

.badge-peach-light {
    background-color: var(--color-peach-light);
    color: var(--color-peach);
}

.badge-yellow-light {
    background-color: var(--color-yellow-light);
    color: var(--color-yellow);
}

.badge-teal-light {
    background-color: var(--color-teal-light);
    color: var(--color-teal);
}

.badge-sky-light {
    background-color: var(--color-sky-light);
    color: var(--color-sky);
}

.badge-sapphire-light {
    background-color: var(--color-sapphire-light);
    color: var(--color-sapphire);
}

.badge-blue-light {
    background-color: var(--color-blue-light);
    color: var(--color-blue);
}

.badge-lavender-light {
    background-color: var(--color-lavender-light);
    color: var(--color-lavender);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-container {
    width: 100%;
    overflow-x: auto;
}

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

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

.table th {
    font-weight: 600;
    color: var(--color-text-secondary);
    background-color: var(--color-background);
    white-space: nowrap;
}

.table tbody tr {
    transition: background-color var(--transition-fast);
}

.table-hover tbody tr:hover {
    background-color: var(--color-background);
}

.table-striped tbody tr:nth-child(even) {
    background-color: var(--color-background);
}

/* Sortable Table Headers */
.table-sortable th {
    cursor: pointer;
    user-select: none;
}

.table-sortable th:hover {
    color: var(--color-primary);
}

.sort-icon {
    margin-left: 0.25rem;
    opacity: 0.5;
}

.sort-icon.active {
    opacity: 1;
    color: var(--color-primary);
}

/* Table Empty State */
.table-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--color-text-muted);
}

.table-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

/* ==========================================================================
   Navigation - Tabs
   ========================================================================== */

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
}

.tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: -1px;
}

.tab:hover {
    color: var(--color-text-primary);
}

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Tab Panels (show/hide for tabbed navigation) */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Pills */
.pills {
    display: flex;
    gap: 0.5rem;
}

.pill {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    background-color: transparent;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pill:hover {
    background-color: var(--color-background);
    color: var(--color-text-primary);
}

.pill.active {
    background-color: var(--color-primary);
    color: var(--color-text-inverse);
}

/* ==========================================================================
   Navigation - Breadcrumbs
   ========================================================================== */

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.breadcrumb-item {
    color: var(--color-text-secondary);
}

.breadcrumb-item a {
    color: var(--color-text-secondary);
}

.breadcrumb-item a:hover {
    color: var(--color-primary);
}

.breadcrumb-item.active {
    color: var(--color-text-primary);
    font-weight: 500;
}

.breadcrumb-separator {
    color: var(--color-text-muted);
}

/* ==========================================================================
   Navigation - Pagination
   ========================================================================== */

.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.page-item {
    display: inline-flex;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.page-link:hover {
    background-color: var(--color-background);
    border-color: var(--color-border-hover);
    color: var(--color-text-primary);
    text-decoration: none;
}

.page-item.active .page-link {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-text-inverse);
}

.page-item.disabled .page-link {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    transition: opacity var(--transition);
}

.modal-backdrop.show {
    opacity: 1;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: var(--z-modal);
    width: 100%;
    max-width: 32rem;
    max-height: 90vh;
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    transition: all var(--transition);
    overflow: hidden;
}

.modal.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.modal-sm {
    max-width: 24rem;
}

.modal-lg {
    max-width: 48rem;
}

.modal-xl {
    max-width: 64rem;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.modal-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    padding: 0.25rem;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--color-text-primary);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    max-height: calc(90vh - 8rem);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background-color: var(--color-background);
}

/* ==========================================================================
   Tooltips
   ========================================================================== */

/*
 * CSS-only tooltips. Place a .tooltip element inside a positioned parent.
 * The parent should have `position: relative` (or use .tooltip-trigger).
 *
 * Usage:
 *   <div style="position: relative;">
 *       Hover me
 *       <div class="tooltip">Tooltip text</div>
 *   </div>
 *
 * Or with the trigger helper:
 *   <div class="tooltip-trigger">
 *       Hover me
 *       <div class="tooltip">Tooltip text</div>
 *   </div>
 *
 * Position variants: .tooltip-top (default), .tooltip-bottom, .tooltip-left, .tooltip-right
 */

.tooltip-trigger {
    position: relative;
    display: inline-block;
}

.tooltip {
    position: absolute;
    z-index: var(--z-tooltip);
    background-color: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    box-shadow: var(--shadow-md);
    font-size: 0.8125rem;
    color: var(--color-text-primary);
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    max-width: 20rem;
}

/* Default position: top (above the parent) */
.tooltip,
.tooltip-top {
    bottom: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
}

/* Bottom position */
.tooltip-bottom {
    top: calc(100% + 0.5rem);
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
}

/* Left position */
.tooltip-left {
    right: calc(100% + 0.5rem);
    top: 50%;
    bottom: auto;
    left: auto;
    transform: translateY(-50%);
}

/* Right position */
.tooltip-right {
    left: calc(100% + 0.5rem);
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
}

/* Show on parent hover or focus */
.tooltip-trigger:hover > .tooltip,
.tooltip-trigger:focus-within > .tooltip,
*:hover > .tooltip,
*:focus > .tooltip {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

/* Spinner */
.spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.spinner-sm {
    width: 1rem;
    height: 1rem;
    border-width: 1.5px;
}

.spinner-lg {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 3px;
}

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-border) 25%,
        var(--color-background) 50%,
        var(--color-border) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.skeleton-image {
    height: 12rem;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Progress Bar */
.progress {
    width: 100%;
    height: 0.5rem;
    background-color: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--color-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition);
}

.progress-bar-animated {
    animation: progress-stripes 1s linear infinite;
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
}

@keyframes progress-stripes {
    0% { background-position: 1rem 0; }
    100% { background-position: 0 0; }
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background-color: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 20rem;
    max-width: 28rem;
    pointer-events: auto;
    animation: toast-in 0.3s ease-out;
}

.toast.toast-out {
    animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1.25rem;
}

.toast-success .toast-icon {
    color: var(--color-success);
}

.toast-warning .toast-icon {
    color: var(--color-warning);
}

.toast-error .toast-icon {
    color: var(--color-error);
}

.toast-info .toast-icon {
    color: var(--color-info);
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.toast-message {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
}

.toast-close {
    flex-shrink: 0;
    padding: 0.125rem;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--color-text-primary);
}

/* ==========================================================================
   Navbar
   ========================================================================== */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 4rem;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text-primary);
    text-decoration: none;
}

.navbar-brand:hover {
    text-decoration: none;
    color: var(--color-text-primary);
}

.navbar-logo {
    height: 2rem;
    width: auto;
}

/* Theme-aware logo visibility */
.logo-dark {
    display: none;
}

[data-theme="dark"] .logo-light {
    display: none;
}

[data-theme="dark"] .logo-dark {
    display: inline;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.navbar-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.navbar-link:hover {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    text-decoration: none;
}

.navbar-link.active {
    background-color: var(--color-primary);
    color: var(--color-text-inverse);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
    width: 16rem;
    height: calc(100vh - 4rem);
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    position: fixed;
    top: 4rem;
    left: 0;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

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

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.5rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.sidebar-link:hover {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    text-decoration: none;
}

.sidebar-link.active {
    background-color: rgba(0, 169, 110, 0.1);
    color: var(--color-primary);
    font-weight: 500;
}

[data-theme="dark"] .sidebar-link.active {
    background-color: rgba(0, 214, 143, 0.15);
}

.sidebar-icon {
    width: 1.25rem;
    text-align: center;
    opacity: 0.7;
}

/* ==========================================================================
   Layout Utilities
   ========================================================================== */

.container {
    width: 100%;
    max-width: 80rem;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.container-sm {
    max-width: 48rem;
}

.container-lg {
    max-width: 96rem;
}

.container-fluid {
    max-width: none;
}

.main-content {
    margin-left: 16rem;
    padding: 1.5rem;
    min-height: calc(100vh - 4rem);
}

.main-content-full {
    margin-left: 0;
}

/* Grid */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 767px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
    
    /* Sidebar now uses mobile drawer behavior - see Responsive Sidebar section */
}

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

/* Spacing utilities */
.m-0 { margin: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.p-0 { padding: 0; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

/* Text utilities */
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Visibility */
.hidden { display: none; }
.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;
}

/* ==========================================================================
   Theme Toggle
   ========================================================================== */

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background-color: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    border-color: var(--color-border-hover);
}

.theme-toggle-icon {
    width: 1.25rem;
    height: 1.25rem;
}

/* Show/hide icons based on theme */
.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

/* ==========================================================================
   Code Blocks (for documentation)
   ========================================================================== */

.code-block {
    position: relative;
    background-color: #1e293b;
    border-radius: var(--radius);
    overflow: hidden;
}

[data-theme="dark"] .code-block {
    background-color: #0f172a;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background-color: rgba(0, 0, 0, 0.2);
    font-size: 0.75rem;
    color: #94a3b8;
}

.code-block-copy {
    padding: 0.25rem 0.5rem;
    background-color: transparent;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.code-block-copy:hover {
    background-color: #334155;
    color: #e2e8f0;
}

.code-block pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: #e2e8f0;
}

.code-block code {
    font-family: inherit;
}

/* Inline code */
code:not([class]) {
    padding: 0.125rem 0.375rem;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.875em;
    color: var(--color-error);
}

[data-theme="dark"] code:not([class]) {
    background-color: var(--color-surface-elevated);
}

/* ==========================================================================
   Page Layout Components
   
   Generic page structure classes for sidebar + main content layouts.
   Used by documentation pages, tool dashboards, and similar interfaces.
   
   IMPORTANT: Keep these names generic (page-*). Do NOT use app-specific
   prefixes like docs-* or tool-*. See app/templates/tetra_ui/README.md.
   ========================================================================== */

.page-section {
    margin-bottom: 3rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid var(--color-border);
}

.page-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.page-section-title {
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--color-primary);
}

.page-subsection {
    margin-bottom: 2rem;
}

.page-subsection-title {
    margin-bottom: 1rem;
    color: var(--color-text-secondary);
}

.page-example {
    padding: 1.5rem;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}

.page-example-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.color-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.color-swatch-preview {
    width: 4rem;
    height: 4rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.color-swatch-name {
    font-size: 0.75rem;
    font-weight: 500;
}

.color-swatch-value {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    font-family: ui-monospace, SFMono-Regular, monospace;
}

/* ==========================================================================
   HTMX Indicators
   ========================================================================== */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Disable element during request */
.htmx-request {
    pointer-events: none;
    opacity: 0.7;
}

/* ==========================================================================
   Chart Containers
   ========================================================================== */

.chart-container {
    position: relative;
    width: 100%;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-text-primary);
}

.chart-wrapper {
    position: relative;
    height: 300px;
}

.chart-wrapper-sm {
    height: 200px;
}

.chart-wrapper-lg {
    height: 400px;
}

/* ==========================================================================
   Page Sidebar (fixed navigation for content pages)
   ========================================================================== */

.page-layout {
    display: flex;
    min-height: calc(100vh - 4rem);
}

.page-sidebar {
    width: 16rem;
    flex-shrink: 0;
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    position: fixed;
    top: 4rem;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 1.5rem 0;
    z-index: var(--z-sticky);
}

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

.page-sidebar-section {
    margin-bottom: 1.5rem;
}

.page-sidebar-title {
    padding: 0.5rem 1.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
}

.page-sidebar-link {
    display: block;
    padding: 0.375rem 1.25rem;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    border-left: 2px solid transparent;
}

.page-sidebar-link:hover {
    color: var(--color-text-primary);
    background-color: var(--color-background);
    text-decoration: none;
}

.page-sidebar-link.active {
    color: var(--color-primary);
    border-left-color: var(--color-primary);
    background-color: rgba(0, 169, 110, 0.08);
    font-weight: 500;
}

[data-theme="dark"] .page-sidebar-link.active {
    background-color: rgba(0, 214, 143, 0.1);
}

.page-sidebar-sublink {
    padding-left: 2rem;
    font-size: 0.75rem;
}

.page-main {
    flex: 1;
    margin-left: 16rem;
    padding: 2rem;
    max-width: calc(100% - 16rem);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 4rem);
}

.page-main .container {
    max-width: 56rem;
    flex: 1;
}

.page-main .page-footer {
    margin-left: -2rem;
    margin-right: -2rem;
    margin-bottom: -2rem;
}

/* Page Header */
.page-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--color-border);
}

.page-header h1 {
    margin-bottom: 0.75rem;
}

.page-header-description {
    font-size: 1.125rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* Layout Preview Cards */
.layout-preview {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: var(--color-surface);
}

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

.layout-preview-title {
    font-size: 0.875rem;
    font-weight: 600;
}

.layout-preview-frame {
    position: relative;
    height: 280px;
    background-color: var(--color-background);
    overflow: hidden;
}

.layout-preview-mini {
    transform: scale(0.5);
    transform-origin: top left;
    width: 200%;
    height: 200%;
    pointer-events: none;
}

/* Layout Diagram */
.layout-diagram {
    display: flex;
    flex-direction: column;
    height: 100%;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.layout-diagram-navbar {
    height: 2rem;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
}

.layout-diagram-body {
    display: flex;
    flex: 1;
}

.layout-diagram-sidebar {
    width: 4rem;
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 0.5rem;
}

.layout-diagram-content {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.layout-diagram-block {
    background-color: var(--color-border);
    border-radius: var(--radius-sm);
    height: 0.75rem;
}

.layout-diagram-block.wide {
    width: 60%;
}

.layout-diagram-block.medium {
    width: 40%;
}

.layout-diagram-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

/* File Tree */
.file-tree {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    line-height: 1.8;
    color: var(--color-text-secondary);
}

.file-tree-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-tree-icon {
    color: var(--color-text-muted);
}

.file-tree-folder {
    color: var(--color-secondary);
}

.file-tree-file {
    color: var(--color-text-primary);
}

.file-tree-new {
    color: var(--color-primary);
    font-weight: 500;
}

.file-tree-indent-1 { padding-left: 1.25rem; }
.file-tree-indent-2 { padding-left: 2.5rem; }
.file-tree-indent-3 { padding-left: 3.75rem; }

/* ==========================================================================
   Tree View Component
   Interactive expandable/collapsible tree (file browser style)
   ========================================================================== */

.tree-view {
    font-size: 0.875rem;
}

.tree-item {
    /* Container for tree row + children */
}

.tree-item-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background-color var(--transition-fast);
    gap: 0.25rem;
}

.tree-item-row:hover {
    background-color: var(--color-background);
}

.tree-item-row.selected {
    background-color: color-mix(in srgb, var(--color-primary) 15%, transparent);
}

.tree-item-toggle {
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
}

.tree-item-toggle:hover {
    background-color: var(--color-border);
}

.tree-item-toggle svg {
    transition: transform var(--transition-fast);
}

.tree-item.open > .tree-item-row .tree-item-toggle svg {
    transform: rotate(90deg);
}

.tree-item-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    margin-right: 0.375rem;
    color: var(--color-text-muted);
}

.tree-item-label {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-item-badge {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.tree-item-actions {
    opacity: 0;
    transition: opacity var(--transition-fast);
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.tree-item-row:hover .tree-item-actions {
    opacity: 1;
}

.tree-item-children {
    display: none;
    padding-left: 1.25rem;
    border-left: 1px solid var(--color-border);
    margin-left: 0.625rem;
}

.tree-item.open > .tree-item-children {
    display: block;
}

/* Tree view empty state */
.tree-view-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--color-text-muted);
}

/* ==========================================================================
   Split Panel Layout
   Two-column layout with adjustable proportions
   ========================================================================== */

.split-panel {
    display: flex;
    min-height: 400px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background-color: var(--color-surface);
    overflow: hidden;
}

.split-panel-left {
    width: 40%;
    min-width: 200px;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    background-color: var(--color-surface);
}

.split-panel-right {
    width: 60%;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    background-color: var(--color-surface);
}

.split-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background-color: var(--color-background);
    flex-shrink: 0;
}

.split-panel-header h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.split-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.split-panel-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
    background-color: var(--color-background);
    flex-shrink: 0;
}

/* Selection indicator for split panel */
.selection-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.selection-indicator-label {
    color: var(--color-text-secondary);
}

.selection-indicator-value {
    font-weight: 500;
    color: var(--color-text-primary);
}

.selection-indicator-clear {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.125rem 0.375rem;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.selection-indicator-clear:hover {
    background-color: var(--color-border);
    color: var(--color-text-primary);
}

/* Responsive: Stack on mobile */
@media (max-width: 768px) {
    .split-panel {
        flex-direction: column;
        min-height: auto;
    }
    
    .split-panel-left,
    .split-panel-right {
        width: 100%;
        min-width: auto;
    }
    
    .split-panel-left {
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        max-height: 300px;
    }
    
    .split-panel-right {
        min-height: 400px;
    }
}

/* Step List */
.step-list {
    counter-reset: step-counter;
    list-style: none;
    padding: 0;
    margin: 0;
}

.step-item {
    counter-increment: step-counter;
    position: relative;
    padding-left: 3rem;
    padding-bottom: 2rem;
    border-left: 2px solid var(--color-border);
    margin-left: 1rem;
}

.step-item:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.step-item::before {
    content: counter(step-counter);
    position: absolute;
    left: -1rem;
    top: 0;
    width: 2rem;
    height: 2rem;
    background-color: var(--color-primary);
    color: var(--color-text-inverse);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.step-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.step-description {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Responsive Page Layout */
@media (max-width: 1024px) {
    .page-sidebar {
        width: 14rem;
    }
    
    .page-main {
        margin-left: 14rem;
        max-width: calc(100% - 14rem);
    }
}

@media (max-width: 767px) {
    .page-sidebar {
        display: none;
    }
    
    .page-main {
        margin-left: 0;
        max-width: 100%;
        padding: 1rem;
    }
    
    .page-main .page-footer {
        margin-left: -1rem;
        margin-right: -1rem;
        margin-bottom: -1rem;
    }
}

/* ==========================================================================
   Main Wrapper & Page Footer
   ========================================================================== */

.main-wrapper {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 4rem); /* Account for navbar height */
}
footer {
    margin-top: 15px;
}
.main-wrapper > .main-content,
.main-wrapper > main {
    flex: 1;
}

.page-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    background-color: var(--color-surface);
}

.page-footer a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.page-footer a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

.page-footer .version {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.7rem;
    padding: 0.125rem 0.375rem;
    background-color: var(--color-background);
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Responsive Breakpoints & Mobile Navigation
   ========================================================================== */

/*
 * Breakpoint Reference:
 * - sm: 640px  (large phones)
 * - md: 768px  (tablets)
 * - lg: 1024px (small desktops)
 * - xl: 1280px (large desktops)
 */

/* Mobile Navigation Toggle Button */
.mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    background: none;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    border-radius: var(--radius);
    transition: background-color var(--transition-fast);
}

.mobile-nav-toggle:hover {
    background-color: var(--color-background);
}

.mobile-nav-toggle svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* Mobile Drawer */
.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    z-index: calc(var(--z-modal) + 10);
    transform: translateX(-100%);
    transition: transform var(--transition);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.mobile-drawer.open {
    transform: translateX(0);
}

.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.mobile-drawer-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text-primary);
    text-decoration: none;
}

.mobile-drawer-brand img {
    height: 1.5rem;
    width: auto;
}

.mobile-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.mobile-drawer-close:hover {
    background-color: var(--color-background);
    color: var(--color-text-primary);
}

.mobile-drawer-close svg {
    width: 1.25rem;
    height: 1.25rem;
}

.mobile-drawer-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.mobile-drawer-section {
    margin-bottom: 1.5rem;
}

.mobile-drawer-title {
    padding: 0.5rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.mobile-drawer-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.mobile-drawer-link:hover {
    background-color: var(--color-background);
    color: var(--color-text-primary);
    text-decoration: none;
}

.mobile-drawer-link.active {
    background-color: rgba(0, 169, 110, 0.1);
    color: var(--color-primary);
    font-weight: 500;
}

[data-theme="dark"] .mobile-drawer-link.active {
    background-color: rgba(0, 214, 143, 0.15);
}

.mobile-drawer-link svg {
    width: 1.25rem;
    height: 1.25rem;
    opacity: 0.7;
}

.mobile-drawer-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

/* Mobile Drawer Backdrop */
.mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-modal) + 5);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
}

.mobile-drawer-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Responsive Visibility Utilities
   ========================================================================== */

/* Hide on specific breakpoints */
@media (max-width: 639px) {
    .hidden-sm { display: none !important; }
}

@media (min-width: 640px) and (max-width: 767px) {
    .hidden-sm-only { display: none !important; }
}

@media (max-width: 767px) {
    .hidden-mobile { display: none !important; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hidden-tablet-only { display: none !important; }
}

@media (max-width: 1023px) {
    .hidden-tablet { display: none !important; }
}

@media (min-width: 1024px) {
    .hidden-desktop { display: none !important; }
}

/* Show only on specific breakpoints */
@media (min-width: 640px) {
    .visible-mobile-only { display: none !important; }
}

@media (max-width: 639px) {
    .visible-mobile-only { display: block !important; }
}

@media (min-width: 768px) {
    .visible-sm-only { display: none !important; }
}

@media (max-width: 767px) {
    .visible-desktop-only { display: none !important; }
}

@media (min-width: 1024px) {
    .visible-tablet-down { display: none !important; }
}

/* Flex variants */
@media (max-width: 767px) {
    .flex-mobile-only { display: flex !important; }
}

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

/* ==========================================================================
   Responsive Grid System
   ========================================================================== */

/* Small screens (640px+) */
@media (min-width: 640px) {
    .sm\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sm\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Medium screens (768px+) */
@media (min-width: 768px) {
    .md\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Large screens (1024px+) */
@media (min-width: 1024px) {
    .lg\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Extra large screens (1280px+) */
@media (min-width: 1280px) {
    .xl\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .xl\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .xl\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .xl\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .xl\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .xl\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ==========================================================================
   Responsive Tables
   ========================================================================== */

/* Option 1: Horizontal scroll (default) - already in .table-container */

/* Option 2: Stacked cards on mobile */
.table-stack {
    width: 100%;
}

@media (max-width: 767px) {
    .table-stack thead {
        display: none;
    }
    
    .table-stack tbody {
        display: block;
    }
    
    .table-stack tr {
        display: block;
        padding: 1rem;
        margin-bottom: 0.75rem;
        background-color: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
    }
    
    .table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid var(--color-border);
        text-align: right;
    }
    
    .table-stack td:last-child {
        border-bottom: none;
    }
    
    .table-stack td::before {
        content: attr(data-label);
        font-weight: 500;
        color: var(--color-text-primary);
        text-align: left;
        flex-shrink: 0;
        margin-right: 1rem;
    }
    
    .table-stack td:has(.btn),
    .table-stack td.table-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .table-stack td.table-actions::before {
        display: none;
    }
}

/* ==========================================================================
   Responsive Modals
   ========================================================================== */

@media (max-width: 639px) {
    .modal {
        max-width: calc(100% - 2rem);
        max-height: calc(100vh - 2rem);
        margin: 1rem;
    }
    
    .modal-sm,
    .modal-lg,
    .modal-xl {
        max-width: calc(100% - 2rem);
    }
    
    .modal-header {
        padding: 0.875rem 1rem;
    }
    
    .modal-title {
        font-size: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 10rem);
    }
    
    .modal-footer {
        padding: 0.875rem 1rem;
        flex-wrap: wrap;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 0;
    }
    
    /* Full-screen modal option for mobile */
    .modal-fullscreen-mobile {
        max-width: 100%;
        max-height: 100%;
        width: 100vw;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .modal-fullscreen-mobile .modal-body {
        max-height: calc(100vh - 8rem);
    }
}

/* ==========================================================================
   Responsive Tabs & Pills
   ========================================================================== */

@media (max-width: 767px) {
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab {
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .pills {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        flex-wrap: nowrap;
    }
    
    .pills::-webkit-scrollbar {
        display: none;
    }
    
    .pill {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* Scrollable tabs with fade indicators */
.tabs-scrollable {
    position: relative;
}

.tabs-scrollable::before,
.tabs-scrollable::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2rem;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.tabs-scrollable::before {
    left: 0;
    background: linear-gradient(to right, var(--color-surface), transparent);
}

.tabs-scrollable::after {
    right: 0;
    background: linear-gradient(to left, var(--color-surface), transparent);
}

.tabs-scrollable.scroll-left::before,
.tabs-scrollable.scroll-right::after {
    opacity: 1;
}

/* ==========================================================================
   Responsive Toast Notifications
   ========================================================================== */

@media (max-width: 639px) {
    .toast-container {
        top: auto;
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
    
    .toast {
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
}

/* ==========================================================================
   Responsive Pagination
   ========================================================================== */

@media (max-width: 639px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination .page-item:not(.page-prev):not(.page-next):not(.page-item.active) {
        display: none;
    }
    
    .pagination .page-item.page-prev,
    .pagination .page-item.page-next,
    .pagination .page-item.active {
        display: inline-flex;
    }
    
    /* Show ellipsis indicators */
    .pagination .page-ellipsis {
        display: inline-flex;
    }
}

/* Compact pagination for mobile */
.pagination-compact {
    gap: 0.125rem;
}

.pagination-compact .page-link {
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.25rem;
    font-size: 0.75rem;
}

/* ==========================================================================
   Responsive Breadcrumbs
   ========================================================================== */

@media (max-width: 639px) {
    .breadcrumbs {
        font-size: 0.8125rem;
        flex-wrap: wrap;
    }
    
    .breadcrumbs .breadcrumb-item:not(:first-child):not(:last-child) {
        display: none;
    }
    
    .breadcrumbs .breadcrumb-separator:not(:first-of-type):not(:last-of-type) {
        display: none;
    }
    
    /* Show ellipsis for collapsed middle items */
    .breadcrumbs-collapse .breadcrumb-ellipsis {
        display: inline;
    }
}

.breadcrumb-ellipsis {
    display: none;
    color: var(--color-text-muted);
}

/* ==========================================================================
   Responsive Typography
   ========================================================================== */

@media (max-width: 639px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.125rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9375rem; }
}

/* ==========================================================================
   Responsive Spacing
   ========================================================================== */

@media (max-width: 639px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .p-4 { padding: 0.75rem; }
    .p-6 { padding: 1rem; }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 0.875rem 1rem;
    }
}

/* ==========================================================================
   Responsive Button Groups
   ========================================================================== */

@media (max-width: 639px) {
    .btn-group-mobile-stack {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group-mobile-stack .btn {
        border-radius: 0;
        width: 100%;
    }
    
    .btn-group-mobile-stack .btn:first-child {
        border-radius: var(--radius) var(--radius) 0 0;
    }
    
    .btn-group-mobile-stack .btn:last-child {
        border-radius: 0 0 var(--radius) var(--radius);
    }
    
    .btn-group-mobile-stack .btn:not(:last-child) {
        border-right-width: 1px;
        border-bottom-width: 0;
    }
}

/* ==========================================================================
   Responsive Forms
   ========================================================================== */

@media (max-width: 639px) {
    .form-row {
        flex-direction: column;
    }
    
    .form-row > .form-group {
        flex: none;
        width: 100%;
    }
    
    /* Stack form actions on mobile */
    .form-actions-stack {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .form-actions-stack .btn {
        width: 100%;
    }
}

/* Form row layout helper */
.form-row {
    display: flex;
    gap: 1rem;
}

.form-row > .form-group {
    flex: 1;
}

/* ==========================================================================
   Responsive Navbar
   ========================================================================== */

@media (max-width: 767px) {
    .navbar {
        padding: 0 0.75rem;
        height: 3.5rem;
    }
    
    .navbar-brand {
        font-size: 1rem;
        gap: 0.5rem;
    }
    
    .navbar-logo {
        display: none;  /* Logo appears in mobile drawer instead */
    }
    
    .navbar-nav {
        display: none;
    }
    
    .navbar-actions .hidden-mobile {
        display: none;
    }
    
    .mobile-nav-toggle {
        display: flex;
    }
}

/* ==========================================================================
   Responsive Sidebar (Hidden on Mobile - Use Mobile Drawer Instead)
   ========================================================================== */

@media (max-width: 767px) {
    .sidebar {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .main-content-full {
        padding: 1rem;
    }
}

/* ==========================================================================
   Responsive Cards
   ========================================================================== */

@media (max-width: 639px) {
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card-value {
        font-size: 1.5rem;
    }
    
    .feature-card {
        padding: 1rem;
    }
}

/* ==========================================================================
   Responsive Main Content
   ========================================================================== */

@media (max-width: 767px) {
    .main-wrapper {
        min-height: calc(100vh - 3.5rem);  /* Account for shorter mobile navbar */
    }
    
    .main-content {
        padding: 1rem;
    }
}

/* ==========================================================================
   Touch-friendly Enhancements
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 2.75rem;
    }
    
    .btn-sm {
        min-height: 2.25rem;
    }
    
    .form-input,
    .form-select,
    .form-textarea {
        min-height: 2.75rem;
    }
    
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }
    
    /* Remove hover states on touch devices */
    .btn:hover:not(:disabled) {
        transform: none;
    }
    
    /* Add active states for feedback */
    .btn:active:not(:disabled) {
        transform: scale(0.98);
    }
    
    .sidebar-link:active,
    .mobile-drawer-link:active {
        background-color: var(--color-background);
    }
}

/* ==========================================================================
   Chat Mention Styles
   ========================================================================== */

.mention {
    background-color: rgba(0, 169, 110, 0.1);
    color: var(--color-primary);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

[data-theme="dark"] .mention {
    background-color: rgba(0, 214, 143, 0.15);
    color: var(--color-primary);
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .navbar,
    .sidebar,
    .theme-toggle,
    .toast-container {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    body {
        background-color: white;
        color: black;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ==========================================================================
   Flow Diagram Styles (Project Manager Admin)
   ========================================================================== */

.flow-diagram-wrapper {
    width: 100%;
}

.flow-diagram {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.flow-diagram-svg {
    display: block;
}

/* Node styling */
.flow-node-rect {
    transition: all 0.2s ease;
}

.flow-node:hover .flow-node-rect {
    filter: brightness(0.95);
}

.flow-node-label {
    font-family: inherit;
    pointer-events: none;
}

/* Edge styling */
.flow-edge {
    transition: stroke 0.2s ease;
}

.flow-edge-inactive {
    stroke-dasharray: 4, 4;
    opacity: 0.6;
}

/* Entry marker */
.flow-entry-marker {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* Terminal indicator */
.flow-terminal-indicator {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* Entry point indicator */
.flow-entry-indicator {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* Inactive node styling */
.flow-node-inactive .flow-node-rect {
    opacity: 0.5;
}

.flow-node-inactive .flow-node-label {
    opacity: 0.7;
}

/* Dark mode adjustments */
[data-theme="dark"] .flow-node-rect {
    filter: brightness(1.1);
}

[data-theme="dark"] .flow-edge {
    opacity: 0.9;
}

/* Flow diagram legend */
.flow-diagram-legend {
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
}

/* ==========================================================================
   Pipeline — Salesforce-style horizontal status bar
   ========================================================================== */

.pipeline {
    display: flex;
    align-items: stretch;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: visible;
}

.pipeline-step {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
    min-width: 0;
}

.pipeline-step-body {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    flex: 1;
    min-width: 0;
}

/* Chevron separator between steps */
.pipeline-chevron {
    flex-shrink: 0;
    color: var(--color-border);
    display: flex;
    align-items: center;
}

/* Step indicator (dot / checkmark container) */
.pipeline-step-indicator {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pipeline-step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-border);
}

.pipeline-step-dot--active {
    background: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 25%, transparent);
}

.pipeline-step--completed .pipeline-step-indicator {
    color: var(--color-success);
}

.pipeline-step--active .pipeline-step-indicator {
    color: var(--color-primary);
}

/* Step content: category label + current value */
.pipeline-step-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.pipeline-step-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pipeline-step-value {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pipeline-step--active .pipeline-step-value {
    color: var(--color-primary);
    font-weight: 600;
}

.pipeline-step--completed .pipeline-step-value {
    color: var(--color-success);
}

.pipeline-step--pending .pipeline-step-value {
    color: var(--color-text-muted);
    font-style: italic;
}

/* Dropdown trigger button */
.pipeline-step-action {
    flex-shrink: 0;
}

.pipeline-step-trigger {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.pipeline-step-trigger:hover {
    background: var(--color-background);
    color: var(--color-text-primary);
    border-color: var(--color-text-muted);
}

/* Status transition dropdown */
.pipeline-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 4px;
    overflow: hidden;
}

.pipeline-dropdown-header {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.pipeline-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--color-text-primary);
    text-align: left;
    transition: background 0.1s;
}

.pipeline-dropdown-item:hover {
    background: var(--color-background);
}

.pipeline-dropdown-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    flex-shrink: 0;
}

.pipeline-dropdown-dot--closing {
    background: var(--color-success);
}

/* ==========================================================================
   Markdown Documentation Layout
   ========================================================================== */

/* Documentation page layout - sidebar TOC + main content */
.docs-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
}

/* Table of Contents Sidebar */
.docs-toc {
    display: block;
    position: sticky;
    top: 4rem;
    align-self: start;
    max-height: calc(100vh - 5rem);
}

.docs-toc-inner {
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    padding: 1rem;
    background: var(--color-surface);
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.docs-toc-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

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

.docs-toc .toc ul {
    list-style: none;
    padding-left: 0.75rem;
    margin: 0.25rem 0;
}

.docs-toc .toc li {
    margin: 0.25rem 0;
}

.docs-toc .toc a {
    display: block;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.docs-toc .toc a:hover {
    color: var(--color-primary);
    background: var(--color-background);
}

.docs-toc .toc a.active {
    color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
    font-weight: 500;
    border-left: 2px solid var(--color-primary);
    margin-left: -2px;
}

/* TOC Toggle Button - hidden on desktop, shown on mobile */
.docs-toc-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 1024px) {
    .docs-toc-toggle {
        display: none;
    }
}

/* Mobile/Tablet: collapsible TOC drawer */
@media (max-width: 1023px) {
    .docs-layout {
        display: block;
    }

    .docs-toc {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        background: var(--color-surface);
        border-right: 1px solid var(--color-border);
        padding: 1rem;
        overflow-y: auto;
    }

    .docs-toc.open {
        transform: translateX(0);
    }

    .docs-toc-inner {
        position: static;
        max-height: none;
        background: none;
        border: none;
        padding: 0;
    }

    .docs-content {
        margin-top: 1rem;
    }

    /* Backdrop when TOC is open */
    .docs-toc-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .docs-toc-backdrop.open {
        opacity: 1;
        visibility: visible;
    }
}

/* ==========================================================================
   Markdown Content Styling
   ========================================================================== */

.markdown-content {
    line-height: 1.7;
}

.markdown-content > *:first-child {
    margin-top: 0;
}

/* Headings */
.markdown-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-border);
    color: var(--color-text-primary);
}

.markdown-content h1:first-child {
    margin-top: 0;
}

.markdown-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-primary);
}

.markdown-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
    color: var(--color-text-primary);
}

.markdown-content h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem;
    color: var(--color-text-secondary);
}

.markdown-content p {
    margin: 0.75rem 0;
}

/* Tables */
.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.875rem;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid var(--color-border);
    padding: 0.5rem 0.75rem;
    text-align: left;
    vertical-align: top;
}

.markdown-content th {
    background: var(--color-background);
    font-weight: 600;
    white-space: nowrap;
}

.markdown-content tr:hover td {
    background: var(--color-background);
}

/* Inline Code */
.markdown-content code {
    background: var(--color-background);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.875em;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Consolas', monospace;
    color: var(--color-primary);
}

/* Code Blocks - works with Prism.js */
.markdown-content pre {
    background: #2d2d2d;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid var(--color-border);
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: #ccc;
    font-size: 0.8125rem;
    line-height: 1.6;
}

/* Blockquotes */
.markdown-content blockquote {
    border-left: 4px solid var(--color-primary);
    padding: 0.5rem 1rem;
    margin: 1rem 0;
    background: var(--color-background);
    border-radius: 0 8px 8px 0;
}

.markdown-content blockquote p {
    margin: 0.25rem 0;
}

.markdown-content blockquote strong {
    color: var(--color-primary);
}

/* Lists */
.markdown-content ul,
.markdown-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.markdown-content li {
    margin: 0.25rem 0;
}

.markdown-content li > ul,
.markdown-content li > ol {
    margin: 0.25rem 0;
}

/* Horizontal Rule */
.markdown-content hr {
    border: none;
    border-top: 2px solid var(--color-border);
    margin: 2rem 0;
}

/* Links */
.markdown-content a {
    color: var(--color-primary);
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

/* Anchor links for headings - offset for fixed headers */
.markdown-content h1[id],
.markdown-content h2[id],
.markdown-content h3[id],
.markdown-content h4[id] {
    scroll-margin-top: 4rem;
}

/* ============================================================================
   PM Settings → Commissions (Sales-Admin compensation structure layout)
   Components mirrored from prototypes/project_manager/sales_admin_settings.html
   ============================================================================ */

.oc-wrap { max-width: 1120px; }

.oc-banner {
    background: #dbeafe;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    display: flex;
    gap: 12px;
    color: var(--color-secondary-hover, #0f408a);
    font-size: 13px;
    margin-bottom: 32px;
}

.oc-banner svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    stroke: currentColor;
}

.oc-banner ul {
    margin: 4px 0 0 18px;
    padding: 0;
}

.oc-banner li { margin-top: 2px; }

.commissions-section .section-intro {
    max-width: 820px;
    margin-bottom: 28px;
}

.commissions-section .section-intro h2 {
    font-size: 24px;
    font-weight: 500;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.commissions-section .section-intro p {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.commissions-section .section-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 4px;
}

.tier-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    overflow: hidden;
    margin-bottom: 16px;
}

.tier-head {
    padding: 20px 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.tier-head:hover { background: var(--color-background); }

.tier-card.open .tier-head {
    background: var(--color-surface-secondary);
    border-bottom: 1px solid var(--color-border);
}

.tier-head-left {
    display: flex;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.tier-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-surface-secondary);
    margin-top: 2px;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
}

.tier-card.open .tier-dot {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.tier-head h4 {
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 4px;
}

.tier-head p {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 0;
}

.tier-head-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.tier-price {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tier-price svg { transition: transform var(--transition-fast); }
.tier-card.open .tier-price svg { transform: rotate(180deg); }

.tier-body {
    display: none;
    padding: 24px;
    grid-template-columns: 1fr 320px;
    gap: 32px;
}

.tier-card.open .tier-body { display: grid; }

.tier-col + .tier-col { padding-left: 0; }

.tier-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

.tier-label.muted { color: var(--color-text-secondary); }

.tier-mode-hint {
    color: var(--color-text-secondary);
    font-size: 12px;
    line-height: 1.4;
    margin: -4px 0 12px;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 32px;
}

.chip {
    padding: 6px 12px;
    background: var(--color-surface-secondary);
    color: var(--color-text-primary);
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.pricing-model-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.pricing-model {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    background: var(--color-surface);
}

.pricing-model:hover { border-color: var(--color-text-muted); }

.pricing-model.selected {
    border-color: var(--color-secondary);
    background: var(--color-surface-secondary);
}

.pricing-model h5 {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 4px;
}

.pricing-model p {
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.4;
    margin: 0;
}

.commission-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    background: var(--color-surface);
}

.commission-row-info h5 {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 2px;
}

.commission-row-info p {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin: 0;
}

.money-input {
    position: relative;
    width: 130px;
    flex-shrink: 0;
}

.money-input span {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: 14px;
}

.money-input input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 26px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    text-align: right;
    background: var(--color-surface);
    outline: none;
    color: var(--color-text-primary);
    font-family: inherit;
}

.money-input input:focus {
    border-color: var(--color-secondary);
}

.money-input input:disabled,
.money-input input[readonly] {
    background: var(--color-background);
    color: var(--color-text-secondary);
    padding-right: 34px;
}

.money-input .lock {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--color-text-secondary);
    display: none;
}

.money-input.locked .lock { display: block; }

.money-input.wide {
    width: 100%;
    max-width: 260px;
}

.price-card {
    margin-top: 16px;
    padding: 18px 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}

.price-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.price-card-head h5 {
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.price-card-head .auto-hint {
    font-size: 12px;
    color: var(--color-text-secondary);
    display: none;
}

.price-card.auto .price-card-head .auto-hint { display: inline; }

.price-card p.hint {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 14px;
}

.price-panel {
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    align-self: start;
    position: sticky;
    top: 24px;
}

.price-panel h4 {
    font-size: 15px;
    font-weight: 500;
    margin: 0 0 18px;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    margin-bottom: 10px;
}

.price-row.muted span:first-child { color: var(--color-text-secondary); }

.price-row strong { font-weight: 500; }

.price-hint {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 2px;
    line-height: 1.4;
}

.price-divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 14px 0;
}

.price-total {
    font-size: 15px;
    font-weight: 500;
}

.tier-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
    gap: 12px;
    flex-wrap: wrap;
}

.tier-footer .add-tier-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tier-footer-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.add-option-btn {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition-fast);
}

.add-option-btn:hover { background: var(--color-background); }

.btn-danger-text {
    background: none;
    border: none;
    color: var(--color-error);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.btn-danger-text:hover { text-decoration: underline; }

.commission-change-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.commission-change-item {
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 10px 12px;
}

.commission-change-values {
    align-items: center;
    color: var(--color-text-secondary);
    display: inline-flex;
    flex-shrink: 0;
    font-size: 13px;
    gap: 8px;
    white-space: nowrap;
}

.commission-change-values strong {
    color: var(--color-text-primary);
    font-weight: 600;
}

@media (max-width: 767px) {
    .commission-change-item {
        align-items: stretch;
        flex-direction: column;
    }

    .commission-change-values {
        white-space: normal;
    }
}

.icon-btn {
    background: none;
    border: none;
    padding: 6px;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: inherit;
}

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

.icon-btn svg { width: 18px; height: 18px; }

/* ============================================================================
   Form controls — explicit checkbox + radio styling so unchecked state is
   visually empty rather than the browser-default solid black. ``accent-color``
   only colourises the *checked* state, so we restyle from scratch with
   ``appearance: none`` and reproduce the check / dot ourselves.
   ============================================================================ */

input[type="checkbox"],
input[type="radio"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    margin: 0;
    border: 1.5px solid var(--color-border-hover, #d0d0d0);
    background-color: var(--color-surface);
    cursor: pointer;
    display: inline-grid;
    place-content: center;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
    flex-shrink: 0;
    vertical-align: middle;
}

input[type="checkbox"] { border-radius: var(--radius-sm); }
input[type="radio"] { border-radius: 50%; }

input[type="checkbox"]:hover:not(:disabled),
input[type="radio"]:hover:not(:disabled) {
    border-color: var(--color-secondary);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 1px;
}

input[type="checkbox"]:checked {
    background-color: var(--color-secondary);
    border-color: var(--color-secondary);
}

input[type="checkbox"]:checked::after {
    content: "";
    width: 9px;
    height: 5px;
    border-left: 2px solid var(--color-text-inverse, #ffffff);
    border-bottom: 2px solid var(--color-text-inverse, #ffffff);
    transform: rotate(-45deg) translate(1px, -1px);
}

input[type="radio"]:checked {
    border-color: var(--color-secondary);
}

input[type="radio"]:checked::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-secondary);
}

input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
    background-color: var(--color-surface-secondary);
    border-color: var(--color-border);
    cursor: not-allowed;
    opacity: 0.6;
}
