* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: #f1f5f9;
    color: #1e293b;
}

#app {
    min-height: 100vh;
}

.header {
    background-color: #1e3a5f;
    color: white;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tabs {
    display: flex;
    list-style: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-button {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}

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

.tab-button.active {
    color: white;
    border-bottom-color: #3b82f6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.accordion {
    margin-bottom: 1.5rem;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0.75rem 0;
    user-select: none;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 1rem;
}

.accordion-header:hover {
    color: #1e3a5f;
}

.accordion-chevron {
    font-size: 0.75rem;
    color: #94a3b8;
    transition: transform 0.2s ease;
    transform: rotate(-90deg);
}

.accordion-chevron.open {
    transform: rotate(0deg);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #1e293b;
}

.filter-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #475569;
}

.filter-group select,
.filter-group input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    font-size: 0.95rem;
    background-color: white;
    color: #1e293b;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-table-wrapper {
    max-width: 400px;
    margin-bottom: 2rem;
}

.summary-table td {
    padding: 0.4rem 0.75rem;
}

.summary-table td:first-child {
    color: #475569;
}

.summary-table td:last-child {
    text-align: right;
}

.accounts-over-time-wrapper {
    overflow-x: auto;
    margin-bottom: 2rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.accounts-over-time-wrapper table {
    min-width: max-content;
    margin-bottom: 0;
}

.accounts-over-time-wrapper th,
.accounts-over-time-wrapper td {
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
}

.accounts-over-time-wrapper th {
    text-align: right;
}

.accounts-over-time-wrapper th:first-child {
    text-align: left;
}

/* White base for everything */
.accounts-over-time-wrapper thead {
    background-color: white;
}

.accounts-over-time-wrapper tbody {
    background-color: white;
}

/* Month group header row */
.accounts-over-time-wrapper thead tr:first-child th {
    text-align: center;
    border-bottom: none;
    padding-bottom: 0;
    font-size: 0.85rem;
    letter-spacing: 0;
    text-transform: none;
    color: #1e293b;
}

/* Sub-header row (Balance / Net) */
.accounts-over-time-wrapper thead tr:last-child th {
    font-size: 0.7rem;
    padding-top: 0.15rem;
    color: #94a3b8;
}

/* Sticky account name column */
.accounts-over-time-wrapper td:first-child,
.accounts-over-time-wrapper th:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: white;
    font-weight: 600;
    min-width: 140px;
    border-right: 2px solid #cbd5e1;
}

.accounts-over-time-wrapper thead th:first-child {
    z-index: 3;
}

/* Right-align all value cells */
.accounts-over-time-wrapper td:not(:first-child) {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
}

/* Vertical month striping — every other month is light grey */
.accounts-over-time-wrapper th.month-odd,
.accounts-over-time-wrapper td.month-odd {
    background-color: #f0f4f8 !important;
}

/* Type group header - sticky on horizontal scroll */
.accounts-over-time-wrapper .acct-type-header td {
    font-weight: 700;
    background-color: #e2e8f0 !important;
    color: #334155;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.4rem 0.75rem;
    border-right: none;
    position: sticky;
    left: 0;
    z-index: 3;
}

/* Subtotal rows */
.accounts-over-time-wrapper .subtotal-row td {
    font-weight: 700;
    border-top: 2px solid #cbd5e1;
    background-color: #f8fafc;
    font-size: 0.85rem;
}

.accounts-over-time-wrapper .subtotal-row td.month-odd {
    background-color: #e9edf2 !important;
}

/* Overall total row */
.accounts-over-time-wrapper .total-row td {
    font-weight: 700;
    border-top: 3px double #94a3b8;
    background-color: #f1f5f9;
    font-size: 0.9rem;
}

.accounts-over-time-wrapper .total-row td.month-odd {
    background-color: #e3e8ee !important;
}

/* Data row hover */
.accounts-over-time-wrapper tbody tr:not(.acct-type-header):not(.subtotal-row):not(.total-row):hover td {
    background-color: #dbeafe !important;
}
.accounts-over-time-wrapper tbody tr:not(.acct-type-header):not(.subtotal-row):not(.total-row):hover td:first-child {
    background-color: #dbeafe !important;
}

.separator-row td {
    padding: 0.25rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.clickable { cursor: pointer; transition: box-shadow 0.15s; }
.clickable:hover { box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2); }

.clickable-row { cursor: pointer; }
.clickable-row:hover { background-color: #e0e7ff !important; }

.card-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
}

.card-value.positive {
    color: #16a34a;
}

.card-value.negative {
    color: #dc2626;
}

