/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    transition: background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

:root {
    /* Color Palette - Dark Mode (Default) */
    --bg-dark-base: #07090e;
    --bg-dark-sidebar: #0c0f16;
    --bg-dark-card: rgba(20, 26, 38, 0.6);
    --bg-dark-hover: rgba(255, 255, 255, 0.05);
    --border-dark: rgba(255, 255, 255, 0.06);
    
    --text-dark-primary: #f8fafc;
    --text-dark-secondary: #94a3b8;
    --text-dark-muted: #64748b;

    /* Light Mode */
    --bg-light-base: #f8fafc;
    --bg-light-sidebar: #ffffff;
    --bg-light-card: #ffffff;
    --bg-light-hover: #f1f5f9;
    --border-light: #e2e8f0;
    
    --text-light-primary: #0f172a;
    --text-light-secondary: #475569;
    --text-light-muted: #94a3b8;

    /* Brand Accents */
    --brand-cyan: #00d2c4;
    --brand-cyan-glow: rgba(0, 210, 196, 0.15);
    --brand-indigo: #6366f1;
    --brand-indigo-glow: rgba(99, 102, 241, 0.15);
    --brand-gradient: linear-gradient(135deg, var(--brand-cyan) 0%, var(--brand-indigo) 100%);
    
    /* Semantic Colors */
    --color-success: #10b981;
    --color-success-bg: rgba(16, 185, 129, 0.1);
    --color-warning: #f59e0b;
    --color-warning-bg: rgba(245, 158, 11, 0.1);
    --color-danger: #ef4444;
    --color-danger-bg: rgba(239, 68, 68, 0.1);
    --color-info: #3b82f6;
    --color-info-bg: rgba(59, 130, 246, 0.1);
    
    /* Dimensions & Constants */
    --sidebar-width: 260px;
    --border-radius-sm: 8px;
    --border-radius-md: 14px;
    --border-radius-lg: 20px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Dynamic Theme Mapping */
    --bg-base: var(--bg-dark-base);
    --bg-sidebar: var(--bg-dark-sidebar);
    --bg-card: var(--bg-dark-card);
    --bg-hover: var(--bg-dark-hover);
    --border-color: var(--border-dark);
    --text-primary: var(--text-dark-primary);
    --text-secondary: var(--text-dark-secondary);
    --text-muted: var(--text-dark-muted);
}

/* Light Theme Overrides */
[data-theme="light"] {
    --bg-base: var(--bg-light-base);
    --bg-sidebar: var(--bg-light-sidebar);
    --bg-card: var(--bg-light-card);
    --bg-hover: var(--bg-light-hover);
    --border-color: var(--border-light);
    --text-primary: var(--text-light-primary);
    --text-secondary: var(--text-light-secondary);
    --text-muted: var(--text-light-muted);
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--border-radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Main Layout Grid */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    scrollbar-width: thin;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-left: 8px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    fill: url(#toldar-gradient);
}

.logo-text {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-item.active a, .nav-item a:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active a {
    border-left: 3px solid var(--brand-cyan);
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Sidebar Footer & Theme Toggle */
.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: var(--bg-hover);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 500;
    width: 100%;
}

.theme-toggle-btn:hover {
    border-color: var(--brand-cyan);
}

/* Main Content Styling */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 40px;
    max-width: 1400px;
    width: calc(100% - var(--sidebar-width));
}

/* Views setup */
.app-view {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.app-view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Top Header Bar */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.view-title h1 {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.view-title p {
    color: var(--text-secondary);
    font-size: 14px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Buttons System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--brand-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 210, 196, 0.2);
}

.btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 210, 196, 0.3);
}

