/* ==========================================================
   TradeFlow ERP — Design System
   Version : 2.0.0
   Status  : Foundation
   
   All CSS custom properties (design tokens), base styles,
   component primitives, and layout utilities for the ERP.
   Import this file on EVERY page BEFORE page-specific CSS.
   ========================================================== */

/* ----------------------------------------------------------
   0. GOOGLE FONTS
   ---------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ----------------------------------------------------------
   1. DESIGN TOKENS — LIGHT THEME (default)
   ---------------------------------------------------------- */
:root {
    /* ---- Backgrounds ---- */
    --bg-body: #f0f2f5;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-input: #ffffff;
    --bg-hover: rgba(59, 130, 246, 0.04);
    --bg-selected: rgba(59, 130, 246, 0.08);

    /* ---- Text ---- */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    --text-link: #3b82f6;

    /* ---- Accent Palette ---- */
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-indigo: #6366f1;
    --accent-emerald: #10b981;
    --accent-emerald-hover: #059669;
    --accent-amber: #f59e0b;
    --accent-amber-hover: #d97706;
    --accent-red: #ef4444;
    --accent-red-hover: #dc2626;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;

    /* ---- Borders ---- */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --border-focus: var(--accent-blue);

    /* ---- Shadows ---- */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
    --shadow-glow: 0 0 0 3px rgba(59, 130, 246, 0.15);

    /* ---- Radii ---- */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* ---- Typography ---- */
    --font-main: 'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* ---- Transitions ---- */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    --transition-spring: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ---- Layout ---- */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 64px;
    --content-max-width: 1440px;
    --demo-banner-height: 0px;

    /* ---- Z-index ---- */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-sidebar: 300;
    --z-topbar: 400;
    --z-modal-backdrop: 500;
    --z-modal: 600;
    --z-toast: 700;
    --z-demo-banner: 10000;
}

body:has(.tf-demo-banner),
body.tf-has-demo-banner {
    --demo-banner-height: 28px;
}

/* ----------------------------------------------------------
   2. DESIGN TOKENS — DARK THEME
   ---------------------------------------------------------- */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --bg-input: #334155;
    --bg-hover: rgba(59, 130, 246, 0.08);
    --bg-selected: rgba(59, 130, 246, 0.15);

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-inverse: #0f172a;
    --text-link: #60a5fa;

    --border-color: #334155;
    --border-light: #1e293b;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.3);
    --shadow-glow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

/* ----------------------------------------------------------
   3. MODERN RESET / BASE
   ---------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--transition-normal), color var(--transition-normal);
    min-height: 100vh;
}

/* ---- Selection ---- */
::selection {
    background: var(--accent-blue);
    color: #ffffff;
}

/* ---- Scrollbar (WebKit) ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-body);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ---- Scrollbar (Firefox) ---- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) var(--bg-body);
}

/* ---- Links ---- */
a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--accent-blue-hover); }

/* ---- Muted text override for dark/light themes ---- */
.text-muted {
    color: var(--text-muted) !important;
}

/* ----------------------------------------------------------
   4. LAYOUT
   ---------------------------------------------------------- */

/* Sidebar + Topbar page wrapper */
.tf-page-wrapper {
    margin-left: var(--sidebar-width);
    padding-top: calc(var(--topbar-height) + var(--demo-banner-height) + 24px);
    padding-right: 24px;
    padding-bottom: 40px;
    padding-left: 24px;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

/* When sidebar is collapsed */
.tf-sidebar-collapsed .tf-page-wrapper {
    margin-left: var(--sidebar-collapsed);
}

/* Content max-width container */
.tf-container {
    max-width: var(--content-max-width);
    margin: 0 auto;
    width: 100%;
}

/* Page header */
.tf-page-header {
    margin-bottom: 24px;
}

.tf-page-title {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.tf-page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ----------------------------------------------------------
   5. SIDEBAR
   ---------------------------------------------------------- */
.tf-sidebar {
    position: fixed;
    top: var(--demo-banner-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--demo-banner-height));
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: var(--z-sidebar);
    transition: width var(--transition-normal);
    display: flex;
    flex-direction: column;
}

.tf-sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.tf-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tf-sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}

.tf-sidebar-app-name {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

.tf-sidebar-app-version {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
}

/* Navigation */
.tf-sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.tf-nav-section {
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.35);
    margin-top: 8px;
}

