/**
 * Accounting System - Main Stylesheet
 */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary: #2563EB;
    --color-primary-dark: #1D4ED8;
    --color-success: #22C55E;
    --color-warning: #F59E0B;
    --color-error: #EF4444;
    --color-bg: #F8FAFC;
    --color-bg-white: #FFFFFF;
    --color-text: #1E293B;
    --color-text-muted: #64748B;
    --color-border: #E2E8F0;
    --sidebar-width: 250px;
    --header-height: 60px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-bg-white);
    border-right: 1px solid var(--color-border);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
    display: block;
}

.sidebar-logo:hover {
    color: var(--color-primary-dark);
}

.sidebar-nav {
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--color-text);
    text-decoration: none;
    transition: background-color 0.2s;
}

.nav-item:hover {
    background-color: var(--color-bg);
}

.nav-item.active {
    background-color: #EFF6FF;
    color: var(--color-primary);
    border-right: 3px solid var(--color-primary);
}

.nav-icon {
    margin-right: 12px;
    font-size: 1.25rem;
}

/* Navigation subgroups */
.nav-group {
    margin-bottom: 0;
}

.nav-subitem {
    display: block;
    padding: 8px 20px 8px 52px;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.nav-subitem:hover {
    background-color: var(--color-bg);
    color: var(--color-text);
}

.nav-subitem.active {
    color: var(--color-primary);
    background-color: #EFF6FF;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
}

/* Header */
.header {
    height: var(--header-height);
    background-color: var(--color-bg-white);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.company-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.company-switcher:hover {
    background-color: var(--color-bg);
}

.company-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Page content */
.page-content {
    padding: 24px;
}

.content {
    padding: 24px;
}

/* Stats cards */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background-color: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
}

.stat-card.stat-warning {
    border-left: 4px solid var(--color-warning);
}

.stat-card.stat-success {
    border-left: 4px solid var(--color-success);
}

.stat-card.stat-danger {
    border-left: 4px solid var(--color-error);
}

/* Card header */
.card-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table th {
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    background-color: var(--color-bg);
}

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

.data-table code {
    background-color: #F1F5F9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
}

/* Quick actions */
.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 24px;
}

/* Cards */
.card {
    background-color: var(--color-bg-white);
    border-radius: 8px;
    border: 1px solid var(--color-border);
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--color-text-muted);
}

/* Grid */
.grid {
    display: grid;
    gap: 16px;
}

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

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

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

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

.btn-primary:hover {
    background-color: var(--color-primary-dark);
}

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

.btn-secondary:hover {
    background-color: var(--color-border);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

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

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background-color: #DCFCE7;
    color: #166534;
}

.badge-warning {
    background-color: #FEF3C7;
    color: #92400E;
}

.badge-error {
    background-color: #FEE2E2;
    color: #991B1B;
}