.btn-secondary {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-danger {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background-color: var(--color-danger);
    color: #ffffff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

/* Dashboard Analytics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.metric-card:hover {
    transform: translateY(-4px) scale(1.015);
    box-shadow: 0 12px 30px rgba(0, 210, 196, 0.08), var(--shadow-md);
    border-color: rgba(0, 210, 196, 0.2);
}

.metric-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--brand-gradient);
    opacity: 0.3;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
}

.metric-title {
    font-size: 14px;
    font-weight: 500;
}

.metric-icon-box {
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-primary);
    margin-top: 4px;
}

.metric-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.trend-up {
    color: var(--color-success);
    font-weight: 600;
}

.trend-down {
    color: var(--color-danger);
    font-weight: 600;
}

/* Dynamic Gauges & Dashboard Charts */
.dashboard-details-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

@media (max-width: 1024px) {
    .dashboard-details-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.chart-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(99, 102, 241, 0.15);
}

.chart-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.chart-title-bar h3 {
    font-size: 18px;
    font-weight: 600;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.chart-placeholder {
    height: 240px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 16px 8px;
    border-bottom: 2px solid var(--border-color);
    position: relative;
}

.chart-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
}

.chart-bar {
    width: 60%;
    max-width: 40px;
    background: var(--brand-gradient);
    border-radius: 6px 6px 0 0;
    opacity: 0.85;
    position: relative;
    cursor: pointer;
    min-height: 10px;
    animation: scaleBar 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: bottom;
}

@keyframes scaleBar {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

.chart-bar:hover {
    opacity: 1;
    box-shadow: 0 0 12px var(--brand-cyan);
}

.chart-bar::before {
    content: attr(data-val);
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chart-bar:hover::before {
    opacity: 1;
}

.chart-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* Status Breakdown Ring/Progress Bar */
.status-breakdown {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.status-progress-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.status-progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
}

.progress-track {
    height: 8px;
    background-color: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
}

/* Invoices Tables */
.table-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.table-card:hover {
    box-shadow: var(--shadow-md);
}

.table-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
}

@media (max-width: 768px) {
    .table-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

.search-input-wrapper {
    position: relative;
    flex-grow: 1;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    stroke: var(--text-muted);
}

.form-control-search {
    width: 100%;
    padding: 10px 12px 10px 36px;
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.form-control-search:focus {
    border-color: var(--brand-cyan);
}

.filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.select-filter {
    padding: 8px 12px;
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    cursor: pointer;
}

select option {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* Table Design */
.invoice-table-wrapper {
    overflow-x: auto;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.invoice-table th {
    background-color: var(--bg-hover);
    padding: 16px 24px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.invoice-table td {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.invoice-table tr:last-child td {
    border-bottom: none;
}

.invoice-table tr:hover td {
    background-color: var(--bg-hover);
}

.invoice-code {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    color: var(--brand-cyan);
}

.client-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.client-name {
    font-weight: 600;
}

.client-email {
    font-size: 12px;
    color: var(--text-muted);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.status-paid {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}

.status-pending {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
}

.status-overdue {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}

.status-draft {
    background-color: var(--bg-hover);
    color: var(--text-muted);
}

.actions-cell {
    display: flex;
    gap: 8px;
}

/* Invoice Creation Layout */
.invoice-creator-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 32px;
}

@media (max-width: 1024px) {
    .invoice-creator-grid {
        grid-template-columns: 1fr;
    }
}

.creator-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.form-group-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 576px) {
    .form-group-row {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.form-control:focus {
    border-color: var(--brand-cyan);
    box-shadow: 0 0 0 2px var(--brand-cyan-glow);
}

/* Dynamic Line Items Editor */
.line-items-editor {
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
}

.section-subtitle {
    font-size: 16px;
    font-weight: 600;
    font-family: 'Plus Jakarta Sans', sans-serif;
    margin-bottom: 8px;
}

.line-items-headings {
    display: grid;
    grid-template-columns: 3fr 1.2fr 1.5fr 1.5fr auto;
    gap: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding-bottom: 4px;
}

.line-item-row {
    display: grid;
    grid-template-columns: 90px 1.5fr 100px 80px 100px 90px 40px;
    gap: 12px;
    align-items: center;
}

.line-item-total-text {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    padding-left: 8px;
}

.delete-row-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.delete-row-btn:hover {
    color: var(--color-danger);
    background-color: var(--color-danger-bg);
}

/* Summary Box in Editor */
.invoice-summary-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    background-color: var(--bg-hover);
    border-radius: var(--border-radius-sm);
    margin-top: 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.summary-row.total {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    font-size: 18px;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.summary-row.total .grand-total-val {
    color: var(--brand-cyan);
}

/* Live Preview Panel (Right Side of Creator) */
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: fit-content;
    position: sticky;
    top: 40px;
}

.preview-container {
    background-color: #ffffff;
    color: #1e293b;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--border-color);
}

/* Live Invoice CSS Styles inside Preview (White Base Paper) */
.preview-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 24px;
    margin-bottom: 28px;
}

.preview-logo-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-logo-text {
    font-size: 20px;
    font-weight: 800;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: #0f172a;
}

.preview-meta {
    text-align: right;
}

.preview-meta h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #0f172a;
    margin-bottom: 6px;
}

.preview-meta-num {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    color: #475569;
}

.preview-addresses {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 32px;
}

.preview-address-block h4 {
    font-size: 11px;
    text-transform: uppercase;
    color: #94a3b8;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.preview-address-block p {
    font-size: 14px;
    line-height: 1.5;
    color: #334155;
}

.preview-dates-vat {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    background-color: #f8fafc;
    padding: 16px 20px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 32px;
}

.preview-date-item h4 {
    font-size: 10px;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 4px;
}

.preview-date-item p {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
}

/* Printable/Preview Items Table */
.preview-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 32px;
}

.preview-table th {
    background-color: #f1f5f9;
    padding: 10px 14px;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    text-align: left;
}

.preview-table th:nth-child(2),
.preview-table th:nth-child(3),
.preview-table th:nth-child(4),
.preview-table th:nth-child(5) {
    text-align: right;
}

.preview-table td {
    padding: 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 13px;
}

.preview-table td:nth-child(2),
.preview-table td:nth-child(3),
.preview-table td:nth-child(4),
.preview-table td:nth-child(5) {
    text-align: right;
}

.preview-table tr:last-child td {
    border-bottom: 2px solid #e2e8f0;
}

.preview-totals-grid {
    display: flex;
    justify-content: flex-end;
}

.preview-totals-table {
    width: 280px;
    border-collapse: collapse;
}

.preview-totals-table td {
    padding: 8px 12px;
    font-size: 13px;
    color: #475569;
}

.preview-totals-table td:last-child {
    text-align: right;
    font-weight: 600;
    color: #0f172a;
}

.preview-totals-table tr.grand-total td {
    border-top: 1px solid #e2e8f0;
    padding-top: 12px;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.preview-totals-table tr.grand-total td:last-child {
    color: #008f85; /* Toldar Brand Greenish/Teal for print */
    font-size: 18px;
}

.preview-footer {
    margin-top: auto;
    border-top: 1px solid #f1f5f9;
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #94a3b8;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content-wrapper {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalSlide {
    from { transform: translateY(24px) scale(0.96); }
    to { transform: translateY(0) scale(1); }
}

.close-modal-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 24px;
}

.close-modal-btn:hover {
    color: var(--text-primary);
}

/* Print Overrides */
@media print {
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    .sidebar, .main-content > *:not(#invoice-preview-print-area), .view-header, .header-actions, .btn, .modal-overlay, .sidebar-footer {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    #invoice-preview-print-area {
        display: block !important;
        position: static !important;
        width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
    }
    .preview-container {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        background-color: #ffffff !important;
    }
    .preview-dates-vat {
        background-color: #f8fafc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .preview-table th {
        background-color: #f1f5f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* CSV Dropzone Drag states */
.dropzone.drag-over {
    border-color: var(--brand-cyan) !important;
    background-color: var(--bg-hover) !important;
    box-shadow: 0 0 15px var(--brand-cyan-glow) !important;
}

/* Match Confidence Badges */
.match-confidence {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.match-high {
    background-color: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.match-medium {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.match-none {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Funding Source Badges */
.funding-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.funding-company {
    background-color: var(--brand-cyan-glow);
    color: var(--brand-cyan);
    border: 1px solid rgba(0, 210, 196, 0.25);
}

.funding-director {
    background-color: var(--brand-indigo-glow);
    color: var(--brand-indigo);
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.funding-unpaid {
    background-color: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

/* Ledger attachments links */
.ledger-attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--brand-cyan);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.ledger-attachment-link:hover {
    text-decoration: underline;
}

/* Financial Reports Accounting Styling */
.financial-tab-view {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

/* Tab button states */
#view-financials button.active,
#view-compliance button.active,
#view-practice-manager button.active,
#view-bank button.active,
#view-specialised button.active,
#view-stock button.active,
#view-integrations button.active,
.btn-secondary.active {
    background: var(--brand-gradient);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px var(--brand-cyan-glow);
}

/* Double underline total style */
[id^="pl-"], [id^="bs-"], [id^="debtors-"] {
    font-variant-numeric: tabular-nums;
}

/* Specific accounting border alignments */
.double-underline {
    border-bottom: 4px double var(--brand-cyan) !important;
}

/* Global Group Bar Header Styling */
.global-group-bar-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 12px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--brand-cyan);
    animation: fadeIn 0.4s ease-out;
}

.global-group-bar-inner {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.group-bar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 180px;
}

.group-bar-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    text-transform: uppercase;
}

.group-bar-subtitle {
    font-size: 10px;
    color: var(--text-muted);
}

.group-bar-tree {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.group-node {
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    position: relative;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 235px;
}

.group-node:hover {
    transform: translateY(-2px);
    border-color: var(--brand-cyan);
    box-shadow: 0 4px 12px var(--brand-cyan-glow);
}

.group-node.subsidiary-node:hover {
    border-color: var(--brand-indigo);
    box-shadow: 0 4px 12px var(--brand-indigo-glow);
}

.group-node.active {
    background-color: var(--bg-hover);
    border-color: var(--brand-cyan);
    box-shadow: 0 0 10px var(--brand-cyan-glow);
}

.group-node.subsidiary-node.active {
    border-color: var(--brand-indigo);
    box-shadow: 0 0 10px var(--brand-indigo-glow);
}

.node-border-accent {
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background-color: var(--brand-cyan);
}

.subsidiary-node .node-border-accent {
    background-color: var(--brand-indigo);
}

.node-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex-grow: 1;
}

.node-type {
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--brand-cyan);
    text-transform: uppercase;
}

.subsidiary-node .node-type {
    color: var(--brand-indigo);
}

.node-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.node-meta {
    font-size: 9px;
    color: var(--text-muted);
}

.node-metrics {
    font-size: 9px;
    margin-top: 2px;
    display: flex;
    gap: 4px;
}

.metric-label {
    color: var(--text-muted);
}

.metric-value {
    font-weight: 700;
}

.profit-positive {
    color: var(--brand-cyan);
}

.profit-negative {
    color: #ef4444;
}

.node-status-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 50%;
    transition: all 0.25s ease;
}

.active .status-dot {
    background-color: var(--brand-cyan);
    box-shadow: 0 0 8px var(--brand-cyan);
}

.subsidiary-node.active .status-dot {
    background-color: var(--brand-indigo);
    box-shadow: 0 0 8px var(--brand-indigo);
}

.node-status-text {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.active .node-status-text {
    color: var(--brand-cyan);
}

.subsidiary-node.active .node-status-text {
    color: var(--brand-indigo);
}

/* Connector Line between Nodes */
.group-connector {
    display: flex;
    align-items: center;
}

.connector-line {
    width: 20px;
    height: 1px;
    background-color: var(--border-color);
}

.connector-label {
    background-color: var(--brand-indigo-glow);
    color: var(--brand-indigo);
    border: 1px solid var(--brand-indigo);
    font-size: 8px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    white-space: nowrap;
}

.group-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 10px;
    height: 28px;
}

.placeholder-node {
    border-style: dashed !important;
    background-color: transparent !important;
    justify-content: center !important;
    align-items: center !important;
    min-width: 235px;
}

.placeholder-node:hover {
    border-color: var(--brand-indigo) !important;
    background-color: var(--brand-indigo-glow) !important;
}

.placeholder-content {
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

/* Tax Status Badges */
.tax-badge-row {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.tax-badge {
    font-size: 8px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
}

.tax-badge.active-tax {
    background-color: var(--brand-cyan-glow);
    color: var(--brand-cyan);
    border: 1px solid rgba(0, 210, 196, 0.25);
}

.tax-badge.active-tax-indigo {
    background-color: var(--brand-indigo-glow);
    color: var(--brand-indigo);
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.tax-badge.inactive-tax {
    background-color: var(--bg-hover);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

/* Settings Icon Trigger */
.node-settings-btn {
    position: absolute;
    right: 6px;
    top: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
}

.group-node:hover .node-settings-btn {
    opacity: 1;
}

.node-settings-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    transform: rotate(30deg);
}

/* UK/IE Flag Indicators */
.flag-indicator {
    font-size: 10px;
    display: inline-block;
}

/* Mobile Optimization & Responsive Drawer Layout */

/* 1. Mobile Top Header */
.mobile-header {
    display: none;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(8, 9, 12, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 190;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* 2. Scrollable Tabs Bar Base styles */
.scrollable-tabs-bar {
    scrollbar-width: none;
}
.scrollable-tabs-bar::-webkit-scrollbar {
    display: none;
}

/* 3. Responsive Breakpoint Rules */
@media (max-width: 768px) {
    /* Mobile Top Header Display */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background-color: var(--bg-sidebar);
        border-bottom: 1px solid var(--border-color);
        padding: 0 20px;
        z-index: 150;
    }
    
    .mobile-header-logo {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .mobile-header-logo .logo-text {
        font-family: 'Plus Jakarta Sans', sans-serif;
        font-weight: 800;
        background: var(--brand-gradient);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .mobile-toggle-btn {
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px;
        border-radius: var(--border-radius-sm);
        transition: background-color 0.2s ease;
    }

    .mobile-toggle-btn:hover {
        background-color: var(--bg-hover);
    }

    .mobile-toggle-btn svg {
        width: 24px;
        height: 24px;
        stroke: currentColor;
        fill: none;
        stroke-width: 2.5;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    /* Off-Canvas Sidebar Menu */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 200;
        width: 280px;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    /* Main Content Spacing Reset */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 20px !important;
        padding-top: 80px !important;
    }

    /* Header stacking */
    .view-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
    }

    .header-actions {
        width: 100% !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .header-actions .btn {
        flex-grow: 1 !important;
        width: 100% !important;
    }

    /* Scrollable Tab bar */
    .scrollable-tabs-bar {
        display: flex !important;
        gap: 8px !important;
        border-bottom: 1px solid var(--border-color) !important;
        margin-bottom: 28px !important;
        padding-bottom: 2px !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .scrollable-tabs-bar button {
        flex-shrink: 0 !important;
        margin-bottom: -1px !important;
    }

    /* Stacking grids */
    .invoice-creator-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .form-group-row {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Invoice / Bill Line Items Stack Card Reflow */
    .line-items-headings {
        display: none !important;
    }

    .line-item-row {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        border: 1px solid var(--border-color) !important;
        padding: 16px !important;
        border-radius: var(--border-radius-md) !important;
        background-color: var(--bg-hover) !important;
        position: relative !important;
        margin-bottom: 12px !important;
    }

    .line-item-row .item-desc {
        grid-column: span 2 !important;
    }

    .line-item-row .item-qty {
        grid-column: span 1 !important;
    }

    .line-item-row .item-price {
        grid-column: span 1 !important;
    }

    .line-item-row .line-item-total-text {
        grid-column: span 1 !important;
        padding-left: 0 !important;
        text-align: left !important;
        align-self: center !important;
        font-weight: 700 !important;
        font-size: 14px !important;
        color: var(--brand-cyan) !important;
    }

    .line-item-row .line-item-total-text::before {
        content: "Total: " !important;
        color: var(--text-muted) !important;
        font-weight: 500 !important;
        font-size: 12px !important;
    }

    .line-item-row .delete-row-btn {
        grid-column: span 1 !important;
        justify-self: end !important;
        align-self: center !important;
        margin-top: 0 !important;
    }
}




/* Compliance Accordion Styling */
.compliance-details-acc {
    transition: all 0.3s ease;
}
.compliance-details-acc summary {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    outline: none;
    color: var(--text-primary);
    font-weight: 700;
}
.compliance-details-acc summary:hover {
    background-color: rgba(255, 255, 255, 0.05);
}


/* CFO Hub Styles */
.cfo-grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.cfo-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.cfo-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}
.cfo-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cfo-card-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}
.cfo-card-trend {
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}
.cfo-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    width: fit-content;
}
.cfo-badge-success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}
.cfo-badge-warning {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
}
.cfo-badge-danger {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}
.cfo-badge-info {
    background-color: var(--color-info-bg);
    color: var(--color-info);
}
.cfo-tab-panel {
    display: none;
    animation: cfoFadeIn 0.3s ease-in-out;
}
.cfo-tab-panel.active {
    display: block;
}
.cfo-slider-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.cfo-slider-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}
.cfo-slider {
    width: 100%;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    accent-color: var(--brand-indigo);
}
.cfo-memo {
    background-color: var(--bg-hover);
    border-left: 4px solid var(--brand-indigo);
    padding: 20px;
    border-radius: 4px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
    margin-top: 16px;
}
.cfo-memo-title {
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 16px;
}
.cfo-memo-header-field {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.cfo-memo-header-field span {
    color: var(--text-primary);
    font-weight: 400;
}
@keyframes cfoFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.group-tree-node-clickable {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}
.group-tree-node-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25) !important;
    filter: brightness(1.08);
}


/* CFO Visual Chart & Pulse Animation Styles */
.cfo-chart-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    width: 6%;
}
.cfo-chart-bar {
    width: 100%;
    background: linear-gradient(to top, var(--brand-indigo) 0%, var(--brand-cyan) 100%);
    border-radius: 3px 3px 0 0;
    transition: height 0.5s ease-in-out;
    position: relative;
}
.cfo-chart-bar:hover {
    filter: brightness(1.2);
    cursor: pointer;
}
.cfo-chart-bar-tooltip {
    display: none;
    position: absolute;
    bottom: 105%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 4px 8px;
    font-size: 9px;
    border-radius: 4px;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    z-index: 100;
}
.cfo-chart-bar:hover .cfo-chart-bar-tooltip {
    display: block;
}
@keyframes cfoPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Sidebar collapsible groups */
.sidebar-group {
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
}
.sidebar-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    border-radius: var(--border-radius-sm);
    transition: color 0.2s, background-color 0.2s;
}
.sidebar-group-header:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}
.sidebar-group-header .toggle-icon {
    transition: transform 0.2s ease;
    width: 12px;
    height: 12px;
    stroke-width: 2.5;
}
.sidebar-group.collapsed .sidebar-group-header .toggle-icon {
    transform: rotate(-90deg);
}
.sidebar-group-items {
    list-style: none;
    padding-left: 8px;
    margin-top: 2px;
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.sidebar-group.collapsed .sidebar-group-items {
    max-height: 0;
}
.sidebar-group-items li {
    margin-bottom: 2px;
}

/* Compliance categories accordions */
.compliance-category {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    margin-bottom: 12px;
    overflow: hidden;
}
.compliance-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    user-select: none;
    transition: background 0.2s;
}
.compliance-category-header:hover {
    background: rgba(255, 255, 255, 0.04);
}
.compliance-category-header .arrow-icon {
    transition: transform 0.2s;
    width: 16px;
    height: 16px;
}
.compliance-category.collapsed .compliance-category-header .arrow-icon {
    transform: rotate(-90deg);
}
.compliance-category-content {
    padding: 16px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    max-height: 500px;
    transition: max-height 0.3s cubic-bezier(0, 1, 0, 1), padding 0.3s;
}
.compliance-category.collapsed .compliance-category-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-color: transparent;
    overflow: hidden;
}

/* Command Palette modal */
#command-palette-modal .command-palette-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 550px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: cfoFadeIn 0.2s ease-out;
}
.command-palette-search-wrapper {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}
.command-palette-search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}
.command-palette-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
}
.command-palette-input::placeholder {
    color: var(--text-muted);
}
.command-palette-results {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
}
.command-palette-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    gap: 12px;
    transition: background 0.2s, color 0.2s;
    color: var(--text-secondary);
}
.command-palette-item:hover, .command-palette-item.selected {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.command-palette-item-icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}
.command-palette-item:hover .command-palette-item-icon, .command-palette-item.selected .command-palette-item-icon {
    color: var(--brand-cyan);
}
.command-palette-item-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.command-palette-item-title {
    font-weight: 600;
    font-size: 14px;
}
.command-palette-item-category {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}
.command-palette-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    font-size: 10px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}
.command-palette-kbd {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 9px;
}

/* Toast Notification System */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10000;
}
.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--brand-cyan);
    color: var(--text-primary);
    padding: 16px 20px;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 250px;
    max-width: 350px;
    animation: slideInRight 0.3s ease-out forwards;
    opacity: 0;
    transform: translateX(100%);
    font-size: 14px;
}
.toast.toast-error {
    border-left-color: var(--color-danger);
}
.toast.toast-success {
    border-left-color: var(--color-success);
}
.toast.toast-warning {
    border-left-color: var(--color-warning);
}
.toast.fade-out {
    animation: fadeOutRight 0.3s ease-in forwards;
}
@keyframes slideInRight {
    to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOutRight {
    to { opacity: 0; transform: translateX(100%); }
}

/* Floating Action Button (FAB) for Help */
.fab-help {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--brand-cyan);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,255,204,0.4);
    cursor: pointer;
    z-index: 9900;
    transition: transform 0.2s, box-shadow 0.2s;
}
.fab-help:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,255,204,0.6);
}
.fab-help svg {
    width: 24px;
    height: 24px;
}

