/* =====================================================
   Instant Ledger by 1Zonic - Enterprise UI
   Premium Accounting ERP Design System
   ===================================================== */

:root {
    --primary: #714B67;
    --primary-light: #8F6B82;
    --primary-dark: #5A3C53;
    --primary-bg: rgba(113,75,103,0.06);
    --secondary: #00A09D;
    --secondary-light: #33B3B1;
    --accent: #017E84;
    --success: #2E7D32;
    --warning: #E65100;
    --danger: #C62828;
    --info: #1565C0;

    --bg-body: #F4F5F7;
    --bg-white: #FFFFFF;
    --bg-panel: #FAFBFC;
    --bg-sidebar: #1E1E2D;
    --bg-sidebar-hover: #2A2A3C;
    --bg-sidebar-active: rgba(113,75,103,0.35);
    --bg-topbar: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-hover: #F0F1F3;
    --bg-selected: #EDE7EB;

    --text-primary: #1A1A2E;
    --text-secondary: #5F6368;
    --text-muted: #9AA0A6;
    --text-white: #FFFFFF;
    --text-sidebar: #B0B0C0;

    --border-color: #DADCE0;
    --border-light: #E8EAED;
    --border-focus: var(--primary);

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);

    --panel-width: 320px;
    --topbar-height: 48px;
    --radius: 6px;
    --radius-sm: 4px;
    --radius-lg: 10px;
    --radius-xl: 16px;

    --transition: all 0.2s ease;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Roboto Mono', 'SF Mono', 'Consolas', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}
a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
table { border-collapse: collapse; width: 100%; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--primary); color: #fff; }

/* ============================================
   SHELL: Topbar + Body(Panel + Main)
   ============================================ */
.app-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* TOPBAR */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-sidebar);
    display: flex; align-items: center;
    padding: 0 16px; z-index: 1000;
    flex-shrink: 0; gap: 12px;
}
.topbar-brand {
    display: flex; align-items: center; gap: 10px;
    padding-right: 16px; border-right: 1px solid rgba(255,255,255,0.1);
    margin-right: 4px; cursor: default;
}
.topbar-brand .brand-mark {
    width: 30px; height: 30px; background: var(--primary);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; color: #fff; letter-spacing: -0.5px;
}
.topbar-brand .brand-name { font-size: 14px; font-weight: 600; color: #fff; white-space: nowrap; letter-spacing: -0.3px; }
.topbar-brand .brand-sub { font-size: 10px; color: rgba(255,255,255,0.4); letter-spacing: 0.5px; text-transform: uppercase; }

.topbar-menu-btn {
    width: 34px; height: 34px; border: none; border-radius: var(--radius);
    background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7);
    cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.topbar-menu-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.topbar-menu-btn svg { width: 18px; height: 18px; }

.topbar-trail {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: rgba(255,255,255,0.5); flex: 1; min-width: 0;
}
.topbar-trail .trail-item { white-space: nowrap; }
.topbar-trail .trail-item.current { color: rgba(255,255,255,0.9); font-weight: 500; }
.topbar-trail .trail-sep { font-size: 10px; }

.topbar-search {
    display: flex; align-items: center;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.06);
    border-radius: 20px; padding: 5px 14px; gap: 8px;
    cursor: pointer; transition: var(--transition); min-width: 220px;
}
.topbar-search:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.1); }
.topbar-search .s-icon { color: rgba(255,255,255,0.4); font-size: 13px; display: flex; }
.topbar-search .s-icon svg { width: 14px; height: 14px; }
.topbar-search .s-text { color: rgba(255,255,255,0.4); font-size: 12px; }
.topbar-search .s-key {
    margin-left: auto; background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 3px;
    padding: 1px 6px; font-size: 10px; color: rgba(255,255,255,0.35);
    font-family: var(--font-mono);
}

.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.topbar-action-btn {
    width: 34px; height: 34px; border: none; border-radius: var(--radius);
    background: transparent; color: rgba(255,255,255,0.5);
    cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; justify-content: center; position: relative;
}
.topbar-action-btn:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); }
.topbar-action-btn svg { width: 18px; height: 18px; }
.topbar-user {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 8px 4px 4px; border-radius: var(--radius);
    cursor: pointer; transition: var(--transition); margin-left: 4px;
}
.topbar-user:hover { background: rgba(255,255,255,0.08); }
.topbar-user .u-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 11px;
}
.topbar-user .u-name { font-size: 12px; color: rgba(255,255,255,0.8); font-weight: 500; }
.topbar-user .u-role { font-size: 10px; color: rgba(255,255,255,0.35); }

/* BODY = Panel + Main */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* LEFT PANEL (WhatsApp-style party list) */
.party-panel {
    width: var(--panel-width); background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column; flex-shrink: 0;
    overflow: hidden; transition: width 0.25s ease;
}
.party-panel.collapsed { width: 0; border-right: none; overflow: hidden; }

