/* AFS Professional Web Financial Statements - Clean Crisp Light Theme */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700;800&display=swap');

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    background-color: #f8fafc;
    color: #0f172a;
    -webkit-font-smoothing: antialiased;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Tab Navigation Buttons - Rock Solid & High Contrast */
.tab-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.875rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #334155 !important;
    background-color: transparent;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    transition: all 0.15s ease-in-out;
    white-space: nowrap;
    cursor: pointer;
}

.tab-btn svg, .tab-btn i {
    color: inherit !important;
    stroke: currentColor !important;
    opacity: 0.85;
}

.tab-btn:hover {
    color: #0284c7 !important;
    background-color: #e0f2fe !important;
    border-color: #bae6fd !important;
}

.tab-btn:hover svg, .tab-btn:hover i {
    opacity: 1;
    color: #0284c7 !important;
}

.tab-btn.active {
    color: #ffffff !important;
    background-color: #0284c7 !important;
    border-color: #0284c7 !important;
    box-shadow: 0 2px 5px rgba(2, 132, 199, 0.35) !important;
}

.tab-btn.active svg, .tab-btn.active i {
    color: #ffffff !important;
    stroke: #ffffff !important;
    opacity: 1;
}

/* Statement Subtab Buttons (Vertical Left Sidebar Navigation) */
.stmt-subtab-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #334155 !important;
    background-color: #ffffff !important;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0 !important;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
    text-align: left;
    user-select: none;
}

.stmt-subtab-btn:hover {
    color: #0284c7 !important;
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

.stmt-subtab-btn:hover .stmt-icon {
    color: #0284c7 !important;
}

.stmt-subtab-btn:hover .stmt-chevron {
    color: #64748b !important;
    opacity: 1 !important;
}

.stmt-subtab-btn.active,
.stmt-subtab-btn[data-active="true"] {
    color: #ffffff !important;
    background-color: #0284c7 !important;
    border-color: #0284c7 !important;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(2, 132, 199, 0.25) !important;
}

.stmt-subtab-btn.active .stmt-icon,
.stmt-subtab-btn.active .stmt-chevron,
.stmt-subtab-btn[data-active="true"] .stmt-icon,
.stmt-subtab-btn[data-active="true"] .stmt-chevron {
    color: #ffffff !important;
    stroke: #ffffff !important;
    opacity: 1 !important;
}

/* Forms */
.form-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
    margin-bottom: 0.375rem;
}

.form-input, .form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    color: #0f172a;
    transition: all 0.15s ease-in-out;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: #0284c7;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

/* Financial Statement Tables */
.stmt-table {
    width: 100%;
    font-size: 0.8125rem;
    border-collapse: collapse;
}

.stmt-table th {
    padding: 0.5rem 0.75rem;
    font-weight: 800;
    border-bottom: 2px solid #0f172a;
    color: #0f172a;
}

.stmt-table td {
    padding: 0.375rem 0.75rem;
    color: #0f172a;
}

.stmt-row-bold {
    font-weight: 800;
    color: #0f172a !important;
}

.stmt-row-subtotal td:nth-child(2),
.stmt-row-total td:nth-child(2) {
    border-top: none !important;
    border-bottom: none !important;
}

.stmt-row-subtotal td {
    border-top: 1px solid #0f172a;
    border-bottom: 1px solid #0f172a;
    font-weight: 800;
}

.stmt-row-total td {
    border-top: 1px solid #0f172a;
    border-bottom: 3px double #0f172a;
    font-weight: 900;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f8fafc;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Trial Balance Scroll Container Scrollbar */
.tb-table-scroll-container::-webkit-scrollbar {
    width: 8px;
    height: 10px;
}
.tb-table-scroll-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 6px;
}
.tb-table-scroll-container::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 6px;
    border: 2px solid #f1f5f9;
}
.tb-table-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Animation */
@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
.animate-scaleUp {
    animation: scaleUp 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Print Stylesheet */
@media print {
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        font-size: 10pt;
    }
    header, aside, #balance-badge, .tab-btn, .stmt-subtab-btn, button, #toast, .toolbar-noprint, .stmt-controls-bar {
        display: none !important;
    }
    main {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    #tab-statements {
        display: block !important;
    }
    .tab-content:not(#tab-statements) {
        display: none !important;
    }
    #print-area {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .page-break {
        page-break-before: always;
    }
}

/* Clean Professional Financial Numeral Typography */
.tabular-nums, table, .stmt-table, input[type="number"] {
    font-variant-numeric: tabular-nums;
    -moz-font-feature-settings: "tnum";
    -webkit-font-feature-settings: "tnum";
    font-feature-settings: "tnum";
}

/* Ensure no slashed zero is used */
body, table, th, td, span, input, select {
    font-variant-numeric: tabular-nums normal;
    font-feature-settings: "tnum" 1, "zero" 0;
}

/* Sticky table header z-index and background */
thead {
    position: sticky;
    top: 0;
    z-index: 20;
}
thead th {
    background-color: #f1f5f9;
}


/* Document-First Editable Canvas & Inputs */
.doc-canvas {
    background: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    padding: 2.5rem 3rem;
    max-width: 56rem;
    margin-left: auto;
    margin-right: auto;
    color: #1e293b;
    font-family: inherit;
}