/* Instruction Book Side Panel */
.side-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 15px rgba(0,0,0,0.3);
    z-index: 9950;
    transition: right 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}
.side-panel.open {
    right: 0;
}
.side-panel-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.side-panel-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-cyan);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.side-panel-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.side-panel-close:hover {
    color: var(--text-primary);
}
.side-panel-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}
.help-article {
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}
.help-article-header {
    background: var(--bg-hover);
    padding: 12px 16px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.help-article-header:hover {
    background: rgba(255,255,255,0.05);
}
.help-article-body {
    padding: 16px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    display: none;
    background: var(--bg-primary);
}
.help-article.expanded .help-article-body {
    display: block;
}
.help-article.expanded .help-article-header {
    border-bottom: 1px solid var(--border-color);
}
.help-article-body h4 {
    color: var(--text-primary);
    margin-top: 0;
    margin-bottom: 8px;
}
.help-article-body ul {
    margin-top: 0;
    padding-left: 20px;
}
.help-article-body li {
    margin-bottom: 4px;
}

/* AI Assistant Chat UI */
.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.ai-chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    line-height: 1.5;
}
.chat-message.user {
    align-self: flex-end;
    background: var(--bg-hover);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}
.chat-message.ai {
    align-self: flex-start;
    background: rgba(0, 255, 204, 0.1);
    border: 1px solid rgba(0, 255, 204, 0.2);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.chat-message.ai strong {
    color: var(--brand-cyan);
}
.ai-chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    background: var(--bg-card);
}
.ai-chat-input {
    flex-grow: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}