.panel-header {
    padding: 12px 16px; border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.panel-header h3 { font-size: 14px; font-weight: 600; flex: 1; }
.panel-header-btn {
    width: 30px; height: 30px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-secondary);
    cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.panel-header-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.panel-header-btn svg { width: 16px; height: 16px; }

.panel-search { padding: 8px 16px; border-bottom: 1px solid var(--border-light); flex-shrink: 0; }
.panel-search-input {
    width: 100%; padding: 7px 10px 7px 32px;
    border: 1px solid var(--border-color); border-radius: var(--radius);
    font-size: 12px; font-family: var(--font-family);
    background: var(--bg-panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239AA0A6' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 10px center no-repeat;
    transition: var(--transition);
}
.panel-search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(113,75,103,0.08); }

.panel-filters {
    padding: 6px 16px; border-bottom: 1px solid var(--border-light);
    display: flex; gap: 4px; flex-shrink: 0;
}
.panel-filter-btn {
    padding: 4px 10px; border-radius: 12px;
    border: 1px solid var(--border-color); background: var(--bg-white);
    font-size: 11px; font-family: var(--font-family);
    color: var(--text-secondary); cursor: pointer; transition: var(--transition);
}
.panel-filter-btn:hover { background: var(--bg-hover); }
.panel-filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.panel-list { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.1) transparent; }
.panel-list::-webkit-scrollbar { width: 4px; }
.panel-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 2px; }

.party-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; cursor: pointer; transition: var(--transition);
    border-bottom: 1px solid var(--border-light); border-left: 3px solid transparent;
}
.party-item:hover { background: var(--bg-hover); }
.party-item.active { background: var(--bg-selected); border-left-color: var(--primary); }
.party-item .p-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--primary-bg); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px; flex-shrink: 0;
}
.party-item .p-avatar.supplier { background: rgba(0,160,157,0.08); color: var(--secondary); }
.party-item .p-avatar.both { background: rgba(21,101,192,0.08); color: var(--info); }
.party-item .p-info { flex: 1; min-width: 0; }
.party-item .p-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.party-item .p-meta { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.party-item .p-balance { text-align: right; flex-shrink: 0; }
.party-item .p-balance .amount { font-size: 12px; font-weight: 600; font-family: var(--font-mono); }
.party-item .p-balance .amount.receivable { color: var(--danger); }
.party-item .p-balance .amount.payable { color: var(--success); }
.party-item .p-balance .lbl { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.panel-footer {
    padding: 8px 16px; border-top: 1px solid var(--border-light);
    font-size: 11px; color: var(--text-muted);
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}

/* MAIN CONTENT */
.main-content {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    display: flex; flex-direction: column; background: var(--bg-body);
    scrollbar-width: thin;
    padding : 20px;
}
#profileMainContent{
    padding: 0px;
}
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }
.workspace { padding: 0px; flex: 1; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; }
.page-header .breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.page-header .breadcrumb a { color: var(--text-secondary); }
.page-header .breadcrumb a:hover { color: var(--primary); }
.page-actions { display: flex; gap: 6px; align-items: center; }

/* ===== PARTY PROFILE ===== */
.profile-header { background: var(--bg-white); border-bottom: 1px solid var(--border-light); padding: 20px 24px; }
.profile-top { display: flex; align-items: flex-start; gap: 16px; }
.profile-avatar {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 20px; flex-shrink: 0;
}
.profile-info { flex: 1; min-width: 0; }
.profile-info h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 2px; }
.profile-info .profile-meta {
    display: flex; align-items: center; gap: 12px;
    font-size: 12px; color: var(--text-secondary); flex-wrap: wrap;
}
.profile-info .profile-meta .sep { color: var(--border-color); }
.profile-stats { display: flex; gap: 24px; margin-left: auto; flex-shrink: 0; }
.profile-stat { text-align: center; min-width: 90px; }
.profile-stat .stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 2px; }
.profile-stat .stat-val { font-size: 18px; font-weight: 700; font-family: var(--font-mono); }
.profile-stat .stat-val.danger { color: var(--danger); }
.profile-stat .stat-val.success { color: var(--success); }
.profile-actions {
    display: flex; gap: 6px; margin-top: 16px;
    padding-top: 12px; border-top: 1px solid var(--border-light);
}

/* Profile avatar with photo upload overlay */
.profile-avatar-wrap {
    position: relative; width: 64px; height: 64px;
    flex-shrink: 0; cursor: pointer;
}
.profile-avatar-wrap .profile-avatar {
    width: 64px; height: 64px; font-size: 22px;
    transition: filter 0.2s;
}
.profile-avatar-wrap:hover .profile-avatar { filter: brightness(0.85); }
.profile-avatar-camera {
    position: absolute; bottom: 0; right: 0;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff; opacity: 0;
    transition: opacity 0.2s;
}
.profile-avatar-wrap:hover .profile-avatar-camera { opacity: 1; }

