:root {
    /* Color Palette - Mysterious & Soft (Custom) */
    --bg-dark: #2C2B30;
    /* Charleston Green Background */
    --sidebar-bg: #1E1D22;
    /* Darker Charleston Sidebar */
    --accent-primary: #F58F7C;
    /* Tea Rose / Warm Accent */
    --accent-blue: #F2C4CE;
    /* Orchid Pink / Soft Accent */
    --text-main: #D6D6D6;
    /* Light Gray Text */
    --text-dim: #8A8A8C;
    /* Dark Liver adjusted for contrast */
    --glass-border: rgba(214, 214, 214, 0.1);
    --glass-bg: rgba(79, 79, 81, 0.2);
    /* Dark Liver Glass */
    --success: #F2C4CE;
    /* Orchid Pink for Success */
    --warning: #F58F7C;
    /* Tea Rose for Warning */
    --danger: #D47B6A;
    /* Warm Deep Rose for Danger */
    --surface: #3E3D42;
    /* Material Surface */

    /* Layout */
    --sidebar-width: 280px;
    --topbar-height: 140px;
    --border-radius: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.02em;
}

/* Tabular Figures for currency and tables */
.stat-value,
.data-table td,
.tabular-nums,
#subtotal,
#vat-total,
#grand-total {
    font-variant-numeric: tabular-nums;
}

/* Glassmorphism Effect */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling - Minimalist Wise Style */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    padding: 2.5rem 0;
}

.logo {
    display: flex;
    align-items: center;
    padding: 0 2rem;
    margin-bottom: 4rem;
    gap: 14px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #163300;
    font-weight: 800;
    font-size: 1.2rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    color: white;
}

.main-nav ul {
    list-style: none;
    padding: 0 1rem;
}

.main-nav li {
    padding: 0.8rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #cbd5e1;
    /* Increased contrast from var(--text-dim) */
    cursor: pointer;
    transition: var(--transition);
    border-radius: 12px;
    margin-bottom: 4px;
    font-weight: 500;
}

.main-nav li:hover {
    color: var(--text-main);
    background: rgba(242, 196, 206, 0.1);
}

.main-nav li.active {
    color: #2C2B30;
    background: var(--accent-primary);
    font-weight: 600;
}

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.top-bar {
    height: var(--topbar-height);
    display: flex;
    align-items: flex-start;
    /* Aligns with sidebar logo padding */
    justify-content: space-between;
    padding: 2.5rem 3rem 0;
    /* Match sidebar's 2.5rem top padding */
}

#header-welcome-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.search-box input {
    background: rgba(249, 236, 220, 0.05);
    border: 1px solid transparent;
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    width: 400px;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-blue);
    width: 350px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.btn {
    padding: 0.8rem 1.8rem;
    border-radius: 100px;
    /* Wise style pills */
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    transition: var(--transition);
}

.btn-primary {
    background: var(--accent-primary);
    color: #2C2B30;
}

.btn-primary:hover {
    background: #b5f08e;
    transform: scale(1.02);
}

#page-content {
    padding: 0 3rem 4rem;
    /* Top padding 0 to align with topbar bottom */
    overflow-y: auto;
    flex: 1;
}

/* Dashboard - Revolut Style Tiles */
.dashboard-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-dim);
    margin-top: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    padding: 2.5rem;
    border-radius: 24px;
    background: #36353b;
    border: 1px solid rgba(214, 214, 214, 0.08);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    background: var(--accent-blue);
    filter: blur(40px);
    opacity: 0.1;
}

.stat-label {
    color: var(--text-dim);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: block;
}

.stat-value {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -2px;
}

.stat-trend {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 100px;
    background: rgba(159, 232, 112, 0.1);
    display: inline-block;
}

/* Activity & List Sections */
.recent-activity {
    margin-top: 2rem;
}

.recent-activity h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 0;
    color: var(--text-dim);
}

.empty-state button {
    margin-top: 1.5rem;
}

/* Page Headers */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

