:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-sub: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --danger-color: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    flex-shrink: 0;
}

.logo-area h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: #fff;
    letter-spacing: -0.025em;
}

.nav-links {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--sidebar-text);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    text-align: left;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nav-item.active {
    background-color: var(--primary-color);
    color: #fff;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}

.btn-logout {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    text-align: center;
}

.btn-logout:hover {
    background: #ef4444;
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 64px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    flex-shrink: 0;
}

.top-bar h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

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

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

.btn.secondary {
    background-color: #fff;
    border-color: var(--border-color);
    color: var(--text-main);
}

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

.btn.full-width {
    width: 100%;
    margin-top: 1rem;
    padding: 0.75rem;
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

/* Content Area */
#content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.tab-content {
    display: none;
    max-width: 1100px;
    margin: 0 auto;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.description {
    color: var(--text-sub);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.form-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

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

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-sub);
}

select,
input[type="number"],
input[type="text"] {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.9rem;
    background-color: #fff;
    width: 100%;
}

.range-select {
    display: flex;
    align-items: center;
}

.split-layout {
    display: flex;
    gap: 2.5rem;
}

.config-main {
    flex: 2;
}

.config-side {
    flex: 1;
    border-left: 1px solid var(--border-color);
    padding-left: 2rem;
}

.preprocess-box {
    background: #f8fafc;
    padding: 1.25rem;
    border-radius: 10px;
    border: 1px solid #eef2f6;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
    font-size: 0.88rem;
    cursor: pointer;
    font-weight: 500;
}

.check-item input {
    width: 17px;
    height: 17px;
    cursor: pointer;
}

/* Mapping Area */
.mapping-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
}

.mapping-group {
    background: #fff;
}

.group-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #eff6ff;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

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

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

th {
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--text-sub);
}

.summary-box {
    display: flex;
    justify-content: space-around;
    padding: 1.5rem;
    background-color: #f1f5f9;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

.summary-box div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.summary-box .label {
    font-size: 0.82rem;
    color: var(--text-sub);
    font-weight: 500;
}

.summary-box .value {
    font-size: 1.35rem;
    font-weight: 800;
}

.value.highlight {
    color: var(--primary-color);
}

.hidden {
    display: none;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.border-t {
    border-top: 1px solid var(--border-color);
}

.pt-4 {
    padding-top: 1rem;
}

.flex-1 {
    flex: 1;
}

.flex-row {
    display: flex;
    align-items: center;
}

.gap-1 {
    gap: 0.25rem;
}

.gap-2 {
    gap: 0.5rem;
}

.text-xs {
    font-size: 0.72rem;
}

.opacity-70 {
    opacity: 0.7;
}

.font-semibold {
    font-weight: 600;
}

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

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

.empty-state {
    text-align: center;
    padding: 4rem;
    color: var(--text-sub);
    border: 2px dashed var(--border-color);
    border-radius: 1rem;
}

/* Tab Header */
.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.tab-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.close-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.close-modal:hover {
    color: var(--primary-color);
}

/* Login Overlay Styles */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top left, #1e293b, #0f172a);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: white;
    text-align: center;
}

.login-header .login-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #f8fafc;
}

.login-header p {
    color: #94a3b8;
    margin-bottom: 32px;
}

.login-form .form-group {
    text-align: left;
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #cbd5e1;
    margin-bottom: 8px;
}


.login-form input {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.2s;
}

.login-form input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.login-msg {
    margin-top: 16px;
    font-size: 14px;
    min-height: 20px;
    color: #ef4444;
}

.login-footer {
    margin-top: 32px;
    font-size: 12px;
    color: #64748b;
}

#login-overlay.hidden {
    display: none;
}

/* Scenario Cards for Journal Analysis */
.scenario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.scenario-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.scenario-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.15);
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.scenario-card.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.scenario-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.scenario-card h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.scenario-card p {
    font-size: 0.82rem;
    color: var(--text-sub);
    margin: 0;
    line-height: 1.4;
}

.scenario-config {
    animation: slideIn 0.3s ease-out;
}

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

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

/* Date Input Styles */
input[type="date"] {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.9rem;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #ffffff;
    width: 100%;
    color: var(--text-main);
    transition: all 0.2s ease;
    height: 38px;
    /* Standardize height with selects */
}

input[type="date"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* Chrome/Safari date picker icon styling */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Custom Styles for Collapsible Tree Table */
.tree-toggle {
    display: inline-block;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px;
    border-radius: 4px;
    transition: background-color 0.2s;
    user-select: none;
    font-size: 0.8rem;
    color: var(--primary-color);
}

.tree-toggle:hover {
    background-color: rgba(37, 99, 235, 0.1);
}

.compact-cell {
    padding: 6px 8px !important;
    font-size: 0.85rem !important;
}

.compact-sub-cell {
    font-size: 0.8rem !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
}

/* Cash Flow Worksheet Styles */
.worksheet-table {
    font-size: 0.8rem;
    white-space: nowrap;
}

.worksheet-table th {
    text-align: center;
    background: #f1f5f9;
    padding: 0.5rem;
    border: 1px solid #cbd5e1;
}

.worksheet-table td {
    padding: 0.4rem 0.6rem;
    border: 1px solid #e2e8f0;
}

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

.sticky-col {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 10;
    font-weight: 500;
    border-right: 2px solid #cbd5e1 !important;
    min-width: 150px;
}

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

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

.bg-light {
    background-color: #f8fafc;
}

.section-op {
    background-color: rgba(37, 99, 235, 0.05);
}

.section-inv {
    background-color: rgba(16, 185, 129, 0.05);
}

.section-fin {
    background-color: rgba(245, 158, 11, 0.05);
}

.editable:hover {
    background-color: #fffbeb;
    cursor: text;
}

.total-row {
    background-color: #e2e8f0;
    font-weight: bold;
}