/* ===== ENTERPRISE INVOICE PREVIEW ===== */
.inv-preview { background: var(--bg-white); }
.inv-preview-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 20px 24px 16px; border-bottom: 2px solid var(--primary);
    background: linear-gradient(135deg, #fafafa 0%, #f0edf3 100%);
}
.inv-preview-brand { }
.inv-preview-doc-type {
    font-size: 10px; font-weight: 700; letter-spacing: 2px;
    text-transform: uppercase; color: var(--primary); margin-bottom: 4px;
}
.inv-preview-no { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; color: var(--text-primary); }
.inv-preview-meta { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.inv-preview-badge {
    display: inline-block; padding: 3px 12px; border-radius: 20px;
    font-size: 10px; font-weight: 700; letter-spacing: 1px;
}
.inv-preview-date { font-size: 12px; color: var(--text-muted); }
.inv-preview-dates { border-collapse: collapse; font-size: 12px; }
.inv-preview-dates td { padding: 1px 4px; color: var(--text-secondary); }
.inv-preview-dates td:first-child { color: var(--text-muted); }
.inv-preview-parties {
    display: flex; gap: 24px; padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
}
.inv-preview-party { flex: 1; }
.inv-preview-party.right { text-align: right; }
.inv-preview-party-label {
    font-size: 10px; font-weight: 600; letter-spacing: 1px;
    text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px;
}
.inv-preview-party-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.inv-preview-party-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.inv-preview-lines { padding: 0 0 0 0; overflow-x: auto; }
.inv-preview-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.inv-preview-table thead tr { background: var(--bg-body); }
.inv-preview-table thead th {
    padding: 8px 12px; font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); border-bottom: 1px solid var(--border-light);
}
.inv-preview-table tbody tr { border-bottom: 1px solid var(--border-light); }
.inv-preview-table tbody tr:last-child { border-bottom: none; }
.inv-preview-table tbody td { padding: 9px 12px; vertical-align: middle; }
.inv-preview-table .inv-line-num { color: var(--text-muted); font-size: 11px; }
.inv-preview-totals {
    display: flex; justify-content: flex-end;
    padding: 12px 24px; border-top: 1px solid var(--border-light);
    background: var(--bg-body);
}
.inv-preview-totals-inner { min-width: 260px; }
.inv-total-row {
    display: flex; justify-content: space-between;
    padding: 4px 0; font-size: 13px; color: var(--text-secondary);
}
.inv-total-row.grand {
    font-size: 16px; font-weight: 700; color: var(--text-primary);
    border-top: 2px solid var(--border-color); margin-top: 6px; padding-top: 8px;
}
.inv-total-row.paid { color: var(--success); font-size: 12px; }
.inv-total-row.balance { font-size: 14px; font-weight: 700; padding-top: 6px; }
.inv-total-row.balance.overdue { color: var(--danger); }
.inv-total-row.balance.settled { color: var(--success); }
.inv-preview-notes {
    padding: 10px 24px; font-size: 12px; color: var(--text-secondary);
    border-top: 1px solid var(--border-light); background: #fffdf5;
}
.inv-preview-amount-hero {
    text-align: center; padding: 28px 24px;
    border-bottom: 1px solid var(--border-light);
}
.inv-preview-amount-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-muted); margin-bottom: 6px;
}
.inv-preview-amount-big {
    font-size: 32px; font-weight: 800;
    font-family: var(--font-mono, monospace); color: var(--primary);
}
.inv-preview-footer-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 24px; border-top: 1px solid var(--border-light);
}