/* Invoice Editor */
.invoice-editor {
    padding: 2.5rem;
    border-radius: var(--border-radius);
    max-width: 1000px;
    margin: 0 auto;
}

.invoice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    margin-bottom: 3rem;
}

.invoice-grid h3,
.items-section h3 {
    font-size: 1rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Data Tables (Lists) */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.data-table th {
    color: var(--text-dim);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1rem 1.5rem;
    font-weight: 700;
    text-align: left;
    /* Default left alignment */
}

.data-table td {
    background: #323138;
    padding: 1.2rem 1.5rem;
    font-weight: 500;
}

.data-table tr td:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.data-table tr td:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.data-table tr:hover td {
    background: #1e293b;
}

/* Alignment Utilities */
.text-left {
    text-align: left !important;
}

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.item-qty,
.item-rate {
    width: 80px !important;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.5;
}

.btn-icon:hover {
    opacity: 1;
}

.invoice-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 700;
}

.invoice-link:hover {
    text-decoration: underline;
}

/* Totals */
.modal-container {
    background: var(--sidebar-bg);
    border-radius: 20px;
    max-width: 900px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7);
    margin: auto;
}

/* Confirmation Modal Specifics */
.confirm-content {
    padding: 3rem !important;
    border-radius: 24px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 50px 100px rgba(0, 0, 0, 0.5) !important;
}

.confirm-icon-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.confirm-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
}

.confirm-icon.danger {
    background: rgba(212, 123, 106, 0.1);
    color: var(--danger);
    border: 2px solid var(--danger);
}

.confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1rem;
}

.btn.danger {
    background: var(--danger);
    color: white;
}

.btn.danger:hover {
    background: #e28a7a;
    transform: scale(1.02);
}

.totals-section {
    margin-top: 3rem;
    margin-left: auto;
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #0f172a;
    padding: 2rem;
    border-radius: 20px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.grand-total {
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.btn-secondary {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Animations */
.page-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Badges */
.badge {
    padding: 0.4rem 1rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-paid {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-overdue {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Action Menus (Three-Dots) */
.action-menu {
    position: relative;
    display: inline-block;
}

.btn-dots {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    line-height: 1;
}

.btn-dots:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 160px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 100;
    margin-top: 5px;
    overflow: hidden;
}

.dropdown-content.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Task Center Hub */
.task-center {
    position: relative;
    margin-right: 15px;
}

.btn-task-bell {
    background: rgba(214, 214, 214, 0.05);
    /* Subtle Light Gray backdrop */
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 10px;
    border-radius: var(--radius-md);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.btn-task-bell:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.task-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent-primary);
    /* Tea Rose */
    color: #2C2B30;
    /* Charleston Green */
    font-size: 0.7rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #2C2B30;
    /* Charleston Green */
}

.task-badge:empty,
.task-badge[data-count="0"] {
    display: none;
}

.task-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    width: 300px;
    margin-top: 10px;
    z-index: 1000;
    padding: 0;
    overflow: hidden;
    animation: fadeIn 0.2s ease-out;
}

.task-dropdown.show {
    display: block;
}

.task-header {
    padding: 15px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
}

.task-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.task-items {
    max-height: 400px;
    overflow-y: auto;
}

.task-item {
    padding: 15px;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 12px;
}

.task-item:last-child {
    border-bottom: none;
}

.task-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.task-icon {
    font-size: 1.25rem;
    margin-top: 2px;
}

.task-content {
    flex: 1;
}

.task-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
}

.task-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.task-item.urgent .task-icon {
    color: var(--danger);
}

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

.task-item.info .task-icon {
    color: var(--accent-blue);
}

.task-item.success .task-icon {
    color: var(--accent-primary);
}

/* === INVOICE EDITOR V2 === */

.invoice-editor {
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 4rem;
}

.sticky-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-dark);
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 2rem;
}

.editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.editor-section {
    padding: 2rem;
    border-radius: var(--radius-lg);
}