.ai-chat-input:focus {
    border-color: var(--brand-cyan);
}
.ai-chat-send {
    background: var(--brand-cyan);
    color: #000;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.ai-chat-send:hover {
    background: #00e6b8;
}

/* Contextual Tooltips */
.help-tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    cursor: help;
    margin-left: 6px;
    vertical-align: middle;
    position: relative;
    border: 1px solid var(--border-color);
}
.help-tooltip-icon:hover {
    color: var(--brand-cyan);
    border-color: var(--brand-cyan);
}

.compliance-category-icon {
    margin-right: 8px;
    vertical-align: middle;
    display: inline-block;
}

.d-none {
    display: none !important;
}
.help-tooltip-icon .tooltip-text {
    visibility: hidden;
    width: 220px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    text-align: left;
    border-radius: var(--border-radius-sm);
    padding: 10px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 11px;
    font-weight: 400;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    line-height: 1.4;
}
.help-tooltip-icon:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Side panel tabs */
.help-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}
.help-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
}
.help-tab.active {
    color: var(--brand-cyan);
    border-bottom-color: var(--brand-cyan);
}

@keyframes highlightPulse {
    0% { background-color: transparent; }
    50% { background-color: rgba(0,255,204,0.3); }
    100% { background-color: transparent; }
}
.highlight-pulse {
    animation: highlightPulse 1.5s ease-in-out 2;
}