.profile-tabs {
    display: flex; gap: 0; border-bottom: 2px solid var(--border-light);
    background: var(--bg-white); padding: 0 24px; overflow-x: auto; flex-shrink: 0;
}
.profile-tab {
    padding: 10px 16px; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); cursor: pointer;
    border-bottom: 2px solid transparent; 
    transition: var(--transition); background: none; border-top: none;
    border-left: none; border-right: none; font-family: var(--font-family);
    white-space: nowrap; display: flex; align-items: center; gap: 6px;
}
.profile-tab:hover { color: var(--primary); }
.profile-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.profile-tab .tab-count {
    background: var(--bg-body); color: var(--text-muted);
    font-size: 10px; padding: 1px 6px; border-radius: 10px; font-weight: 600;
}
.profile-tab.active .tab-count { background: var(--primary-bg); color: var(--primary); }
.profile-content { padding: 20px 24px; flex: 1; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs); border: 1px solid var(--border-light); overflow: hidden;
}
.card-header {
    padding: 14px 20px; border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between; background: var(--bg-panel);
}
.card-header h3 { font-size: 14px; font-weight: 600; }
.card-body { padding: 16px 20px; }
.card-footer { padding: 10px 20px; border-top: 1px solid var(--border-light); background: var(--bg-panel); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card {
    background: var(--bg-white); border-radius: var(--radius-lg);
    padding: 16px 20px; box-shadow: var(--shadow-xs);
    border: 1px solid var(--border-light);
    display: flex; align-items: flex-start; gap: 14px; transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-icon {
    width: 40px; height: 40px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.purple { background: rgba(113,75,103,0.08); color: var(--primary); }
.stat-icon.teal { background: rgba(0,160,157,0.08); color: var(--secondary); }
.stat-icon.green { background: rgba(46,125,50,0.08); color: var(--success); }
.stat-icon.red { background: rgba(198,40,40,0.08); color: var(--danger); }
.stat-icon.blue { background: rgba(21,101,192,0.08); color: var(--info); }
.stat-icon.orange { background: rgba(230,81,0,0.08); color: var(--warning); }
.stat-info h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 2px; }
.stat-info .stat-value { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1.2; font-family: var(--font-mono); }
.stat-info .stat-change { font-size: 11px; margin-top: 2px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: var(--radius);
    font-size: 13px; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; transition: var(--transition);
    line-height: 1.4; white-space: nowrap; font-family: var(--font-family);
}
.btn:hover { box-shadow: var(--shadow-xs); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-outline { background: var(--bg-white); color: var(--text-primary); border-color: var(--border-color); }
.btn-outline:hover { background: var(--bg-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: none; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); box-shadow: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }
.btn-icon svg { width: 16px; height: 16px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-group { display: flex; gap: 2px; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-icon-danger {
    width: 28px; height: 28px; border: none; background: transparent;
    color: var(--danger); cursor: pointer; border-radius: var(--radius-sm);
    font-size: 18px; display: inline-flex; align-items: center; justify-content: center;
    line-height: 1; padding: 0;
}
.btn-icon-danger:hover { background: #ffebee; }

/* ===== PRODUCT TYPEAHEAD ===== */
.product-search-wrap { position: relative; }
.product-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 600;
    background: var(--bg-white); border: 1px solid var(--border-color);
    border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    max-height: 240px; overflow-y: auto; margin-top: 2px;
}
.pd-item {
    padding: 8px 12px; cursor: pointer; display: flex; align-items: center;
    gap: 8px; font-size: 13px; border-bottom: 1px solid var(--border-light, #f0f0f0);
    transition: background 0.1s;
}
.pd-item:last-child { border-bottom: none; }
.pd-item:hover, .pd-item.selected { background: var(--bg-hover); }
.pd-item-name { flex: 1; font-weight: 500; color: var(--text-primary); }
.pd-sku { font-size: 11px; color: var(--text-muted); font-family: monospace; }
.pd-price { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.pd-empty { padding: 12px; text-align: center; color: var(--text-muted); font-size: 12px; font-style: italic; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-control {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border-color);
    border-radius: var(--radius); font-size: 13px; font-family: var(--font-family);
    transition: var(--transition); background: var(--bg-white); color: var(--text-primary);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(113,75,103,0.08); }
.form-control.error { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 11px; margin-top: 3px; }
.form-hint { color: var(--text-muted); font-size: 11px; margin-top: 3px; }
select.form-control { appearance: auto; }
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.form-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ===== LINE ITEMS TABLE ===== */
.line-items-wrap { overflow-x: auto; margin: 0 -4px; }
#invLinesTable td .form-control,
#billLinesTable td .form-control,
#soLinesTable td .form-control,
#poLinesTable td .form-control {
    padding: 5px 7px; font-size: 12px; min-width: 0;
}
#invLinesTable td:first-child .form-control,
#billLinesTable td:first-child .form-control,
#soLinesTable td:first-child .form-control,
#poLinesTable td:first-child .form-control { min-width: 160px; }
.totals-box {
    background: var(--bg-panel); border: 1px solid var(--border-light);
    border-radius: var(--radius); padding: 12px 16px; min-width: 260px;
}
.totals-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 13px; }
.totals-row.grand { border-top: 2px solid var(--border-color); margin-top: 4px; padding-top: 8px; font-size: 16px; font-weight: 700; color: var(--text-primary); }
.totals-label { color: var(--text-secondary); }
.totals-value { font-family: var(--font-mono); font-weight: 500; }

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    background: var(--bg-panel); padding: 8px 14px;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted);
    text-align: left; border-bottom: 1px solid var(--border-color);
    white-space: nowrap; user-select: none; position: sticky; top: 0; z-index: 1;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--primary); }
.data-table td { padding: 8px 14px; border-bottom: 1px solid var(--border-light); font-size: 13px; vertical-align: middle; }
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }
.data-table .row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.data-table .empty-state { text-align: center; padding: 40px; color: var(--text-muted); }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center; padding: 2px 8px;
    border-radius: 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
}
.badge-draft { background: #ECEFF1; color: #546E7A; }
.badge-posted { background: #E8F5E9; color: #2E7D32; }
.badge-paid { background: #E3F2FD; color: #1565C0; }
.badge-partial { background: #FFF3E0; color: #E65100; }
.badge-cancelled { background: #FFEBEE; color: #C62828; }
.badge-confirmed { background: #E0F7FA; color: #00838F; }
.badge-invoiced { background: #E8F5E9; color: #2E7D32; }
.badge-billed { background: #E8F5E9; color: #2E7D32; }
.badge-overdue { background: #FFEBEE; color: #C62828; }
.badge-active { background: #E8F5E9; color: #2E7D32; }
.badge-inactive { background: #ECEFF1; color: #546E7A; }
.badge-customer { background: rgba(113,75,103,0.08); color: var(--primary); }
.badge-supplier { background: rgba(0,160,157,0.08); color: var(--secondary); }
.badge-both { background: rgba(21,101,192,0.08); color: var(--info); }

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45); z-index: 2000;
    display: none; align-items: center; justify-content: center;
    padding: 20px; backdrop-filter: blur(3px);
}
.modal-overlay.active { display: flex; animation: fadeIn 0.15s ease; }
.modal {
    background: var(--bg-white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl); width: 100%; max-height: 90vh;
    display: flex; flex-direction: column; animation: slideUp 0.2s ease;
}
.modal-sm { max-width: 420px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 860px; }
.modal-xl { max-width: 1060px; }
.modal-header {
    padding: 14px 20px; border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    border: none; background: transparent; cursor: pointer;
    font-size: 18px; display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); transition: var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 10px 20px; border-top: 1px solid var(--border-light);
    display: flex; justify-content: flex-end; gap: 6px;
}

/* ===== DRAWER ===== */
.drawer-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.35); z-index: 2000;
    display: none; backdrop-filter: blur(2px);
}
.drawer-overlay.active { display: block; animation: fadeIn 0.15s ease; }
.drawer {
    position: fixed; top: 0; right: -520px; bottom: 0;
    width: 480px; max-width: 90vw; background: var(--bg-white);
    z-index: 2001; box-shadow: var(--shadow-xl);
    transition: right 0.25s ease; display: flex; flex-direction: column;
}
.drawer.active { right: 0; }
.drawer-header {
    padding: 14px 20px; border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
}
.drawer-header h3 { font-size: 15px; font-weight: 600; }
.drawer-close {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    border: none; background: transparent; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); transition: var(--transition); font-size: 18px;
}
.drawer-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer-footer {
    padding: 10px 20px; border-top: 1px solid var(--border-light);
    display: flex; justify-content: flex-end; gap: 6px;
}

/* ===== PIPELINE ===== */
.pipeline-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 10px;
    background: var(--primary-bg); color: var(--primary);
    font-size: 11px; font-weight: 600;
    cursor: pointer; transition: var(--transition);
    border: none; font-family: var(--font-family);
}
.pipeline-btn:hover { background: rgba(113,75,103,0.12); }
.pipeline-btn svg { width: 12px; height: 12px; }
.pipeline-dialog { max-width: 400px; }
.pipeline-chain { padding: 12px 0; }
.pipeline-node {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: var(--radius);
    transition: var(--transition); cursor: pointer;
}
.pipeline-node:hover { background: var(--bg-hover); }
.pipeline-node .node-dot {
    width: 10px; height: 10px; border-radius: 50%;
    border: 2px solid var(--primary); flex-shrink: 0;
}
.pipeline-node .node-dot.filled { background: var(--primary); }
.pipeline-node .node-info { flex: 1; }
.pipeline-node .node-title { font-size: 13px; font-weight: 500; }
.pipeline-node .node-sub { font-size: 11px; color: var(--text-muted); }
.pipeline-connector { display: flex; padding-left: 16px; }
.pipeline-connector .line { width: 2px; height: 16px; background: var(--border-color); }

/* ===== SPOTLIGHT + GRID MENU ===== */
.spotlight-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45); z-index: 3000;
    display: none; justify-content: center; padding-top: 10vh;
    backdrop-filter: blur(4px);
}
.spotlight-overlay.active { display: flex; animation: fadeIn 0.1s ease; }
.spotlight {
    width: 640px; max-width: 92vw; background: var(--bg-white);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
    overflow: hidden; animation: slideDown 0.15s ease;
    max-height: 70vh; display: flex; flex-direction: column;
}
.spotlight-input-wrap {
    display: flex; align-items: center; padding: 14px 20px;
    border-bottom: 1px solid var(--border-light); gap: 10px;
}
.spotlight-input-wrap .s-icon { color: var(--text-muted); display: flex; }
.spotlight-input-wrap .s-icon svg { width: 18px; height: 18px; }
.spotlight-input {
    flex: 1; border: none; outline: none; font-size: 15px;
    font-family: var(--font-family); color: var(--text-primary); background: transparent;
}
.spotlight-input::placeholder { color: var(--text-muted); }

.spotlight-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 2px; padding: 12px;
}
.spotlight-grid-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; padding: 16px 8px; border-radius: var(--radius);
    cursor: pointer; transition: var(--transition);
    text-decoration: none; color: var(--text-primary);
}
.spotlight-grid-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.spotlight-grid-item .grid-icon {
    width: 44px; height: 44px; border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
}
.spotlight-grid-item .grid-icon svg { width: 22px; height: 22px; }
.spotlight-grid-item .grid-icon.purple { background: rgba(113,75,103,0.08); color: var(--primary); }
.spotlight-grid-item .grid-icon.teal { background: rgba(0,160,157,0.08); color: var(--secondary); }
.spotlight-grid-item .grid-icon.green { background: rgba(46,125,50,0.08); color: var(--success); }
.spotlight-grid-item .grid-icon.red { background: rgba(198,40,40,0.08); color: var(--danger); }
.spotlight-grid-item .grid-icon.blue { background: rgba(21,101,192,0.08); color: var(--info); }
.spotlight-grid-item .grid-icon.orange { background: rgba(230,81,0,0.08); color: var(--warning); }
.spotlight-grid-item .grid-label { font-size: 11px; font-weight: 500; text-align: center; }