.section-title {
    color: var(--accent-blue);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Form Refinements within Editor */
.invoice-editor input[type="text"],
.invoice-editor input[type="email"],
.invoice-editor input[type="number"],
.invoice-editor input[type="date"],
.invoice-editor input[list] {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    transition: all 0.2s ease;
}

.invoice-editor input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 117, 255, 0.2);
}

.editor-totals {
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

/* Forms (continued) */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.8rem 1.2rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    color: white;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus {
    border-color: var(--accent-primary);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 2rem;
    margin-top: auto;
    border-top: 1px solid var(--glass-border);
}

.company-badge {
    display: flex;
    flex-direction: column;
}

.company-name {
    color: white;
    font-weight: 700;
}

.vat-status {
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Modal & A4 Preview */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding: 3rem 2rem;
    overflow-y: auto;
}

.modal-container {
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1001;
    padding-bottom: 1rem;
}

.a4-paper {
    width: 800px;
    min-height: 1131px;
    background: white;
    margin: 0 auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    color: #111;
}

.btn-close {
    background: #333;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
}

.btn-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    transform: rotate(90deg);
}

/* Settings Masterpiece Layout */
.settings-container {
    display: flex;
    gap: 0;
    height: calc(100vh - var(--topbar-height) - 4rem);
    background: rgba(79, 79, 81, 0.05);
    /* Dark Liver based Glass */
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.settings-sidebar {
    width: 240px;
    background: rgba(30, 29, 34, 0.6);
    border-right: 1px solid var(--glass-border);
    padding: 2rem 1rem;
}

.settings-tab {
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    color: var(--text-dim);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.settings-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.settings-tab.active {
    color: #2C2B30;
    background: var(--accent-primary);
    font-weight: 600;
}

.settings-content {
    flex: 1;
    padding: 3.5rem;
    overflow-y: auto;
    background: rgba(44, 43, 48, 0.2);
}

.settings-view {
    max-width: 700px;
}

.settings-view h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 2.5rem;
    color: white;
    letter-spacing: -0.03em;
}

.settings-section {
    margin-bottom: 3.5rem;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-section h3 {
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    opacity: 0.9;
}

/* Custom Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    user-select: none;
}

.toggle-input {
    display: none;
}

.toggle-slider {
    width: 44px;
    height: 22px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    position: relative;
    transition: var(--transition);
    border: 1px solid var(--glass-border);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--text-dim);
    border-radius: 50%;
    top: 3px;
    left: 4px;
    transition: var(--transition);
}

.toggle-input:checked+.toggle-slider {
    background: var(--accent-primary);
    border-color: rgba(0, 0, 0, 0.1);
}

.toggle-input:checked+.toggle-slider::before {
    transform: translateX(22px);
    background: #2C2B30;
}

.settings-footer {
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
    margin-top: 3rem;
    display: flex;
    justify-content: flex-start;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Identity Selector Styles - Sidebar Footer Version */
#identity-selector-container {
    padding: 0 1.5rem;
}

.identity-selector {
    padding: 2px 4px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    transition: var(--transition);
}

.identity-selector select {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 8px 4px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
}

.identity-selector select option {
    background: var(--sidebar-bg);
    color: var(--text-main);
}

.identity-selector:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-main);
}

.identity-selector:hover select {
    color: var(--text-main);
}

/* Banking Styles */
.active-account-card {
    transition: all 0.2s ease;
    cursor: default;
    border: 1px solid var(--glass-border);
}

.active-account-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
}

.bank-accounts-list {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.transaction-triage {
    min-height: 500px;
}

[data-page="banking"].active {
    background: rgba(var(--primary-rgb), 0.1);
}

/* === SPRINT 5.1: CUSTOM SVG ICONS & ANIMATIONS === */

.icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--accent-primary);
    transition: var(--transition);
    margin-right: 1rem;
}

.icon-wrapper svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: var(--transition);
}

.icon-wrapper:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    color: var(--accent-blue);
}