.table-wrapper {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

thead {
    background-color: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

th {
    padding: 0.45rem 0.6rem;
    text-align: left;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

td {
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid #e2e8f0;
}

tbody tr:hover {
    background-color: #f8fafc;
}

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

.amount.positive {
    color: #16a34a;
    font-weight: 600;
}

.amount.negative {
    color: #dc2626;
    font-weight: 600;
}

.progress-bar {
    height: 0.5rem;
    background-color: #e2e8f0;
    border-radius: 0.25rem;
    overflow: hidden;
    min-width: 100px;
}

.progress-fill {
    height: 100%;
    background-color: #3b82f6;
    transition: width 0.3s ease;
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: #2563eb;
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-primary:disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-danger {
    background-color: #dc2626;
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

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

.btn-success:hover {
    background-color: #15803d;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
}

.add-form {
    background-color: #f8fafc;
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    border: 1px solid #e2e8f0;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #475569;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    font-size: 0.95rem;
    font-family: inherit;
    background-color: white;
    color: #1e293b;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
}

.edit-row-form {
    background-color: #f0f4f8;
    padding: 0.75rem;
    border-radius: 0.375rem;
}

.edit-row-form input,
.edit-row-form select {
    padding: 0.375rem 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    font-size: 0.9rem;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background-color: white;
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 90%;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.alert.error {
    background-color: #fee2e2;
    color: #7f1d1d;
    border-left: 4px solid #dc2626;
}

.alert.success {
    background-color: #dbeafe;
    color: #0c4a6e;
    border-left: 4px solid #2563eb;
}

.alert.loading {
    background-color: #f3e8ff;
    color: #581c87;
    border-left: 4px solid #9333ea;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #64748b;
}

.empty-state-text {
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.no-data {
    text-align: center;
    padding: 2rem;
    color: #94a3b8;
    font-size: 0.95rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.75rem;
}
.pagination-info {
    font-size: 0.9rem;
    color: #64748b;
    margin: 0 0.5rem;
}

.export-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}
.export-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
}
.export-card-icon {
    font-size: 2rem;
}
.export-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
}
.export-card-desc {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.4;
    flex: 1;
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #cbd5e1;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.inline-edit {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.inline-edit input,
.inline-edit select {
    flex: 1;
    padding: 0.375rem 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    font-size: 0.9rem;
}

.tag {
    display: inline-block;
    background-color: #dbeafe;
    color: #0c4a6e;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 500;
}

.tab-content {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.flash-updated {
    animation: flashGreen 1.5s ease;
}

@keyframes flashGreen {
    0% { background-color: #bbf7d0; }
    100% { background-color: transparent; }
}

.error-message {
    color: #dc2626;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.bulk-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.bulk-bar span {
    font-size: 0.9rem;
    font-weight: 500;
    color: #1e40af;
}

.checkbox-cell {
    width: 40px;
    text-align: center;
}

.checkbox-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #2563eb;
}

.override-cell {
    position: relative;
    min-width: 130px;
}

.override-cell .override-display {
    display: none;
}

.override-cell .override-select {
    display: block;
    width: 100%;
    padding: 0.2rem 0.3rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    font-size: 0.85rem;
    background: white;
}

.desc-clickable {
    cursor: pointer;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.2s;
}

.desc-clickable:hover {
    border-bottom-color: #3b82f6;
    color: #2563eb;
}

.quick-rule-popover {
    position: fixed;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    padding: 1rem;
    z-index: 1001;
    width: 320px;
}

.quick-rule-popover h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #1e293b;
}

.quick-rule-popover .form-group {
    margin-bottom: 0.5rem;
}

.quick-rule-popover .form-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
    display: block;
    margin-bottom: 0.25rem;
}

.quick-rule-popover .form-group input,
.quick-rule-popover .form-group select {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    font-size: 0.85rem;
}

.quick-rule-popover .form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem;
}

th.sortable:hover {
    background-color: #e2e8f0;
}

th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 0.4rem;
    opacity: 0.3;
    font-size: 0.75rem;
}

th.sortable.asc::after {
    content: '▲';
    opacity: 0.7;
}

th.sortable.desc::after {
    content: '▼';
    opacity: 0.7;
}

.import-modal {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.import-step {
    margin-bottom: 1.5rem;
}

.import-step-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #1e293b;
}

.import-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background-color: #2563eb;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    margin-right: 0.5rem;
}

.mapping-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.mapping-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mapping-item label {
    min-width: 90px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #475569;
}

.mapping-item select {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    font-size: 0.9rem;
}

.mapping-item .required {
    color: #dc2626;
}

.csv-preview {
    max-height: 300px;
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
}

.csv-preview table {
    font-size: 0.85rem;
}

.csv-preview th, .csv-preview td {
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
}

.import-summary {
    padding: 1rem;
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 0.375rem;
    color: #166534;
}

.import-summary.has-errors {
    background-color: #fef9c3;
    border-color: #fde68a;
    color: #854d0e;
}

.file-drop {
    border: 2px dashed #cbd5e1;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background-color: #fafafa;
}

.file-drop:hover {
    border-color: #2563eb;
    background-color: #eff6ff;
}

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

.debit-credit-note {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: #f8fafc;
    border-left: 3px solid #3b82f6;
    border-radius: 0 0.25rem 0.25rem 0;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

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

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

    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 0.75rem;
    }

    .button-group {
        flex-wrap: wrap;
    }

    .tabs {
        overflow-x: auto;
    }

    .tab-button {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
}

/* Login screen */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 0.75rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
    color: #1e3a5f;
}

/* AI Chat */
.ai-tab {
    display: flex;
    flex-direction: column;
}