.spotlight-section { padding: 6px 0; }
.spotlight-section-title {
    padding: 6px 20px; font-size: 10px; text-transform: uppercase;
    letter-spacing: 1px; color: var(--text-muted); font-weight: 600;
}
.spotlight-results { overflow-y: auto; flex: 1; }
.spotlight-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 20px; cursor: pointer; transition: background 0.1s;
}
.spotlight-item:hover, .spotlight-item.active { background: var(--bg-hover); }
.spotlight-item .item-icon {
    width: 30px; height: 30px; border-radius: var(--radius);
    background: var(--bg-panel); display: flex;
    align-items: center; justify-content: center; color: var(--text-secondary);
}
.spotlight-item .item-icon svg { width: 14px; height: 14px; }
.spotlight-item .item-text { flex: 1; }
.spotlight-item .item-title { font-size: 13px; font-weight: 500; }
.spotlight-item .item-subtitle { font-size: 11px; color: var(--text-muted); }
.spotlight-item .item-shortcut {
    font-size: 11px; color: var(--text-muted);
    background: var(--bg-panel); padding: 2px 6px;
    border-radius: var(--radius-sm); font-family: var(--font-mono);
}
.spotlight-footer {
    padding: 8px 20px; border-top: 1px solid var(--border-light);
    font-size: 11px; color: var(--text-muted); display: flex; gap: 16px;
}

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 2px; padding: 12px 0; }
.pagination .page-btn {
    padding: 5px 10px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-color); background: var(--bg-white);
    cursor: pointer; font-size: 12px; transition: var(--transition); font-family: var(--font-family);
}
.pagination .page-btn:hover { background: var(--bg-hover); }
.pagination .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-info { font-size: 12px; color: var(--text-secondary); margin: 0 6px; }