.icon-wrapper:hover svg {
    transform: scale(1.1);
}

.icon-large {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    margin-bottom: 1.5rem;
}

.icon-large svg {
    width: 32px;
    height: 32px;
}

/* Page Header Icon Alignment */
.page-header-with-icon {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.page-header-with-icon .icon-wrapper {
    width: 56px;
    height: 56px;
    margin-right: 0;
}

.page-header-with-icon .icon-wrapper svg {
    width: 28px;
    height: 28px;
}

.icon-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

.icon-sm svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.settings-tab .icon-sm {
    opacity: 0.6;
    transition: var(--transition);
}

.settings-tab:hover .icon-sm,
.settings-tab.active .icon-sm {
    opacity: 1;
    color: var(--accent-primary);
}

/* === AI CHAT DRAWER === */
.chat-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 999;
}

.chat-drawer {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    border-left: 1px solid var(--glass-border);
}

.chat-drawer.open {
    right: 0;
}

.chat-drawer .chat-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.chat-logo {
    width: 32px;
    height: 32px;
    background: var(--accent-blue);
    color: #2C2B30;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    max-width: 85%;
    padding: 1rem 1.2rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.message.ai {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.user {
    background: var(--accent-primary);
    color: #2C2B30;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

.chat-input-area {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 12px;
}

.chat-input-area input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    color: white;
    outline: none;
}

.btn-send {
    background: var(--accent-blue);
    color: #2C2B30;
    border: none;
    border-radius: 12px;
    width: 46px;
    height: 46px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-send:hover {
    transform: scale(1.05);
    background: var(--accent-primary);
}

/* ============================================
   INVOICE PREVIEW MODAL & A4 DOCUMENT STYLES
   ============================================ */

.invoice-preview-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.invoice-preview-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    gap: 1rem;
}

.preview-actions-left,
.preview-actions-right {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.invoice-preview-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* === A4 Invoice Document === */
.invoice-doc {
    background: #ffffff;
    color: #1f2937;
    width: 100%;
    max-width: 794px;
    min-height: 1000px;
    border-radius: 6px;
    padding: 52px 60px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    font-family: 'Inter', 'Outfit', -apple-system, sans-serif;
    font-size: 0.875rem;
    line-height: 1.6;
}

.invoice-doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 2rem;
}

.invoice-from { flex: 1; }

.invoice-company-name {
    font-size: 1.6rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.invoice-address {
    color: #4b5563;
    font-size: 0.8rem;
    line-height: 1.75;
    margin-bottom: 0.25rem;
}

.invoice-meta-line {
    color: #6b7280;
    font-size: 0.78rem;
    margin-top: 2px;
}

.invoice-title-block { text-align: right; }

.invoice-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: #9ca3af;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.invoice-number-big {
    font-size: 1.9rem;
    font-weight: 800;
    color: #111827;
    line-height: 1.1;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.invoice-status-tag {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.invoice-status-tag.status-paid { background: #dcfce7; color: #16a34a; }
.invoice-status-tag.status-overdue { background: #fee2e2; color: #dc2626; }
.invoice-status-tag.status-pending { background: #fef3c7; color: #b45309; }

.invoice-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 1.75rem 0;
}

.invoice-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.invoice-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: #9ca3af;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.invoice-client-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
}

.invoice-client-detail {
    color: #6b7280;
    font-size: 0.85rem;
    margin-top: 2px;
}

.invoice-dates-table { width: 100%; font-size: 0.85rem; border-collapse: collapse; }
.invoice-dates-table td { padding: 4px 0; }
.invoice-dates-table td:first-child { color: #6b7280; padding-right: 1.5rem; }
.invoice-dates-table td:last-child { text-align: right; color: #111827; }

/* Items Table */
.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.invoice-items-table th {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #9ca3af;
    text-transform: uppercase;
    padding: 10px 10px;
    border-bottom: 2px solid #e5e7eb;
    text-align: left;
}

.invoice-items-table .inv-text-right { text-align: right; }

.invoice-items-table td {
    padding: 13px 10px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    vertical-align: top;
}

.invoice-items-table td:first-child { font-weight: 500; color: #111827; }

/* Totals */
.invoice-totals-block {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 2.5rem;
}

.invoice-totals-inner { width: 280px; }

.invoice-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 7px 0;
    color: #4b5563;
    font-size: 0.9rem;
    border-bottom: 1px solid #f3f4f6;
}

.invoice-totals-row.grand {
    font-size: 1.1rem;
    font-weight: 800;
    color: #111827;
    border-top: 2px solid #111827;
    border-bottom: 2px solid #111827;
    padding: 10px 0;
    margin-top: 4px;
}

/* Bank Details */
.invoice-bank-section {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.75rem;
}

.invoice-bank-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 0.6rem;
}

.invoice-bank-grid div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.invoice-bank-grid div span {
    font-size: 0.68rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.invoice-bank-grid div strong {
    color: #111827;
    font-size: 0.88rem;
    font-weight: 600;
}

/* Notes */
.invoice-notes-section {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
    margin-bottom: 2rem;
}

.invoice-notes-text {
    color: #4b5563;
    font-size: 0.85rem;
    line-height: 1.7;
    margin: 0;
    white-space: pre-wrap;
}

/* Footer */
.invoice-footer {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.75rem;
    margin-top: 2rem;
}

/* Compliance Status Cards (FRS 105) */
.compliance-card {
    padding: 1.5rem;
    border-radius: 16px;
    border-left: 5px solid transparent;
    transition: var(--transition);
    margin-bottom: 1.5rem;
}

.compliance-card.status-good {
    background: rgba(16, 185, 129, 0.05); /* Greenish (adjusted for success) */
    border-color: #10b981;
}

.compliance-card.status-alert {
    background: rgba(239, 68, 68, 0.05); /* Reddish (adjusted for danger) */
    border-color: #ef4444;
}

.compliance-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.compliance-stat:last-child {
    border-bottom: none;
}

.compliance-label {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 500;
}

.compliance-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
}

/* Legal Page Layout */
.legal-page {
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.7;
    color: var(--text-inner);
    padding-bottom: 5rem;
}

.legal-section {
    margin-bottom: 3rem;
}

.legal-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: white;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.legal-section p {
    margin-bottom: 1.2rem;
    font-size: 1rem;
}

.disclaimer-box {
    background: rgba(245, 143, 124, 0.1);
    border: 1px solid var(--accent-primary);
    padding: 2rem;
    border-radius: 12px;
    margin: 2rem 0;
}

.disclaimer-box strong {
    color: var(--accent-primary);
    display: block;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* AI Insights & Magic Bar Styles */
.magic-bar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 15vh;
}

.magic-bar-container {
    width: 600px;
    max-width: 90%;
    display: flex;
    align-items: center;
    padding: 1.5rem 2rem;
    border-radius: 20px;
    box-shadow: 0 0 40px rgba(110, 107, 255, 0.2);
    border: 1px solid #6e6bff;
    background: rgba(20, 20, 25, 0.95);
}

.magic-icon {
    font-size: 1.5rem;
    margin-right: 1rem;
}

#magic-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    font-family: 'Outfit';
    outline: none;
}

.magic-hint {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-left: 1rem;
}

.magic-response-container {
    margin-top: 2rem;
    width: 600px;
    max-width: 90%;
    padding: 2rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    animation: slideUp 0.3s ease-out;
}

.magic-response-container p {
    margin: 0;
    line-height: 1.6;
    color: white;
}

/* Safe-to-Spend Dashboard Card */
.safe-to-spend-card {
    transition: var(--transition);
    cursor: default;
}

.safe-to-spend-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(242, 196, 206, 0.15);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
/* --- Team & RBAC Management Styles --- */
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 1.5rem;
}

.team-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.3s ease;
}

.team-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.team-card-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: var(--bg-dark);
    border-radius: 50