.tf-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin: 2px 8px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.65);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.tf-nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.tf-nav-item.active {
    background: rgba(59, 130, 246, 0.2);
    color: #fff;
    font-weight: 600;
}

.tf-nav-item .tf-nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.tf-nav-item .tf-nav-badge {
    margin-left: auto;
    background: var(--accent-red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

/* Sidebar footer */
.tf-sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.tf-sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tf-sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent-emerald), var(--accent-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
}

.tf-sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.tf-sidebar-username {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tf-sidebar-userrole {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ----------------------------------------------------------
   6. TOPBAR
   ---------------------------------------------------------- */
.tf-topbar {
    position: fixed;
    top: var(--demo-banner-height);
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: var(--z-topbar);
    transition: left var(--transition-normal);
}

.tf-sidebar-collapsed .tf-topbar {
    left: var(--sidebar-collapsed);
}

.tf-topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tf-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tf-topbar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.tf-topbar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tf-theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 6px;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 32px;
    user-select: none;
    line-height: 1;
}

.tf-theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
}

/* ---- Accordion / Collapsible Submenu in Sidebar ---- */
.tf-nav-group {
    margin: 2px 8px;
}

.tf-nav-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.tf-nav-group-header:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.tf-nav-group.open > .tf-nav-group-header,
.tf-nav-group.has-active > .tf-nav-group-header {
    color: #fff;
}

.tf-nav-group.has-active:not(.open) > .tf-nav-group-header {
    background: rgba(59, 130, 246, 0.15);
}

.tf-nav-group-arrow {
    margin-left: auto;
    font-size: 12px;
    opacity: 0.6;
    transition: transform var(--transition-normal);
    display: inline-block;
}

.tf-nav-group.open .tf-nav-group-arrow {
    transform: rotate(180deg);
    opacity: 1;
}

.tf-nav-submenu {
    display: none;
    flex-direction: column;
    padding: 2px 0 2px 10px;
    border-left: 2px solid rgba(255, 255, 255, 0.15);
    margin: 2px 0 4px 18px;
}

.tf-nav-group.open .tf-nav-submenu {
    display: flex;
}

.tf-nav-subitem {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    margin: 1px 0;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.65);
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tf-nav-subitem:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.tf-nav-subitem.active {
    background: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
    font-weight: 600;
}

.tf-nav-subicon {
    font-size: 14px;
    width: 16px;
    display: inline-flex;
    justify-content: center;
}

/* ----------------------------------------------------------
   7. CARD SYSTEM
   ---------------------------------------------------------- */
.tf-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.tf-card:hover {
    box-shadow: var(--shadow-md);
}

.tf-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.tf-card-title {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.tf-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Glassmorphism accent card */
.tf-card-glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .tf-card-glass {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ----------------------------------------------------------
   8. FORM CONTROLS
   ---------------------------------------------------------- */
.tf-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.tf-input,
.tf-select,
.tf-textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 13px;
    color: var(--text-primary);
    padding: 8px 12px;
    transition: all var(--transition-fast);
    outline: none;
}

.tf-input:focus,
.tf-select:focus,
.tf-textarea:focus {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-glow);
}

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

.tf-input:disabled,
.tf-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-body);
}

.tf-textarea {
    min-height: 80px;
    resize: vertical;
}

.tf-input-sm { padding: 6px 10px; font-size: 12px; }
.tf-input-lg { padding: 12px 16px; font-size: 14px; }

/* Search input with icon */
.tf-search-wrapper {
    position: relative;
}

.tf-search-wrapper .tf-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

.tf-search-wrapper .tf-input {
    padding-left: 36px;
}

/* ----------------------------------------------------------
   9. TABLE SYSTEM
   ---------------------------------------------------------- */