/* ===== FILTER BAR ===== */
.filter-bar { display: flex; align-items: center; gap: 10px; padding: 10px 0; flex-wrap: wrap; }
.filter-bar .filter-input {
    padding: 6px 10px; border: 1px solid var(--border-color);
    border-radius: var(--radius); font-size: 12px; font-family: var(--font-family);
    min-width: 160px; background: var(--bg-white);
}
.filter-bar .filter-input:focus { outline: none; border-color: var(--primary); }
.filter-bar .filter-count { margin-left: auto; font-size: 12px; color: var(--text-secondary); }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 2px solid var(--border-light); margin-bottom: 16px; }
.tab-btn {
    padding: 8px 16px; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: var(--transition); background: none;
    border-top: none; border-left: none; border-right: none; font-family: var(--font-family);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== TREE VIEW ===== */
.tree-view { list-style: none; padding: 0; }
.tree-node { border-bottom: 1px solid var(--border-light); }
.tree-node-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; transition: var(--transition); }
.tree-node-header:hover { background: var(--bg-hover); }
.tree-toggle { width: 20px; text-align: center; font-size: 10px; color: var(--text-muted); transition: var(--transition); }
.tree-node.expanded > .tree-node-header .tree-toggle { transform: rotate(90deg); }
.tree-children { display: none; padding-left: 24px; }
.tree-node.expanded > .tree-children { display: block; }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 56px; right: 16px; z-index: 5000; display: flex; flex-direction: column; gap: 6px; }
.toast {
    padding: 10px 16px; border-radius: var(--radius);
    box-shadow: var(--shadow-md); font-size: 13px;
    display: flex; align-items: center; gap: 8px;
    animation: slideLeft 0.2s ease; min-width: 280px; max-width: 420px;
}
.toast-success { background: #E8F5E9; color: #1B5E20; border-left: 3px solid var(--success); }
.toast-error { background: #FFEBEE; color: #B71C1C; border-left: 3px solid var(--danger); }
.toast-warning { background: #FFF3E0; color: #BF360C; border-left: 3px solid var(--warning); }
.toast-info { background: #E3F2FD; color: #0D47A1; border-left: 3px solid var(--info); }
.toast-close { margin-left: auto; cursor: pointer; opacity: 0.6; background: none; border: none; font-size: 14px; color: inherit; padding: 2px; }
.toast-close:hover { opacity: 1; }

/* ===== LOADING ===== */
.loading-spinner {
    display: inline-block; width: 18px; height: 18px;
    border: 2px solid var(--border-color); border-top-color: var(--primary);
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
.loading-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.7); display: flex;
    align-items: center; justify-content: center; z-index: 10; border-radius: inherit;
}
.page-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px; color: var(--text-secondary); gap: 10px; }

/* ===== DROPDOWN ===== */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; top: 100%; right: 0; min-width: 180px;
    background: var(--bg-white); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); border: 1px solid var(--border-light);
    z-index: 100; display: none; padding: 4px 0; animation: fadeIn 0.1s ease;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 14px; font-size: 13px; cursor: pointer;
    color: var(--text-primary); transition: background 0.1s;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item svg { width: 14px; height: 14px; }
.dropdown-divider { border-top: 1px solid var(--border-light); margin: 4px 0; }

/* ===== COLLAPSIBLE RECORD ===== */
.record-detail {
    background: var(--bg-panel); border-radius: var(--radius);
    border: 1px solid var(--border-light); margin: 8px 0;
}
.record-detail-header {
    padding: 10px 14px; display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; transition: var(--transition);
}
.record-detail-header:hover { background: var(--bg-hover); }
.record-detail-header .rd-title { font-size: 13px; font-weight: 600; }
.record-detail-header .rd-meta { font-size: 12px; color: var(--text-muted); }
.record-detail-header .rd-toggle { transition: transform 0.2s; }
.record-detail-header .rd-toggle.open { transform: rotate(180deg); }
.record-detail-body { display: none; padding: 0 14px 14px; border-top: 1px solid var(--border-light); }
.record-detail-body.open { display: block; }
.record-detail-actions { display: flex; gap: 4px; padding-top: 8px; border-top: 1px solid var(--border-light); margin-top: 8px; }

/* ===== SETTINGS LAYOUT ===== */
.settings-layout {
    display: flex; gap: 0; min-height: 500px;
    border: 1px solid var(--border-light); border-radius: var(--radius-lg);
    overflow: hidden; background: var(--bg-white);
}
.settings-nav { width: 220px; background: var(--bg-panel); border-right: 1px solid var(--border-light); flex-shrink: 0; }
.settings-nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; font-size: 13px; color: var(--text-secondary);
    cursor: pointer; transition: var(--transition); border-left: 3px solid transparent;
}
.settings-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.settings-nav-item.active { background: var(--bg-white); color: var(--primary); border-left-color: var(--primary); font-weight: 500; }
.settings-nav-item svg { width: 16px; height: 16px; }
.settings-body { flex: 1; padding: 24px; overflow-y: auto; }
.settings-section { display: none; }
.settings-section.active { display: block; }
.settings-section-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin: 0 0 6px; }
.settings-section-desc { font-size: 12px; color: var(--text-secondary); margin: 0 0 20px; }
.settings-fields { max-width: 480px; }
.settings-footer { padding-top: 20px; border-top: 1px solid var(--border-light); margin-top: 24px; }