.ai-chat-container {
    display: flex;
    flex-direction: column;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #f8fafc;
    height: calc(100vh - 220px);
    min-height: 400px;
}

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

.ai-empty {
    color: #94a3b8;
    text-align: center;
    padding: 3rem 1rem;
    font-size: 1rem;
    line-height: 1.6;
}

.ai-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    line-height: 1.5;
    font-size: 0.95rem;
}

.ai-user {
    align-self: flex-end;
    background: #2563eb;
    color: #fff;
}

.ai-user .ai-message-label {
    color: rgba(255, 255, 255, 0.7);
}

.ai-assistant {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
}

.ai-assistant .ai-message-label {
    color: #64748b;
}

.ai-message-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.ai-message-text {
    word-wrap: break-word;
}

.ai-message-text p {
    margin: 0 0 0.5rem 0;
}

.ai-message-text p:last-child {
    margin-bottom: 0;
}

.ai-message-text ul, .ai-message-text ol {
    margin: 0.25rem 0 0.5rem 1.25rem;
    padding: 0;
}

.ai-message-text li {
    margin-bottom: 0.2rem;
}

.ai-message-text code {
    background: rgba(0, 0, 0, 0.06);
    padding: 0.1rem 0.35rem;
    border-radius: 0.2rem;
    font-size: 0.88em;
}

.ai-user .ai-message-text code {
    background: rgba(255, 255, 255, 0.2);
}

.ai-message-text pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.ai-message-text pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.ai-message-text blockquote {
    border-left: 3px solid #94a3b8;
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 0 0.25rem 0.25rem 0;
    color: #64748b;
    font-size: 0.9em;
}

.ai-table-container {
    position: relative;
    margin: 0.5rem 0;
}

.ai-table-export {
    position: absolute;
    top: -0.25rem;
    right: 0;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    color: #475569;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.ai-table-export:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.ai-message-text table {
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.9em;
    width: 100%;
}

.ai-message-text th, .ai-message-text td {
    border: 1px solid #e2e8f0;
    padding: 0.35rem 0.6rem;
    text-align: left;
}

.ai-message-text th {
    background: #f1f5f9;
    font-weight: 600;
}

.ai-message-text h1, .ai-message-text h2, .ai-message-text h3 {
    margin: 0.75rem 0 0.35rem 0;
    font-size: 1em;
    font-weight: 600;
}

.ai-message-text hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 0.5rem 0;
}

.ai-input-row {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 0 0 0.5rem 0.5rem;
}

.ai-input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    resize: none;
    overflow-y: auto;
    min-height: 2.5rem;
    max-height: 150px;
    line-height: 1.4;
}

.ai-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ai-input:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
}

.ai-input-row {
    align-items: flex-end;
}

.ai-upload-btn {
    background: none;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    padding: 0.5rem;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.ai-upload-btn:hover {
    color: #2563eb;
    border-color: #2563eb;
}

.ai-upload-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ai-attachment-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: #eff6ff;
    border-top: 1px solid #e2e8f0;
    font-size: 0.85rem;
    color: #1e40af;
}

.ai-attachment-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-attachment-remove {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #64748b;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.ai-attachment-remove:hover {
    color: #dc2626;
}

.ai-status {
    align-self: center;
    color: #64748b;
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.25rem 0;
}

.ai-status .ai-message-label {
    display: none;
}

.ai-toolcalls {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ai-toolcall {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 0.35rem;
    font-size: 0.8rem;
    color: #475569;
    cursor: pointer;
    transition: background 0.15s;
}

.ai-toolcall:hover {
    background: #e2e8f0;
}

.ai-toolcall-icon {
    font-weight: 700;
    font-size: 0.85rem;
}

.ai-toolcall-icon:first-child {
    color: #16a34a;
}

.ai-toolcall:has(.ai-toolcall-detail [style*="color: #dc2626"]) .ai-toolcall-icon {
    color: #dc2626;
}

.ai-toolcall-label {
    flex: 1;
    font-family: monospace;
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-toolcall-rows {
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
}

.ai-toolcall-detail {
    width: 100%;
    margin-top: 0.35rem;
}

.ai-toolcall-detail pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.78rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.ai-pending {
    align-self: stretch;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: 0.5rem;
    padding: 1rem;
}

.ai-pending-header {
    font-weight: 600;
    color: #92400e;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.ai-pending-sql {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    overflow-x: auto;
    margin: 0 0 0.5rem 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-pending-params {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 0.75rem;
    word-break: break-word;
}

.ai-pending-actions {
    display: flex;
    gap: 0.5rem;
}

.ai-chart-message {
    max-width: 95%;
}

.ai-chart-wrapper {
    background: #fff;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-top: 0.25rem;
    max-height: 400px;
    position: relative;
}

.ai-chart-expand {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    padding: 0.2rem 0.45rem;
    cursor: pointer;
    font-size: 1rem;
    color: #475569;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.ai-chart-expand:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.ai-chart-modal {
    max-width: 90vw;
    width: 900px;
    padding: 1.5rem;
}

.ai-chart-modal-body {
    height: 70vh;
    position: relative;
}