/* Instruction Book layout and fullscreen fixes */
.side-panel-content {
    display: block !important;
}
.help-article {
    display: block !important;
    width: 100% !important;
}
.side-panel.fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
}


/* Tabular numbers for perfect layout alignment */
table td, .metric-value, .amount-field {
    font-variant-numeric: tabular-nums;
}

/* Glassmorphic navigation hover lift */
.nav-item a {
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
.nav-item a:hover {
    transform: translateX(4px);
}

/* Premium active state with neon glow bar */
.nav-item.active a {
    border-left: 3px solid var(--brand-cyan) !important;
    box-shadow: inset 4px 0 10px rgba(0, 210, 196, 0.05);
}

/* The Razor Interface UI Styling */
:root {
    --sidebar-width: 260px;
}

body.sidebar-collapsed {
    --sidebar-width: 68px;
}

.app-container {
    display: flex !important;
}

.main-content {
    margin-left: var(--sidebar-width) !important;
    width: calc(100% - var(--sidebar-width)) !important;
    padding: 68px 24px 100px 24px !important; /* Spacing for HUD at top, Blade at bottom */
    max-width: 1500px;
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Glassmorphic Top HUD Status Bar */
.razor-hud {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    height: 42px;
    background: rgba(11, 15, 25, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 999;
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hud-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-divider {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    margin: 0 16px;
}

.hud-select {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.hud-select:focus {
    border-color: var(--brand-cyan);
}

.hud-icon-btn:hover {
    color: var(--brand-cyan) !important;
    border-color: rgba(0, 210, 196, 0.3) !important;
    background: rgba(0, 210, 196, 0.05) !important;
}

/* Floating Bottom Command Blade */
.razor-blade-container {
    position: fixed;
    bottom: 24px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 999;
    padding: 0 20px;
    box-sizing: border-box;
    pointer-events: none; /* Let clicks pass through outside container */
}

.razor-blade {
    pointer-events: auto; /* Re-enable clicks for the input box */
    width: 100%;
    max-width: 680px;
    background: rgba(12, 16, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(0, 210, 196, 0.1);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.razor-blade:focus-within {
    border-color: var(--brand-cyan);
    box-shadow: 0 16px 48px rgba(0,0,0,0.6), 0 0 0 3px var(--brand-cyan-glow);
    transform: translateY(-2px);
}

.razor-blade input {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
}

.razor-blade input::placeholder {
    color: var(--text-muted);
}

.razor-execute-btn {
    background: var(--brand-gradient);
    border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 210, 196, 0.2);
    transition: all 0.2s;
}

.razor-execute-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 210, 196, 0.3);
}

/* Hide Sidebar/Advanced Items in Standard Mode via DOM styles */
.mode-standard .dashboard-details-grid {
    grid-template-columns: 1fr !important; /* Hide secondary detail sheets */
}

/* Dynamic background mesh gradient aura */
body {
    background: radial-gradient(circle at 10% 20%, rgba(0, 210, 196, 0.05) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
                #06070a !important;
}

/* Collapsible Sidebar Styles */
body.sidebar-collapsed .sidebar .logo-text,
body.sidebar-collapsed .sidebar .company-switcher-container label,
body.sidebar-collapsed .sidebar .company-switcher-container select,
body.sidebar-collapsed .sidebar .company-switcher-container button,
body.sidebar-collapsed .sidebar #global-api-mode-badge,
body.sidebar-collapsed .sidebar .nav-item a span,
body.sidebar-collapsed .sidebar .sidebar-footer {
    display: none !important;
}

body.sidebar-collapsed .sidebar {
    padding: 24px 8px !important;
}

body.sidebar-collapsed .sidebar .logo-container {
    padding-left: 0 !important;
    justify-content: center !important;
    margin-bottom: 24px !important;
}

body.sidebar-collapsed .sidebar .nav-item a {
    justify-content: center !important;
    padding: 10px 0 !important;
}

body.sidebar-collapsed .sidebar .nav-item a svg {
    margin-right: 0 !important;
}

/* Sidebar transition on window resizing/state toggling */
.sidebar {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Hover style for toggle button in HUD */
.hud-btn:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

/* Hide HUD brand logo if sidebar is expanded, show it if sidebar is collapsed */
.razor-hud .hud-brand {
    display: flex;
    transition: all 0.3s ease;
}
body:not(.sidebar-collapsed) .razor-hud .hud-brand {
    display: none !important;
}