.badge-info {
    background-color: #DBEAFE;
    color: #1E40AF;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Input warning state - for validation warnings */
.form-input.input-warning {
    border-color: var(--color-warning);
    background-color: #FFFBEB;
}

.form-input.input-warning:focus {
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

/* Input group - for inputs with buttons */
.input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-group .form-input {
    flex: 1;
}

.input-group .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

/* VAT status indicator */
.vat-status-indicator {
    margin-left: 6px;
    font-weight: bold;
}

.vat-status-indicator .text-success {
    color: var(--color-success);
}

.vat-status-indicator .text-warning {
    color: var(--color-warning);
}

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

/* Exchange rate preview */
.exchange-rate-preview {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px 16px;
    text-align: center;
}

.exchange-rate-preview .text-lg {
    font-size: 1.25rem;
}

.exchange-rate-preview .font-bold {
    font-weight: 700;
}

/* Text utilities */
.text-lg {
    font-size: 1.25rem;
}

.font-bold {
    font-weight: 700;
}

/* Stat widget */
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* Quick actions */
.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--color-bg-white);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.login-form {
    margin-bottom: 24px;
}

.login-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.login-footer strong {
    color: var(--color-text);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.alert-error {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-success {
    background-color: #DCFCE7;
    color: #166534;
    border: 1px solid #BBF7D0;
}

.alert-warning {
    background-color: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
}

.alert-info {
    background-color: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

/* Alert with icon and content */
.alert-icon {
    font-size: 1.5rem;
    margin-right: 12px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

/* Duplicate warning list */
.duplicate-list {
    margin: 8px 0 0 0;
    padding-left: 20px;
    list-style: disc;
}

.duplicate-list li {
    margin: 4px 0;
    line-height: 1.6;
}

.duplicate-list a {
    color: inherit;
    text-decoration: underline;
}

.duplicate-list a:hover {
    text-decoration: none;
}

/* Button block */
.btn-block {
    width: 100%;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* User menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-menu-dropdown {
    position: relative;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.user-menu-toggle:hover {
    background-color: var(--color-bg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 8px 0;
    margin-top: 4px;
    display: none;
    z-index: 1000;
}

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

.dropdown-item {
    display: block;
    padding: 10px 16px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

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

.dropdown-divider {
    height: 1px;
    background-color: var(--color-border);
    margin: 8px 0;
}

/* Company switcher dropdown */
.company-switcher-dropdown {
    position: relative;
}

.company-dropdown {
    min-width: 280px;
    left: 0;
    right: auto;
}

.company-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.company-item.active {
    background-color: #EFF6FF;
}

.company-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background-color: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.company-item-info {
    flex: 1;
    min-width: 0;
}

.company-item-name {
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.company-item-role {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: capitalize;
}

.company-item-check {
    color: var(--color-primary);
    font-weight: bold;
}

/* Period switcher dropdown */
.period-switcher-dropdown {
    position: relative;
    margin-left: 16px;
}

.period-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.875rem;
}

.period-switcher:hover {
    background-color: var(--color-bg);
}

.period-icon {
    font-size: 1rem;
}

.period-name {
    font-weight: 500;
    color: var(--color-text);
}

.period-dropdown {
    min-width: 320px;
    left: 0;
    right: auto;
}

.period-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
}

.period-item.active {
    background-color: #EFF6FF;
}

.period-item-info {
    flex: 1;
    min-width: 0;
}

.period-item-name {
    font-weight: 500;
    color: var(--color-text);
}

.period-item-dates {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.period-item-status {
    flex-shrink: 0;
}

.period-item-check {
    color: var(--color-primary);
    font-weight: bold;
    margin-left: 8px;
}

/* Page header with actions */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header .page-title {
    margin-bottom: 0;
}

.page-actions {
    display: flex;
    gap: 12px;
}

/* Filter form */
.filter-form {
    margin: 0;
}

.filter-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.filter-group {
    margin-bottom: 0;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

/* Account code */
.account-code {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.875rem;
    background-color: var(--color-bg);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Account tree indentation */
.account-child td:first-child {
    padding-left: 24px;
}

.account-indent {
    display: inline-block;
    width: 12px;
    margin-right: 4px;
    color: var(--color-border);
}

.account-indent::before {
    content: '└';
}

/* Text utilities */
.text-muted {
    color: var(--color-text-muted);
}

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

/* Account table styles */
.table-accounts tbody tr {
    transition: opacity 0.2s;
}

.account-inactive {
    opacity: 0.2;
}

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

.account-inactive .account-code {
    background-color: #f1f5f9;
    color: var(--color-text-muted);
}

/* Account group rows */
.account-group {
    background-color: var(--color-bg-secondary);
}

/* Inactive group rows */
.account-group.account-inactive {
    opacity: 0.2;
}

.account-group.account-inactive .account-code {
    background-color: #94a3b8;
    color: white;
}

.account-group td {
    font-weight: 500;
}

.account-group .account-code {
    background-color: var(--color-primary);
    color: white;
}

/* Group toggle checkbox styling */
.group-active-toggle {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.account-analytic .account-code {
    font-size: 0.8125rem;
}

.account-active-toggle {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--color-text-muted);
}

.empty-state p {
    margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-backdrop,
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background-color: var(--color-bg-white);
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 16px;
    z-index: 1001;
}

.modal-content.modal-lg {
    max-width: 700px;
}

.modal-content.modal-xl {
    max-width: 900px;
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    background-color: var(--color-bg);
    border-radius: 0 0 12px 12px;
}

/* Form row for inline fields */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* Form help text */
.form-help {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* Alert messages */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.alert-error {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-success {
    background-color: #DCFCE7;
    color: #166534;
    border: 1px solid #BBF7D0;
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.2s;
    border-radius: 24px;
}

.switch .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background-color: var(--color-success);
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* Switch label for inline checkbox with label */
.switch-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
}

.switch-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Inactive row */
.row-inactive {
    opacity: 0.5;
}

.row-inactive td {
    text-decoration: line-through;
}

.row-inactive td:last-child,
.row-inactive td:first-child {
    text-decoration: none;
}

/* Settings page */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.settings-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background-color: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-card:hover:not(.disabled) {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.settings-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.settings-card-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.settings-card-content {
    flex: 1;
}

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

.settings-card-description {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin: 0;
}

.settings-card-arrow {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

/* Templates grid */
.templates-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.template-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--color-bg);
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.template-card.template-inactive {
    opacity: 0.6;
}

.template-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.template-info {
    flex: 1;
}

.template-name {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 4px;
}

.template-description {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin: 0;
}

.template-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Checkbox group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 8px;
    background-color: var(--color-bg-white);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    max-width: 450px;
    pointer-events: auto;
    animation: toast-slide-in 0.3s ease-out;
}

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

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

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

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

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

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

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

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

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

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 2px;
    color: var(--color-text);
}

.toast-message {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0;
    font-size: 1.25rem;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 8px 8px;
    animation: toast-progress linear forwards;
}

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

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

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

.toast-info .toast-progress {
    background-color: var(--color-primary);
}

@keyframes toast-progress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Charts container */
.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    justify-content: center;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.chart-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Invoice timeline */
.invoice-timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background-color: var(--color-bg);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

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

.timeline-item.overdue {
    background-color: #FEE2E2;
    border-left: 3px solid var(--color-error);
}

.timeline-item.due-soon {
    background-color: #FEF3C7;
    border-left: 3px solid var(--color-warning);
}

.timeline-date {
    width: 80px;
    font-weight: 500;
    flex-shrink: 0;
}

.timeline-partner {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-amount {
    font-weight: 600;
    text-align: right;
    flex-shrink: 0;
}

.timeline-type {
    width: 20px;
    flex-shrink: 0;
    text-align: center;
    margin-right: 8px;
}

/* Cash flow summary */
.cash-flow-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.cash-flow-item {
    text-align: center;
    padding: 12px;
    background-color: var(--color-bg);
    border-radius: 6px;
}

.cash-flow-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.cash-flow-value {
    font-size: 1.125rem;
    font-weight: 600;
}

.cash-flow-value.positive {
    color: var(--color-success);
}

.cash-flow-value.negative {
    color: var(--color-error);
}

/* Text colors */
.text-danger {
    color: var(--color-error);
}

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

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

/* ========================================
   Logo Upload
   ======================================== */

.logo-upload-area {
    max-width: 400px;
}

.current-logo {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--color-bg);
    border-radius: 8px;
    margin-bottom: 8px;
}

.current-logo img {
    max-width: 150px;
    max-height: 80px;
    object-fit: contain;
}

.logo-dropzone {
    border: 2px dashed var(--color-border);
    border-radius: 8px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.logo-dropzone:hover,
.logo-dropzone.dragover {
    border-color: var(--color-primary);
    background-color: #EFF6FF;
}

.logo-dropzone.hidden {
    display: none;
}

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

.dropzone-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.dropzone-content p {
    margin-bottom: 4px;
}

.dropzone-content a {
    color: var(--color-primary);
    text-decoration: none;
}

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

/* ========================================
   Number Sequences
   ======================================== */

.sequence-preview {
    padding: 12px;
    background: var(--color-bg);
    border-radius: 6px;
    font-family: monospace;
    font-size: 1rem;
    text-align: center;
    color: var(--color-primary);
    font-weight: 600;
}

/* ========================================
   User Management
   ======================================== */

.user-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

.user-card:last-child {
    border-bottom: none;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.125rem;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.user-email {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: #EFF6FF;
    color: var(--color-primary);
}

.user-actions {
    display: flex;
    gap: 8px;
}

/* Invitation Cards */
.invitations-list {
    display: flex;
    flex-direction: column;
}

.invitation-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

.invitation-card:last-child {
    border-bottom: none;
}

.invitation-info {
    flex: 1;
}

.invitation-email {
    font-weight: 500;
    margin-bottom: 4px;
}

.invitation-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
}

.invitation-actions {
    display: flex;
    gap: 8px;
}

/* ========================================
   QR Payment Code Styles
   ======================================== */

.payment-info-grid {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.payment-info-details {
    flex: 1;
}

.payment-qr-code {
    flex-shrink: 0;
}

.qr-code-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: #F8FAFC;
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.qr-code-image {
    width: 150px;
    height: 150px;
    border-radius: 4px;
    background: white;
}

.qr-code-label {
    margin-top: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary);
}

.qr-code-amount {
    margin-top: 4px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.qr-payment-card {
    text-align: center;
}

.qr-payment-card .qr-code-wrapper {
    display: inline-flex;
    margin: 0 auto;
}

.qr-code-hint {
    margin-top: 12px;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.qr-payment-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

/* Responsive adjustments for QR code */
@media (max-width: 768px) {
    .payment-info-grid {
        flex-direction: column;
        gap: 20px;
    }

    .payment-qr-code {
        width: 100%;
    }

    .qr-code-wrapper {
        margin: 0 auto;
    }
}

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

:root {
    --sidebar-collapsed-width: 60px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.sidebar-toggle-icon {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

/* Collapsed sidebar state */
.sidebar.collapsed,
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-header,
body.sidebar-collapsed .sidebar .sidebar-header {
    padding: 20px 10px;
}

.sidebar.collapsed .sidebar-logo,
body.sidebar-collapsed .sidebar .sidebar-logo {
    font-size: 0;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar-logo::after,
body.sidebar-collapsed .sidebar .sidebar-logo::after {
    content: 'ÚS';
    font-size: 1rem;
}

.sidebar.collapsed .nav-item,
body.sidebar-collapsed .sidebar .nav-item {
    padding: 12px 0;
    justify-content: center;
}

.sidebar.collapsed .nav-icon,
body.sidebar-collapsed .sidebar .nav-icon {
    margin-right: 0;
    font-size: 1.25rem;
}

/* Hide text labels in collapsed state */
.sidebar.collapsed .nav-label,
body.sidebar-collapsed .sidebar .nav-label {
    display: none;
}

.sidebar.collapsed .nav-subitem,
body.sidebar-collapsed .sidebar .nav-subitem {
    display: none;
}

.sidebar.collapsed .sidebar-toggle,
body.sidebar-collapsed .sidebar .sidebar-toggle {
    padding: 10px;
}

.sidebar.collapsed .sidebar-toggle-label,
body.sidebar-collapsed .sidebar .sidebar-toggle-label {
    display: none;
}

.sidebar.collapsed .sidebar-toggle-icon,
body.sidebar-collapsed .sidebar .sidebar-toggle-icon {
    transform: rotate(180deg);
}

/* Adjust main content when sidebar is collapsed */
.sidebar.collapsed + .main-content,
body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Tooltip for collapsed sidebar items */
.sidebar.collapsed .nav-item,
body.sidebar-collapsed .sidebar .nav-item {
    position: relative;
}

.sidebar.collapsed .nav-item::after,
body.sidebar-collapsed .sidebar .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-text);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8125rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    margin-left: 8px;
    z-index: 1000;
    pointer-events: none;
}

.sidebar.collapsed .nav-item:hover::after,
body.sidebar-collapsed .sidebar .nav-item:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Toggle Switch for Settings
   ======================================== */

.toggle-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 12px 0;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--color-border);
    border-radius: 13px;
    transition: background 0.3s;
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-label input:checked + .toggle-switch {
    background: var(--color-success);
}

.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(22px);
}

.toggle-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toggle-text strong {
    font-weight: 600;
    color: var(--color-text);
}

.toggle-text small {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.form-group.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Info Box */
.info-box {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    margin-top: 16px;
}

.info-box-info {
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
}

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

.info-box-content {
    font-size: 0.875rem;
    color: var(--color-text);
}

.info-box-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.info-box-content li {
    margin: 4px 0;
}

/* Input with suffix */
.input-with-suffix {
    display: flex;
    align-items: center;
}

.input-with-suffix .form-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex: 1;
}

.input-suffix {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-left: none;
    padding: 10px 12px;
    border-radius: 0 6px 6px 0;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* ========================================
   Attachment Preview
   ======================================== */

.attachment-preview {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.attachment-image {
    max-width: 400px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.attachment-image img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s;
}

.attachment-image img:hover {
    opacity: 0.9;
}

.attachment-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.attachment-link {
    font-size: 1rem;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

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

.attachment-actions {
    display: flex;
    gap: 8px;
}

/* ========================================
   File Upload Zone
   ======================================== */

.upload-dropzone {
    border: 2px dashed var(--color-border);
    border-radius: 8px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--color-bg);
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
}

.upload-dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.6;
}

.upload-dropzone-text {
    font-size: 0.9375rem;
    color: var(--color-text);
    margin-bottom: 4px;
}

.upload-dropzone-hint {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.upload-dropzone input[type="file"] {
    display: none;
}

.upload-file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-top: 12px;
}

.upload-file-icon {
    font-size: 1.5rem;
}

.upload-file-info {
    flex: 1;
    min-width: 0;
}

.upload-file-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-file-size {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.upload-file-remove {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 8px;
}

.upload-file-remove:hover {
    color: var(--color-error);
}

/* Progress bar */
.progress-bar {
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    transition: width 0.2s;
}

/* Language Selection */
.language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.language-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.language-option:hover {
    border-color: var(--color-primary);
    background: var(--color-bg-white);
}

.language-option.active {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
}

.language-flag {
    font-size: 2rem;
}

.language-info {
    flex: 1;
}

.language-name {
    font-weight: 600;
    color: var(--color-text);
}

.language-native {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.language-check {
    font-size: 1.25rem;
    color: var(--color-primary);
    font-weight: bold;
    width: 24px;
    text-align: center;
}

/* ================================================
   PAYMENT MATCHING STYLES
   ================================================ */

/* Bank transaction info in payment table */
.bank-transaction-info {
    padding: 8px 0;
}

.bank-transaction-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.bank-account-name {
    font-weight: 500;
    color: var(--color-text);
}

.bank-transaction-details {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    background: var(--color-bg);
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.bank-transaction-details div {
    margin-bottom: 4px;
}

.bank-transaction-details div:last-child {
    margin-bottom: 0;
}

.bank-transaction-details strong {
    color: var(--color-text);
}

.bank-transaction-missing {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Payment matching section */
.payment-matching-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--color-bg);
    border-radius: 8px;
    text-align: center;
}

.payment-matching-section p {
    margin-bottom: 12px;
}

/* Payment summary */
.payment-summary {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--color-bg);
    border-radius: 8px;
}

.payment-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.payment-summary-row .amount {
    font-weight: 600;
}

.payment-summary-remaining {
    border-top: 1px solid var(--color-border);
    margin-top: 8px;
    padding-top: 8px;
    font-weight: 600;
}

/* Match score badges */
.match-score {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.match-score-high {
    background: rgba(34, 197, 94, 0.1);
    color: var(--color-success);
}

.match-score-medium {
    background: rgba(234, 179, 8, 0.1);
    color: var(--color-warning);
}

.match-score-low {
    background: rgba(148, 163, 184, 0.1);
    color: var(--color-text-muted);
}

/* Account Tags Input (WordPress-like tag selector) */
.account-tags-container {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    min-height: 42px;
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: text;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.account-tags-container:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.account-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.account-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--color-primary);
    color: white;
    font-size: 13px;
    font-weight: 500;
    border-radius: 4px;
    white-space: nowrap;
}

.account-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    margin-left: 2px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}

.account-tag-remove:hover {
    background: rgba(255, 255, 255, 0.4);
}

.account-tags-input {
    flex: 1;
    min-width: 150px;
    padding: 4px 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: var(--color-text);
}

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

.account-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
}

.account-dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
    transition: background 0.15s;
}

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

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

.account-dropdown-item strong {
    color: var(--color-primary);
    margin-right: 4px;
}

/* ============================================
   Customs/JCD Specific Styles
   ============================================ */

/* Stats grid for JCD overview */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stats-grid-mb {
    margin-bottom: 24px;
}

/* Warning color for stat values */
.stat-value-warning {
    color: var(--color-warning) !important;
}

/* Card with margin-top */
.card-mt {
    margin-top: 24px;
}

/* Info list in card body */
.info-list {
    margin: 16px 0;
    padding-left: 24px;
}

.info-list li {
    margin-bottom: 8px;
}

/* Detail grid (two column layout) */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
}

/* Detail table for key-value pairs */
.detail-table {
    width: 100%;
}

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

.detail-table th {
    font-weight: 500;
    color: var(--color-text-muted);
    width: 40%;
}

/* Separator line */
.separator {
    margin: 16px 0;
    border: 0;
    border-top: 1px solid var(--color-border);
}

.separator-lg {
    margin: 24px 0;
}

/* Data table variants */
.data-table-narrow {
    max-width: 600px;
}

.data-table-medium {
    max-width: 800px;
}

/* Table row with background */
.table-row-highlight {
    background: var(--color-bg);
}

/* Table row for totals */
.table-row-total {
    font-size: 1.1rem;
    font-weight: bold;
    background: var(--color-bg);
}

/* Form row flex */
.form-group-flex {
    flex: 1;
}

/* Info box */
.info-box {
    padding: 16px;
    background: var(--color-bg);
    border-radius: 8px;
}

.info-box-hidden {
    display: none;
}

.info-box-mt {
    margin-top: 16px;
}

/* Totals box */
.totals-box {
    margin-top: 24px;
    padding: 16px;
    background: var(--color-bg);
    border-radius: 8px;
}

.totals-box-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.totals-box-label {
    font-size: 1.25rem;
}

.totals-box-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Read-only period banner */
.period-readonly-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    background: linear-gradient(90deg, #FEF3C7 0%, #FDE68A 100%);
    border-bottom: 1px solid #F59E0B;
    color: #92400E;
    font-size: 0.875rem;
}

.period-readonly-icon {
    font-size: 1rem;
}

.period-readonly-banner strong {
    color: #78350F;
}

.period-readonly-link {
    margin-left: auto;
    color: #B45309;
    text-decoration: underline;
    font-weight: 500;
}

.period-readonly-link:hover {
    color: #92400E;
}

/* Disabled state for buttons in read-only period */
.period-readonly .btn-primary,
.period-readonly .btn-success,
.period-readonly .btn-warning,
.period-readonly .btn-danger,
.period-readonly [data-action="edit"],
.period-readonly [data-action="delete"],
.period-readonly [data-action="create"] {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* ========================================
   REGISTRATION & ONBOARDING
   ======================================== */

/* Registration form adjustments */
.register-box {
    max-width: 480px;
}

.register-box .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Onboarding page layout */
.onboarding-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.onboarding-container {
    width: 100%;
    max-width: 700px;
}

.onboarding-box {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
}

.onboarding-box-wide {
    max-width: 800px;
}

/* Onboarding header */
.onboarding-header {
    text-align: center;
    margin-bottom: 30px;
}

.onboarding-header h1 {
    font-size: 28px;
    color: #1e293b;
    margin: 0 0 10px 0;
}

.onboarding-header p {
    color: #64748b;
    font-size: 16px;
    margin: 0;
}

/* Onboarding progress bar */
.onboarding-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
    padding: 0 20px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.step-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
}

.progress-step.active .step-dot {
    background: #2563eb;
    color: white;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.progress-step.completed .step-dot {
    background: #22c55e;
    color: white;
}

.step-label {
    margin-top: 8px;
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.progress-step.active .step-label {
    color: #2563eb;
}

.progress-step.completed .step-label {
    color: #22c55e;
}

.progress-line {
    flex: 1;
    height: 3px;
    background: #e2e8f0;
    margin: 0 10px 20px;
    max-width: 80px;
}

.progress-line.completed {
    background: #22c55e;
}

/* Onboarding content */
.onboarding-content {
    text-align: center;
}

.onboarding-info {
    text-align: left;
    margin: 30px 0;
}

.onboarding-info h2 {
    font-size: 18px;
    color: #1e293b;
    margin-bottom: 15px;
}

.onboarding-steps-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.onboarding-steps-list li {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.onboarding-steps-list li:last-child {
    border-bottom: none;
}

.step-number {
    width: 28px;
    height: 28px;
    background: #e0e7ff;
    color: #4f46e5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    margin-right: 15px;
}

.step-text {
    color: #475569;
}

.onboarding-note {
    background: #f8fafc;
    border-radius: 8px;
    padding: 15px 20px;
    margin: 20px 0;
}

.onboarding-note p {
    margin: 5px 0;
    font-size: 14px;
    color: #64748b;
}

.onboarding-actions {
    margin-top: 30px;
}

.onboarding-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #f1f5f9;
    text-align: center;
}

.onboarding-footer p {
    margin: 5px 0;
    font-size: 14px;
    color: #64748b;
}

.onboarding-footer a {
    color: #2563eb;
}

/* Radio cards for onboarding options */
.radio-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.radio-cards-vertical {
    grid-template-columns: 1fr;
}

.radio-card {
    display: block;
    cursor: pointer;
}

.radio-card input {
    display: none;
}

.radio-card-content {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.radio-card input:checked + .radio-card-content {
    border-color: #2563eb;
    background: #eff6ff;
}

.radio-card:hover .radio-card-content {
    border-color: #94a3b8;
}

.radio-card-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.radio-card-desc {
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

/* Summary cards on complete page */
.summary-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.summary-table {
    width: 100%;
}

.summary-table td {
    padding: 8px 0;
    vertical-align: top;
}

.summary-table .label {
    color: #64748b;
    width: 100px;
}

.summary-table .value {
    color: #1e293b;
    font-weight: 500;
}

.card-edit {
    float: right;
    font-size: 13px;
    font-weight: normal;
    color: #2563eb;
}

.card-edit:hover {
    text-decoration: underline;
}

.create-list {
    margin: 0;
    padding-left: 20px;
    color: #475569;
}

.create-list li {
    padding: 5px 0;
}

/* Large button */
.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* Card highlight animation */
.card.highlight {
    animation: cardHighlight 0.5s ease;
}

@keyframes cardHighlight {
    0% { background: white; }
    50% { background: #ecfdf5; }
    100% { background: white; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .onboarding-box {
        padding: 25px;
    }

    .onboarding-header h1 {
        font-size: 22px;
    }

    .radio-cards {
        grid-template-columns: 1fr;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .progress-line {
        max-width: 40px;
    }

    .step-label {
        display: none;
    }

    .register-box .form-row {
        grid-template-columns: 1fr;
    }
}

/* Password toggle button */
.password-wrapper {
    position: relative;
}

.password-wrapper .form-input {
    padding-right: 45px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: #1e293b;
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

/* ================================
   DOCUMENTS ARCHIVE
   ================================ */

.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.document-card {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.document-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.document-preview {
    position: relative;
    height: 160px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.document-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.document-icon {
    font-size: 4rem;
    opacity: 0.5;
}

.document-preview .badge-ai {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(37, 99, 235, 0.9);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.document-info {
    padding: 0.75rem 1rem;
}

.document-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.document-counterparty {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

.document-status {
    margin-top: 0.5rem;
}

.document-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
    background: #fafafa;
}

.document-actions .btn-sm {
    flex: 1;
    text-align: center;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
}

/* Documents table view */
.document-icon-cell {
    text-align: center;
    vertical-align: middle;
}

.doc-type-icon {
    font-size: 1.5rem;
}

.document-link {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
}

.document-link:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

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

.document-link-deleted:hover {
    color: var(--color-primary);
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Trash view styles */
.document-name-deleted {
    color: var(--color-text-muted);
}

.btn-error {
    background-color: var(--color-error);
    color: white;
    border: none;
}

.btn-error:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--color-success);
    color: white;
    border: none;
}

.btn-success:hover {
    background-color: #16a34a;
}

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

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

.btn-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.alert-info {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.btn-delete-doc {
    color: var(--color-error);
}

.btn-delete-doc:hover {
    background-color: #fef2f2;
}

/* Document upload */
.upload-zone {
    border: 2px dashed var(--color-border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
}

.upload-zone-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-zone-text {
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.upload-zone-hint {
    font-size: 0.875rem;
    color: #94a3b8;
}

.upload-preview {
    margin-top: 1.5rem;
    padding: 1rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    display: none;
}

.upload-preview.has-file {
    display: block;
}

.upload-preview-file {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.upload-preview-icon {
    font-size: 2.5rem;
}

.upload-preview-info {
    flex: 1;
}

.upload-preview-name {
    font-weight: 600;
}

.upload-preview-size {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.upload-preview-remove {
    background: none;
    border: none;
    color: var(--color-error);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.5rem;
}

/* Document detail */
.document-detail-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
}

.document-viewer {
    background: #1e293b;
    border-radius: 8px;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.document-viewer img {
    max-width: 100%;
    max-height: 80vh;
}

.document-viewer iframe {
    width: 100%;
    height: 80vh;
    border: none;
}

.document-no-preview {
    color: white;
    text-align: center;
}

.document-no-preview-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.document-no-preview .btn {
    margin-top: 1rem;
}

.document-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.linked-entries {
    list-style: none;
}

.linked-entry-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

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

.linked-entry-info {
    flex: 1;
}

.linked-entry-number {
    font-weight: 600;
    color: var(--color-primary);
}

.linked-entry-date {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* Checkbox inline */
.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 42px;
}

.checkbox-inline input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.checkbox-inline label {
    font-size: 0.875rem;
    cursor: pointer;
}

/* Stat card info variant */
.stat-card.stat-info {
    border-left: 4px solid var(--color-primary);
}

.stat-card.stat-info .stat-value {
    color: var(--color-primary);
}

@media (max-width: 1024px) {
    .documents-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    .document-detail-grid {
        grid-template-columns: 1fr;
    }
}

/* ================================
   JOURNAL ENTRY FORM - MODE SELECTION
   ================================ */

.mode-option {
    transition: all 0.2s;
}

.mode-option:hover {
    border-color: var(--color-primary) !important;
    background: rgba(37, 99, 235, 0.02);
}

.mode-option.selected {
    border-color: var(--color-primary) !important;
    background: rgba(37, 99, 235, 0.05);
}

.linked-doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.linked-doc-item span {
    font-size: 0.875rem;
}

.linked-doc-item .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* ====================================
   AI Journal Entry - Enhanced OCR Results
   ==================================== */

/* Stats bar */
.ai-stats-bar {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--color-bg);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.ai-stats-bar .stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-stats-bar .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.ai-stats-bar .stat-value {
    font-weight: 600;
}

.ai-stats-bar .stat-value.high { color: #059669; }
.ai-stats-bar .stat-value.medium { color: #f59e0b; }
.ai-stats-bar .stat-value.low { color: #dc2626; }

/* Issues box (critical errors) */
.ai-issues-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.ai-issues-box h4 {
    color: #991b1b;
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
}

.ai-issues-box ul {
    margin: 0;
    padding-left: 1.25rem;
    color: #991b1b;
    font-size: 0.875rem;
}

/* Warnings box */
.ai-warnings-box {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.ai-warnings-box h4 {
    color: #92400e;
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
}

.ai-warnings-box ul {
    margin: 0;
    padding-left: 1.25rem;
    color: #92400e;
    font-size: 0.875rem;
}

.period-warning {
    background: #fef2e2;
    border-color: #e67e22;
}

.period-warning h4 {
    color: #7c3a00;
}

.period-warning p {
    color: #7c3a00;
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

.period-warning .period-warning-info {
    font-weight: 600;
    margin-top: 0.5rem;
}

.period-modal-error {
    background: #fef2f2;
    border-bottom-color: #dc2626;
}

.period-modal-error h2 {
    color: #991b1b;
}

.period-modal-warning {
    background: #fef2e2;
    border-bottom-color: #e67e22;
}

.period-modal-warning h2 {
    color: #7c3a00;
}

/* Transaction type box */
.ai-transaction-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.ai-transaction-box .transaction-icon {
    font-size: 2rem;
}

.ai-transaction-box .transaction-info {
    flex: 1;
}

.ai-transaction-box .transaction-type {
    font-weight: 700;
    font-size: 1rem;
}

.ai-transaction-box .transaction-desc {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.ai-transaction-box .transaction-vat {
    padding: 6px 12px;
    background: rgba(0,0,0,0.1);
    border-radius: 16px;
    font-weight: 600;
    font-size: 0.8rem;
}

.ai-transaction-box.domestic {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    border: 1px solid #86efac;
}

.ai-transaction-box.intra_eu {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border: 1px solid #a5b4fc;
}

.ai-transaction-box.third_country {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fcd34d;
}

.ai-transaction-box.export {
    background: linear-gradient(135deg, #f3e8ff 0%, #e9d5ff 100%);
    border: 1px solid #d8b4fe;
}

/* Customer warning box */
.ai-customer-warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.ai-customer-warning .warning-title {
    font-weight: 600;
    color: #92400e;
    margin-bottom: 0.5rem;
}

.ai-customer-warning ul {
    margin: 0;
    padding-left: 1.25rem;
    color: #92400e;
    font-size: 0.875rem;
}

/* Flags section */
.ai-flags-section {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ai-flags-section .flag-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.ai-flags-section .flag-badge.active {
    background: #dcfce7;
    color: #166534;
}

.ai-flags-section .flag-badge.inactive {
    background: #f1f5f9;
    color: var(--color-text-muted);
}

/* Notes section */
.ai-notes-section {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.ai-notes-section .notes-title {
    font-weight: 600;
    color: #0369a1;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.ai-notes-section .notes-content {
    color: #0c4a6e;
    font-size: 0.875rem;
    white-space: pre-wrap;
}

/* Raw JSON/Markdown section */
.ai-raw-section {
    margin-top: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}

.ai-raw-section summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.ai-raw-section summary:hover {
    background: #f1f5f9;
}

.ai-raw-section .raw-tabs {
    display: flex;
    background: #2d2d2d;
}

.ai-raw-section .raw-tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.8rem;
}

.ai-raw-section .raw-tab:hover {
    color: #e5e7eb;
}

.ai-raw-section .raw-tab.active {
    background: #1e1e1e;
    color: #f97316;
}

.ai-raw-section .raw-content {
    display: none;
    background: #1e1e1e;
    padding: 1rem;
    max-height: 300px;
    overflow: auto;
}

.ai-raw-section .raw-content.active {
    display: block;
}

.ai-raw-section .raw-content pre {
    margin: 0;
    color: #e5e7eb;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Editable fields */
.ai-field-editable {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 4px 8px;
    width: 100%;
    font-size: 0.875rem;
}

.ai-field-editable:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.ai-field-editable.edited {
    border-color: #f59e0b !important;
    background: #fffbeb !important;
}

/* Amounts validation */
.ai-amounts-warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #991b1b;
}

/* Two column grid for supplier/customer */
.ai-parties-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .ai-parties-grid {
        grid-template-columns: 1fr;
    }
}

/* Journal Entry Detail */
.journal-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.journal-detail-item {
    padding: 0.75rem;
    background: var(--color-background-secondary, #f8fafc);
    border-radius: 6px;
}

.journal-detail-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.journal-detail-value {
    font-size: 0.95rem;
    font-weight: 500;
}

.journal-detail-value.empty {
    color: var(--color-text-muted);
    font-style: italic;
    font-weight: normal;
}

.journal-section-divider {
    border-top: 1px solid var(--color-border);
    margin: 1.5rem 0;
}

/* Journal Entry Linked Documents */
.journal-linked-doc {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--color-background-secondary, #f8fafc);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.journal-linked-doc-icon {
    font-size: 1.5rem;
}

.journal-linked-doc-info {
    flex: 1;
}

.journal-linked-doc-name {
    font-weight: 500;
}

.journal-linked-doc-meta {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Journal Entry Payment Status */
.journal-payment-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.journal-payment-status.unpaid {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger, #ef4444);
}

.journal-payment-status.paid {
    background: rgba(34, 197, 94, 0.1);
    color: var(--color-success, #22c55e);
}

.journal-payment-status.partial {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-warning, #f59e0b);
}

/* Journal Entry Balance Indicator */
.journal-balance-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
}

.journal-balance-indicator.balanced {
    background: rgba(34, 197, 94, 0.1);
    color: var(--color-success, #22c55e);
}

.journal-balance-indicator.unbalanced {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger, #ef4444);
}

/* Journal Entry Items Table */
.journal-items-table th,
.journal-items-table td {
    padding: 0.5rem 0.75rem;
}

.journal-items-table .text-right {
    text-align: right;
}

/* Journal Entry Totals Box */
.journal-totals-box {
    background: var(--color-background-secondary, #f8fafc);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.journal-totals-row {
    display: flex;
    justify-content: flex-end;
    gap: 2rem;
    align-items: center;
    padding: 0.25rem 0;
}

.journal-totals-row.total-final {
    border-top: 2px solid var(--color-border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    font-size: 1.1rem;
}

.journal-vat-breakdown {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* ========================================
   Chat Widget - AI Accounting Assistant
   ======================================== */

.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
}

.chat-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--color-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.chat-widget.open .chat-bubble {
    display: none;
}

.chat-panel {
    display: none;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    flex-direction: column;
    overflow: hidden;
}

.chat-widget.open .chat-panel {
    display: flex;
    animation: chatSlideUp 0.25s ease-out;
}

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--color-primary);
    color: #fff;
}

.chat-header-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
    line-height: 1;
}

.chat-close:hover {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 300px;
    max-height: 380px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-message {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-message-user {
    align-self: flex-end;
    background-color: var(--color-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message-assistant {
    align-self: flex-start;
    background-color: #F1F5F9;
    color: var(--color-text);
    border-bottom-left-radius: 4px;
}

.chat-message-error {
    align-self: flex-start;
    background-color: #FEF2F2;
    color: #B91C1C;
    border-bottom-left-radius: 4px;
    font-size: 0.85rem;
}

.chat-message-sources {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #E2E8F0;
    font-size: 0.8rem;
    color: #64748B;
}

.chat-message-sources-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.chat-message-source-item {
    padding: 1px 0;
}

.chat-message-tokens {
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px solid #E2E8F0;
    font-size: 0.75rem;
    color: #94A3B8;
}

.chat-typing {
    align-self: flex-start;
    padding: 10px 14px;
    background-color: #F1F5F9;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.chat-typing-dots {
    display: inline-flex;
    gap: 4px;
}

.chat-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #94A3B8;
    animation: chatDotBounce 1.4s infinite ease-in-out;
}

.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatDotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.chat-input-area {
    display: flex;
    padding: 10px 12px;
    border-top: 1px solid #E2E8F0;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    border: 1px solid #CBD5E1;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--color-primary);
}

.chat-input:disabled {
    background-color: #F8FAFC;
    color: #94A3B8;
}

.chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--color-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.chat-send:hover {
    filter: brightness(1.1);
}

.chat-send:disabled {
    background-color: #CBD5E1;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .chat-panel {
        width: calc(100vw - 24px);
        max-height: 70vh;
    }
    .chat-widget {
        bottom: 12px;
        right: 12px;
    }
}