.doc-input {
    width: 100%;
    background-color: #f0f9ff;
    border: 1.5px solid #38bdf8;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 0;
    color: #334155;
    font-size: 0.8125rem;
    line-height: 1.65;
    text-align: left;
    resize: none;
    overflow: hidden;
    outline: none;
    transition: all 0.15s ease-in-out;
    font-family: inherit;
    display: block;
    box-shadow: 0 1px 2px 0 rgba(14, 165, 233, 0.04);
}

.doc-input:hover {
    background-color: #e0f2fe;
    border-color: #0ea5e9;
    box-shadow: 0 1px 3px 0 rgba(14, 165, 233, 0.12);
}

.doc-input:focus {
    background-color: #f0f9ff;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.doc-input-title {
    background-color: #f0f9ff;
    border: 1.5px solid #38bdf8;
    border-radius: 0.375rem;
    padding: 0.375rem 0.625rem;
    font-weight: 700;
    color: #0f172a;
    outline: none;
    transition: all 0.15s ease-in-out;
}

.doc-input-title:hover {
    background-color: #e0f2fe;
    border-color: #0ea5e9;
}

.doc-input-title:focus {
    background-color: #f0f9ff;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}



/* DRAFT Watermark Styling for Financial Statements */
#print-area {
    position: relative;
}

#print-area.has-watermark::before {
    content: "DRAFT";
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 7.5rem;
    font-weight: 900;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #475569;
    opacity: 0.12;
    pointer-events: none;
    z-index: 20;
    letter-spacing: 0.22em;
    user-select: none;
}

/* Interactive Editable Statement Line Items & Descriptions */
.stmt-inline-edit {
    background: transparent;
    border: 1px dashed transparent;
    border-radius: 4px;
    padding: 2px 6px;
    margin: -2px -6px;
    font: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    transition: all 0.15s ease-in-out;
}

.stmt-inline-edit:hover {
    background-color: rgba(241, 245, 249, 0.85);
    border-color: #94a3b8;
    cursor: text;
}

.stmt-inline-edit:focus {
    background-color: #ffffff;
    border-color: #0284c7;
    border-style: solid;
    outline: none;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25);
}

@media print {
    .stmt-inline-edit {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
    }
}



/* ==========================================================================
   Rich Text Editor & Floating Formatting Bubble Toolbar
   ========================================================================== */
.afs-rich-editor {
    min-height: 96px;
    outline: none;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.75rem 0.875rem;
    font-size: 0.75rem; /* text-xs */
    line-height: 1.6;
    color: #1e293b;
    cursor: text;
    transition: all 0.15s ease-in-out;
    word-break: break-word;
}

.afs-rich-editor:hover {
    border-color: #cbd5e1;
}

.afs-rich-editor:focus {
    border-color: #0284c7;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.afs-rich-editor p {
    margin: 0.15rem 0;
}

.afs-rich-editor p:first-child {
    margin-top: 0;
}

.afs-rich-editor p:last-child {
    margin-bottom: 0;
}

.afs-rich-editor p:has(> b:only-child),
.afs-rich-editor p:has(> strong:only-child),
.afs-rich-editor p.font-bold {
    margin-top: 0.25rem;
    margin-bottom: 0.05rem;
}

.afs-rich-editor b, .afs-rich-editor strong {
    font-weight: 700;
    color: #0f172a;
}

.afs-rich-editor i, .afs-rich-editor em {
    font-style: italic;
}

.afs-rich-editor u {
    text-decoration: underline;
}

.afs-rich-editor ul {
    list-style-type: disc;
    padding-left: 1.35rem;
    margin: 0.4rem 0;
}

.afs-rich-editor ol {
    list-style-type: decimal;
    padding-left: 1.35rem;
    margin: 0.4rem 0;
}

.afs-rich-editor li {
    margin: 0.2rem 0;
}

.afs-rich-editor blockquote {
    border-left: 3px solid #0284c7;
    padding-left: 0.75rem;
    margin: 0.5rem 0;
    color: #475569;
    font-style: italic;
    background-color: #f8fafc;
    border-radius: 0 4px 4px 0;
}

.afs-rich-editor[contenteditable]:empty::before,
.afs-rich-editor[contenteditable]:has(> br:only-child)::before,
.afs-rich-editor[contenteditable]:has(> p:only-child:empty)::before,
.afs-rich-editor[contenteditable]:has(> p:only-child > br:only-child)::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
    display: block;
}

/* Floating Formatting Bubble Toolbar */
#afs-floating-toolbar {
    position: fixed;
    z-index: 9999;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    padding: 0.25rem;
    box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.15), 0 4px 10px -2px rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    gap: 2px;
    user-select: none;
    animation: afsFadeIn 0.12s ease-out;
}

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

#afs-floating-toolbar.hidden {
    display: none !important;
}

#afs-floating-toolbar .fmt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    min-width: 28px;
    padding: 0 0.4rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.4rem;
    color: #334155;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s ease;
}

#afs-floating-toolbar .fmt-btn:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

#afs-floating-toolbar .fmt-btn.active {
    background-color: #e0f2fe;
    color: #0284c7;
    border-color: #bae6fd;
}