/* ===== PRINT ===== */
@media print {
    .topbar, .party-panel, .no-print, .page-actions, .filter-bar,
    .profile-tabs, .profile-actions { display: none !important; }
    .main-content { overflow: visible !important; }
    .app-body { display: block !important; }
    .workspace { padding: 0 !important; }
    .card { box-shadow: none !important; border: none !important; }
    body { background: #fff !important; overflow: visible !important; height: auto !important; }
}

.watermark {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 80px; font-weight: 700; opacity: 0.02;
    color: var(--primary); pointer-events: none; z-index: 0;
    white-space: nowrap; user-select: none;
}

/* ===== LOGIN ===== */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--bg-sidebar); padding: 20px;
}
.login-card {
    background: var(--bg-white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl); width: 380px; max-width: 100%;
    padding: 36px; text-align: center;
}
.login-card .login-brand { margin-bottom: 28px; }
.login-card .login-brand h1 { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 2px; letter-spacing: -0.5px; }
.login-card .login-brand span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 2px; }
.login-card .form-group { text-align: left; }
.login-card .btn { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }
.login-error { background: #FFEBEE; color: #C62828; padding: 8px 12px; border-radius: var(--radius); font-size: 12px; margin-bottom: 14px; text-align: left; }

/* ===== INVOICE PRINT ===== */
.invoice-print { max-width: 800px; margin: 0 auto; padding: 40px; background: #fff; position: relative; }
.invoice-print .invoice-header { display: flex; justify-content: space-between; margin-bottom: 32px; align-items: flex-start; }
.invoice-print .company-info h2 { font-size: 20px; color: var(--primary); }
.invoice-print .invoice-meta { text-align: right; }
.invoice-print .invoice-meta h1 { font-size: 28px; color: var(--primary); font-weight: 700; }
.invoice-print .invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.invoice-print .party-box h4 { font-size: 11px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; letter-spacing: 1px; }
.invoice-print .items-table th { background: var(--primary); color: #fff; }
.invoice-print .invoice-totals { display: flex; justify-content: flex-end; margin-top: 20px; }
.invoice-print .totals-table { width: 300px; }
.invoice-print .totals-table td { padding: 6px 12px; font-size: 13px; }
.invoice-print .totals-table .total-row { font-weight: 700; font-size: 16px; border-top: 2px solid var(--primary); }
.invoice-print .invoice-footer { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: flex-end; }
.invoice-print .qr-code { text-align: center; }
.invoice-print .qr-code img { width: 100px; height: 100px; }
.invoice-print .qr-code p { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

.verify-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-body); padding: 20px; }
.verify-card { background: var(--bg-white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 420px; max-width: 100%; padding: 36px; }
.verify-detail { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.verify-detail:last-child { border-bottom: none; }
.verify-detail .label { color: var(--text-secondary); }
.verify-detail .value { font-weight: 600; }

/* ===== EMPTY STATE ===== */
.empty-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; }
.empty-placeholder svg { width: 48px; height: 48px; color: var(--text-muted); margin-bottom: 12px; }
.empty-placeholder h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty-placeholder p { font-size: 13px; color: var(--text-muted); max-width: 320px; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideLeft { from { transform: translateX(60px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .party-panel { position: fixed; left: 0; top: var(--topbar-height); bottom: 0; z-index: 900; box-shadow: var(--shadow-lg); }
    .party-panel.collapsed { width: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .spotlight-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .workspace { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .modal { max-width: 95vw; }
    .drawer { width: 100%; max-width: 100vw; }
    .spotlight-grid { grid-template-columns: repeat(2, 1fr); }
    .profile-top { flex-direction: column; }
    .profile-stats { margin-left: 0; }
    /* Hide "Home" breadcrumb on mobile */
    .trail-item-home, .trail-sep-home { display: none !important; }
    /* Hide username/role text, show only avatar */
    .topbar-user .u-name, .topbar-user .u-role { display: none; }
    /* Party panel: off-canvas overlay on mobile */
    .party-panel {
        width: var(--panel-width) !important;
        position: fixed;
        left: calc(-1 * var(--panel-width));
        top: var(--topbar-height);
        bottom: 0;
        z-index: 900;
        transition: left 0.3s ease, box-shadow 0.3s ease;
        box-shadow: none;
    }
    .party-panel.collapsed { left: calc(-1 * var(--panel-width)); }
    .party-panel.mobile-open { left: 0 !important; box-shadow: var(--shadow-lg); }
    /* Semi-transparent overlay behind open panel */
    .panel-overlay {
        display: none;
        position: fixed;
        inset: 0;
        top: var(--topbar-height);
        background: rgba(0,0,0,0.45);
        z-index: 899;
    }
    .panel-overlay.active { display: block; }
}
@media (max-width: 480px) {
    html { font-size: 13px; }
    .topbar { padding: 0 10px; }
    .topbar-search { display: none; }
}

/* Utility */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.clickable { cursor: pointer; }
.money { font-family: var(--font-mono); text-align: right; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ═══════════════════════════════════════════════════════════════
   MICRO-ANIMATIONS  (v2)
═══════════════════════════════════════════════════════════════ */

/* Fade-in for page cards */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.28s ease both; }

/* Table row slide-in */
@keyframes rowSlideIn {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}
.table-row-anim {
    animation: rowSlideIn 0.2s ease both;
}
.data-table tbody tr:nth-child(n) { animation-delay: calc(var(--row-idx, 0) * 0.03s); }

/* Item row add animation */
@keyframes itemRowDrop {
    from { opacity: 0; transform: scaleY(0.7); }
    to   { opacity: 1; transform: scaleY(1); }
}
.item-row-anim {
    animation: itemRowDrop 0.18s ease both;
    transform-origin: top;
}

/* Badge pulse on status change */
@keyframes badgePop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}
.badge-anim { animation: badgePop 0.4s ease both; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

/* Skeleton loading */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3, #2a2a3a) 50%, var(--surface-2) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 4px;
    height: 14px;
}

/* Number counter (used in dashboard stat cards) */
@keyframes countUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.stat-number { animation: countUp 0.5s ease both; }

/* Modal slide-in */
@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.96) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-overlay.open .modal {
    animation: modalSlide 0.22s cubic-bezier(0.34, 1.16, 0.64, 1) both;
}

/* Button click feedback */
.btn:active { transform: scale(0.97); transition: transform 0.08s; }

/* Toast slide-in */
@keyframes toastIn {
    from { opacity: 0; transform: translateX(60px); }
    to   { opacity: 1; transform: translateX(0); }
}
.toast { animation: toastIn 0.25s ease both; }

/* Tab switch underline */
.tab-btn { position: relative; transition: color 0.15s; }
.tab-btn.active::after {
    content: '';
    position: absolute; bottom: -2px; left: 0; right: 0;
    height: 2px; background: var(--primary);
    animation: fadeInUp 0.2s ease both;
}

/* ═══════════════════════════════════════════════════════════════
   PIPELINE TREE  (Invoice → Payment flow)
═══════════════════════════════════════════════════════════════ */
.pipeline-tree { padding: 8px 0; }

.pipeline-node {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    animation: fadeInUp 0.22s ease both;
}
.pipeline-root    { border-color: var(--primary); }
.pipeline-payment { border-color: var(--success); }
.pipeline-pending { border-color: var(--warning); opacity: 0.7; border-style: dashed; }

.pipeline-icon  { font-size: 20px; flex-shrink: 0; }
.pipeline-label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.pipeline-label strong { font-size: 14px; }

.pipeline-connector {
    width: 2px;
    height: 24px;
    background: var(--border);
    margin-left: 26px;
}
.pipeline-connector-dashed {
    background: repeating-linear-gradient(
        to bottom,
        var(--border) 0, var(--border) 5px,
        transparent 5px, transparent 10px
    );
}

/* ═══════════════════════════════════════════════════════════════
   TABS
═══════════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab-btn {
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border-radius: 4px 4px 0 0;
    transition: color 0.15s, background 0.15s;
}
.tab-btn:hover  { color: var(--text); background: var(--surface-2); }
.tab-btn.active { color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════
   STATUS COLORS
═══════════════════════════════════════════════════════════════ */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--text-muted) !important; }

/* ═══════════════════════════════════════════════════════════════
   form-control-sm
═══════════════════════════════════════════════════════════════ */
.form-control-sm {
    padding: 4px 8px;
    font-size: 12px;
    height: auto;
}