.tf-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.tf-table thead th {
    background: var(--bg-body);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.tf-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

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

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

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

/* Compact table variant */
.tf-table-compact thead th { padding: 8px 12px; font-size: 10px; }
.tf-table-compact tbody td { padding: 8px 12px; font-size: 12px; }

/* Striped variant */
.tf-table-striped tbody tr:nth-child(even) {
    background: var(--bg-hover);
}

/* ----------------------------------------------------------
   10. STATUS BADGES
   ---------------------------------------------------------- */
.tf-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.tf-badge-draft { background: #f1f5f9; color: #64748b; }
.tf-badge-issued { background: #dbeafe; color: #2563eb; }
.tf-badge-approved { background: #d1fae5; color: #059669; }
.tf-badge-paid { background: #d1fae5; color: #059669; }
.tf-badge-pending { background: #fef3c7; color: #d97706; }
.tf-badge-cancelled { background: #fee2e2; color: #dc2626; }
.tf-badge-voided { background: #fef3c7; color: #92400e; }
.tf-badge-closed { background: #e2e8f0; color: #475569; }
.tf-badge-active { background: #dbeafe; color: #1d4ed8; }
.tf-badge-archived { background: #f1f5f9; color: #94a3b8; }

[data-theme="dark"] .tf-badge-draft { background: #334155; color: #94a3b8; }
[data-theme="dark"] .tf-badge-issued { background: rgba(59,130,246,0.15); color: #60a5fa; }
[data-theme="dark"] .tf-badge-approved { background: rgba(16,185,129,0.15); color: #34d399; }
[data-theme="dark"] .tf-badge-paid { background: rgba(16,185,129,0.15); color: #34d399; }
[data-theme="dark"] .tf-badge-pending { background: rgba(245,158,11,0.15); color: #fbbf24; }
[data-theme="dark"] .tf-badge-cancelled { background: rgba(239,68,68,0.15); color: #f87171; }
[data-theme="dark"] .tf-badge-voided { background: rgba(245,158,11,0.15); color: #fbbf24; }
[data-theme="dark"] .tf-badge-closed { background: #334155; color: #64748b; }

/* Document type badges */
.tf-badge-pi { background: linear-gradient(135deg, #dbeafe, #ede9fe); color: #4338ca; }
.tf-badge-invoice { background: linear-gradient(135deg, #d1fae5, #cffafe); color: #047857; }
.tf-badge-challan { background: linear-gradient(135deg, #cffafe, #dbeafe); color: #0369a1; }
.tf-badge-receipt { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.tf-badge-packing { background: linear-gradient(135deg, #e2e8f0, #f1f5f9); color: #475569; }

/* ----------------------------------------------------------
   11. BUTTON SYSTEM
   ---------------------------------------------------------- */
.tf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

.tf-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary */
.tf-btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: #fff;
    box-shadow: 0 2px 4px rgba(59,130,246,0.2);
}
.tf-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-blue-hover), #4f46e5);
    box-shadow: 0 4px 8px rgba(59,130,246,0.3);
    transform: translateY(-1px);
}

/* Success */
.tf-btn-success {
    background: var(--accent-emerald);
    color: #fff;
}
.tf-btn-success:hover:not(:disabled) {
    background: var(--accent-emerald-hover);
    transform: translateY(-1px);
}

/* Danger */
.tf-btn-danger {
    background: var(--accent-red);
    color: #fff;
}
.tf-btn-danger:hover:not(:disabled) {
    background: var(--accent-red-hover);
    transform: translateY(-1px);
}

/* Warning */
.tf-btn-warning {
    background: var(--accent-amber);
    color: #000;
}
.tf-btn-warning:hover:not(:disabled) {
    background: var(--accent-amber-hover);
    transform: translateY(-1px);
}

/* Ghost */
.tf-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.tf-btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

/* Outline */
.tf-btn-outline-primary {
    background: transparent;
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
}
.tf-btn-outline-primary:hover:not(:disabled) {
    background: var(--accent-blue);
    color: #fff;
}

.tf-btn-outline-danger {
    background: transparent;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}
.tf-btn-outline-danger:hover:not(:disabled) {
    background: var(--accent-red);
    color: #fff;
}

/* Icon button */
.tf-btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.tf-btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Sizes */
.tf-btn-sm { padding: 5px 10px; font-size: 12px; gap: 5px; }
.tf-btn-lg { padding: 12px 24px; font-size: 15px; gap: 10px; }
.tf-btn-xs { padding: 3px 8px; font-size: 11px; gap: 4px; }

/* ----------------------------------------------------------
   12. STAT CARDS (Dashboard)
   ---------------------------------------------------------- */
.tf-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.tf-stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition-fast);
}

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

.tf-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.tf-stat-icon-blue { background: rgba(59,130,246,0.1); color: var(--accent-blue); }
.tf-stat-icon-emerald { background: rgba(16,185,129,0.1); color: var(--accent-emerald); }
.tf-stat-icon-amber { background: rgba(245,158,11,0.1); color: var(--accent-amber); }
.tf-stat-icon-red { background: rgba(239,68,68,0.1); color: var(--accent-red); }
.tf-stat-icon-purple { background: rgba(139,92,246,0.1); color: var(--accent-purple); }
.tf-stat-icon-cyan { background: rgba(6,182,212,0.1); color: var(--accent-cyan); }
.tf-stat-icon-pink { background: rgba(236,72,153,0.1); color: var(--accent-pink); }
.tf-stat-icon-indigo { background: rgba(99,102,241,0.1); color: var(--accent-indigo); }

[data-theme="dark"] .tf-stat-icon-blue { background: rgba(59,130,246,0.15); }
[data-theme="dark"] .tf-stat-icon-emerald { background: rgba(16,185,129,0.15); }
[data-theme="dark"] .tf-stat-icon-amber { background: rgba(245,158,11,0.15); }
[data-theme="dark"] .tf-stat-icon-red { background: rgba(239,68,68,0.15); }
[data-theme="dark"] .tf-stat-icon-purple { background: rgba(139,92,246,0.15); }
[data-theme="dark"] .tf-stat-icon-cyan { background: rgba(6,182,212,0.15); }

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

.tf-stat-value {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.tf-stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.tf-stat-change {
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}

.tf-stat-change-up { color: var(--accent-emerald); }
.tf-stat-change-down { color: var(--accent-red); }

/* ----------------------------------------------------------
   13. TOOLBAR / ACTION BAR
   ---------------------------------------------------------- */
.tf-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.tf-toolbar-spacer {
    flex: 1;
}

.tf-toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 8px;
}

/* ----------------------------------------------------------
   14. EMPTY STATE
   ---------------------------------------------------------- */
.tf-empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.tf-empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.tf-empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.tf-empty-state-description {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto 20px;
}

/* ----------------------------------------------------------
   15. MODAL (layered on Bootstrap)
   ---------------------------------------------------------- */
.tf-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.tf-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.tf-modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(20px) scale(0.95);
    transition: transform var(--transition-spring);
}

.tf-modal-overlay.active .tf-modal {
    transform: translateY(0) scale(1);
}

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

.tf-modal-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
}

.tf-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
}

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

.tf-modal-body { padding: 24px; }

.tf-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* Danger modal variant */
.tf-modal-danger .tf-modal-header {
    background: linear-gradient(135deg, rgba(239,68,68,0.05), rgba(239,68,68,0.02));
    border-bottom-color: rgba(239,68,68,0.15);
}
.tf-modal-danger .tf-modal-title { color: var(--accent-red); }

/* ----------------------------------------------------------
   16. TOAST / NOTIFICATION
   ---------------------------------------------------------- */
.tf-toast-container {
    position: fixed;
    top: calc(var(--demo-banner-height) + var(--topbar-height) + 16px);
    right: 16px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.tf-toast {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 420px;
    font-size: 13px;
    pointer-events: auto;
    animation: tf-slide-in-right 300ms ease forwards;
}

.tf-toast-success { border-left: 4px solid var(--accent-emerald); }
.tf-toast-error { border-left: 4px solid var(--accent-red); }
.tf-toast-warning { border-left: 4px solid var(--accent-amber); }
.tf-toast-info { border-left: 4px solid var(--accent-blue); }

.tf-toast-icon { font-size: 18px; flex-shrink: 0; }
.tf-toast-message { flex: 1; }
.tf-toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
}

/* ----------------------------------------------------------
   17. MICRO-ANIMATIONS
   ---------------------------------------------------------- */
@keyframes tf-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes tf-slide-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tf-slide-in-right {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes tf-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes tf-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

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

.tf-animate-in {
    animation: tf-slide-up 400ms ease forwards;
}

.tf-animate-fade {
    animation: tf-fade-in 300ms ease forwards;
}

.tf-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: tf-spin 600ms linear infinite;
}

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

/* ----------------------------------------------------------
   18. DEMO SECURITY BANNER
   ---------------------------------------------------------- */
.tf-demo-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--demo-banner-height);
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    z-index: var(--z-demo-banner);
    padding: 0 16px;
    text-align: center;
}

.tf-demo-banner::before {
    content: "⚠️ ";
}

.tf-demo-banner::after {
    content: " ⚠️";
}

/* ----------------------------------------------------------
   19. UTILITY CLASSES
   ---------------------------------------------------------- */
.tf-text-center { text-align: center; }
.tf-text-right { text-align: right; }
.tf-text-left { text-align: left; }
.tf-text-muted { color: var(--text-muted); }
.tf-text-primary { color: var(--accent-blue); }
.tf-text-success { color: var(--accent-emerald); }
.tf-text-danger { color: var(--accent-red); }
.tf-text-warning { color: var(--accent-amber); }

.tf-fw-500 { font-weight: 500; }
.tf-fw-600 { font-weight: 600; }
.tf-fw-700 { font-weight: 700; }

.tf-mb-0 { margin-bottom: 0; }
.tf-mb-8 { margin-bottom: 8px; }
.tf-mb-16 { margin-bottom: 16px; }
.tf-mb-24 { margin-bottom: 24px; }
.tf-mt-16 { margin-top: 16px; }
.tf-mt-24 { margin-top: 24px; }

.tf-gap-8 { gap: 8px; }
.tf-gap-16 { gap: 16px; }

.tf-flex { display: flex; }
.tf-flex-col { flex-direction: column; }
.tf-items-center { align-items: center; }
.tf-justify-between { justify-content: space-between; }
.tf-flex-wrap { flex-wrap: wrap; }
.tf-flex-1 { flex: 1; }

.tf-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tf-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.tf-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.tf-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tf-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

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

/* Amount / Currency display */
.tf-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: -0.3px;
}

.tf-amount-lg {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
}

/* ----------------------------------------------------------
   20. THEME TOGGLE
   ---------------------------------------------------------- */
.tf-theme-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--border-color);
    border: none;
    cursor: pointer;
    transition: background var(--transition-fast);
    padding: 0;
}

.tf-theme-toggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast);
}

[data-theme="dark"] .tf-theme-toggle {
    background: var(--accent-indigo);
}

[data-theme="dark"] .tf-theme-toggle::after {
    transform: translateX(20px);
}

/* ----------------------------------------------------------
   21. PRINT ISOLATION
   Never let screen styles contaminate print output.
   ---------------------------------------------------------- */
@media print {
    /* Hide shell elements */
    .tf-demo-banner,
    .tf-sidebar,
    .tf-topbar,
    .tf-toolbar,
    .tf-toast-container,
    .tf-theme-toggle,
    .tf-modal-overlay,
    .no-print { display: none !important; }

    /* Reset page wrapper */
    .tf-page-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    /* Reset backgrounds and colors */
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt !important;
    }

    .tf-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
    }

    /* Remove shadows and transitions */
    * {
        box-shadow: none !important;
        transition: none !important;
        animation: none !important;
    }

    a { color: #000 !important; text-decoration: none !important; }
}

/* ----------------------------------------------------------
   22. RESPONSIVE
   ---------------------------------------------------------- */

/* Tablet */
@media (max-width: 1024px) {
    .tf-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .tf-sidebar.tf-sidebar-open {
        transform: translateX(0);
    }

    .tf-page-wrapper {
        margin-left: 0;
    }

    .tf-topbar {
        left: 0;
    }

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

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

/* Mobile */
@media (max-width: 768px) {
    .tf-page-wrapper {
        padding-left: 16px;
        padding-right: 16px;
    }

    .tf-card { padding: 16px; }

    .tf-stats-grid {
        grid-template-columns: 1fr;
    }

    .tf-grid-2 { grid-template-columns: 1fr; }
    .tf-grid-3 { grid-template-columns: 1fr; }
    .tf-grid-4 { grid-template-columns: 1fr; }

    .tf-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .tf-topbar {
        padding: 0 16px;
    }

    .tf-modal {
        width: 95%;
        max-height: 90vh;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .tf-page-wrapper {
        padding-left: 12px;
        padding-right: 12px;
        padding-top: calc(var(--topbar-height) + var(--demo-banner-height) + 16px);
    }

    .tf-page-title { font-size: 20px; }

    .tf-stat-card { padding: 16px; gap: 12px; }
    .tf-stat-value { font-size: 20px; }
    .tf-stat-icon { width: 40px; height: 40px; font-size: 18px; }
}
